diff --git a/Package/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs b/Package/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs index 7f322957..64b0eb84 100644 --- a/Package/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs +++ b/Package/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs @@ -197,6 +197,11 @@ public void SetGoal(IGoalBase goal, bool endAction) this.EndAction(); } + public void ClearGoal() + { + this.CurrentGoal = null; + } + public void SetAction(IActionBase action, List path, ITarget target) { if (this.CurrentAction != null) diff --git a/Package/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs b/Package/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs index f9934d49..83eb7a44 100644 --- a/Package/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs +++ b/Package/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs @@ -57,7 +57,9 @@ private void Run(GlobalWorldData globalData, IMonoAgent agent) if (this.IsGoalCompleted(localData, agent)) { - agent.Events.GoalCompleted(agent.CurrentGoal); + var goal = agent.CurrentGoal; + agent.ClearGoal(); + agent.Events.GoalCompleted(goal); return; } diff --git a/Package/Runtime/CrashKonijn.Goap/Interfaces/IAgent.cs b/Package/Runtime/CrashKonijn.Goap/Interfaces/IAgent.cs index 2088b5a2..664eedde 100644 --- a/Package/Runtime/CrashKonijn.Goap/Interfaces/IAgent.cs +++ b/Package/Runtime/CrashKonijn.Goap/Interfaces/IAgent.cs @@ -18,9 +18,9 @@ public interface IAgent IAgentDistanceObserver DistanceObserver { get; } void Run(); - - void SetGoal(bool endAction) where TGoal : IGoalBase; + void ClearGoal(); + void SetGoal(bool endAction) where TGoal : IGoalBase; void SetGoal(IGoalBase goal, bool endAction); void SetAction(IActionBase action, List path, ITarget target); void EndAction(bool enqueue = true);