示例#1
0
        public void RandomizeBackstories()
        {
            CustomPawn  currentPawn = state.CurrentPawn;
            PawnKindDef kindDef     = currentPawn.Pawn.kindDef;
            FactionDef  factionDef  = kindDef.defaultFactionType;

            if (factionDef == null)
            {
                factionDef = Faction.OfPlayer.def;
            }
            List <BackstoryCategoryFilter> backstoryCategoryFiltersFor = Reflection.PawnBioAndNameGenerator
                                                                         .GetBackstoryCategoryFiltersFor(currentPawn.Pawn, factionDef);

            if (!Reflection.PawnBioAndNameGenerator.TryGetRandomUnusedSolidBioFor(backstoryCategoryFiltersFor,
                                                                                  kindDef, currentPawn.Gender, null, out PawnBio pawnBio))
            {
                return;
            }
            currentPawn.Childhood = pawnBio.childhood;
            // TODO: Remove the hard-coded adult age and get the value from a provider instead?
            if (currentPawn.BiologicalAge >= 20)
            {
                currentPawn.Adulthood = pawnBio.adulthood;
            }
        }
        private Pawn SpawnPawn(PawnKindDef kindDef, FactionDef factionDef, IntVec3 cell, Map map)
        {
            // Generate the pawn
            Pawn pawn = null;

            if (factionDef == null)
            {
                pawn = PawnGenerator.GeneratePawn(kindDef, this.Faction);
            }
            else
            {
                Faction faction;
                if (!Find.FactionManager.AllFactions.Where(f => f.def == factionDef).TryRandomElement(out faction))
                {
                    Log.Error("Error spawning pawn. Could not find faction with factionDef:" + factionDef.defName);
                    return(null);
                }

                pawn = PawnGenerator.GeneratePawn(kindDef, faction);
            }

            // Spawn the pawn
            //GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(Position, Map, 1, null), Map);

            // Spawn the pawn
            GenPlace.TryPlaceThing(pawn, base.Position, base.Map, ThingPlaceMode.Near, null);

            return(pawn);
        }
            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);
            }
示例#4
0
        public static void Postfix(Pawn pawn, FactionDef faction, ref List <BackstoryCategoryFilter> __result)
        {
            if (!LoadedModManager.GetMod <NoMoreRandomSkillsMod>().GetSettings <NoMoreRandomSkillsSettings>()
                .OnlyCustomBackstories)
            {
                return;
            }

            foreach (var backstoryCategoryFilter in __result)
            {
                for (var j = 0; j < backstoryCategoryFilter.categories.Count; j++)
                {
                    // Log.Message($"Found: {backstoryCategoryFilter.categories[j]}");
                    if (backstoryCategoryFilter.categories[j] == "OutlanderCivil" ||
                        backstoryCategoryFilter.categories[j] == "OutlanderRough" ||
                        backstoryCategoryFilter.categories[j] == "Outlander" ||
                        backstoryCategoryFilter.categories[j] == "Slave" ||
                        backstoryCategoryFilter.categories[j] == "Tribal" ||
                        backstoryCategoryFilter.categories[j] == "TribeCivil" ||
                        backstoryCategoryFilter.categories[j] == "TribeRough" ||
                        backstoryCategoryFilter.categories[j] == "Pirate" ||
                        backstoryCategoryFilter.categories[j] == "Trader" ||
                        backstoryCategoryFilter.categories[j] == "PlayerColony" ||
                        backstoryCategoryFilter.categories[j] == "Offworld")
                    {
                        backstoryCategoryFilter.categories[j] = "REB_" + backstoryCategoryFilter.categories[j];
                    }

                    // Log.Message($"Final: {backstoryCategoryFilter.categories[j]}");
                }
            }
        }
示例#5
0
    public DeathListTracker(string faction)
    {
        LogDebug("DeathListTracker ctor: " + faction);

        this.faction = faction;
        factionDef   = sim.GetFactionDef(faction);

        // TODO comment this
        foreach (var factionNames in IncludedFactions)
        {
            var def = sim.GetFactionDef(factionNames);
            if (!IncludedFactions.Contains(def.FactionValue.Name))
            {
                continue;
            }
            if (factionDef != def && factionDef.Enemies.Contains(def.FactionValue.Name))
            {
                deathList.Add(def.FactionValue.Name, Settings.KLValuesEnemies);
            }
            else if (factionDef != def && factionDef.Allies.Contains(def.FactionValue.Name))
            {
                deathList.Add(def.FactionValue.Name, Settings.KLValueAllies);
            }
            else if (factionDef != def)
            {
                deathList.Add(def.FactionValue.Name, Settings.KLValuesNeutral);
            }
        }
    }
        public static bool GiveShuffledBioTo_AdultAge_Prefix(Pawn pawn, FactionDef factionType, string requiredLastName, ref List <BackstoryCategoryFilter> backstoryCategories)
        {
            if (pawn != null)
            {
                return(true);
            }
            if (!pawn.RaceProps.Humanlike)
            {
                return(true);
            }
            bool ext = pawn.kindDef.HasModExtension <BackstoryExtension>();

            if (ext)
            {
                BackstoryCategoryFilter backstoryCategoryFilter = backstoryCategories.RandomElementByWeight((BackstoryCategoryFilter c) => c.commonality);
                backstoryCategories.Clear();
                backstoryCategories.Add(backstoryCategoryFilter);
            }
            if (pawn.ageTracker.AgeBiologicalYears < 20 && pawn.def.modContentPack.PackageIdPlayerFacing.Contains("AdMech"))
            {
                bool act = pawn.RaceProps.lifeStageAges.Any(x => x.def.reproductive);
                if (act)
                {
                    GiveShuffledBioTo(pawn, factionType, requiredLastName, backstoryCategories);
                    return(false);
                }
            }
            if (backstoryCategories.NullOrEmpty())
            {
                Log.Warning(string.Format("{0} backstoryCategories null", pawn.NameShortColored));
            }
            return(true);
        }
 public void CheckFaction()
 {
     if (this.parent.Faction == Faction.OfPlayer)
     {
         Pawn pawn = parent as Pawn;
         if (pawn != null)
         {
             if (!Props.goesManhunter)
             {
                 parent.SetFaction(null, null);
             }
             else if (Props.factionToReturnTo == "")
             {
                 pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
             }
             else
             {
                 parent.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToReturnTo)), null);
                 pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
             };
             if (Props.sendMessage)
             {
                 Messages.Message(Props.message.Translate(pawn.LabelIndefinite().CapitalizeFirst()), pawn, MessageTypeDefOf.NegativeEvent, true);
             }
         }
     }
 }
        public static void FinaliseFactionGoodwillCharacteristics(FactionDef faction)
        {
            if (goodwillScenParts == null)
            {
                goodwillScenParts = Find.Scenario.AllParts.Where(p => p.def == ScenPartDefOf.VFEC_ForcedFactionGoodwill).Cast <ScenPart_ForcedFactionGoodwill>().ToList();
            }

            // Go through each scenario part that modifies goodwill in reverse order and return an appropriate natural goodwill range
            for (int i = goodwillScenParts.Count - 1; i >= 0; i--)
            {
                var curScenPart = goodwillScenParts[i];
                if (curScenPart.AffectsFaction(faction))
                {
                    faction.permanentEnemy = curScenPart.alwaysHostile;
                    if (curScenPart.affectNaturalGoodwill)
                    {
                        faction.naturalColonyGoodwill = curScenPart.naturalGoodwillRange;
                    }
                    return;
                }
            }

            // Otherwise use cached
            faction.permanentEnemy        = cachedFactionPermanentEnemyFlags[faction];
            faction.naturalColonyGoodwill = cachedFactionNaturalGoodwillRanges[faction];
        }
示例#9
0
 public override void Init()
 {
     ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
     if (settingsRef.riftChallenge > 0)
     {
         base.Init();
         this.disabled = false;
         this.FindGoodCenterLocation();
         this.thing = ThingMaker.MakeThing(ThingDef.Named("TM_ElementalRift"), ThingDefOf.BlocksGranite);
         GenSpawn.Spawn(thing, centerLocation.ToIntVec3, this.SingleMap, Rot4.North, WipeMode.Vanish, false);
         Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("TM_ElementalFaction"));
         if (!faction.HostileTo(Faction.OfPlayer))
         {
             thing.SetFaction(Faction.OfMechanoids, null);
         }
         else
         {
             thing.SetFaction(faction, null);
         }
     }
     else
     {
         this.disabled = true;
         Log.Message("Rift spawning disabled.");
     }
 }
示例#10
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("PLAHF_faction"));
            Map     map     = (Map)parms.target;
            //List<TargetInfo> list = new List<TargetInfo>();
            float shrapnelDirection = Rand.Range(0f, 360f);
            Thing lookhere;


            IntVec3 intVec;

            if (!CellFinderLoose.TryFindSkyfallerCell(RimWorld.ThingDefOf.DropPodIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
            {
                return(false);
            }
            Building_TacticalManaBomb building_tacticalmanabomb = (Building_TacticalManaBomb)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("Building_TacticalManaBomb", true));

            building_tacticalmanabomb.SetFaction(faction, null);
            building_tacticalmanabomb.spawnpoints = (float)(parms.points * 0.8);
            lookhere = building_tacticalmanabomb;

            Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(RimWorld.ThingDefOf.DropPodIncoming, building_tacticalmanabomb);

            skyfaller.shrapnelDirection = shrapnelDirection;
            GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);



            Find.LetterStack.ReceiveLetter("LetterLabelPLAHFTMBAttack".Translate(), "LetterPLAHFTMBAttack".Translate(), LetterDefOf.ThreatBig, lookhere, null, null);


            Find.TickManager.slower.SignalForceNormalSpeedShort();
            Find.StoryWatcher.statsRecord.numRaidsEnemy++;
            return(true);
        }
示例#11
0
        public override void CompTick()
        {
            base.CompTick();
            if (!AlphaAnimalsEvents_Mod.settings.flagAlphaMechanoids)
            {
                if (parent.Map != null && Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToChangeTo)) != null)
                {
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.defToChangeTo), Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToChangeTo)), PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    GenSpawn.Spawn(pawn, this.parent.Position, parent.Map, WipeMode.Vanish);

                    Lord lord = null;
                    if (pawn.Map.mapPawns.SpawnedPawnsInFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToChangeTo))).Any((Pawn p) => p != pawn))
                    {
                        lord = ((Pawn)GenClosest.ClosestThing_Global(pawn.Position, pawn.Map.mapPawns.SpawnedPawnsInFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToChangeTo))), 99999f, (Thing p) => p != pawn && ((Pawn)p).GetLord() != null, null)).GetLord();
                    }
                    if (lord == null)
                    {
                        LordJob_DefendPoint lordJob = new LordJob_DefendPoint(pawn.Position, null, false, true);
                        lord = LordMaker.MakeNewLord(Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToChangeTo)), lordJob, Find.CurrentMap, null);
                    }
                    lord.AddPawn(pawn);


                    this.parent.Destroy();
                }
            }
        }
示例#12
0
        private static TechLevel FindBGTechLevel(Pawn pawn, out TechLevel childhoodLevel, out SkillDef childhoodSkill)
        {
            TechLevel asAdult = 0;
            TechLevel asChild = 0;

            childhoodSkill = null;
            if (pawn.story != null)
            {
                asChild = PawnBackgroundUtility.TechLevelByBackstory[pawn.story.childhood.identifier];
                if (pawn.story.adulthood != null)
                {
                    asAdult = PawnBackgroundUtility.TechLevelByBackstory[pawn.story.adulthood.identifier];
                }
                childhoodSkill = pawn.story.childhood.skillGainsResolved.Aggregate((a, b) => (a.Value >= b.Value) ? a : b).Key;
            }
            if (asAdult == 0 || asChild == 0)
            {
                FactionDef faction  = pawn.Faction?.def ?? pawn.kindDef.defaultFactionType;
                TechLevel  fallback = faction?.techLevel ?? TechLevel.Industrial;
                if (asAdult == 0)
                {
                    asAdult = fallback;
                }
                if (asChild == 0)
                {
                    asChild = fallback;
                }
            }
            childhoodLevel = asChild;
            return(asAdult);
        }
示例#13
0
        public static PawnKindDef GetFactionKindDef(PawnKindDef kindDef, Faction faction)
        {
            int factionID = 0;

            if (faction.def == FactionDef.Named("BI_InsectRedFaction"))
            {
                factionID = 1;
            }
            else if (faction.def == FactionDef.Named("BI_InsectBlackFaction"))
            {
                factionID = 2;
            }
            else if (faction.def == FactionDef.Named("BI_InsectGreenFaction"))
            {
                factionID = 3;
            }
            if (queenKindDef.Contains(kindDef))
            {
                return(queenKindDef[factionID]);
            }
            else if (megaspiderKindDef.Contains(kindDef))
            {
                return(megaspiderKindDef[factionID]);
            }
            else if (spelopedeKindDef.Contains(kindDef))
            {
                return(spelopedeKindDef[factionID]);
            }
            else if (megascarabKindDef.Contains(kindDef))
            {
                return(megascarabKindDef[factionID]);
            }
            return(null);
        }
 public void CheckFaction()
 {
     //If I detect the creature is part of the player's faction (has been tamed)
     if (this.parent.Faction == Faction.OfPlayer)
     {
         Pawn pawn = parent as Pawn;
         if (pawn != null)
         {
             //if goesManhunter is false, the creature is just returned to the wild, no faction
             if (!Props.goesManhunter)
             {
                 parent.SetFaction(null, null);
             }
             //if goesManhunter is true and factionToReturnTo is not set, the creature is made manhunter
             else if (Props.factionToReturnTo == "")
             {
                 pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
             }
             //if goesManhunter is true and factionToReturnTo is set, the creature is made manhunter and placed on the
             //faction it should belong to
             else
             {
                 parent.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named(Props.factionToReturnTo)), null);
                 pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
             };
             //Optionally a message can be sent when this happens
             if (Props.sendMessage)
             {
                 Messages.Message(Props.message.Translate(pawn.LabelIndefinite().CapitalizeFirst()), pawn, MessageTypeDefOf.NegativeEvent, true);
             }
         }
     }
 }
        public IEnumerable <PawnKindDef> GetPawnKindsForFactionDefLabel(FactionDef def)
        {
            string defLabel = def.label.ToLower();
            var    keys     = factionDefPawnKindLookup.Keys.Where((FactionDef f) => { return(defLabel == f.label.ToLower()); });
            IEnumerable <PawnKindDef> result = null;

            if (keys != null)
            {
                foreach (var key in keys)
                {
                    var list = factionDefPawnKindLookup[key];
                    if (list == null)
                    {
                        continue;
                    }
                    if (result == null)
                    {
                        result = list;
                    }
                    else
                    {
                        result = result.Concat(list);
                    }
                }
            }
            if (result == null)
            {
                return(Enumerable.Empty <PawnKindDef>());
            }
            return(result);
        }
示例#16
0
        public void AcquireExpertise()
        {
            if (Prefs.LogVerbose)
            {
                Log.Warning($"[HumanResources] Acquiring expertise for {pawn}...");
            }
            expertise = new Dictionary <ResearchProjectDef, float>();
            FactionDef faction           = pawn.Faction?.def ?? pawn.kindDef.defaultFactionType;
            var        acquiredExpertise = GetExpertiseDefsFor(pawn, faction);

            if (!acquiredExpertise.EnumerableNullOrEmpty())
            {
                expertise = acquiredExpertise.Where(x => x != null).ToDictionary(x => x, x => 1f);
                if (Prefs.LogVerbose)
                {
                    Log.Message($"... {pawn.gender.GetPossessive().CapitalizeFirst()} knowledge is going to be {expertise.Keys.ToStringSafeEnumerable()}.");
                }
            }
            else
            {
                Log.Warning($"[HumanResources] {pawn} spawned without acquiring any expertise.");
            }
            AcquireWeaponKnowledge(faction);
            if (Prefs.LogVerbose && proficientWeapons.Any())
            {
                Log.Message($"... {pawn.gender.GetPossessive().CapitalizeFirst()} weapon proficiency is going to be: {proficientWeapons.ToStringSafeEnumerable()}");
            }
            AcquirePlantKnowledge();
            if (Prefs.LogVerbose && proficientPlants.Any())
            {
                Log.Message($"... {pawn.gender.GetPronoun().CapitalizeFirst()} will be able to cultivate the following plants: {proficientPlants.ToStringSafeEnumerable()}");
            }
        }
示例#17
0
        public override void Generate(Map map, GenStepParams parms)
        {
            CellRect rectToDefend;

            if (!MapGenerator.TryGetVar <CellRect>("RectOfInterest", out rectToDefend))
            {
                rectToDefend = CellRect.SingleCell(map.Center);
            }
            Faction faction;

            if (map.ParentFaction == null || map.ParentFaction == Faction.OfPlayer)
            {
                faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named(
                                                                    "ROMV_Sabbat")); //Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined);
            }
            else
            {
                faction = map.ParentFaction;
            }
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect             = this.GetOutpostRect(rectToDefend, map);
            resolveParams.faction          = faction;
            resolveParams.edgeDefenseWidth = new int?(2);
            //resolveParams.edgeDefenseTurretsCount = new int?(Rand.RangeInclusive(0, 1));
            resolveParams.edgeDefenseMortarsCount   = new int?(0);
            resolveParams.settlementPawnGroupPoints = new float?(0.4f);
            BaseGen.globalSettings.map          = map;
            BaseGen.globalSettings.minBuildings = 1;
            BaseGen.globalSettings.minBarracks  = 1;
            BaseGen.symbolStack.Push("factionBase", resolveParams);
            BaseGen.Generate();
        }
示例#18
0
 public static bool IsWarBorder(StarSystem system, SimGameState Sim)
 {
     try {
         FactionDef factiondef = Sim.FactionsDict[system.Owner];
         bool       result     = false;
         if (Sim.Starmap != null)
         {
             if (system.Owner != Faction.NoFaction)
             {
                 foreach (StarSystem neigbourSystem in Sim.Starmap.GetAvailableNeighborSystem(system))
                 {
                     if (factiondef.Enemies.Contains(neigbourSystem.Owner) && neigbourSystem.Owner != Faction.NoFaction)
                     {
                         result = true;
                         break;
                     }
                 }
             }
         }
         return(result);
     }
     catch (Exception ex) {
         Logger.LogError(ex);
         return(false);
     }
 }
示例#19
0
        public void AcquireExpertise()
        {
            if (Prefs.LogVerbose)
            {
                Log.Warning("Acquiring expertise for " + pawn + "...");
            }
            expertise = new Dictionary <ResearchProjectDef, float>();
            FactionDef faction           = pawn.Faction?.def ?? pawn.kindDef.defaultFactionType;
            var        acquiredExpertise = GetExpertiseDefsFor(pawn, faction);

            if (!acquiredExpertise.EnumerableNullOrEmpty())
            {
                expertise = acquiredExpertise.Where(x => x != null).ToDictionary(x => x, x => 1f);
                if (Prefs.LogVerbose)
                {
                    Log.Message(pawn.gender.GetPossessive().CapitalizeFirst() + " expertise is " + expertise.Keys.ToStringSafeEnumerable() + ".");
                }
            }
            else
            {
                Log.Warning("[HumanResources] " + pawn + " spawned without acquiring any expertise.");
            }
            AcquireWeaponKnowledge(faction);
            if (Prefs.LogVerbose && proficientWeapons.Any())
            {
                Log.Message(pawn.gender.GetPronoun().CapitalizeFirst() + " can use the following weapons: " + proficientWeapons.ToStringSafeEnumerable());
            }
            AcquirePlantKnowledge();
            if (Prefs.LogVerbose && proficientPlants.Any())
            {
                Log.Message(pawn.gender.GetPronoun().CapitalizeFirst() + " can cultivate the following plants: " + proficientPlants.ToStringSafeEnumerable());
            }
            string test2 = expertise != null ? "ok" : "bad";
        }
示例#20
0
 public void Ignore(FactionDef faction)
 {
     if (!ignoredFactions.Contains(faction))
     {
         ignoredFactions.Add(faction);
     }
 }
示例#21
0
        private void GenerateFactions()
        {
            if (regenerate)
            {
                RemoveAllFactions();
            }

            for (int i = 0; i < FactionToGenerate; i++)
            {
                FactionDef facDef = (from fa in DefDatabase <FactionDef> .AllDefs
                                     where fa.canMakeRandomly && !fa.hidden && !fa.isPlayer select fa).RandomElement();
                Faction faction = NewGeneratedFaction(facDef);
                Find.FactionManager.Add(faction);
            }

            int num = GenMath.RoundRandom((float)Find.WorldGrid.TilesCount / 100000f * SettlementsPer100kTiles.RandomInRange);

            num -= Find.WorldObjects.Settlements.Count;
            for (int k = 0; k < num; k++)
            {
                Faction faction3 = (from x in Find.World.factionManager.AllFactionsListForReading
                                    where !x.def.isPlayer && !x.def.hidden
                                    select x).RandomElementByWeight((Faction x) => x.def.settlementGenerationWeight);
                Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);
                settlement.SetFaction(faction3);
                settlement.Tile = TileFinder.RandomSettlementTileFor(faction3);
                settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement);
                Find.WorldObjects.Add(settlement);
            }
        }
示例#22
0
 static bool Prefix(SGNavigationActiveFactionWidget __instance, List <string> activeFactions, string OwnerFaction, List <HBSButton> ___FactionButtons, List <Image> ___FactionIcons, SimGameState ___simState)
 {
     try {
         ___FactionButtons.ForEach(delegate(HBSButton btn) {
             btn.gameObject.SetActive(false);
         });
         int index = 0;
         foreach (string faction in activeFactions)
         {
             FactionDef factionDef = FactionEnumeration.GetFactionByName(faction).FactionDef;
             ___FactionIcons[index].sprite = factionDef.GetSprite();
             HBSTooltip component = ___FactionIcons[index].GetComponent <HBSTooltip>();
             if (component != null)
             {
                 component.SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(factionDef));
             }
             ___FactionButtons[index].SetState(ButtonState.Enabled, false);
             ___FactionButtons[index].gameObject.SetActive(true);
             index++;
         }
         return(false);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }
        public static CastDef CreateCast(CombatGameState combat, string sourceGUID, Team team, string employerFactionName = "Support")
        {
            string castDefId = $"castDef_{sourceGUID}";

            if (combat.DataManager.CastDefs.Exists(castDefId))
            {
                return(combat.DataManager.CastDefs.Get(castDefId));
            }

            FactionValue actorFaction  = team?.FactionValue;
            bool         factionExists = actorFaction.Name != "INVALID_UNSET" && actorFaction.Name != "NoFaction" &&
                                         actorFaction.FactionDefID != null && actorFaction.FactionDefID.Length != 0 ? true : false;

            if (factionExists)
            {
                Mod.Log.Debug?.Write($"Found factionDef for id:{actorFaction}");
                string     factionId          = actorFaction?.FactionDefID;
                FactionDef employerFactionDef = UnityGameInstance.Instance.Game.DataManager.Factions.Get(factionId);
                if (employerFactionDef == null)
                {
                    Mod.Log.Error?.Write($"Error finding FactionDef for faction with id '{factionId}'");
                }
                else
                {
                    employerFactionName = employerFactionDef.Name.ToUpper();
                }
            }
            else
            {
                Mod.Log.Debug?.Write($"FactionDefID does not exist for faction: {actorFaction}");
            }

            CastDef newCastDef = new CastDef
            {
                // Temp test data
                FactionValue  = actorFaction,
                firstName     = $"{employerFactionName} -",
                showRank      = false,
                showCallsign  = true,
                showFirstName = true,
                showLastName  = false
            };

            // DisplayName order is first, callsign, lastname

            newCastDef.id = castDefId;
            string portraitPath = GetRandomPortraitPath();

            newCastDef.callsign = GetRandomCallsign();
            Mod.Log.Debug?.Write($" Generated cast with callsign: {newCastDef.callsign} and DisplayName: {newCastDef.DisplayName()} using portrait: '{portraitPath}'");

            // Load the associated portrait
            newCastDef.defaultEmotePortrait.portraitAssetPath = portraitPath;
            Mod.Log.Debug?.Write($"Generated random portrait: {portraitPath}.");

            ((DictionaryStore <CastDef>)UnityGameInstance.BattleTechGame.DataManager.CastDefs).Add(newCastDef.id, newCastDef);

            return(newCastDef);
        }
示例#24
0
        static AMXBMain()
        {
            ThingDef thingDef = DefDatabase <ThingDef> .GetNamed("Human");

            AdeptusThingDefOf.OG_Human_Mechanicus.recipes = thingDef.recipes;
            //    Log.Message(string.Format("adding {0} to Mechanicus_Race", OGAdeptusMechanicusDefOf.OG_Human_Mechanicus.recipes.Count));

            /*
             * foreach (var item in ModLister.AllInstalledMods)
             * {
             * //    log.message(string.Format("{0}", item));
             * }
             */
            if (!AMAMod.settings.AllowTyranid || !AMAMod.settings.AllowTyranidWeapons || !AMAMod.settings.AllowTyranidInfestation)
            {
                AdeptusIncidentDefOf.OG_Tyranid_Infestation.baseChance            = 0f;
                AdeptusIncidentDefOf.OG_Tyranid_Infestation.baseChanceWithRoyalty = 0f;
            }
            if (!AMAMod.settings.AllowChaosDeamons || !AMAMod.settings.AllowChaosDeamonicInfestation || !AMAMod.settings.AllowChaosDeamonicIncursion)
            {
                if (!AMAMod.settings.AllowChaosDeamons || !AMAMod.settings.AllowChaosDeamonicInfestation)
                {
                    AdeptusIncidentDefOf.OG_Chaos_Deamon_Daemonic_Infestation.baseChance            = 0f;
                    AdeptusIncidentDefOf.OG_Chaos_Deamon_Daemonic_Infestation.baseChanceWithRoyalty = 0f;
                }
                if (!AMAMod.settings.AllowChaosDeamons || !AMAMod.settings.AllowChaosDeamonicIncursion)
                {
                    AdeptusIncidentDefOf.OG_Chaos_Deamon_Deamonic_Incursion.baseChance            = 0f;
                    AdeptusIncidentDefOf.OG_Chaos_Deamon_Deamonic_Incursion.baseChanceWithRoyalty = 0f;
                }
            }
            if (!AMAMod.settings.AllowEldarWraithguard)
            {
                FactionDef fd = AdeptusFactionDefOf.OG_Eldar_Craftworld_Faction;
                ThingDef   td = AdeptusThingDefOf.OG_Eldar_Wraithguard_Race;
                Filter(fd, td);
            }
            //    Log.Message(string.Format("post AllowEldarWraithguard"));
            if (!AMAMod.settings.AllowKrootAuxiliaries)
            {
                FactionDef fd = AdeptusFactionDefOf.OG_Tau_Faction;
                ThingDef   td = AdeptusThingDefOf.OG_Alien_Kroot;
                Filter(fd, td);
                td = AdeptusThingDefOf.OG_Kroothound_Kindred;
                Filter(fd, td);
                td = AdeptusThingDefOf.OG_Knarloc_Kindred;
                Filter(fd, td);
                td = AdeptusThingDefOf.OG_KrootOx_Kindred;
                Filter(fd, td);
            }
            //    Log.Message(string.Format("post AllowKrootAuxiliaries"));
            if (!AMAMod.settings.AllowGueVesaAuxiliaries)
            {
                FactionDef fd = AdeptusFactionDefOf.OG_Tau_Faction;
                ThingDef   td = ThingDefOf.Human;
                Filter(fd, td);
            }
            //    Log.Message(string.Format("post AllowGueVesaAuxiliaries"));
        }
 public static void Postfix(FactionDef employer)
 {
     if (Fields.needsToReloadEnemies)
     {
         Traverse.Create(employer).Property("Enemies").SetValue(Fields.enemyHolder.ToArray());
         Fields.needsToReloadEnemies = false;
     }
 }
 public static HiveFactionExtension HiveExt(this FactionDef faction)
 {
     if (faction.HasModExtension <OgsOld_ExtraHives.HiveFactionExtension>())
     {
         return(faction.GetModExtension <OgsOld_ExtraHives.HiveFactionExtension>());
     }
     return(null);
 }
示例#27
0
 private Dialog_FactionSpawning(IEnumerator <FactionDef> enumerator)
 {
     doCloseButton           = false;
     forcePause              = true;
     absorbInputAroundWindow = true;
     factionEnumerator       = enumerator;
     factionDef              = enumerator.Current;
 }
        public void SetPlayerFactionVarsToNewGeneratedFaction(FactionDef def)
        {
            var generatedFaction = FactionGenerator.NewGeneratedFaction(def);

            generatedFaction.loadID = this.WorldData.FactionManager.OfPlayer.loadID;

            SetFactionVars(generatedFaction, this.WorldData.FactionManager.OfPlayer, FactionMode.Reset, true);
        }
示例#29
0
 public static bool FactionManagerFirstFactionOfDefPrefix(ref FactionDef facDef)
 {
     if (ModStuff.Settings.LimitTechnology && facDef != null && facDef.techLevel > RemoveModernStuff.MAX_TECHLEVEL)
     {
         return(false);
     }
     return(true);
 }
示例#30
0
        public override void Randomize()
        {
            chance  = GenMath.RoundedHundredth(Rand.Range(0.05f, 1f));
            context = Extensions.GetEnumValues <PawnModifierContext>().RandomElement();
            faction = faction = DefDatabase <FactionDef> .AllDefs.Where(f => !f.isPlayer).RandomElement();

            gender = Extensions.GetEnumValues <PawnModifierGender>().RandomElement();
        }
示例#31
0
 private static HairDef RandomHairDefFor(Colonist c, FactionDef factionType)
 {
     IEnumerable<HairDef> source =
         from hair in DefDatabase<HairDef>.AllDefs
         where hair.hairTags.SharesElementWith(factionType.hairTags)
         select hair;
     return source.RandomElementByWeight((HairDef hair) => HairChoiceLikelihoodFor(hair, c));
 }