Add GridMap.get_used_cells_by_item
This commit is contained in:
parent
98b97d34df
commit
19a2ec3d04
3 changed files with 21 additions and 0 deletions
|
@ -79,6 +79,13 @@
|
||||||
Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
|
Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_used_cells_by_item" qualifiers="const">
|
||||||
|
<return type="Array" />
|
||||||
|
<argument index="0" name="item" type="int" />
|
||||||
|
<description>
|
||||||
|
Returns an array of all cells with the given item index specified in [code]item[/code].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="make_baked_meshes">
|
<method name="make_baked_meshes">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="gen_lightmap_uv" type="bool" default="false" />
|
<argument index="0" name="gen_lightmap_uv" type="bool" default="false" />
|
||||||
|
|
|
@ -878,6 +878,7 @@ void GridMap::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
|
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells);
|
ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_used_cells_by_item", "item"), &GridMap::get_used_cells_by_item);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
|
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
|
||||||
ClassDB::bind_method(D_METHOD("get_bake_meshes"), &GridMap::get_bake_meshes);
|
ClassDB::bind_method(D_METHOD("get_bake_meshes"), &GridMap::get_bake_meshes);
|
||||||
|
@ -950,6 +951,18 @@ Array GridMap::get_used_cells() const {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Array GridMap::get_used_cells_by_item(int p_item) const {
|
||||||
|
Array a;
|
||||||
|
for (const KeyValue<IndexKey, Cell> &E : cell_map) {
|
||||||
|
if (E.value.item == p_item) {
|
||||||
|
Vector3 p(E.key.x, E.key.y, E.key.z);
|
||||||
|
a.push_back(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
Array GridMap::get_meshes() const {
|
Array GridMap::get_meshes() const {
|
||||||
if (mesh_library.is_null()) {
|
if (mesh_library.is_null()) {
|
||||||
return Array();
|
return Array();
|
||||||
|
|
|
@ -266,6 +266,7 @@ public:
|
||||||
float get_cell_scale() const;
|
float get_cell_scale() const;
|
||||||
|
|
||||||
Array get_used_cells() const;
|
Array get_used_cells() const;
|
||||||
|
Array get_used_cells_by_item(int p_item) const;
|
||||||
|
|
||||||
Array get_meshes() const;
|
Array get_meshes() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue