/// <summary> /// Remove an entity from being controlled by this peer. /// </summary> public void RevokeControlInternal(RailEntityBase entity) { RailDebug.Assert(entity.Controller == this); controlledEntities.Remove(entity); entity.AssignController(null); }
/// <summary> /// Adds an entity to be controlled by this peer. /// </summary> public void GrantControlInternal(RailEntityBase entity) { if (entity.Controller == this) { return; } RailDebug.Assert(entity.Controller == null); controlledEntities.Add(entity); entity.AssignController(this); }
protected void RemoveEntity(RailEntityBase entity) { if (entities.ContainsKey(entity.Id)) { entities.Remove(entity.Id); entity.RoomBase = null; entity.Removed(); // TODO: Pooling entities? HandleRemovedEntity(entity.Id); EntityRemoved?.Invoke(entity); } }
protected void RegisterEntity(RailEntityBase entity) { entities.Add(entity.Id, entity); entity.RoomBase = this; entity.Added(); }