Skip to content

Commit

Permalink
Fix: #109
Browse files Browse the repository at this point in the history
  • Loading branch information
crashkonijn committed Nov 16, 2023
1 parent b438549 commit 1783f23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Package/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IActionBase> path, ITarget target)
{
if (this.CurrentAction != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions Package/Runtime/CrashKonijn.Goap/Interfaces/IAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public interface IAgent
IAgentDistanceObserver DistanceObserver { get; }

void Run();

void SetGoal<TGoal>(bool endAction) where TGoal : IGoalBase;

void ClearGoal();
void SetGoal<TGoal>(bool endAction) where TGoal : IGoalBase;
void SetGoal(IGoalBase goal, bool endAction);
void SetAction(IActionBase action, List<IActionBase> path, ITarget target);
void EndAction(bool enqueue = true);
Expand Down

0 comments on commit 1783f23

Please sign in to comment.