MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / RemoveObject

Method RemoveObject

Source/Editors/map_editor.cpp:249–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void MapEditor::RemoveObject(Object* o, SceneGraph* scenegraph, bool removed_by_socket) {
250 Online* online = Online::Instance();
251
252 if (online->IsActive()) {
253 if (online->IsHosting()) {
254 online->RemoveObject(o, o->GetID());
255 } else if (removed_by_socket == false) {
256 // This case is for the editor
257 // If we removed something, and it was not by the socket
258 // we want to inform the host.
259 // we will not remove this object until the host tells us to
260 online->RemoveObject(o, o->GetID());
261 return;
262 }
263 }
264
265 if (o->GetType() == _env_object && !((EnvObject*)o)->ofr->dynamic) {
266 shadow_cache_dirty = true;
267 }
268 if (o->IsGroupDerived()) {
269 Group* group = static_cast<Group*>(o);
270 while (!group->children.empty()) {
271 RemoveObject(group->children.back().direct_ptr, scenegraph, true);
272 }
273 }
274 if (o->GetType() == _movement_object) {
275 RiggedObject* ro = static_cast<MovementObject*>(o)->rigged_object();
276 /*while(!ro->attached_items.items.empty()) {
277 RemoveObject(ro->attached_items.items.front().item.obj, scenegraph);
278 }*/
279 while (!ro->children.empty()) {
280 RemoveObject(ro->children.back().direct_ptr, scenegraph, true);
281 }
282 }
283 o->SetParent(NULL); // Disconnects from any parent objects
284 // Notify everyone that object is deleted
285 const int BUF_SIZE = 255;
286 char buf[BUF_SIZE];
287 snprintf(buf, BUF_SIZE, "notify_deleted %d", o->GetID());
288 scenegraph->level->Message(buf);
289 for (auto obj : scenegraph->objects_) {
290 obj->NotifyDeleted(o);
291 }
292 scenegraph->UnlinkObject(o);
293 o->Dispose();
294 delete (o);
295}
296
297void LoadLevel(bool local) {
298 const int BUF_SIZE = kPathSize;

Callers

nothing calls this directly

Calls 14

RemoveObjectClass · 0.85
IsHostingMethod · 0.80
rigged_objectMethod · 0.80
IsActiveMethod · 0.45
GetIDMethod · 0.45
GetTypeMethod · 0.45
IsGroupDerivedMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
SetParentMethod · 0.45
MessageMethod · 0.45
NotifyDeletedMethod · 0.45

Tested by

no test coverage detected