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

Method GetRawSingleton

BG3Extender/GameDefinitions/EntitySystem.cpp:1180–1201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1178}
1179
1180void* EntitySystemHelpersBase::GetRawSingleton(ExtComponentType type)
1181{
1182 auto& meta = GetComponentMeta(type);
1183 if (meta.SingleComponentQuery == ecs::UndefinedQuery) {
1184 WARN("No query defined for singleton %s?", GetComponentName(meta.ComponentIndex)->c_str());
1185 return nullptr;
1186 }
1187
1188 auto world = GetEntityWorld();
1189 auto const& query = world->Queries.Queries[(unsigned)meta.SingleComponentQuery];
1190 if (query.EntityStorages.empty()) {
1191 return nullptr;
1192 }
1193
1194 auto const& storage = query.EntityStorages.values()[0];
1195 if (storage.Storage->InstanceToPageMap.empty()) {
1196 return nullptr;
1197 }
1198
1199 auto page = storage.Storage->InstanceToPageMap.values()[0];
1200 return storage.Storage->GetComponent(page, storage.GetComponentIndex(0), meta.Size, meta.IsProxy);
1201}
1202
1203EntityHandle EntitySystemHelpersBase::GetSingletonEntity(ExtComponentType type)
1204{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected