mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 14:45:57 +01:00
TileMaps now support navigation map overrides.
This commit is contained in:
parent
102ef3ac12
commit
268c27458a
@ -153,6 +153,19 @@
|
|||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="set_navigation_map">
|
||||||
|
<return type="void" />
|
||||||
|
<argument index="0" name="navigation_map" type="RID" />
|
||||||
|
<description>
|
||||||
|
Sets the [RID] of the navigation map this region should use. By default the region will automatically join the [World2D] default navigation map so this function is only required to override the default map.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
|
<method name="get_navigation_map" qualifiers="const">
|
||||||
|
<return type="RID" />
|
||||||
|
<description>
|
||||||
|
Returns the current navigation map [RID] use by this region.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
|
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
|
||||||
|
@ -68,8 +68,6 @@ void TileMap::_notification(int p_what) {
|
|||||||
while (c) {
|
while (c) {
|
||||||
navigation = Object::cast_to<Navigation2D>(c);
|
navigation = Object::cast_to<Navigation2D>(c);
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
// only for <3.5 backward compatibility
|
|
||||||
bake_navigation = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,11 +695,7 @@ void TileMap::update_dirty_quadrants() {
|
|||||||
|
|
||||||
RID region = Navigation2DServer::get_singleton()->region_create();
|
RID region = Navigation2DServer::get_singleton()->region_create();
|
||||||
Navigation2DServer::get_singleton()->region_set_owner_id(region, get_instance_id());
|
Navigation2DServer::get_singleton()->region_set_owner_id(region, get_instance_id());
|
||||||
if (navigation) {
|
Navigation2DServer::get_singleton()->region_set_map(region, get_navigation_map());
|
||||||
Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
|
|
||||||
} else {
|
|
||||||
Navigation2DServer::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map());
|
|
||||||
}
|
|
||||||
Navigation2DServer::get_singleton()->region_set_navigation_layers(region, navigation_layers);
|
Navigation2DServer::get_singleton()->region_set_navigation_layers(region, navigation_layers);
|
||||||
Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
|
Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
|
||||||
Navigation2DServer::get_singleton()->region_set_navigation_polygon(region, navigation_polygon);
|
Navigation2DServer::get_singleton()->region_set_navigation_polygon(region, navigation_polygon);
|
||||||
@ -1771,6 +1765,29 @@ bool TileMap::is_centered_textures_enabled() const {
|
|||||||
return centered_textures;
|
return centered_textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileMap::set_navigation_map(RID p_navigation_map) {
|
||||||
|
if (navigation_map_override == p_navigation_map) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
navigation_map_override = p_navigation_map;
|
||||||
|
|
||||||
|
for (RBMap<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
|
||||||
|
_make_quadrant_dirty(E);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RID TileMap::get_navigation_map() const {
|
||||||
|
if (navigation_map_override.is_valid()) {
|
||||||
|
return navigation_map_override;
|
||||||
|
} else if (navigation) {
|
||||||
|
return navigation->get_rid();
|
||||||
|
} else if (is_inside_tree()) {
|
||||||
|
return get_world_2d()->get_navigation_map();
|
||||||
|
}
|
||||||
|
return RID();
|
||||||
|
}
|
||||||
|
|
||||||
Array TileMap::get_used_cells() const {
|
Array TileMap::get_used_cells() const {
|
||||||
Array a;
|
Array a;
|
||||||
a.resize(tile_map.size());
|
a.resize(tile_map.size());
|
||||||
@ -1961,6 +1978,9 @@ void TileMap::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles);
|
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles);
|
||||||
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);
|
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &TileMap::set_navigation_map);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_navigation_map"), &TileMap::get_navigation_map);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_used_cells"), &TileMap::get_used_cells);
|
ClassDB::bind_method(D_METHOD("get_used_cells"), &TileMap::get_used_cells);
|
||||||
ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "id"), &TileMap::get_used_cells_by_id);
|
ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "id"), &TileMap::get_used_cells_by_id);
|
||||||
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
|
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
|
||||||
|
@ -79,6 +79,7 @@ private:
|
|||||||
bool use_parent;
|
bool use_parent;
|
||||||
CollisionObject2D *collision_parent;
|
CollisionObject2D *collision_parent;
|
||||||
bool use_kinematic;
|
bool use_kinematic;
|
||||||
|
RID navigation_map_override;
|
||||||
Navigation2D *navigation;
|
Navigation2D *navigation;
|
||||||
bool bake_navigation;
|
bool bake_navigation;
|
||||||
uint32_t navigation_layers;
|
uint32_t navigation_layers;
|
||||||
@ -350,6 +351,9 @@ public:
|
|||||||
void set_centered_textures(bool p_enable);
|
void set_centered_textures(bool p_enable);
|
||||||
bool is_centered_textures_enabled() const;
|
bool is_centered_textures_enabled() const;
|
||||||
|
|
||||||
|
void set_navigation_map(RID p_navigation_map);
|
||||||
|
RID get_navigation_map() const;
|
||||||
|
|
||||||
// TODO change these to PoolVector2iArrays
|
// TODO change these to PoolVector2iArrays
|
||||||
Array get_used_cells() const;
|
Array get_used_cells() const;
|
||||||
Array get_used_cells_by_id(int p_id) const;
|
Array get_used_cells_by_id(int p_id) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user