private void UnregisterDrone(MyEntity entity, bool immediate = true) { long antennaEntityId = 0; DroneInfo info = null; Debug.Assert(m_droneInfos.ContainsKey(entity.EntityId), "Unregistering drone with inconsistend entity id"); m_droneInfos.TryGetValue(entity.EntityId, out info); if (info != null) { antennaEntityId = info.AntennaEntityId; DroneInfo.Deallocate(info); } m_droneInfos.Remove(entity.EntityId, immediate: immediate); PirateAntennaInfo antennaInfo = null; m_pirateAntennas.TryGetValue(antennaEntityId, out antennaInfo); if (antennaInfo != null) { antennaInfo.SpawnedDrones--; Debug.Assert(antennaInfo.SpawnedDrones >= 0, "Inconsistence in registered drone counts!"); } entity.OnClosing -= DroneMainEntityOnClosing; var remote = entity as MyRemoteControl; if (remote != null) { remote.OwnershipChanged -= DroneRemoteOwnershipChanged; } }
internal void SyncClientEwarBlocks() { foreach (var ewarPair in CurrentClientEwaredCubes) { BlockState state; MyEntity ent; var entId = ewarPair.Key; if (MyEntities.TryGetEntityById(entId, out ent)) { var cube = (MyCubeBlock)ent; var func = (IMyFunctionalBlock)cube; func.RefreshCustomInfo(); if (!_activeEwarCubes.ContainsKey(entId)) { state = new BlockState { FunctBlock = func, FirstState = func.Enabled, Endtick = Tick + ewarPair.Value.EndTick, Session = this }; _activeEwarCubes[entId] = state; ActivateClientEwarState(ref state); } } else if (_activeEwarCubes.TryGetValue(entId, out state)) { DeactivateClientEwarState(ref state); _activeEwarCubes.Remove(entId); } ClientEwarStale = false; } _activeEwarCubes.ApplyChanges(); foreach (var activeEwar in _activeEwarCubes) { if (!CurrentClientEwaredCubes.ContainsKey(activeEwar.Key)) { var state = activeEwar.Value; DeactivateClientEwarState(ref state); _activeEwarCubes.Remove(activeEwar.Key); } } _activeEwarCubes.ApplyRemovals(); }