| 967 | } |
| 968 | |
| 969 | void EntitySystemHelpersBase::UpdateComponentMappings() |
| 970 | { |
| 971 | if (initialized_) return; |
| 972 | |
| 973 | componentNameToIndexMappings_.clear(); |
| 974 | ecsComponentData_.Clear(); |
| 975 | components_.fill(PerComponentData{}); |
| 976 | staticDataIndices_.fill(resource::UndefinedStaticDataType); |
| 977 | systemIndices_.fill(UndefinedSystem); |
| 978 | |
| 979 | std::unordered_map<int32_t*, TypeIdContext> contexts; |
| 980 | for (auto const& context : GetStaticSymbols().IndexSymbolToContextMaps) { |
| 981 | auto name = ecs::SimplifyComponentName(context.second); |
| 982 | if (name == "ecs::OneFrameComponentTypeIdContext") { |
| 983 | contexts.insert(std::make_pair(context.first, TypeIdContext::OneFrameComponent)); |
| 984 | } else if (name == "ecs::ComponentTypeIdContext") { |
| 985 | contexts.insert(std::make_pair(context.first, TypeIdContext::Component)); |
| 986 | } else if (name == "ecs::EntityWorld::SystemsContext") { |
| 987 | contexts.insert(std::make_pair(context.first, TypeIdContext::System)); |
| 988 | } else if (name == "ecs::sync::ReplicatedTypeContext") { |
| 989 | contexts.insert(std::make_pair(context.first, TypeIdContext::Replication)); |
| 990 | } else if (name == "ls::ImmutableDataHeadmaster") { |
| 991 | contexts.insert(std::make_pair(context.first, TypeIdContext::ImmutableData)); |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | auto const& symbolMaps = GetStaticSymbols().IndexSymbolToNameMaps; |
| 996 | for (auto const& mapping : symbolMaps) { |
| 997 | auto s = STDString(mapping.second.name); |
| 998 | auto name = SimplifyComponentName(mapping.second.name); |
| 999 | if (name.starts_with("ecs::query::spec::Spec<")) { |
| 1000 | // Queries ignored |
| 1001 | } else { |
| 1002 | auto contextIt = contexts.find(mapping.second.context); |
| 1003 | if (contextIt != contexts.end()) { |
| 1004 | switch (contextIt->second) { |
| 1005 | case TypeIdContext::System: |
| 1006 | BindSystem(name, SystemTypeIndex(*mapping.first)); |
| 1007 | break; |
| 1008 | |
| 1009 | case TypeIdContext::ImmutableData: |
| 1010 | BindStaticData(name, resource::StaticDataTypeIndex(*mapping.first)); |
| 1011 | break; |
| 1012 | |
| 1013 | case TypeIdContext::Component: |
| 1014 | BindComponent(name, ComponentTypeIndex(*mapping.first)); |
| 1015 | break; |
| 1016 | |
| 1017 | case TypeIdContext::OneFrameComponent: |
| 1018 | BindComponent(name, ComponentTypeIndex(*mapping.first | 0x8000)); |
| 1019 | break; |
| 1020 | |
| 1021 | case TypeIdContext::Replication: |
| 1022 | BindReplication(name, ReplicationTypeIndex(*mapping.first)); |
| 1023 | break; |
| 1024 | } |
| 1025 | } |
| 1026 | } |
nothing calls this directly
no test coverage detected