| 21 | using namespace ALife; |
| 22 | |
| 23 | void CALifeSimulatorBase::register_object(CSE_ALifeDynamicObject* object, bool add_object) |
| 24 | { |
| 25 | object->on_before_register(); |
| 26 | |
| 27 | if (add_object) |
| 28 | objects().add(object); |
| 29 | |
| 30 | graph().update(object); |
| 31 | scheduled().add(object); |
| 32 | story_objects().add(object->m_story_id, object); |
| 33 | smart_terrains().add(object); |
| 34 | groups().add(object); |
| 35 | |
| 36 | setup_simulator(object); |
| 37 | |
| 38 | CSE_ALifeInventoryItem* item = smart_cast<CSE_ALifeInventoryItem*>(object); |
| 39 | if (item && item->attached()) |
| 40 | { |
| 41 | CSE_ALifeDynamicObject* II = objects().object(item->base()->ID_Parent); |
| 42 | |
| 43 | #ifdef DEBUG |
| 44 | if (std::find(II->children.begin(), II->children.end(), item->base()->ID) != II->children.end()) |
| 45 | { |
| 46 | Msg("[LSS] Specified item [%s][%d] is already attached to the specified object [%s][%d]", item->base()->name_replace(), item->base()->ID, II->name_replace(), II->ID); |
| 47 | FATAL("[LSS] Cannot recover from the previous error!"); |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | II->children.push_back(item->base()->ID); |
| 52 | II->attach(item, true, false); |
| 53 | } |
| 54 | |
| 55 | if (can_register_objects()) |
| 56 | object->on_register(); |
| 57 | } |
| 58 | |
| 59 | void CALifeSimulatorBase::unregister_object(CSE_ALifeDynamicObject* object, bool alife_query) |
| 60 | { |
no test coverage detected