private string FormatBeholdLine(SocketUserMessage message, CrewData crew) { List <string> result = new List <string>(); result.Add($"[Full details for {crew.name}]({_datacoreURL}crew/{crew.symbol}/)"); result.Add(FormatCrewStatsWithEmotes(message, crew)); var rankLine = $"Voyage #{crew.ranks.voyRank}, Gauntlet #{crew.ranks.gauntletRank}, {(crew.events.HasValue ? crew.events.Value : 0)} events, {crew.collections.Count()} collections"; if (crew.bigbook_tier.HasValue) { rankLine += $", Big book **tier {crew.bigbook_tier.Value}**"; } result.Add(rankLine); var coolRanks = CrewFormatter.FormatCrewCoolRanks(crew, true); if (!string.IsNullOrEmpty(coolRanks)) { result.Add($"*{coolRanks}*"); } return(string.Join("\n", result)); }
private void InitEmployeeContent(ref List <EmployeeContent> contentList, ref Transform contentTransform) { contentList = new List <EmployeeContent>(); for (int i = 0; i < contentTransform.childCount; i++) { contentList.Add(contentTransform.GetChild(i).GetComponent <EmployeeContent>()); CrewData crewData = contentList[i].CrewData == null ? (CrewData)ScriptableObject.CreateInstance(typeof(CrewData)) : contentList[i].CrewData; contentList[i].UpdateUI(crewData); } foreach (EmployeeContent content in contentList) { CrewData crewData = content.CrewData; content.transform.SetParent(crewData.isHired ? _crewTransform : _unemployedTransform); if (!_crew.crewDataList.Contains(crewData) && crewData.isHired) { _crew.crewDataList.Add(crewData); } else if (_crew.crewDataList.Contains(crewData) && !crewData.isHired) { _crew.crewDataList.Remove(crewData); } } }
private static string FormatCrewStatsWithEmotes(SocketUserMessage message, CrewData crew, int raritySearch = 0, bool forGauntlet = false) { return(string.Join(" ", CrewFormatter.FormatCrewStats(crew, true, raritySearch, forGauntlet).Select(s => $"{s.Replace("^", " ")}")) .Replace("SCI", GetEmoteOrString(message, "sci", "SCI")) .Replace("SEC", GetEmoteOrString(message, "sec", "SEC")) .Replace("ENG", GetEmoteOrString(message, "eng", "ENG")) .Replace("DIP", GetEmoteOrString(message, "dip", "DIP")) .Replace("CMD", GetEmoteOrString(message, "cmd", "CMD")) .Replace("MED", GetEmoteOrString(message, "med", "MED"))); }
public void UpdateUI(CrewData crewData) { _crewData = crewData; _portrait.sprite = _crewData.sprite; _name.text = _crewData.crewName; _age.text = $"{_crewData.age}"; _gender.text = $"{_crewData.gender}"; _quirk.text = _crewData.quirk; _length.text = $"{_crewData.lengthCM}cm"; _profession.text = $"{_crewData.profession}"; _bloodType.text = _bloodTypes[(int)_crewData.bloodType]; }
static void Main(string[] args) { DataTable crewPanels = CsvReader.GetCrewPanels(); DataTable jsPanels = CsvReader.GetPanels(); DataTable plannedJs = CrewData.GetOffPeriods(); StringBuilder sb = new StringBuilder(); foreach (DataRow crewRow in crewPanels.Rows) { string partTimeType = crewRow["Part Time Type"].ToString(); if (partTimeType != "FT") { string crewMember = crewRow[0].ToString(); var crewPlannedJs = plannedJs.Select($"P_LTR_CODE = '{crewMember}'"); List <DateTime> plannedDates = GetPlannedDates(crewPlannedJs); foreach (DataRow jsRow in jsPanels.Rows) { if (jsRow[partTimeType].ToString() == "1") { DateTime panelDate = DateTime.Parse(jsRow[0].ToString()); if (plannedDates.Contains(panelDate) == false) { sb.AppendLine($"{crewMember} does not match panel {partTimeType}"); break; } } } } else { string crewMember = crewRow[0].ToString(); var crewPlannedJs = plannedJs.Select($"P_LTR_CODE = '{crewMember}'"); if (crewPlannedJs.Count() > 0) { sb.AppendLine($"{crewMember} does not match panel {partTimeType}"); break; } } } System.IO.File.WriteAllText("C:\\Users\\david.bracken\\OneDrive - TUI\\Documents\\Furlough\\CC Infor\\Panel Errors.txt", sb.ToString()); }
/// <summary> ///List halinde bir veya birden fazla Crew datası iletir. /// </summary> /// <param name="client"></param> private static void CrewData_Post(HttpClient client) { CrewData crewData = new CrewData() { Crew = new List <Crew> { new Crew { CrewId = "000111", Airline = "SXS", Airport = "AYT", FirstName = "SAM", LastName = "BROWN", Title = "SE", StartDate = "2019-07-01Z", EndDate = "2019-08-01Z" }, new Crew { CrewId = "000222", Airline = "SXS", Airport = "AYT", FirstName = "JOHN", LastName = "WHITE", Title = "SE", StartDate = "2019-07-01Z", EndDate = "2019-08-01Z" }, new Crew { CrewId = "000333", Airline = "SXS", Airport = "AYT", FirstName = "CHARLES", LastName = "BARKLEY", Title = "SE", StartDate = "2019-07-01Z", EndDate = "2019-08-01Z" }, } }; CrewDataRootObject root = new CrewDataRootObject(); root.CrewData = crewData; ///StructureCheck string jsonContent = JsonConvert.SerializeObject(root); string apiQuery = ($"/api/CrewData/Post?user={username}&pass={password}"); Uri url = new Uri(client.BaseAddress + apiQuery); var postTask = client.PostAsJsonAsync(url, root); postTask.Wait(); var result = postTask.Result; var innerMsg = result.Content.ReadAsStringAsync().Result; Console.WriteLine($"{(Int32)result.StatusCode}, {result.ReasonPhrase},{innerMsg}"); }
protected override void OnLoad(ConfigNode configNode) { base.OnLoad(configNode); vesselsCreated = ConfigNodeUtil.ParseValue <bool>(configNode, "vesselsCreated"); deferVesselCreation = ConfigNodeUtil.ParseValue <bool?>(configNode, "deferVesselCreation", (bool?)false).Value; foreach (ConfigNode child in configNode.GetNodes("VESSEL_DETAIL")) { // Read all the orbit data VesselData vd = new VesselData(); vd.name = child.GetValue("name"); vd.id = ConfigNodeUtil.ParseValue <Guid?>(child, "id", (Guid?)null); vd.craftURL = child.GetValue("craftURL"); vd.craftPart = ConfigNodeUtil.ParseValue <AvailablePart>(child, "craftPart", null); vd.flagURL = ConfigNodeUtil.ParseValue <string>(child, "flagURL", (string)null); vd.vesselType = ConfigNodeUtil.ParseValue <VesselType>(child, "vesselType"); vd.body = ConfigNodeUtil.ParseValue <CelestialBody>(child, "body"); vd.latitude = ConfigNodeUtil.ParseValue <double>(child, "lat"); vd.longitude = ConfigNodeUtil.ParseValue <double>(child, "lon"); vd.altitude = ConfigNodeUtil.ParseValue <double?>(child, "alt", (double?)null); vd.heading = ConfigNodeUtil.ParseValue <float>(child, "heading", 0.0f); vd.pitch = ConfigNodeUtil.ParseValue <float>(child, "pitch", 0.0f); vd.roll = ConfigNodeUtil.ParseValue <float>(child, "roll", 0.0f); vd.orbiting = ConfigNodeUtil.ParseValue <bool?>(child, "orbiting", (bool?)child.HasNode("ORBIT")).Value; vd.owned = ConfigNodeUtil.ParseValue <bool>(child, "owned"); if (child.HasNode("ORBIT")) { vd.orbit = new OrbitSnapshot(child.GetNode("ORBIT")).Load(); } // Load crew data foreach (ConfigNode crewNode in child.GetNodes("CREW")) { CrewData cd = new CrewData(); cd.name = ConfigNodeUtil.ParseValue <string>(crewNode, "name", (string)null); cd.addToRoster = ConfigNodeUtil.ParseValue <bool>(crewNode, "addToRoster"); vd.crew.Add(cd); } // Add to the global list vessels.Add(vd); } }
private void SetEmployeeStatus(bool hire) { CrewData crewData = _employeeContract.CrewData; crewData.isHired = hire; if (hire) { _crew.crewDataList.Add(crewData); } else { _crew.crewDataList.Remove(crewData); } _currentEmployeeContent.transform.SetParent(hire ? _crewTransform : _unemployedTransform); SetEmployeeContract(false); }
public static SpawnVessel Create(ConfigNode configNode, SpawnVesselFactory factory) { SpawnVessel spawnVessel = new SpawnVessel(); ConfigNodeUtil.ParseValue <bool>(configNode, "deferVesselCreation", x => spawnVessel.deferVesselCreation = x, factory, false); bool valid = true; int index = 0; foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "VESSEL")) { DataNode dataNode = new DataNode("VESSEL_" + index++, factory.dataNode, factory); try { ConfigNodeUtil.SetCurrentDataNode(dataNode); VesselData vessel = new VesselData(); // Get name if (child.HasValue("name")) { valid &= ConfigNodeUtil.ParseValue <string>(child, "name", x => vessel.name = x, factory); } // Get craft details if (child.HasValue("craftURL")) { valid &= ConfigNodeUtil.ParseValue <string>(child, "craftURL", x => vessel.craftURL = x, factory); } if (child.HasValue("craftPart")) { valid &= ConfigNodeUtil.ParseValue <AvailablePart>(child, "craftPart", x => vessel.craftPart = x, factory); } valid &= ConfigNodeUtil.AtLeastOne(child, new string[] { "craftURL", "craftPart" }, factory); valid &= ConfigNodeUtil.ParseValue <string>(child, "flagURL", x => vessel.flagURL = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue <VesselType>(child, "vesselType", x => vessel.vesselType = x, factory, VesselType.Ship); // Use an expression to default - then it'll work for dynamic contracts if (!child.HasValue("targetBody")) { child.AddValue("targetBody", "@/targetBody"); } valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => vessel.body = x, factory); // Get landed stuff if (child.HasValue("pqsCity")) { string pqsCityStr = null; valid &= ConfigNodeUtil.ParseValue <string>(child, "pqsCity", x => pqsCityStr = x, factory); if (pqsCityStr != null) { try { vessel.pqsCity = vessel.body.GetComponentsInChildren <PQSCity>(true).Where(pqs => pqs.name == pqsCityStr).First(); } catch (Exception e) { LoggingUtil.LogError(typeof(WaypointGenerator), "Couldn't load PQSCity with name '" + pqsCityStr + "'"); LoggingUtil.LogException(e); valid = false; } } valid &= ConfigNodeUtil.ParseValue <Vector3d>(child, "pqsOffset", x => vessel.pqsOffset = x, factory, new Vector3d()); // Don't expect these to load anything, but do it to mark as initialized valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => vessel.latitude = x, factory, 0.0); valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => vessel.longitude = x, factory, 0.0); // Do load alt and height valid &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); valid &= ConfigNodeUtil.ParseValue <float>(child, "height", x => vessel.height = x, factory, !string.IsNullOrEmpty(vessel.craftURL) ? 0.0f : 2.5f); vessel.orbiting = false; } else if (child.HasValue("lat") && child.HasValue("lon")) { valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => vessel.latitude = x, factory); valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => vessel.longitude = x, factory); valid &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); valid &= ConfigNodeUtil.ParseValue <float>(child, "height", x => vessel.height = x, factory, !string.IsNullOrEmpty(vessel.craftURL) ? 0.0f : 2.5f); vessel.orbiting = false; } // Get orbit else { valid &= ConfigNodeUtil.ParseValue <Orbit>(child, "ORBIT", x => vessel.orbit = x, factory); vessel.orbiting = true; } valid &= ConfigNodeUtil.ParseValue <float>(child, "heading", x => vessel.heading = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue <float>(child, "pitch", x => vessel.pitch = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue <float>(child, "roll", x => vessel.roll = x, factory, 0.0f); // Get additional flags valid &= ConfigNodeUtil.ParseValue <bool>(child, "owned", x => vessel.owned = x, factory, false); // Handle the CREW nodes foreach (ConfigNode crewNode in ConfigNodeUtil.GetChildNodes(child, "CREW")) { int count = 1; valid &= ConfigNodeUtil.ParseValue <int>(crewNode, "count", x => count = x, factory, 1); for (int i = 0; i < count; i++) { CrewData cd = new CrewData(); // Read crew details valid &= ConfigNodeUtil.ParseValue <string>(crewNode, "name", x => cd.name = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue <bool>(crewNode, "addToRoster", x => cd.addToRoster = x, factory, true); // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(crewNode, factory); // Add the record vessel.crew.Add(cd); } } // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(child, factory); // Add to the list spawnVessel.vessels.Add(vessel); } finally { ConfigNodeUtil.SetCurrentDataNode(factory.dataNode); } } if (!configNode.HasNode("VESSEL")) { valid = false; LoggingUtil.LogError(factory, "SpawnVessel requires at least one VESSEL node."); } return(valid ? spawnVessel : null); }
public static List <BaseCrew> GetCrewData() { List <BaseCrew> retList = new List <BaseCrew>(); Manager m1 = new Manager { CrewId = "89201", CrewEmail = "*****@*****.**", CrewExtension = "55545", CrewPhoneNumber = "4435680439", FirstName = "Michael", LastName = "Cavallo", ProductList = new List <ProductData> { new ProductData { ProductName = "Balances and Holdings", ProductOwner = "Theresa Young", TechnicalOwner = "Michael Cavallo" }, new ProductData { ProductName = "Address", ProductOwner = "Theresa Young", TechnicalOwner = "Michael Cavallo" }, new ProductData { ProductName = "Portfolio Watch", ProductOwner = "Theresa Young", TechnicalOwner = "Michael Cavallo" } } }; ProjectManager pm1 = new ProjectManager { CrewEmail = "*****@*****.**", FirstName = "Jae", LastName = "Lee", CrewExtension = "99341", CrewPhoneNumber = "22049385550", ManagerId = m1.CrewId, CrewId = "10592" }; CrewData c1 = new CrewData(); CrewData c2 = new CrewData(); CrewData c3 = new CrewData(); CrewData c4 = new CrewData(); CrewData c5 = new CrewData(); CrewData c6 = new CrewData(); CrewData c7 = new CrewData(); CrewData c8 = new CrewData(); CrewData c9 = new CrewData(); CrewData c10 = new CrewData(); retList.Add(c1); retList.Add(c2); retList.Add(c3); retList.Add(c4); retList.Add(c5); retList.Add(c6); retList.Add(c7); retList.Add(c8); retList.Add(c9); retList.Add(c10); // retList.Add(m1); // retList.Add(pm1); c1.FirstName = "Yumi"; c1.LastName = "Yu"; c1.CrewExtension = "83942"; c1.CrewManagerId = m1.CrewId; c1.CrewPMId = pm1.CrewId; c1.CrewEmail = "*****@*****.**"; c1.CrewPhoneNumber = "2839482127"; c1.CrewId = "12345"; c2.FirstName = "Alex"; c2.LastName = "Jones"; c2.CrewExtension = "77483"; c2.CrewManagerId = m1.CrewId; c2.CrewPMId = pm1.CrewId; c2.CrewEmail = "*****@*****.**"; c2.CrewPhoneNumber = "1039459304"; c2.CrewId = "23456"; c3.FirstName = "Jack"; c3.LastName = "Son"; c3.CrewExtension = "88293"; c3.CrewManagerId = m1.CrewId; c3.CrewPMId = pm1.CrewId; c3.CrewEmail = "*****@*****.**"; c3.CrewPhoneNumber = "3049587302"; c3.CrewId = "34567"; c4.FirstName = "Lauren"; c4.LastName = "Haggle"; c4.CrewExtension = "11039"; c4.CrewManagerId = m1.CrewId; c4.CrewPMId = pm1.CrewId; c4.CrewEmail = "*****@*****.**"; c4.CrewPhoneNumber = "1043998930"; c4.CrewId = "45678"; c5.FirstName = "Arthor"; c5.LastName = "Ash"; c6.CrewExtension = "20394"; c5.CrewManagerId = m1.CrewId; c5.CrewPMId = pm1.CrewId; c5.CrewEmail = "*****@*****.**"; c5.CrewPhoneNumber = "1034931098"; c5.CrewId = "77458"; c6.FirstName = "Thor"; c6.LastName = "Ragnorok"; c7.CrewExtension = "920387"; c6.CrewManagerId = m1.CrewId; c6.CrewPMId = pm1.CrewId; c6.CrewEmail = "*****@*****.**"; c6.CrewPhoneNumber = "7069854730"; c6.CrewId = "92034"; c7.FirstName = "Peter"; c7.LastName = "Parker"; c7.CrewExtension = "77869"; c7.CrewManagerId = m1.CrewId; c7.CrewPMId = pm1.CrewId; c7.CrewEmail = "*****@*****.**"; c7.CrewPhoneNumber = "9074520980"; c7.CrewId = "11830"; c8.FirstName = "Brandon"; c8.LastName = "Bjergson"; c8.CrewExtension = "20394"; c8.CrewManagerId = m1.CrewId; c8.CrewPMId = pm1.CrewId; c8.CrewEmail = "*****@*****.**"; c8.CrewPhoneNumber = "6098753200"; c8.CrewId = "75982"; c9.FirstName = "Zack"; c9.LastName = "Johnson"; c9.CrewExtension = "90125"; c9.CrewManagerId = m1.CrewId; c9.CrewPMId = pm1.CrewId; c9.CrewEmail = "*****@*****.**"; c9.CrewPhoneNumber = "30234534908"; c9.CrewId = "22309"; c10.FirstName = "Akiko"; c10.LastName = "Yokosama"; c10.CrewExtension = "50184"; c10.CrewManagerId = m1.CrewId; c10.CrewPMId = pm1.CrewId; c10.CrewEmail = "*****@*****.**"; c10.CrewPhoneNumber = "3027784747"; c10.CrewId = "88930"; return(retList); }
protected override void OnLoad(ConfigNode configNode) { base.OnLoad(configNode); vesselsCreated = ConfigNodeUtil.ParseValue<bool>(configNode, "vesselsCreated"); deferVesselCreation = ConfigNodeUtil.ParseValue<bool?>(configNode, "deferVesselCreation", (bool?)false).Value; foreach (ConfigNode child in configNode.GetNodes("VESSEL_DETAIL")) { // Read all the orbit data VesselData vd = new VesselData(); vd.name = child.GetValue("name"); vd.id = ConfigNodeUtil.ParseValue<Guid?>(child, "id", (Guid?)null); vd.craftURL = child.GetValue("craftURL"); vd.flagURL = ConfigNodeUtil.ParseValue<string>(child, "flagURL", (string)null); vd.vesselType = ConfigNodeUtil.ParseValue<VesselType>(child, "vesselType"); vd.body = ConfigNodeUtil.ParseValue<CelestialBody>(child, "body"); vd.latitude = ConfigNodeUtil.ParseValue<double>(child, "lat"); vd.longitude = ConfigNodeUtil.ParseValue<double>(child, "lon"); vd.altitude = ConfigNodeUtil.ParseValue<double?>(child, "alt", (double?)null); vd.heading = ConfigNodeUtil.ParseValue<float>(child, "heading", 0.0f); vd.pitch = ConfigNodeUtil.ParseValue<float>(child, "pitch", 0.0f); vd.roll = ConfigNodeUtil.ParseValue<float>(child, "roll", 0.0f); vd.orbiting = ConfigNodeUtil.ParseValue<bool?>(child, "orbiting", (bool?)child.HasNode("ORBIT")).Value; vd.owned = ConfigNodeUtil.ParseValue<bool>(child, "owned"); if (child.HasNode("ORBIT")) { vd.orbit = new OrbitSnapshot(child.GetNode("ORBIT")).Load(); } // Load crew data foreach (ConfigNode crewNode in child.GetNodes("CREW")) { CrewData cd = new CrewData(); cd.name = ConfigNodeUtil.ParseValue<string>(crewNode, "name", (string)null); cd.addToRoster = ConfigNodeUtil.ParseValue<bool>(crewNode, "addToRoster"); vd.crew.Add(cd); } // Add to the global list vessels.Add(vd); } }
public CrewData(CrewData cd) { name = cd.name; gender = cd.gender; addToRoster = cd.addToRoster; }
public static SpawnVessel Create(ConfigNode configNode, SpawnVesselFactory factory) { SpawnVessel spawnVessel = new SpawnVessel(); ConfigNodeUtil.ParseValue<bool>(configNode, "deferVesselCreation", x => spawnVessel.deferVesselCreation = x, factory, false); bool valid = true; int index = 0; foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "VESSEL")) { DataNode dataNode = new DataNode("VESSEL_" + index++, factory.dataNode, factory); try { ConfigNodeUtil.SetCurrentDataNode(dataNode); VesselData vessel = new VesselData(); // Get name if (child.HasValue("name")) { valid &= ConfigNodeUtil.ParseValue<string>(child, "name", x => vessel.name = x, factory); } // Get craft details if (child.HasValue("craftURL")) { valid &= ConfigNodeUtil.ParseValue<string>(child, "craftURL", x => vessel.craftURL = x, factory); } if (child.HasValue("craftPart")) { valid &= ConfigNodeUtil.ParseValue<AvailablePart>(child, "craftPart", x => vessel.craftPart = x, factory); } valid &= ConfigNodeUtil.AtLeastOne(child, new string[] { "craftURL", "craftPart" }, factory); valid &= ConfigNodeUtil.ParseValue<string>(child, "flagURL", x => vessel.flagURL = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue<VesselType>(child, "vesselType", x => vessel.vesselType = x, factory, VesselType.Ship); // Use an expression to default - then it'll work for dynamic contracts if (!child.HasValue("targetBody")) { child.AddValue("targetBody", "@/targetBody"); } valid &= ConfigNodeUtil.ParseValue<CelestialBody>(child, "targetBody", x => vessel.body = x, factory); // Get landed stuff if (child.HasValue("pqsCity")) { string pqsCityStr = null; valid &= ConfigNodeUtil.ParseValue<string>(child, "pqsCity", x => pqsCityStr = x, factory); if (pqsCityStr != null) { try { vessel.pqsCity = vessel.body.GetComponentsInChildren<PQSCity>(true).Where(pqs => pqs.name == pqsCityStr).First(); } catch (Exception e) { LoggingUtil.LogError(typeof(WaypointGenerator), "Couldn't load PQSCity with name '" + pqsCityStr + "'"); LoggingUtil.LogException(e); valid = false; } } valid &= ConfigNodeUtil.ParseValue<Vector3d>(child, "pqsOffset", x => vessel.pqsOffset = x, factory, new Vector3d()); // Don't expect these to load anything, but do it to mark as initialized valid &= ConfigNodeUtil.ParseValue<double>(child, "lat", x => vessel.latitude = x, factory, 0.0); valid &= ConfigNodeUtil.ParseValue<double>(child, "lon", x => vessel.longitude = x, factory, 0.0); // Do load alt and height valid &= ConfigNodeUtil.ParseValue<double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); valid &= ConfigNodeUtil.ParseValue<float>(child, "height", x => vessel.height = x, factory, !string.IsNullOrEmpty(vessel.craftURL) ? 0.0f : 2.5f); vessel.orbiting = false; // Generate PQS city coordinates LoggingUtil.LogVerbose(factory, "Generating coordinates from PQS city for Vessel " + vessel.name); // Translate by the PQS offset (inverse transform of coordinate system) Vector3d position = vessel.pqsCity.transform.position; Vector3d v = vessel.pqsOffset; Vector3d i = vessel.pqsCity.transform.right; Vector3d j = vessel.pqsCity.transform.forward; Vector3d k = vessel.pqsCity.transform.up; Vector3d offsetPos = new Vector3d( (j.y * k.z - j.z * k.y) * v.x + (i.z * k.y - i.y * k.z) * v.y + (i.y * j.z - i.z * j.y) * v.z, (j.z * k.x - j.x * k.z) * v.x + (i.x * k.z - i.z * k.x) * v.y + (i.z * j.x - i.x * j.z) * v.z, (j.x * k.y - j.y * k.x) * v.x + (i.y * k.x - i.x * k.y) * v.y + (i.x * j.y - i.y * j.x) * v.z ); offsetPos *= (i.x * j.y * k.z) + (i.y * j.z * k.x) + (i.z * j.x * k.y) - (i.z * j.y * k.x) - (i.y * j.x * k.z) - (i.x * j.z * k.y); vessel.latitude = vessel.body.GetLatitude(position + offsetPos); vessel.longitude = vessel.body.GetLongitude(position + offsetPos); } else if (child.HasValue("lat") && child.HasValue("lon")) { valid &= ConfigNodeUtil.ParseValue<double>(child, "lat", x => vessel.latitude = x, factory); valid &= ConfigNodeUtil.ParseValue<double>(child, "lon", x => vessel.longitude = x, factory); valid &= ConfigNodeUtil.ParseValue<double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); valid &= ConfigNodeUtil.ParseValue<float>(child, "height", x => vessel.height = x, factory, !string.IsNullOrEmpty(vessel.craftURL) ? 0.0f : 2.5f); vessel.orbiting = false; } // Get orbit else { valid &= ConfigNodeUtil.ParseValue<Orbit>(child, "ORBIT", x => vessel.orbit = x, factory); vessel.orbiting = true; } valid &= ConfigNodeUtil.ParseValue<float>(child, "heading", x => vessel.heading = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue<float>(child, "pitch", x => vessel.pitch = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue<float>(child, "roll", x => vessel.roll = x, factory, 0.0f); // Get additional flags valid &= ConfigNodeUtil.ParseValue<bool>(child, "owned", x => vessel.owned = x, factory, false); // Handle the CREW nodes foreach (ConfigNode crewNode in ConfigNodeUtil.GetChildNodes(child, "CREW")) { int count = 1; valid &= ConfigNodeUtil.ParseValue<int>(crewNode, "count", x => count = x, factory, 1); for (int i = 0; i < count; i++) { CrewData cd = new CrewData(); // Read crew details valid &= ConfigNodeUtil.ParseValue<string>(crewNode, "name", x => cd.name = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue<bool>(crewNode, "addToRoster", x => cd.addToRoster = x, factory, true); // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(crewNode, factory); // Add the record vessel.crew.Add(cd); } } // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(child, factory); // Add to the list spawnVessel.vessels.Add(vessel); } finally { ConfigNodeUtil.SetCurrentDataNode(factory.dataNode); } } if (!configNode.HasNode("VESSEL")) { valid = false; LoggingUtil.LogError(factory, "SpawnVessel requires at least one VESSEL node."); } return valid ? spawnVessel : null; }
public static SpawnVessel Create(ConfigNode configNode, CelestialBody defaultBody, SpawnVesselFactory factory) { SpawnVessel spawnVessel = new SpawnVessel(); bool valid = true; int index = 0; foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "VESSEL")) { DataNode dataNode = new DataNode("VESSEL_" + index++, factory.dataNode, factory); try { ConfigNodeUtil.SetCurrentDataNode(dataNode); VesselData vessel = new VesselData(); // Get name if (child.HasValue("name")) { vessel.name = child.GetValue("name"); } // Get paths vessel.craftURL = ConfigNodeUtil.ParseValue <string>(child, "craftURL"); vessel.flagURL = ConfigNodeUtil.ParseValue <string>(child, "flagURL", (string)null); vessel.vesselType = ConfigNodeUtil.ParseValue <VesselType>(child, "vesselType", VesselType.Ship); // Get celestial body valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => vessel.body = x, factory, defaultBody, Validation.NotNull); // Get landed stuff if (child.HasValue("lat") && child.HasValue("lon")) { valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => vessel.latitude = x, factory); valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => vessel.longitude = x, factory); valid &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); vessel.landed = true; } // Get orbit else { valid &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory); vessel.orbit = new OrbitSnapshot(ConfigNodeUtil.GetChildNode(child, "ORBIT")).Load(); vessel.orbit.referenceBody = vessel.body; } // Get additional flags valid &= ConfigNodeUtil.ParseValue <bool>(child, "owned", x => vessel.owned = x, factory, false); // Handle the CREW nodes foreach (ConfigNode crewNode in ConfigNodeUtil.GetChildNodes(child, "CREW")) { int count = 1; valid &= ConfigNodeUtil.ParseValue <int>(crewNode, "count", x => count = x, factory, 1); for (int i = 0; i < count; i++) { CrewData cd = new CrewData(); // Read crew details valid &= ConfigNodeUtil.ParseValue <string>(crewNode, "name", x => cd.name = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue <bool>(crewNode, "addToRoster", x => cd.addToRoster = x, factory, true); // Add the record vessel.crew.Add(cd); } } // Add to the list spawnVessel.vessels.Add(vessel); } finally { ConfigNodeUtil.SetCurrentDataNode(factory.dataNode); } } return(valid ? spawnVessel : null); }
public void ShowEmployeeContract(CrewData crewData, EmployeeContent employeeContent) { _employeeContract.UpdateUI(crewData); _currentEmployeeContent = employeeContent; SetEmployeeContract(true); }
public static SpawnVessel Create(ConfigNode configNode, SpawnVesselFactory factory) { SpawnVessel spawnVessel = new SpawnVessel(); ConfigNodeUtil.ParseValue<bool>(configNode, "deferVesselCreation", x => spawnVessel.deferVesselCreation = x, factory, false); bool valid = true; int index = 0; foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "VESSEL")) { DataNode dataNode = new DataNode("VESSEL_" + index++, factory.dataNode, factory); try { ConfigNodeUtil.SetCurrentDataNode(dataNode); VesselData vessel = new VesselData(); // Get name if (child.HasValue("name")) { valid &= ConfigNodeUtil.ParseValue<string>(child, "name", x => vessel.name = x, factory); } // Get craft details if (child.HasValue("craftURL")) { valid &= ConfigNodeUtil.ParseValue<string>(child, "craftURL", x => vessel.craftURL = x, factory); } if (child.HasValue("craftPart")) { valid &= ConfigNodeUtil.ParseValue<AvailablePart>(child, "craftPart", x => vessel.craftPart = x, factory); } valid &= ConfigNodeUtil.AtLeastOne(child, new string[] { "craftURL", "craftPart" }, factory); valid &= ConfigNodeUtil.ParseValue<string>(child, "flagURL", x => vessel.flagURL = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue<VesselType>(child, "vesselType", x => vessel.vesselType = x, factory, VesselType.Ship); // Use an expression to default - then it'll work for dynamic contracts if (!child.HasValue("targetBody")) { child.AddValue("targetBody", "@/targetBody"); } valid &= ConfigNodeUtil.ParseValue<CelestialBody>(child, "targetBody", x => vessel.body = x, factory); // Get landed stuff if (child.HasValue("lat") && child.HasValue("lon")) { valid &= ConfigNodeUtil.ParseValue<double>(child, "lat", x => vessel.latitude = x, factory); valid &= ConfigNodeUtil.ParseValue<double>(child, "lon", x => vessel.longitude = x, factory); valid &= ConfigNodeUtil.ParseValue<double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null); valid &= ConfigNodeUtil.ParseValue<float>(child, "height", x => vessel.height = x, factory, !string.IsNullOrEmpty(vessel.craftURL) ? 0.0f : 2.5f); vessel.orbiting = false; } // Get orbit else { valid &= ConfigNodeUtil.ParseValue<Orbit>(child, "ORBIT", x => vessel.orbit = x, factory); vessel.orbiting = true; } valid &= ConfigNodeUtil.ParseValue<float>(child, "heading", x => vessel.heading = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue<float>(child, "pitch", x => vessel.pitch = x, factory, 0.0f); valid &= ConfigNodeUtil.ParseValue<float>(child, "roll", x => vessel.roll = x, factory, 0.0f); // Get additional flags valid &= ConfigNodeUtil.ParseValue<bool>(child, "owned", x => vessel.owned = x, factory, false); // Handle the CREW nodes foreach (ConfigNode crewNode in ConfigNodeUtil.GetChildNodes(child, "CREW")) { int count = 1; valid &= ConfigNodeUtil.ParseValue<int>(crewNode, "count", x => count = x, factory, 1); for (int i = 0; i < count; i++) { CrewData cd = new CrewData(); // Read crew details valid &= ConfigNodeUtil.ParseValue<string>(crewNode, "name", x => cd.name = x, factory, (string)null); valid &= ConfigNodeUtil.ParseValue<bool>(crewNode, "addToRoster", x => cd.addToRoster = x, factory, true); // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(crewNode, factory); // Add the record vessel.crew.Add(cd); } } // Check for unexpected values valid &= ConfigNodeUtil.ValidateUnexpectedValues(child, factory); // Add to the list spawnVessel.vessels.Add(vessel); } finally { ConfigNodeUtil.SetCurrentDataNode(factory.dataNode); } } if (!configNode.HasNode("VESSEL")) { valid = false; LoggingUtil.LogError(factory, "SpawnVessel requires at least one VESSEL node."); } return valid ? spawnVessel : null; }
public CrewData(CrewData cd) { name = cd.name; }