-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save the ship: retreat if local is not clean.
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,56 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Sanderling.Motor; | ||
using BotEngine.Common; | ||
using Sanderling.ABot.Parse; | ||
using Sanderling.Interface.MemoryStruct; | ||
|
||
namespace Sanderling.ABot.Bot.Task | ||
{ | ||
public class SaveShipTask : IBotTask | ||
{ | ||
public Bot Bot; | ||
|
||
public bool AllowRoam; | ||
|
||
static public bool ChatIsClean(WindowChatChannel chatWindow) | ||
{ | ||
if (null == chatWindow) | ||
return false; | ||
|
||
if (chatWindow?.ParticipantView?.Scroll?.IsScrollable() ?? true) | ||
return false; | ||
|
||
var listParticipantNeutralOrEnemy = | ||
chatWindow?.ParticipantView?.Entry?.Where(participant => participant.IsNeutralOrEnemy())?.ToArray(); | ||
|
||
// we expect own char to show up there as well so there has to be one participant with neutral or enemy flag. | ||
return 1 == listParticipantNeutralOrEnemy?.Length; | ||
} | ||
|
||
public IEnumerable<IBotTask> Component | ||
{ | ||
get | ||
{ | ||
var memoryMeasurement = Bot?.MemoryMeasurementAtTime?.Value; | ||
|
||
var charIsLocatedInHighsec = 500 < memoryMeasurement?.InfoPanelCurrentSystem?.SecurityLevelMilli; | ||
|
||
var localChatWindow = memoryMeasurement?.WindowChatChannel?.FirstOrDefault(window => window?.Caption?.RegexMatchSuccessIgnoreCase(@"local\s*\[") ?? false); | ||
|
||
if (charIsLocatedInHighsec || ChatIsClean(localChatWindow)) | ||
{ | ||
AllowRoam = true; | ||
yield break; | ||
} | ||
|
||
yield return new RetreatTask | ||
{ | ||
Bot = Bot, | ||
}; | ||
} | ||
} | ||
|
||
public MotionParam Motion => null; | ||
} | ||
} |
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