Skip to content

Commit

Permalink
Turnur based routing as an option
Browse files Browse the repository at this point in the history
  • Loading branch information
BitBaboonSteve committed Sep 8, 2024
1 parent 0dbcdd3 commit dd98559
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 97 deletions.
114 changes: 114 additions & 0 deletions EVEData/EveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ public static EveManager Instance
/// </summary>
public event TheraUpdatedHandler TheraUpdateEvent;


/// <summary>
/// Turnur Connections Updated Event Handler
/// </summary>
public delegate void TurnurUpdatedHandler();

/// <summary>
/// Turnur Updated Added Events
/// </summary>
public event TurnurUpdatedHandler TurnurUpdateEvent;


/// <summary>
/// Storms Updated Event Handler
/// </summary>
Expand Down Expand Up @@ -327,6 +339,12 @@ public static EveManager Instance
/// </summary>
public List<TheraConnection> TheraConnections { get; set; }

/// <summary>
/// Gets or sets the current list of Turnur connections
/// </summary>
public List<TurnurConnection> TurnurConnections { get; set; }


public bool UseESIForCharacterPositions { get; set; }

public List<Storm> MetaliminalStorms { get; set; }
Expand Down Expand Up @@ -2354,6 +2372,89 @@ public async void UpdateTheraConnections()
}
}

/// <summary>
/// Update the current Turnur Connections from EVE-Scout
/// </summary>
public async void UpdateTurnurConnections()
{
string turnurApiURL = "https://api.eve-scout.com/v2/public/signatures?system_name=Turnur";
string strContent = string.Empty;

try
{
HttpClient hc = new HttpClient();
var response = await hc.GetAsync(turnurApiURL);
response.EnsureSuccessStatusCode();
strContent = await response.Content.ReadAsStringAsync();

JsonTextReader jsr = new JsonTextReader(new StringReader(strContent));

TurnurConnections.Clear();

/*
new format
"id": "46",
"created_at": "2023-12-02T11:24:49.000Z",
"created_by_id": 93027866,
"created_by_name": "Das d'Alembert",
"updated_at": "2023-12-02T11:27:01.000Z",
"updated_by_id": 93027866,
"updated_by_name": "Das d'Alembert",
"completed_at": "2023-12-02T11:27:01.000Z",
"completed_by_id": 93027866,
"completed_by_name": "Das d'Alembert",
"completed": true,
"wh_exits_outward": true,
"wh_type": "Q063",
"max_ship_size": "medium",
"expires_at": "2023-12-03T04:24:49.000Z",
"remaining_hours": 14,
"signature_type": "wormhole",
"out_system_id": 31000005,
"out_system_name": "Thera",
"out_signature": "HMM-222",
"in_system_id": 30001715,
"in_system_class": "hs",
"in_system_name": "Moutid",
"in_region_id": 10000020,
"in_region_name": "Tash-Murkon",
"in_signature": "LPI-677"
*/

while (jsr.Read())
{
if (jsr.TokenType == JsonToken.StartObject)
{
JObject obj = JObject.Load(jsr);
string inSignatureId = obj["in_signature"].ToString();
string outSignatureId = obj["out_signature"].ToString();
long solarSystemId = long.Parse(obj["in_system_id"].ToString());
string wormHoleEOL = obj["expires_at"].ToString();
string type = obj["signature_type"].ToString();

if (type != null && type == "wormhole" && solarSystemId != 0 && wormHoleEOL != null && SystemIDToName.ContainsKey(solarSystemId))
{
System turnurConnectionSystem = GetEveSystemFromID(solarSystemId);

TurnurConnection tc = new TurnurConnection(turnurConnectionSystem.Name, turnurConnectionSystem.Region, inSignatureId, outSignatureId, wormHoleEOL);
TurnurConnections.Add(tc);
}
}
}
}
catch
{
return;
}

if (TurnurUpdateEvent != null)
{
TurnurUpdateEvent();
}
}


public void UpdateMetaliminalStorms()
{
MetaliminalStorms.Clear();
Expand Down Expand Up @@ -2567,6 +2668,7 @@ private void Init()
LoadCharacters();

InitTheraConnections();
InitTurnurConnections();

InitMetaliminalStorms();
InitFactionWarfareInfo();
Expand Down Expand Up @@ -2638,6 +2740,17 @@ private void InitTheraConnections()
UpdateTheraConnections();
}

/// <summary>
/// Initialise the Turnur Connection Data from EVE-Scout
/// </summary>
private void InitTurnurConnections()
{
TurnurConnections = new List<TurnurConnection>();
UpdateTurnurConnections();
}



/// <summary>
/// Initialise the Zarzakh Connection Data
/// </summary>
Expand Down Expand Up @@ -3167,6 +3280,7 @@ private void StartBackgroundThread()
UpdateESIUniverseData();
UpdateServerInfo();
UpdateTheraConnections();
UpdateTurnurConnections();
}
if ((NextDotlanUpdate - DateTime.Now).Minutes < 0)
Expand Down
38 changes: 35 additions & 3 deletions EVEData/LocalCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class LocalCharacter : Character, INotifyPropertyChanged

private bool m_UseZarzakhRouting;

private bool m_UseTurnurRouting;

private bool m_isOnline;

private bool m_ObservatoryDecloakWarningEnabled;
Expand Down Expand Up @@ -420,6 +422,26 @@ public bool UseZarzakhRouting
}
}

public bool UseTurnurRouting
{
get
{
return m_UseTurnurRouting;
}
set
{
if (m_UseTurnurRouting == value)
{
return;
}

m_UseTurnurRouting = value;
routeNeedsUpdate = true;
esiRouteNeedsUpdate = true;
OnPropertyChanged("UseTurnurRouting");
}
}


public int DangerZoneRange { get; set; }

Expand Down Expand Up @@ -778,12 +800,21 @@ private async void UpdateActiveRoute()

// grab the simple list of thera connections
List<string> currentActiveTheraConnections = new List<string>();
foreach (TheraConnection tc in EveManager.Instance.TheraConnections)
foreach (TheraConnection tc in EveManager.Instance.TheraConnections.ToList())
{
currentActiveTheraConnections.Add(tc.System);
}
Navigation.UpdateTheraConnections(currentActiveTheraConnections);

// grab the simple list of turnur connections
List<string> currentActiveTurnurConnections = new List<string>();
foreach (TurnurConnection tc in EveManager.Instance.TurnurConnections.ToList())
{
currentActiveTurnurConnections.Add(tc.System);
}
Navigation.UpdateTurnurConnections(currentActiveTurnurConnections);


lock (ActiveRouteLock)
{
if (Location == Waypoints[0])
Expand All @@ -800,7 +831,7 @@ private async void UpdateActiveRoute()
start = end;
end = Waypoints[i];

List<Navigation.RoutePoint> sysList = Navigation.Navigate(start, end, UseAnsiblexGates, UseTheraRouting, UseZarzakhRouting, NavigationMode);
List<Navigation.RoutePoint> sysList = Navigation.Navigate(start, end, UseAnsiblexGates, UseTheraRouting, UseZarzakhRouting, UseTurnurRouting, NavigationMode);

if (sysList != null)
{
Expand Down Expand Up @@ -829,7 +860,8 @@ private async void UpdateActiveRoute()
// explicitly add interim waypoints for ansiblex gates or actual waypoints
if (
rp.GateToTake == Navigation.GateType.Ansiblex ||
rp.GateToTake == Navigation.GateType.Thera ||
rp.GateToTake == Navigation.GateType.Thera ||
rp.GateToTake == Navigation.GateType.Turnur ||
rp.GateToTake == Navigation.GateType.Zarzakh||
Waypoints.Contains(rp.SystemName)
)
Expand Down
Loading

0 comments on commit dd98559

Please sign in to comment.