private static void Init()
        {
            Settings_ModdedFactions.VerifyCustomFactions();

            List <CustomFaction> loaded = new List <CustomFaction>();

            foreach (FactionDef def in DefDatabase <FactionDef> .AllDefs)
            {
                if (def.isPlayer)
                {
                    continue;
                }

                switch (def.defName)
                {
                case "Ancients":
                case "AncientsHostile":
                case "Mechanoid":
                case "Insect":
                case "OutlanderCivil":
                case "OutlanderRough":
                case "TribeCivil":
                case "TribeRough":
                case "TribeSavage":
                case "Pirate":
                case "Empire":
                    continue;

                default:
                    CustomFaction cf = new CustomFaction
                    {
                        FactionDef           = def,
                        RequiredCountDefault = def.requiredCountAtGameStart,
                        RequiredCount        = def.requiredCountAtGameStart,
                        MaxCountAtStart      = def.maxCountAtGameStart
                    };

                    bool contains = false;
                    foreach (CustomFaction f in Main.CustomFactions)
                    {
                        if (f.FactionDef == def)
                        {
                            f.MaxCountAtStart      = def.maxCountAtGameStart;
                            f.RequiredCountDefault = def.requiredCountAtGameStart;
                            if (f.RequiredCount == -1)
                            {
                                f.RequiredCount = def.requiredCountAtGameStart;
                            }
                            contains = true;
                            break;
                        }
                    }
                    loaded.Add(cf);
                    if (!contains)
                    {
                        Main.CustomFactions.Add(cf);
                    }
                    break;
                }
            }

            for (int i = CustomFactions.Count - 1; i >= 0; --i)
            {
                if (!loaded.Contains(CustomFactions[i]))
                {
                    CustomFactions.RemoveAt(i);
                }
            }
            SetIncidents.SetIncidentLevels();

            loaded.Clear();
            loaded = null;
        }
Esempio n. 2
0
 public Controller_CustomFactions(ModContentPack content) : base(content)
 {
     Settings = GetSettings <Settings_ModdedFactions>();
 }