Cleanup
This commit is contained in:
Submodule src/godot updated: f70472f1cc...361b0dff17
@@ -21,7 +21,6 @@ struct scene_data {
|
|||||||
Ref<PackedScene> packed_scene;
|
Ref<PackedScene> packed_scene;
|
||||||
String path;
|
String path;
|
||||||
Ref<ResourceInteractiveLoader> loader;
|
Ref<ResourceInteractiveLoader> loader;
|
||||||
// std::vector<String> buildings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CBuildingInstance {
|
struct CBuildingInstance {
|
||||||
@@ -433,13 +432,6 @@ void BuildingsData::remove_scene_item(const String &key, const String &bkey)
|
|||||||
assert(e.is_valid());
|
assert(e.is_valid());
|
||||||
CSceneData *d = e.get_mut<CSceneData>();
|
CSceneData *d = e.get_mut<CSceneData>();
|
||||||
assert(d);
|
assert(d);
|
||||||
#if 0
|
|
||||||
std::vector<String>::iterator b = d->sd.buildings.begin();
|
|
||||||
std::vector<String>::iterator h = d->sd.buildings.end();
|
|
||||||
// if (item_nodes.has(item))
|
|
||||||
// item_nodes[item]->queue_delete();
|
|
||||||
d->sd.buildings.erase(std::remove(b, h, bkey), d->sd.buildings.end());
|
|
||||||
#endif
|
|
||||||
flecs::query_builder<const CBuildingInstance> qb =
|
flecs::query_builder<const CBuildingInstance> qb =
|
||||||
ecs.query_builder<const CBuildingInstance>().with(
|
ecs.query_builder<const CBuildingInstance>().with(
|
||||||
flecs::ChildOf, e);
|
flecs::ChildOf, e);
|
||||||
@@ -463,11 +455,6 @@ void BuildingsData::add_scene_item(const String &key, const String &bkey)
|
|||||||
assert(e.is_valid());
|
assert(e.is_valid());
|
||||||
CSceneData *d = e.get_mut<CSceneData>();
|
CSceneData *d = e.get_mut<CSceneData>();
|
||||||
assert(d);
|
assert(d);
|
||||||
#if 0
|
|
||||||
if (std::find(d->sd.buildings.begin(), d->sd.buildings.end(), bkey) ==
|
|
||||||
d->sd.buildings.end())
|
|
||||||
d->sd.buildings.push_back(bkey);
|
|
||||||
#endif
|
|
||||||
String ename = "bi:" + bkey;
|
String ename = "bi:" + bkey;
|
||||||
flecs::entity ce = e.lookup(ename.ascii().ptr());
|
flecs::entity ce = e.lookup(ename.ascii().ptr());
|
||||||
if (ce.is_valid())
|
if (ce.is_valid())
|
||||||
@@ -488,11 +475,6 @@ void BuildingsData::create_scene_data(const String &key, const String &bkey)
|
|||||||
sd.path = path;
|
sd.path = path;
|
||||||
sd.loader = ResourceLoader::load_interactive(
|
sd.loader = ResourceLoader::load_interactive(
|
||||||
path, "PackedScene", true);
|
path, "PackedScene", true);
|
||||||
#if 0
|
|
||||||
if (std::find(sd.buildings.begin(), sd.buildings.end(), bkey) ==
|
|
||||||
sd.buildings.end())
|
|
||||||
sd.buildings.push_back(bkey);
|
|
||||||
#endif
|
|
||||||
e.set<CSceneData>({ sd });
|
e.set<CSceneData>({ sd });
|
||||||
assert(e.get_mut<CSceneData>());
|
assert(e.get_mut<CSceneData>());
|
||||||
String ename = "bi:" + bkey;
|
String ename = "bi:" + bkey;
|
||||||
@@ -572,11 +554,6 @@ void BuildingsData::set_scene_item_node(const String &key, const String &bkey,
|
|||||||
assert(e.is_valid());
|
assert(e.is_valid());
|
||||||
CSceneData *d = e.get_mut<CSceneData>();
|
CSceneData *d = e.get_mut<CSceneData>();
|
||||||
assert(d);
|
assert(d);
|
||||||
#if 0
|
|
||||||
if (std::find(d->sd.buildings.begin(), d->sd.buildings.end(), bkey) ==
|
|
||||||
d->sd.buildings.end())
|
|
||||||
d->sd.buildings.push_back(bkey);
|
|
||||||
#endif
|
|
||||||
String ename = "bi:" + bkey;
|
String ename = "bi:" + bkey;
|
||||||
flecs::entity ce = e.lookup(ename.ascii().ptr());
|
flecs::entity ce = e.lookup(ename.ascii().ptr());
|
||||||
assert(ce.is_valid());
|
assert(ce.is_valid());
|
||||||
@@ -612,12 +589,6 @@ Node *BuildingsData::get_scene_item_node(const String &key,
|
|||||||
}
|
}
|
||||||
void BuildingsData::item_nodes_delete_node(const String &key)
|
void BuildingsData::item_nodes_delete_node(const String &key)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (item_nodes.has(key)) {
|
|
||||||
item_nodes[key]->queue_delete();
|
|
||||||
item_nodes.erase(key);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
flecs::query_builder<const CBuildingInstance> qb =
|
flecs::query_builder<const CBuildingInstance> qb =
|
||||||
ecs.query_builder<const CBuildingInstance>();
|
ecs.query_builder<const CBuildingInstance>();
|
||||||
flecs::query<const CBuildingInstance> q = qb.build();
|
flecs::query<const CBuildingInstance> q = qb.build();
|
||||||
@@ -633,64 +604,9 @@ void BuildingsData::item_nodes_delete_node(const String &key)
|
|||||||
ib->node = nullptr;
|
ib->node = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
bool BuildingsData::item_nodes_exists(const String &key) const
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
bool result = false;
|
|
||||||
return item_nodes.has(key);
|
|
||||||
flecs::query_builder<const CBuildingInstance> qb =
|
|
||||||
ecs.query_builder<const CBuildingInstance>();
|
|
||||||
flecs::query<const CBuildingInstance> q = qb.build();
|
|
||||||
uint64_t key_hash = key.hash64();
|
|
||||||
q.run([key_hash, &result](flecs::iter &it) {
|
|
||||||
while (it.next()) {
|
|
||||||
auto em = it.field<flecs::entity>(0);
|
|
||||||
auto ib = it.field<const CBuildingInstance>(1);
|
|
||||||
if (ib->key.hash64() == key_hash) {
|
|
||||||
result = true;
|
|
||||||
it.fini();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
#endif
|
|
||||||
String ename = "bi:" + key;
|
|
||||||
flecs::entity ce = ecs.lookup(ename.ascii().ptr());
|
|
||||||
bool result = ce.is_valid();
|
|
||||||
if (!result)
|
|
||||||
return result;
|
|
||||||
const CBuildingInstance *bi = ce.get<CBuildingInstance>();
|
|
||||||
if (!bi)
|
|
||||||
return false;
|
|
||||||
if (bi->node)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildingsData::item_nodes_set_node(const String &key, Node *node)
|
|
||||||
{
|
|
||||||
item_nodes[key] = node;
|
|
||||||
String ename = "bi:" + key;
|
|
||||||
print_line(ename);
|
|
||||||
flecs::entity ce = ecs.lookup(ename.ascii().ptr());
|
|
||||||
assert(ce.is_valid());
|
|
||||||
CBuildingInstance *bi = ce.get_mut<CBuildingInstance>();
|
|
||||||
assert(bi);
|
|
||||||
bi->node = node;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void BuildingsData::item_nodes_item_removed(const String &key)
|
void BuildingsData::item_nodes_item_removed(const String &key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
#if 0
|
|
||||||
if (item_nodes[key])
|
|
||||||
item_nodes[key]->queue_delete();
|
|
||||||
item_nodes.erase(key);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
flecs::query_builder<const CBuildingInstance> qb =
|
flecs::query_builder<const CBuildingInstance> qb =
|
||||||
ecs.query_builder<const CBuildingInstance>();
|
ecs.query_builder<const CBuildingInstance>();
|
||||||
flecs::query<const CBuildingInstance> q = qb.build();
|
flecs::query<const CBuildingInstance> q = qb.build();
|
||||||
@@ -713,20 +629,6 @@ String BuildingsData::item_nodes_get_key(int item) const
|
|||||||
return buildings[item].key;
|
return buildings[item].key;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
Node *BuildingsData::item_nodes_get_node(const String &key) const
|
|
||||||
{
|
|
||||||
if (!item_nodes_exists(key))
|
|
||||||
return nullptr;
|
|
||||||
// return item_nodes[key];
|
|
||||||
String ename = "bi:" + key;
|
|
||||||
flecs::entity ce = ecs.lookup(ename.ascii().ptr());
|
|
||||||
assert(ce.is_valid());
|
|
||||||
CBuildingInstance *bi = ce.get_mut<CBuildingInstance>();
|
|
||||||
assert(bi);
|
|
||||||
return bi->node;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Node *BuildingsData::item_nodes_get_node(const String &key) const
|
Node *BuildingsData::item_nodes_get_node(const String &key) const
|
||||||
{
|
{
|
||||||
flecs::query_builder<const CBuildingInstance> qb =
|
flecs::query_builder<const CBuildingInstance> qb =
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public:
|
|||||||
/* Data for each building in a world */
|
/* Data for each building in a world */
|
||||||
private:
|
private:
|
||||||
std::vector<struct building> buildings;
|
std::vector<struct building> buildings;
|
||||||
// HashMap<String, Node *> item_nodes;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int get_building_count() const;
|
int get_building_count() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user