private void OnControllerAdded(IRailControllerServer controller) { ControlledEntity controlled = this.server.AddNewEntity <ControlledEntity>(); controlled.State.ArchetypeId = 0; controller.GrantControl(controlled); controller.ScopeEvaluator = new GameScopeEvaluator(controlled); controller.UserData = controlled; MimicEntity mimic = this.server.AddNewEntity <MimicEntity>(); mimic.State.ArchetypeId = 2; mimic.Bind(controlled, 3.5f, 0.0f); }
/// <summary> /// Removes an entity from the world and destroys it. /// </summary> public void DestroyEntity(RailEntity entity) { if (entity.Controller != null) { IRailControllerServer serverController = (IRailControllerServer)entity.Controller; serverController.RevokeControl(entity); } if (entity.IsRemoving == false) { entity.MarkForRemove(); this.destroyedEntities.Add(entity.Id, entity); } }
private void OnControllerLeft(IRailControllerServer controller) { ControlledEntity controlled = (ControlledEntity)controller.UserData; this.server.DestroyEntity(controlled); }