public static int GetTravelTime(this Ship ship) { int?traveltime = null; switch (ship.Type) { case "upgradeable": traveltime = Definitions.UpgrDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.Levels .Level.FirstOrDefault(n => n.Id == ship.TargetLevel)?.TravelTime; break; case "marketplace": traveltime = Definitions.MarketDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId) ?.TravelTime; break; case "wreck": var wrk = Core.GlobalData.Wrecks.FirstOrDefault(n => n.InstId == ship.TargetId); var tm = Definitions.WreckDef.Items.Item.FirstOrDefault(n => n.DefId == wrk.DefId)?.TravelTime; if (tm != null) { traveltime = (int)tm; } break; case "contractor": var l = Definitions.ConDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.TravelTime; if (l != null) { traveltime = (int)l; } break; case "global_contractor": var time = Definitions.GConDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.TravelTime; if (time != null) { traveltime = (int)time; } break; case "outpost": OutpostDefinitions.Item first = null; foreach (var n in Definitions.OutpostDef.Items.Item) { if (n.DefId == ship.TargetId) { first = n; break; } } traveltime = first.TravelTime; break; case "social_contract": var soccontract = Core.GlobalData.SocialContracts.Where(n => n.InstId == ship.TargetId) .FirstOrDefault(); var travelTime = Definitions.SContractDef.Items.Item .FirstOrDefault(n => n.DefId == soccontract?.DefId)?.TravelTime; if (travelTime != null) { traveltime = (int)travelTime; } break; case "dealer": var o = Definitions.DealerDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.TravelTime; if (o != null) { traveltime = (int)o; } break; } return(!traveltime.HasValue ? int.MaxValue : traveltime.Value); }
public static string GetTravelName(this Ship ship) { var pointname = string.Empty; switch (ship.Type) { case "upgradeable": pointname = Definitions.UpgrDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.NameLoc; break; case "marketplace": pointname = Definitions.MarketDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.NameLoc; break; case "wreck": var wrk = Core.GlobalData.Wrecks.FirstOrDefault(n => n.InstId == ship.TargetId); pointname = Definitions.WreckDef.Items.Item.FirstOrDefault(n => n.DefId == wrk.DefId)?.NameLoc; break; case "contractor": pointname = Definitions.ConDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.NameLoc; break; case "global_contractor": pointname = Definitions.GConDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.NameLoc; break; case "outpost": OutpostDefinitions.Item first = null; foreach (var n in Definitions.OutpostDef.Items.Item) { if (n.DefId == ship.TargetId) { first = n; break; } } pointname = first?.NameLoc; break; case "social_contract": pointname = Definitions.SContractDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId) ?.NameLoc; break; case "dealer": pointname = Definitions.DealerDef.Items.Item.FirstOrDefault(n => n.DefId == ship.TargetId)?.NameLoc; break; } return(pointname); }