MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetupIdsMapping

Method SetupIdsMapping

Source/Engine/Level/SceneObjectsFactory.cpp:101–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void SceneObjectsFactory::Context::SetupIdsMapping(const SceneObject* obj, ISerializeModifier* modifier) const
102{
103 int32 instanceIndex;
104 const Guid id = obj->GetID();
105 if (ObjectToInstance.TryGet(id, instanceIndex))
106 {
107 // Apply the current prefab instance objects ids table to resolve references inside a prefab properly
108 const auto& instance = Instances[instanceIndex];
109 if (instanceIndex != modifier->CurrentInstance)
110 {
111 modifier->CurrentInstance = instanceIndex;
112 for (const auto& e : instance.IdsMapping)
113 modifier->IdsMapping[e.Key] = e.Value;
114 }
115 int32 nestedIndex;
116 if (instance.ObjectToNested.TryGet(id, nestedIndex))
117 {
118 // Each nested prefab has own object ids mapping that takes precedence
119 const auto& nested = instance.Nested[nestedIndex];
120 for (const auto& e : nested.IdsMapping)
121 modifier->IdsMapping[e.Key] = e.Value;
122 }
123 }
124}
125
126SceneObject* SceneObjectsFactory::Spawn(Context& context, const ISerializable::DeserializeStream& stream)
127{

Callers 4

DeserializeMethod · 0.80

Calls 2

GetIDMethod · 0.80
TryGetMethod · 0.45

Tested by

no test coverage detected