Skip to content

Commit

Permalink
Merge pull request #162 from crashkonijn/feature/re-queue-agent-on-no…
Browse files Browse the repository at this point in the history
…-action

Requeue agent when no action is found
  • Loading branch information
crashkonijn authored Apr 14, 2024
2 parents 0116c21 + de76a44 commit 81c6bfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public void Initialize(IGoap goap)
{
this.goap = goap;
this.goap.Events.OnAgentResolve += this.OnAgentResolve;
this.goap.Events.OnNoActionFound += this.OnNoActionFound;
}

public void Disable()
{
this.goap.Events.OnAgentResolve -= this.OnAgentResolve;
this.goap.Events.OnNoActionFound -= this.OnNoActionFound;
}

public void OnUpdate()
Expand Down Expand Up @@ -59,6 +61,11 @@ public void OnLateUpdate()
runner.Complete();
}
}

private void OnNoActionFound(IAgent agent, IGoal goal)
{
this.GetQueue(agent.AgentType).Add(agent as IMonoAgent);
}

private void OnAgentResolve(IAgent agent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public void Initialize(IGoap goap)
{
this.goap = goap;
this.goap.Events.OnAgentResolve += this.OnAgentResolve;
this.goap.Events.OnNoActionFound += this.OnNoActionFound;
}

public void Disable()
{
this.goap.Events.OnAgentResolve -= this.OnAgentResolve;
this.goap.Events.OnNoActionFound -= this.OnNoActionFound;
}

public void OnUpdate()
Expand Down Expand Up @@ -47,6 +49,11 @@ public void OnLateUpdate()
}
}

private void OnNoActionFound(IAgent agent, IGoal goal)
{
this.GetQueue(agent.AgentType).Add(agent as IMonoAgent);
}

private void OnAgentResolve(IAgent agent)
{
this.GetQueue(agent.AgentType).Add(agent as IMonoAgent);
Expand Down

0 comments on commit 81c6bfe

Please sign in to comment.