forked from DivverGit/Daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
State now knows what controller it is in, can assign delegates to eve…
…nts within state to assign variables before state from controller. Added example travel controller with states
- Loading branch information
Showing
9 changed files
with
222 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Daedalus.Eve.Bot.States; | ||
using EVE.ISXEVE; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Daedalus.Eve.Bot.Controllers | ||
{ | ||
class TravelController : Controller | ||
{ | ||
private SolarSystem Destination; | ||
|
||
protected override void RegisterStates() | ||
{ | ||
AddState("undock", new UndockState(), "travel"); | ||
|
||
WarpAndJumpState travel = new WarpAndJumpState(); | ||
travel.PreState += (state) => (state as WarpAndJumpState)?.SetDesto(Destination); | ||
|
||
AddState("travel", travel, "dock"); | ||
AddState("dock", new DockState()); | ||
} | ||
} | ||
} |
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,41 @@ | ||
using Daedalus.Eve.Cache; | ||
using Daedalus.Eve.Wrappers; | ||
using EVE.ISXEVE; | ||
using LavishVMAPI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Daedalus.Eve.Bot.States | ||
{ | ||
class DockState : State | ||
{ | ||
int StationID = -1; | ||
|
||
public override bool DoWork() | ||
{ | ||
using (new FrameLock(true)) | ||
{ | ||
if (StationID == -1) | ||
{ | ||
// Dock at top station if avaliable | ||
List<DEntity> entities = EveCache.Instance.EntityCache.AllEntities; | ||
|
||
// Shouldn't use GetRaw, should expose the data through DEntity | ||
DEntity station = entities.Where(e => e.CategoryType == CategoryType.Station).FirstOrDefault(); | ||
|
||
if (station != null) | ||
{ | ||
station.GetRaw().WarpToAndDock(); | ||
return true; | ||
} | ||
|
||
|
||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |
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,35 @@ | ||
using Daedalus.Eve.Bot.Controllers; | ||
using EVE.ISXEVE; | ||
using LavishVMAPI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Daedalus.Eve.Bot.States | ||
{ | ||
class UndockState : State | ||
{ | ||
private bool Undocked = false; | ||
public override bool DoWork() | ||
{ | ||
using (new FrameLock(true)) | ||
{ | ||
Me me = new Me(); | ||
EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); | ||
|
||
if (!me.InSpace && me.InStation && !Undocked) | ||
{ | ||
eve.Execute(ExecuteCommand.CmdExitStation); | ||
Undocked = true; | ||
|
||
} else if (Undocked && me.InSpace && !me.InStation) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |
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,54 @@ | ||
using EVE.ISXEVE; | ||
using LavishVMAPI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Daedalus.Eve.Bot.States | ||
{ | ||
class WarpAndJumpState : State | ||
{ | ||
private SolarSystem Desto; | ||
|
||
public void SetDesto(SolarSystem desto) | ||
{ | ||
this.Desto = desto; | ||
} | ||
|
||
public override bool DoWork() | ||
{ | ||
using (new FrameLock(true)) | ||
{ | ||
if (Desto == null) | ||
return false; | ||
|
||
EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); | ||
Me me = new Me(); | ||
|
||
if (me.SolarSystemID == Desto.ID) | ||
return true; | ||
|
||
List<int> Waypoints = eve.GetWaypoints(); | ||
if (Waypoints.Count > 1 && Waypoints.Contains(Desto.ID)) | ||
{ | ||
eve.ClearAllWaypoints(); | ||
// Wait till next pulse | ||
return false; | ||
} else if (Waypoints.Count == 1 && !Waypoints.Contains(Desto.ID)) | ||
{ | ||
Desto.SetDestination(); | ||
return false; | ||
} | ||
|
||
if (!me.AutoPilotOn) | ||
{ | ||
eve.Execute(ExecuteCommand.CmdToggleAutopilot); | ||
return false; | ||
} | ||
return false; | ||
} | ||
} | ||
} | ||
} |
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