private void Start() { BtAction executeTactic = new BtAction(ExecuteTactic); BtAction ability = new BtAction(() => _activeAbility != null); BtAction allInPosition = new BtAction(() => !_activeAbility.GetData().InPositionBeforeActivation || _groupManager.Imps.All(pair => pair.Key.GetComponent <ContextGroupFormation>().InPosition())); BtAction doAbility = new BtAction(ExecuteAbility); BtSequence combatSequence = new BtSequence(new IBtTask[] { executeTactic, ability, allInPosition, doAbility }); FSMState outOfCombat = new FSMState(); FSMState inCombat = new FSMState(); FSMTransition battleEnter = new FSMTransition(() => _inBattle); FSMTransition battleExit = new FSMTransition(() => !_inBattle); outOfCombat.AddTransition(battleEnter, inCombat); inCombat.AddTransition(battleExit, outOfCombat); inCombat.enterActions.Add(() => OnTacticChanged?.Invoke(_activeTactic)); inCombat.stayActions.Add(() => combatSequence.Run()); outOfCombat.stayActions.Add(SetPlayer); FSM groupFsm = new FSM(outOfCombat); StartCoroutine(FsmStayAlive(groupFsm)); }
private void AssignTactic(TacticFactory newTactic) { if (_activeAbility != null) { return; } if (newTactic == _activeTactic) { return; } _activeTactic = newTactic; OnTacticChanged?.Invoke(_activeTactic); OnTacticChangedGlobal?.Invoke(newTactic, _groupManager.ThisGroupName); }