public Stargate AddOrUpdateStargateToSystemId(int id, GetUniverseSystemsSystemIdOk system) { var gate = _context.Stargates.FirstOrDefault(x => x.Id == id); if (gate == null) { var esiResult = _universeApi.GetUniverseStargatesStargateId(id, null, null); var destoSystem = _universeApi.GetUniverseSystemsSystemId(esiResult.Destination.SystemId.Value, "en-us", null, null, "en-us"); var desto = new Stargate { Id = esiResult.Destination.StargateId.Value, SystemId = esiResult.Destination.SystemId.Value, }; _context.Stargates.Add(desto); gate = new Stargate { Id = id, SystemId = esiResult.SystemId.Value, }; _context.Stargates.Add(gate); _context.SaveChanges(); AddAdjacency(system.SystemId.Value, esiResult.Destination.SystemId.Value, -1, destoSystem.SecurityStatus <= 0.45 || system.SecurityStatus <= 0.45 ? 100 : // Null/Low sec connection = 100 1); desto.DestinationId = gate.Id; gate.DestinationId = desto.Id; _context.SaveChanges(); } return(gate); }
public ServiceLocation( IConfiguration configuration, IHttpClientFactory clientFactory) { _client = clientFactory.CreateClient(); var section = configuration.GetSection("Dependencies"); Account = TrySet(section["AccountPath"], "https://account.aiursoft.com"); Gateway = TrySet(section["GatewayPath"], "https://gateway.aiursoft.com"); Archon = TrySet(section["ArchonPath"], "https://archon.aiursoft.com"); UI = TrySet(section["UIPath"], "https://ui.aiursoft.com"); Colossus = TrySet(section["ColossusPath"], "https://colossus.aiursoft.com"); Developer = TrySet(section["DeveloperPath"], "https://developer.aiursoft.com"); EE = TrySet(section["EEPath"], "https://ee.aiursoft.com"); Stargate = TrySet(section["StargatePath"], "https://stargate.aiursoft.com"); Wiki = TrySet(section["WikiPath"], "https://wiki.aiursoft.com"); WWW = TrySet(section["WWWPath"], "https://www.aiursoft.com"); Probe = TrySet(section["ProbePath"], "https://probe.aiursoft.com"); ProbeIO = TrySet(section["ProbeIOPath"], "https://{0}.aiursoft.io"); Status = TrySet(section["StatusPath"], "https://status.aiursoft.com"); StargateListenAddress = Stargate .Replace("https://", "wss://") .Replace("http://", "ws://"); AsyncHelper.RunSync(async() => { UI = await TryGetCDNDomain(UI); }); }
public void JumpToGalaxy(Stargate target) { SolarID = target.SolarsystemID; Solar = target.Position + new Vector2(5, 5); SolarTarget = Solar; }
private void CreateStargate(Stargate stargate) { var stargateObj = Instantiate(IconPrefab); stargateObj.transform.SetParent(Content.transform, false); stargateObj.Body = stargate; stargateObj.transform.localPosition = stargate.Position; stargateObj.Init(stargate as SolarSystemBody, TerminalNavigationSolarIcon.BodyTypes.STARGATE); stargateObj.OnClick += OnIconClicked; }
void GenerateStargates() { int sgcount = _random.Next(_wormholes.Count > 0 ? 0 : 1, MAX_STARGATES); for (int i = 0; i < sgcount; i++) { Stargate s = new Stargate( "Stargate", GetLocation(500), _random); _stargates.Add(s); _pointsOfInterest.Add(s); } }
private void OnStargateClicked(TerminalNavigationSolarIcon icon, PointerEventData eventData) { Marker.transform.localPosition = icon.Body.Position; if (eventData.button == PointerEventData.InputButton.Right) { Selector.transform.localPosition = SelectorPosition = icon.Body.Position; ShipHandler.Instance.ActiveShip.Position.SetSolarDestination(SelectorPosition); } if (Vector2.Distance(ShipHandler.Instance.ActiveShip.Position.Solar, icon.Body.Position) > 15) { return; } var menu = Instantiate(Resources.Load <MenuStargate>("Terminals/Navigation/Prefabs/Menu_Stargate")); menu.transform.SetParent(MainCanvas.Instance.transform, false); Stargate stargate = icon.Body as Stargate; menu.OnClose += (x) => { ShipHandler.Instance.ActiveShip.Position.JumpToGalaxy(stargate.Target); GenerateSolarSystem(); }; }
private static void AddStargates() { Dictionary <Stargate, int> gates = new Dictionary <Stargate, int>(); foreach (var con in StargateConnections) { int solarsystemID = Constellation.SolarSystemByPosition(con.Key).SolarsystemID; foreach (var stargate in con.Value.Connections) { int targetID = Constellation.SolarSystemByPosition(stargate.Position).SolarsystemID; Stargate sgate = new Stargate(Vector2Int.zero, solarsystemID); gates.Add(sgate, targetID); Constellation.SolarSystems[solarsystemID].Stargates.Add(sgate); } } Dictionary <Stargate, int> connectedGates = new Dictionary <Stargate, int>(); foreach (KeyValuePair <Stargate, int> stargate in gates) { if (connectedGates.ContainsKey(stargate.Key)) { continue; } // Grab a gate from the Gate list foreach (var targetGate in gates) { if (connectedGates.ContainsKey(targetGate.Key)) { continue; } if (stargate.Key == targetGate.Key) { continue; } // If the gates are poiting towards the same system, continue. if (targetGate.Value == stargate.Value) { continue; } // If the target system ID doesnt' match the gate target ID, continue. if (targetGate.Key.SolarsystemID != stargate.Value) { continue; } // Add the connected gates to the "ConnectedGates" list. connectedGates.Add(stargate.Key, stargate.Value); connectedGates.Add(targetGate.Key, targetGate.Value); stargate.Key.Target = targetGate.Key; targetGate.Key.Target = stargate.Key; break; } } }
/// <summary> /// Load the yaml files. /// </summary> /// <param name="worker">The worker thread that is calling this function.</param> /// <param name="start">The starting percentage of the work.</param> /// <param name="portion">The portion of the progress that is for this activity.</param> /// <returns>The error message or null on success.</returns> public static string LoadYAML(BackgroundWorker worker, int start, int portion) { bool solarSystemsCached = false; string solarSystemCacheFile = UserData.cachePath + Path.GetFileName(UserData.sdeZip) + ".SolarSystems.Cache"; if (File.Exists(solarSystemCacheFile)) { if (worker != null && !worker.CancellationPending) { // Updatee the worker status. worker.ReportProgress(start, "Loading cached system files..."); } try { using (FileStream file = new FileStream(solarSystemCacheFile, FileMode.Open)) { using (BinaryReader load = new BinaryReader(file)) { bool success = SolarSystem.LoadAll(load); success &= Stargate.LoadAll(load); success &= OrbitalBody.LoadAll(load); success &= NPCStation.LoadAll(load); if (success) { // Successfully loaded cache. solarSystemsCached = true; } } } } catch (Exception e) { // An error occured, we should delete the file it appears corrupted. File.Delete(solarSystemCacheFile); } } baseComplete = false; List <string> solarSystemFiles = new List <string>(); if (File.Exists(UserData.sdeZip)) { FileStream fileStream = File.OpenRead(UserData.sdeZip); ZipArchive zip = new ZipArchive(fileStream); foreach (ZipArchiveEntry zipFile in zip.Entries) { string fName = zipFile.FullName; bool isSystem = fName.EndsWith("solarsystem.staticdata") && !solarSystemsCached; if (fName.EndsWith(".yaml") || isSystem) { MemoryStream memStream = new MemoryStream(); Stream zStream = zipFile.Open(); zStream.CopyTo(memStream); memStream.Position = 0; zipFiles[zipFile.FullName] = memStream; } if (isSystem) { if (fName.StartsWith("sde")) { fName = fName.Remove(0, 3); } solarSystemFiles.Add(fName); } } } // Get the yaml files. List <LoadYamlItem> yamlFiles = GetYamlFiles(); int baseFiles = yamlFiles.Count; worker.ReportProgress(start, "Searching solar system files..."); int cnt = 0; int total = yamlFiles.Count + solarSystemFiles.Count; while (cnt < total) { while (yamlFiles.Count < 40 && solarSystemFiles.Count > 0 && cnt >= baseFiles) { // Start loading some files. string solarSystemFile = solarSystemFiles[0]; yamlFiles.Add(new LoadYamlItem(solarSystemFile, SolarSystem.LoadYAML)); solarSystemFiles.Remove(solarSystemFile); } // We still have files to parse. foreach (LoadYamlItem item in yamlFiles) { if (item.complete == false) { if (worker != null) { // We are using a worker, check for cancel. if (worker.CancellationPending) { return("Cancled by user request."); } } if (item.err != null) { // There was an error. return(item.err); } // This file still not loaded. continue; } // Increment out count and remove the item. cnt++; if (cnt >= baseFiles) { baseComplete = true; } yamlFiles.Remove(item); if (worker != null && !worker.CancellationPending && ((cnt % 10) == 0 || cnt < 20)) { // Updatee the worker status. int pct = (cnt * portion) / total; worker.ReportProgress(start + pct, "Loading YAML files... (" + cnt + " of " + total + " complete)"); } break; } } zipFiles.Clear(); // Save cache if (!solarSystemsCached) { using (FileStream mem = new FileStream(solarSystemCacheFile, FileMode.Create)) { using (BinaryWriter save = new BinaryWriter(mem)) { SolarSystem.SaveAll(save); Stargate.SaveAll(save); OrbitalBody.SaveAll(save); NPCStation.SaveAll(save); //byte[] ary = mem.ToArray(); } } } return(null); }
public RestDatabaseService(string BaseUrl) { this.BaseUrl = BaseUrl; this.StargateApi = Stargate.Create(BaseUrl); }