MCPcopy Create free account
hub / github.com/Norbyte/bg3se / GetSingletonEntity

Method GetSingletonEntity

BG3Extender/GameDefinitions/EntitySystem.cpp:1203–1223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203EntityHandle EntitySystemHelpersBase::GetSingletonEntity(ExtComponentType type)
1204{
1205 auto& meta = GetComponentMeta(type);
1206 if (meta.SingleComponentQuery == ecs::UndefinedQuery) {
1207 WARN("No query defined for singleton %s?", GetComponentName(meta.ComponentIndex)->c_str());
1208 return {};
1209 }
1210
1211 auto world = GetEntityWorld();
1212 auto const& query = world->Queries.Queries[(unsigned)meta.SingleComponentQuery];
1213 if (query.EntityStorages.empty()) {
1214 return {};
1215 }
1216
1217 auto const& storage = query.EntityStorages.values()[0];
1218 if (storage.Storage->InstanceToPageMap.empty()) {
1219 return {};
1220 }
1221
1222 return storage.Storage->InstanceToPageMap.keys()[0];
1223}
1224
1225SystemTypeEntry* EntitySystemHelpersBase::GetSystemEntry(ExtSystemType type)
1226{

Callers

nothing calls this directly

Calls 4

GetComponentNameFunction · 0.85
GetEntityWorldFunction · 0.85
valuesMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected