MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / createObject

Method createObject

engine/source/runtime/function/framework/level/level.cpp:27–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 }
26
27 GObjectID Level::createObject(const ObjectInstanceRes& object_instance_res)
28 {
29 GObjectID object_id = ObjectIDAllocator::alloc();
30 ASSERT(object_id != k_invalid_gobject_id);
31
32 std::shared_ptr<GObject> gobject;
33 try
34 {
35 gobject = std::make_shared<GObject>(object_id);
36 }
37 catch (const std::bad_alloc&)
38 {
39 LOG_FATAL("cannot allocate memory for new gobject");
40 }
41
42 bool is_loaded = gobject->load(object_instance_res);
43 if (is_loaded)
44 {
45 m_gobjects.emplace(object_id, gobject);
46 }
47 else
48 {
49 LOG_ERROR("loading object " + object_instance_res.m_name + " failed");
50 return k_invalid_gobject_id;
51 }
52 return object_id;
53 }
54
55 bool Level::load(const std::string& level_res_url)
56 {

Callers 1

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected