public void PrintPath() { for (int x = 0; x < Grid.Rows; x++) { for (int y = 0; y < Grid.Columns; y++) { if (Grid.Tiles[x, y] == Grid.Goal) { Console.Write("# "); } else if (Grid.Tiles[x, y].Position == Position) { Console.Write("P "); } else if (Waypoints.Contains(Grid.Tiles[x, y])) { Console.Write(". "); } else if (Grid.Tiles[x, y].IsOccupied) { Console.Write("B "); } else { Console.Write("* "); } } Console.WriteLine(); } }
/// <summary> /// Add Destination to the route /// </summary> /// <param name="systemID">System to set destination to</param> /// <param name="clear">Clear all waypoints before setting?</param> public async void AddDestination(long systemID, bool clear) { if (clear) { Waypoints.Clear(); ActiveRoute.Clear(); } Waypoints.Add(EveManager.Instance.SystemIDToName[systemID]); UpdateActiveRoute(); ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient; esiClient.SetCharacterData(ESIAuthData); bool firstRoute = true; foreach (Navigation.RoutePoint rp in ActiveRoute) { // explicitly add interim waypoints for ansiblex gates or actual waypoints if (rp.GateToTake == Navigation.GateType.Ansibex || Waypoints.Contains(rp.SystemName)) { long wayPointSysID = EveManager.Instance.GetEveSystem(rp.SystemName).ID; ESI.NET.EsiResponse <string> esr = await esiClient.UserInterface.Waypoint(wayPointSysID, false, firstRoute); if (EVEData.ESIHelpers.ValidateESICall <string>(esr)) { routeNeedsUpdate = true; } firstRoute = false; } } /* * ESI.NET.EsiResponse<string> esr = await esiClient.UserInterface.Waypoint(systemID, false, true); * if(EVEData.ESIHelpers.ValidateESICall<string>(esr)) * { * routeNeedsUpdate = true; * } */ }
/// <summary> /// Update the active route for the character /// </summary> private async void UpdateActiveRoute() { if (Waypoints.Count == 0) { return; } lock (ActiveRouteLock) { // new routing string start = string.Empty; string end = Location; Application.Current.Dispatcher.Invoke((Action)(() => { if (Location == Waypoints[0]) { Waypoints.RemoveAt(0); } ActiveRoute.Clear(); }), DispatcherPriority.ApplicationIdle); // loop through all the waypoints and query ESI for the route for (int i = 0; i < Waypoints.Count; i++) { start = end; end = Waypoints[i]; List <Navigation.RoutePoint> sysList = Navigation.Navigate(start, end, UseAnsiblexGates, NavigationMode); if (sysList != null) { foreach (Navigation.RoutePoint s in sysList) { Application.Current.Dispatcher.Invoke((Action)(() => { ActiveRoute.Add(s); }), DispatcherPriority.ContextIdle, null); } } } } if (esiRouteNeedsUpdate) { esiRouteNeedsUpdate = false; List <long> WayPointsToAdd = new List <long>(); lock (ActiveRouteLock) { foreach (Navigation.RoutePoint rp in ActiveRoute) { // explicitly add interim waypoints for ansiblex gates or actual waypoints if (rp.GateToTake == Navigation.GateType.Ansibex || Waypoints.Contains(rp.SystemName)) { long wayPointSysID = EveManager.Instance.GetEveSystem(rp.SystemName).ID; WayPointsToAdd.Add(wayPointSysID); } } } bool firstRoute = true; foreach (long SysID in WayPointsToAdd) { ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient; esiClient.SetCharacterData(ESIAuthData); ESI.NET.EsiResponse <string> esr = await esiClient.UserInterface.Waypoint(SysID, false, firstRoute); if (EVEData.ESIHelpers.ValidateESICall <string>(esr)) { // routeNeedsUpdate = true; } firstRoute = false; //Thread.Sleep(50); } } }
/// <summary> /// Update the active route for the character /// </summary> private async void UpdateActiveRoute() { if (esiSendRouteClear) { esiSendRouteClear = false; esiRouteNeedsUpdate = false; System s = EveManager.Instance.GetEveSystem(Location); if (s != null) { ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient; esiClient.SetCharacterData(ESIAuthData); ESI.NET.EsiResponse <string> esr = await esiClient.UserInterface.Waypoint(s.ID, false, true); if (EVEData.ESIHelpers.ValidateESICall <string>(esr)) { // failed to clear route } } return; } if (Waypoints.Count == 0) { return; } { // new routing string start = string.Empty; string end = Location; // grab the simple list of thera connections List <string> currentActiveTheraConnections = new List <string>(); foreach (TheraConnection tc in EveManager.Instance.TheraConnections) { currentActiveTheraConnections.Add(tc.System); } Navigation.UpdateTheraConnections(currentActiveTheraConnections); Application.Current.Dispatcher.Invoke((Action)(() => { lock (ActiveRouteLock) { if (Location == Waypoints[0]) { Waypoints.RemoveAt(0); } } ActiveRoute.Clear(); }), DispatcherPriority.Normal); // loop through all the waypoints for (int i = 0; i < Waypoints.Count; i++) { start = end; end = Waypoints[i]; List <Navigation.RoutePoint> sysList = Navigation.Navigate(start, end, UseAnsiblexGates, UseTheraRouting, NavigationMode); if (sysList != null) { Application.Current.Dispatcher.Invoke((Action)(() => { lock (ActiveRouteLock) { foreach (Navigation.RoutePoint s in sysList) { ActiveRoute.Add(s); } } }), DispatcherPriority.Normal, null); } } } if (esiRouteNeedsUpdate && !esiRouteUpdating) { esiRouteNeedsUpdate = false; esiRouteUpdating = true; List <long> WayPointsToAdd = new List <long>(); lock (ActiveRouteLock) { foreach (Navigation.RoutePoint rp in ActiveRoute) { // explicitly add interim waypoints for ansiblex gates or actual waypoints if (rp.GateToTake == Navigation.GateType.Ansiblex || rp.GateToTake == Navigation.GateType.Thera || Waypoints.Contains(rp.SystemName)) { long wayPointSysID = EveManager.Instance.GetEveSystem(rp.SystemName).ID; if (rp.GateToTake == Navigation.GateType.Ansiblex) { foreach (JumpBridge jb in EveManager.Instance.JumpBridges) { if (jb.From == rp.SystemName) { if (jb.FromID != 0) { wayPointSysID = jb.FromID; } break; } if (jb.To == rp.SystemName) { if (jb.ToID != 0) { wayPointSysID = jb.ToID; } break; } } } WayPointsToAdd.Add(wayPointSysID); } } } bool firstRoute = true; foreach (long SysID in WayPointsToAdd) { ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient; esiClient.SetCharacterData(ESIAuthData); ESI.NET.EsiResponse <string> esr = await esiClient.UserInterface.Waypoint(SysID, false, firstRoute); if (EVEData.ESIHelpers.ValidateESICall <string>(esr)) { // routeNeedsUpdate = true; } firstRoute = false; // with a shorter wait, ive found the occasional out of order route Thread.Sleep(200); } esiRouteUpdating = false; } }
public string GetWayPointText() { string ClipboardText = "Waypoints\n==============\n"; lock (ActiveRouteLock) { foreach (Navigation.RoutePoint rp in ActiveRoute) { string WayPointText = string.Empty; long wayPointSysID = EveManager.Instance.GetEveSystem(rp.SystemName).ID; // explicitly add interim waypoints for ansiblex gates or actual waypoints if (rp.GateToTake == Navigation.GateType.Ansiblex) { bool isSystemLink = true; if (rp.GateToTake == Navigation.GateType.Ansiblex) { string GateDesto = string.Empty; foreach (JumpBridge jb in EveManager.Instance.JumpBridges) { if (jb.From == rp.SystemName) { if (jb.FromID != 0) { wayPointSysID = jb.FromID; isSystemLink = false; } GateDesto = jb.To; break; } if (jb.To == rp.SystemName) { if (jb.ToID != 0) { wayPointSysID = jb.ToID; isSystemLink = false; } GateDesto = jb.From; break; } } if (isSystemLink) { WayPointText = "Ansiblex: <url=showinfo:5//" + wayPointSysID + ">" + rp.SystemName + " » " + GateDesto + " </url>\n"; } else { WayPointText = "Ansiblex: <url=showinfo:35841//" + wayPointSysID + ">" + rp.SystemName + " » " + GateDesto + "</url>\n"; } } } if (Waypoints.Contains(rp.SystemName)) { // regular waypoint wayPointSysID = EveManager.Instance.GetEveSystem(rp.SystemName).ID; WayPointText = "<url=showinfo:5//" + wayPointSysID + ">" + rp.SystemName + "</url>\n"; } ClipboardText += WayPointText; } } return(ClipboardText); }
internal bool IsWaypoint(int x, int y) => Waypoints.Contains(new Tuple <int, int>(x, y));