From df6f2e6739a0ff5589e0352567c9948bc66fe599 Mon Sep 17 00:00:00 2001 From: David McDonagh <60879630+toastisme@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:51:02 +0100 Subject: [PATCH] Removed stopAction_==false check for default GOAPAction preconditions Erroneous default `GOAPAction` behaviour: - `GOAPAction.PreconditionsSatisfied()` checks if `stopAction_==false`. - Default `GOAPAction.OnDeactivate()` sets `stopAction_=false`, and is called by `GOAPPlanner` when completing/stopping an action - `stopAction_` is only set to `true` again in `GOAPAction.OnActivate()`, called by `GOAPPlanner` when selecting the action - However `GOAPAction.PreconditionsSatisfied()` is called in the planning stage when seeing if a path is viable, and so by default if a `GOAPAction` was deactivated by the planner, it could not be selected again for a viable path. - This just removes the `stopAction_==false` check --- Runtime/GOAP/GOAPAction.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Runtime/GOAP/GOAPAction.cs b/Runtime/GOAP/GOAPAction.cs index 3f1dbda..c486b04 100644 --- a/Runtime/GOAP/GOAPAction.cs +++ b/Runtime/GOAP/GOAPAction.cs @@ -126,7 +126,6 @@ public virtual bool PreconditionsSatisfied(WorldState worldState){ * true if worldState is a superset of preconditions */ - if (stopAction_){ return false; } return(worldState.IsSubset(preconditions)); } @@ -268,4 +267,4 @@ protected void ClearTemporaryStates(){ } } -} \ No newline at end of file +}