public void AddGameHumanBehaviourState(Game.PlayerBehaviourIndex newBehaviour, Game.BehaviorState newState) { var index = GameComponentsLookup.GameHumanBehaviourState; var component = (Game.HumanBehaviourStateComponent)CreateComponent(index, typeof(Game.HumanBehaviourStateComponent)); component.Behaviour = newBehaviour; component.State = newState; AddComponent(index, component); }
public void ReplaceGameHumanBehaviourState(Game.PlayerBehaviourIndex newBehaviour, Game.BehaviorState newState) { var entity = gameHumanBehaviourStateEntity; if (entity == null) { entity = SetGameHumanBehaviourState(newBehaviour, newState); } else { entity.ReplaceGameHumanBehaviourState(newBehaviour, newState); } }
public GameEntity SetGameHumanBehaviourState(Game.PlayerBehaviourIndex newBehaviour, Game.BehaviorState newState) { if (hasGameHumanBehaviourState) { throw new Entitas.EntitasException("Could not set GameHumanBehaviourState!\n" + this + " already has an entity with Game.HumanBehaviourStateComponent!", "You should check if the context already has a gameHumanBehaviourStateEntity before setting it or use context.ReplaceGameHumanBehaviourState()."); } var entity = CreateEntity(); entity.AddGameHumanBehaviourState(newBehaviour, newState); return(entity); }