MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / CreateContainerEntity

Method CreateContainerEntity

src/plugin/kernel/src/AFCKernelModule.cpp:220–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220std::shared_ptr<AFIEntity> AFCKernelModule::CreateContainerEntity(
221 const AFGUID& self, const uint32_t container_index, const std::string& class_name, const ID_TYPE config_id)
222{
223 auto pEntity = GetEntity(self);
224 if (pEntity == nullptr)
225 {
226 ARK_LOG_ERROR("There is no object, object = {}", self);
227 return nullptr;
228 }
229
230 auto pContainer = pEntity->FindContainer(container_index);
231 if (pContainer == nullptr)
232 {
233 ARK_LOG_ERROR("There is no container, container = {}", container_index);
234 return nullptr;
235 }
236
237 auto pClassMeta = m_pClassModule->FindMeta(class_name);
238 if (nullptr == pClassMeta)
239 {
240 ARK_LOG_ERROR("There is no class meta, name = {}", class_name);
241 return nullptr;
242 }
243
244 std::shared_ptr<AFIStaticEntity> pStaticEntity = nullptr;
245 if (config_id > 0)
246 {
247 auto pStaticEntity = GetStaticEntity(config_id);
248 if (nullptr == pStaticEntity)
249 {
250 ARK_LOG_ERROR("There is no config, config_id = {}", config_id);
251 return nullptr;
252 }
253
254 if (pStaticEntity->GetClassName() != class_name)
255 {
256 ARK_LOG_ERROR("Config class does not match entity class, config_id = {}", config_id);
257 return nullptr;
258 }
259 }
260
261 auto map_id = pEntity->GetMapID();
262 auto pMapInfo = m_pMapModule->GetMapInfo(map_id);
263 if (pMapInfo == nullptr)
264 {
265 ARK_LOG_ERROR("There is no scene, scene = {}", map_id);
266 return nullptr;
267 }
268
269 auto map_instance_id = pEntity->GetMapEntityID();
270 if (!pMapInfo->ExistInstance(map_instance_id))
271 {
272 ARK_LOG_ERROR("There is no group, scene = {} group = {}", map_id, map_instance_id);
273 return nullptr;
274 }
275
276 AFGUID object_id = m_pGUIDModule->CreateGUID();
277

Callers

nothing calls this directly

Calls 9

GetMapIDMethod · 0.80
GetMapInfoMethod · 0.80
GetMapEntityIDMethod · 0.80
ExistInstanceMethod · 0.80
CreateGUIDMethod · 0.80
PlaceMethod · 0.80
FindContainerMethod · 0.45
FindMetaMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected