Пример #1
0
        public static FactionDef GetFactionDef(this HediffComp_RandySpawner comp, RandomFactionParameter RFP)
        {
            Pawn p = comp.Pawn;

            if (RFP.HasInheritedFaction)
            {
                return(p.Faction.def);
            }
            else if (RFP.HasForcedFaction)
            {
                return(RFP.forcedFaction);
            }
            else if (RFP.HasPlayerFaction)
            {
                return(Faction.OfPlayerSilentFail.def);
            }
            else if (RFP.HasNoFaction)
            {
                return(null);
            }
            else if (RFP.HasDefaultPawnKindFaction)
            {
                return(comp.CurIP.pawnKindToSpawn?.defaultFactionType ?? null);
            }

            return(null);
        }
Пример #2
0
        public static Faction GetFaction(this HediffComp_RandySpawner comp, RandomFactionParameter RFP)
        {
            FactionDef fDef = comp.GetFactionDef(RFP);

            if (fDef == null)
            {
                return(null);
            }
            return(Find.FactionManager.AllFactions.Where(F => F.def == fDef).FirstOrFallback());
        }
Пример #3
0
        public static void ComputeRandomFaction(this HediffComp_RandySpawner comp)
        {
            if (comp.CurIP.HasFactionParams)
            {
                int FactionIndex = comp.GetWeightedRandomFaction();
                if (FactionIndex == -1)
                {
                    Tools.Warn("ComputeRandomFaction - found no index", comp.MyDebug);
                    return;
                }

                comp.newBorn = comp.CurIP.randomFactionParameters[FactionIndex].newBorn;
                RandomFactionParameter RFP = comp.CurIP.randomFactionParameters[FactionIndex];
                comp.Itemfaction = comp.GetFaction(RFP);
                Tools.Warn("ComputeRandomFaction - found:" + comp.Itemfaction?.GetCallLabel(), comp.MyDebug);
            }
        }