Esempio n. 1
0
        private void SpawnWithBases()
        {
            Dialog_NewFactionSpawningSettlements.OpenDialog(SpawnCallback);

            void SpawnCallback(int amount, int minDistance)
            {
                try
                {
                    var faction = NewFactionSpawningUtility.SpawnWithSettlements(factionDef, amount, minDistance, out var spawned);
                    if (faction == null || spawned == 0)
                    {
                        Messages.Message("VanillaFactionsExpanded.FactionMessageFailedFull".Translate(), MessageTypeDefOf.RejectInput, false);
                    }
                    else
                    {
                        Messages.Message("VanillaFactionsExpanded.FactionMessageSuccessFull".Translate(new NamedArgument(faction.GetCallLabel(), "FactionName"), new NamedArgument(spawned, "Amount")), MessageTypeDefOf.TaskCompletion);
                        Close();
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"An error occurred when trying to spawn faction {factionDef?.defName}:\n{e.Message}\n{e.StackTrace}");
                    Messages.Message("VanillaFactionsExpanded.FactionMessageFailedFull".Translate(), MessageTypeDefOf.RejectInput, false);
                }
            }
        }
            private static bool Validator(FactionDef faction)
            {
                if (faction == null)
                {
                    return(false);
                }
                if (faction.isPlayer)
                {
                    return(false);
                }
                if (!faction.canMakeRandomly && faction.hidden && faction.maxCountAtGameStart <= 0)
                {
                    return(false);
                }
                var count = Find.FactionManager.AllFactions.Count(f => f.def == faction);

                if (count > 0)
                {
                    return(false);
                }
                if (Find.World?.GetComponent <NewFactionSpawningState>()?.IsIgnored(faction) == true)
                {
                    return(false);
                }
                if (NewFactionSpawningUtility.NeverSpawn(faction))
                {
                    return(false);
                }
                return(true);
            }
Esempio n. 3
0
 private void SpawnWithoutBases()
 {
     try
     {
         var faction = NewFactionSpawningUtility.SpawnWithoutSettlements(factionDef);
         Messages.Message("VanillaFactionsExpanded.FactionMessageSuccess".Translate(new NamedArgument(faction.GetCallLabel(), "FactionName")), MessageTypeDefOf.TaskCompletion);
         Close();
     }
     catch (Exception e)
     {
         Log.Error($"An error occurred when trying to spawn faction {factionDef?.defName}:\n{e.Message}\n{e.StackTrace}");
         Messages.Message("VanillaFactionsExpanded.FactionMessageFailed".Translate(), MessageTypeDefOf.RejectInput, false);
     }
 }
Esempio n. 4
0
 private bool ValidatorAnyFactionLeft(FactionDef faction)
 {
     if (faction == null)
     {
         return(false);
     }
     if (faction.isPlayer)
     {
         return(false);
     }
     if (!faction.canMakeRandomly && faction.hidden && faction.maxCountAtGameStart <= 0)
     {
         return(false);
     }
     if (Find.FactionManager.AllFactions.Count(f => f.def == faction) > 0)
     {
         return(false);
     }
     if (NewFactionSpawningUtility.NeverSpawn(faction))
     {
         return(false);
     }
     return(true);
 }