public override void Dispose( ) { if (IsDisposed) { return; } base.Dispose( ); if (BackingObject != null) { //Only remove if the backing object isn't already disposed bool isDisposed = (bool)InvokeEntityMethod(BackingObject, BaseEntityGetIsDisposedMethod); if (!isDisposed) { m_networkManager.RemoveEntity( ); Action action = InternalRemoveEntity; SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action); } } if (EntityId != 0) { GameEntityManager.RemoveEntity(EntityId); } EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent( ); newEvent.type = EntityEventManager.EntityEventType.OnBaseEntityDeleted; newEvent.timestamp = DateTime.Now; newEvent.entity = this; newEvent.priority = 1; EntityEventManager.Instance.AddEvent(newEvent); }
public override void Dispose() { m_isDisposed = true; Parent.DeleteCubeBlock(this); EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent(); newEvent.type = EntityEventManager.EntityEventType.OnCubeBlockDeleted; newEvent.timestamp = DateTime.Now; newEvent.entity = this; newEvent.priority = (ushort)((EntityId != 0) ? 1 : 2); EntityEventManager.Instance.AddEvent(newEvent); if (EntityId != 0) { GameEntityManager.RemoveEntity(EntityId); } base.Dispose(); }
public override void Dispose( ) { if (SandboxGameAssemblyWrapper.IsDebugging) { LogManager.APILog.WriteLine("Disposing CubeGridEntity '" + Name + "' ..."); } //Dispose the cube grid by disposing all of the blocks //This may be slow but it's reliable ... so far /* * List<CubeBlockEntity> blocks = CubeBlocks; * int blockCount = blocks.Count; * foreach (CubeBlockEntity cubeBlock in blocks) * { * cubeBlock.Dispose(); * } * * if (SandboxGameAssemblyWrapper.IsDebugging) * LogManager.APILog.WriteLine("Disposed " + blockCount.ToString() + " blocks on CubeGridEntity '" + Name + "'"); */ //Broadcast the removal to the clients just to save processing time for the clients BaseNetworkManager.RemoveEntity( ); m_isDisposed = true; if (EntityId != 0) { GameEntityManager.RemoveEntity(EntityId); } EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent { type = EntityEventManager.EntityEventType.OnCubeGridDeleted, timestamp = DateTime.Now, entity = this, priority = 1 }; EntityEventManager.Instance.AddEvent(newEvent); }