public static List <string> GetEmployees(StarSystem system, SimGameState Sim, Objects.System warsystem) { try { List <string> employees = new List <string>(); if (Sim.Starmap != null) { // If a faction owns the planet, add the owning faction and local government if (system.OwnerValue != FactionEnumeration.GetNoFactionValue()) { employees.Add(FactionEnumeration.GetFactionByName("Locals").Name); if (system.OwnerValue != FactionEnumeration.GetFactionByName("Locals")) { employees.Add(system.OwnerValue.Name); } } // Look across neighboring systems, and add employees of factions that border this system List <FactionValue> distinctNeighbors = Sim.Starmap.GetAvailableNeighborSystem(system) .Select(s => s.OwnerValue) .Where(f => f != FactionEnumeration.GetNoFactionValue() && f != system.OwnerValue && f != FactionEnumeration.GetFactionByName("Locals")) .Distinct() .ToList(); foreach (FactionValue neighbour in distinctNeighbors) { if (!Fields.settings.cannotBeTarget.Contains(neighbour.Name)) { if (Web.isEventFaction(neighbour.Name)) { if (warsystem != null && warsystem.hasInfluence(neighbour)) { employees.Add(neighbour.Name); } } else { employees.Add(neighbour.Name); } } } // If a capital is occupied, add the faction that originally owned the capital to the employer list if (Helper.capitalsBySystemName.Contains(system.Name)) { foreach (string originalCapitalFaction in Helper.capitalsBySystemName[system.Name]) { if (!employees.Contains(FactionEnumeration.GetFactionByName(originalCapitalFaction).Name)) { employees.Add(FactionEnumeration.GetFactionByName(originalCapitalFaction).Name); } } } } return(employees); } catch (Exception ex) { PersistentMapClient.Logger.LogError(ex); return(null); } }
public static List <string> GetTargets(StarSystem system, SimGameState Sim, Objects.System warSystem) { try { List <string> targets = new List <string>(); if (Sim.Starmap != null) { targets.Add(FactionEnumeration.GetAuriganPiratesFactionValue().Name); if (system.OwnerValue != FactionEnumeration.GetNoFactionValue()) { if (system.OwnerValue != FactionEnumeration.GetFactionByName("Locals")) { targets.Add(system.OwnerValue.Name); } targets.Add(FactionEnumeration.GetFactionByName("Locals").Name); } foreach (StarSystem neigbourSystem in Sim.Starmap.GetAvailableNeighborSystem(system)) { if (system.OwnerValue != neigbourSystem.OwnerValue && !targets.Contains(neigbourSystem.OwnerValue.Name) && neigbourSystem.OwnerValue != FactionEnumeration.GetNoFactionValue() && !Fields.settings.cannotBeTarget.Contains(neigbourSystem.OwnerValue.Name)) { if (Web.isEventFaction(neigbourSystem.OwnerValue.Name)) { if (warSystem != null && warSystem.hasInfluence(neigbourSystem.OwnerValue)) { targets.Add(neigbourSystem.OwnerValue.Name); } } else { targets.Add(neigbourSystem.OwnerValue.Name); } } } } else { foreach (FactionValue faction in FactionEnumeration.FactionList) { targets.Add(faction.Name); } } return(targets); } catch (Exception ex) { PersistentMapClient.Logger.LogError(ex); return(null); } }