コード例 #1
0
 public static double GetDistanceInLY(StarSystem currPosition, Objects.System target, List <StarSystem> allSystems)
 {
     try {
         StarSystem targetSystem = allSystems.FirstOrDefault(x => x.Name.Equals(target.name));
         return(Math.Sqrt(Math.Pow(targetSystem.Position.x - currPosition.Position.x, 2) + Math.Pow(targetSystem.Position.y - currPosition.Position.y, 2)));
     }
     catch (Exception ex) {
         PersistentMapClient.Logger.LogError(ex);
         return(0);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        public static bool canBypassSupport(string opfor, SimGameState sim, Objects.System system)
        {
            RefreshServerSettings();
            if (!isAllied(sim))
            {
                PersistentMapClient.Logger.Log($"No Allies, cannot bypass gain!");
                return(false);
            }
            bool ret = serverSettings.SupportBypass.Contains(opfor);

            if (system != null && system.alwaysInWar)
            {
                ret = true;
            }
            PersistentMapClient.Logger.Log($"Able to bypass gain reqs against opfor:{opfor} : {ret}, system: {system.name}");
            return(ret);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        public static StarSystem ChangeWarDescription(StarSystem system, SimGameState Sim, Objects.System warsystem)
        {
            try {
                //if (IsBorder(system, Sim)) {
                List <string> factionList = new List <string>();
                if (!Fields.FluffDescriptions.ContainsKey(system.Name))
                {
                    Fields.FluffDescriptions.Add(system.Name, system.Def.Description.Details);
                }
                if (warsystem.isInsurrect())
                {
                    factionList.Add("<b><color=#de0202>System is Insurrect</color></b>\n");
                }
                if (warsystem.immuneFromWar)
                {
                    factionList.Add("<b><color=#de0202>System is Immune From War Changes</color></b>\n");
                }
                if (warsystem.alwaysInWar)
                {
                    factionList.Add("<b><color=#088A08>System Ignores Support Requirements</color></b>\n");
                }
                if (warsystem.hasOnlineEvent())
                {
                    factionList.Add("<b><color=#8904B1>Online Capture event target</color></b>\n");
                }
                if (warsystem.hasHoldTheLineEvent())
                {
                    factionList.Add("<b><color=#8904B1>Hold The Line event target</color></b>\n");
                }
                if (warsystem.generatesItems)
                {
                    factionList.Add("<b><color=#088A08>Generates Items:</color></b>");
                    foreach (string item in warsystem.itemsGenerated)
                    {
                        factionList.Add($"<b><color=#088A08>{item}</color></b>");
                    }

                    factionList.Add("\n");
                }
                factionList.Add(Fields.FluffDescriptions[system.Name]);
                factionList.Add("\nCurrent Control:");
                foreach (FactionControl fc in warsystem.factions)
                {
                    factionList.Add(GetFactionName(fc.Name) + $": Companies: {fc.ActivePlayers}, Control: {fc.control}%");
                }

                factionList.Add("\nCompanies Present:");
                foreach (string cname in warsystem.mercStrings)
                {
                    factionList.Add(cname);
                }

                AccessTools.Method(typeof(DescriptionDef), "set_Details").Invoke(system.Def.Description, new object[] { string.Join("\n", factionList.ToArray()) });
                //}
                //else if (Fields.FluffDescriptions.ContainsKey(system.Name)) {
                //    AccessTools.Method(typeof(DescriptionDef), "set_Details").Invoke(system.Def.Description, new object[] { Fields.FluffDescriptions[system.Name] });
                //    Fields.FluffDescriptions.Remove(system.Name);
                //}
                return(system);
            }
            catch (Exception ex) {
                PersistentMapClient.Logger.LogError(ex);
                return(null);
            }
        }