public void CheckTriggers(StateComponent statecomp, IEntity entity) { string state = statecomp.currentState; foreach (Trigger trigger in triggers.OrderBy(t => t.Priority)) { bool result = trigger.Condition(entity); if (result) { trigger.Effect(entity); if (statecomp.currentState != state) { break; } } else if (trigger.Else != null) { trigger.Else(entity); if (statecomp.currentState != state) { break; } } } }
public override Component Clone() { StateComponent newone = new StateComponent {states = this.states}; // notice the shallow copy! return newone; }
public override Component Clone() { StateComponent newone = new StateComponent { states = this.states }; // notice the shallow copy! return(newone); }
// this is for when <State> appears in an effect, used for changing state public static Effect ParseEffect(XElement effectNode) { string newstate = effectNode.Value; return(entity => { StateComponent state = entity.GetComponent <StateComponent>(); if (state != null) { state.ChangeState(newstate); } }); }
public void CheckTriggers(StateComponent statecomp, IEntity entity) { string state = statecomp.currentState; foreach (Trigger trigger in triggers) { bool result = trigger.Condition(entity); if (result) { trigger.Effect(entity); if (statecomp.currentState != state) { break; } } } }
public void CheckTriggers(StateComponent statecomp, IEntity entity) { string state = statecomp.currentState; foreach (Trigger trigger in triggers.OrderBy(t => t.Priority)) { bool result = trigger.Condition(entity); if (result) { trigger.Effect(entity); if (statecomp.currentState != state) break; } else if (trigger.Else != null) { trigger.Else(entity); if (statecomp.currentState != state) break; } } }
public void CheckTriggers(StateComponent statecomp, IEntity entity) { string state = statecomp.currentState; foreach (Trigger trigger in triggers) { bool result = trigger.Condition(entity); if (result) { trigger.Effect(entity); if (statecomp.currentState != state) break; } } }