private void ActionState() { act = (fsm, gameObj) => { if (currentActions.Count == 0) { fsm.popState(); fsm.pushState(idle); return; } GoapAction action = currentActions.Peek(); if (!action.init) { if (!action.inWait) { bool success = action.IsSucc(); if (!success) { fsm.popState(); fsm.pushState(idle); goapAgent.PlanAborted(action); action.DoReset(); return; } if (action.IsDone()) { action.DoReset(); goapAgent.ActionFinished(action); currentActions.Dequeue(); } } else { return; } } if (currentActions.Count > 0) { action = currentActions.Peek(); if (action.IsInRange()) { action.DoAction(gameObj); action.init = false; } else { fsm.pushState(move); } } else { fsm.popState(); fsm.pushState(idle); } }; }