public StateCondition(StateCondition _c) { this.conditionType = _c.conditionType; this.animalState = _c.animalState; this.nextState.Clear(); this.nextState.AddRange((IEnumerable <OneState>)_c.nextState); this.nextStateTemp.Clear(); }
public bool ChangeState(AnimalState _nextState = AnimalState.None) { if (Object.op_Equality((Object)this.Animal, (Object)null)) { return(false); } AnimalState currentState = this.Animal.CurrentState; AnimalState prevState = this.Animal.PrevState; if (!this.StateConditionTable.ContainsKey(currentState)) { if (_nextState != AnimalState.None) { this.Animal.CurrentState = _nextState; } return(false); } StateCondition _c = this.StateConditionTable[currentState]; ConditionType conditionType = _c.conditionType; switch (conditionType) { case ConditionType.None: if (_nextState != AnimalState.None) { this.Animal.CurrentState = _nextState; } return(false); case ConditionType.NonOverlap: if (!this.StateNonOverlapTable.ContainsKey(currentState)) { this.StateNonOverlapTable[currentState] = new StateCondition(_c); break; } if (_c.Count <= 0) { _c.SetNextState(this.StateNonOverlapTable[currentState].AllState(false)); break; } break; } bool flag = false; switch (conditionType - 1) { case ConditionType.None: flag = this.SetCurrentState(_c.FirstElement); break; case ConditionType.Forced: flag = this.SetCurrentState(_c.GetProportionState()); break; case ConditionType.Proportion: flag = this.SetCurrentState(_c.GetRandomState()); break; case ConditionType.Random: flag = this.SetCurrentState(_c.GetNonOverlapState()); break; } if (flag) { return(true); } if (_nextState != AnimalState.None) { this.Animal.CurrentState = _nextState; } return(false); }