You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
Merge pull request #72148 from smix8/tileset_navigationlayers_bitmask_helpers_4.x
Add TileSet helper functions to set/get navigation layer bitmask values
This commit is contained in:
@@ -143,6 +143,14 @@
|
|||||||
Returns the custom data layers count.
|
Returns the custom data layers count.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_navigation_layer_layer_value" qualifiers="const">
|
||||||
|
<return type="bool" />
|
||||||
|
<param index="0" name="layer_index" type="int" />
|
||||||
|
<param index="1" name="layer_number" type="int" />
|
||||||
|
<description>
|
||||||
|
Returns whether or not the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index] is enabled, given a navigation_layers [param layer_number] between 1 and 32.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_navigation_layer_layers" qualifiers="const">
|
<method name="get_navigation_layer_layers" qualifiers="const">
|
||||||
<return type="int" />
|
<return type="int" />
|
||||||
<param index="0" name="layer_index" type="int" />
|
<param index="0" name="layer_index" type="int" />
|
||||||
@@ -500,6 +508,15 @@
|
|||||||
Sets the type of the custom data layer identified by the given index.
|
Sets the type of the custom data layer identified by the given index.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="set_navigation_layer_layer_value">
|
||||||
|
<return type="void" />
|
||||||
|
<param index="0" name="layer_index" type="int" />
|
||||||
|
<param index="1" name="layer_number" type="int" />
|
||||||
|
<param index="2" name="value" type="bool" />
|
||||||
|
<description>
|
||||||
|
Based on [param value], enables or disables the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index], given a navigation_layers [param layer_number] between 1 and 32.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="set_navigation_layer_layers">
|
<method name="set_navigation_layer_layers">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="layer_index" type="int" />
|
<param index="0" name="layer_index" type="int" />
|
||||||
|
|||||||
@@ -991,6 +991,28 @@ uint32_t TileSet::get_navigation_layer_layers(int p_layer_index) const {
|
|||||||
return navigation_layers[p_layer_index].layers;
|
return navigation_layers[p_layer_index].layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileSet::set_navigation_layer_layer_value(int p_layer_index, int p_layer_number, bool p_value) {
|
||||||
|
ERR_FAIL_COND_MSG(p_layer_number < 1, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||||
|
ERR_FAIL_COND_MSG(p_layer_number > 32, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||||
|
|
||||||
|
uint32_t _navigation_layers = get_navigation_layer_layers(p_layer_index);
|
||||||
|
|
||||||
|
if (p_value) {
|
||||||
|
_navigation_layers |= 1 << (p_layer_number - 1);
|
||||||
|
} else {
|
||||||
|
_navigation_layers &= ~(1 << (p_layer_number - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
set_navigation_layer_layers(p_layer_index, _navigation_layers);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TileSet::get_navigation_layer_layer_value(int p_layer_index, int p_layer_number) const {
|
||||||
|
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||||
|
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Navigation layer number must be between 1 and 32 inclusive.");
|
||||||
|
|
||||||
|
return get_navigation_layer_layers(p_layer_index) & (1 << (p_layer_number - 1));
|
||||||
|
}
|
||||||
|
|
||||||
// Custom data.
|
// Custom data.
|
||||||
int TileSet::get_custom_data_layers_count() const {
|
int TileSet::get_custom_data_layers_count() const {
|
||||||
return custom_data_layers.size();
|
return custom_data_layers.size();
|
||||||
@@ -3387,6 +3409,8 @@ void TileSet::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("remove_navigation_layer", "layer_index"), &TileSet::remove_navigation_layer);
|
ClassDB::bind_method(D_METHOD("remove_navigation_layer", "layer_index"), &TileSet::remove_navigation_layer);
|
||||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_layers", "layer_index", "layers"), &TileSet::set_navigation_layer_layers);
|
ClassDB::bind_method(D_METHOD("set_navigation_layer_layers", "layer_index", "layers"), &TileSet::set_navigation_layer_layers);
|
||||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_layers", "layer_index"), &TileSet::get_navigation_layer_layers);
|
ClassDB::bind_method(D_METHOD("get_navigation_layer_layers", "layer_index"), &TileSet::get_navigation_layer_layers);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_navigation_layer_layer_value", "layer_index", "layer_number", "value"), &TileSet::set_navigation_layer_layer_value);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_navigation_layer_layer_value", "layer_index", "layer_number"), &TileSet::get_navigation_layer_layer_value);
|
||||||
|
|
||||||
// Custom data
|
// Custom data
|
||||||
ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count);
|
ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count);
|
||||||
|
|||||||
@@ -475,6 +475,8 @@ public:
|
|||||||
void remove_navigation_layer(int p_index);
|
void remove_navigation_layer(int p_index);
|
||||||
void set_navigation_layer_layers(int p_layer_index, uint32_t p_layers);
|
void set_navigation_layer_layers(int p_layer_index, uint32_t p_layers);
|
||||||
uint32_t get_navigation_layer_layers(int p_layer_index) const;
|
uint32_t get_navigation_layer_layers(int p_layer_index) const;
|
||||||
|
void set_navigation_layer_layer_value(int p_layer_index, int p_layer_number, bool p_value);
|
||||||
|
bool get_navigation_layer_layer_value(int p_layer_index, int p_layer_number) const;
|
||||||
|
|
||||||
// Custom data
|
// Custom data
|
||||||
int get_custom_data_layers_count() const;
|
int get_custom_data_layers_count() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user