forked from julianperrott/WowClassicGrindBot
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: FleeGoal: uses a slightly different implementation to bette…
…r fit with the current project setup.
- Loading branch information
Showing
5 changed files
with
111 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Core.GOAP; | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace Core.Goals; | ||
|
||
public sealed class SafeSpotCollector : IDisposable | ||
{ | ||
private readonly PlayerReader playerReader; | ||
private readonly GoapAgentState state; | ||
private readonly AddonBits bits; | ||
|
||
private readonly Timer timer; | ||
|
||
public SafeSpotCollector( | ||
PlayerReader playerReader, | ||
GoapAgentState state, | ||
AddonBits bits) | ||
{ | ||
this.playerReader = playerReader; | ||
this.state = state; | ||
this.bits = bits; | ||
|
||
timer = new(Update, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
timer.Dispose(); | ||
} | ||
|
||
public void Update(object? obj) | ||
{ | ||
if (bits.Combat()) | ||
return; | ||
|
||
if (state.SafeLocations.TryPeek(out var lastPos) && | ||
lastPos == playerReader.MapPosNoZ) | ||
return; | ||
|
||
state.SafeLocations.Push(playerReader.MapPosNoZ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters