Пример #1
0
        public static void MinPointsTest(PawnGroupKindWorker_Normal __instance, PawnGroupMaker groupMaker)
        {
//            if (groupMaker?.options?.Count == null ||
//                groupMaker.options.Count <= 0)
//            {
//                Log.Message("No options available.");
//            }
//            foreach (var x in groupMaker.options)
//            {
//                Log.Message(x.kind.defName + " " + x.kind.isFighter.ToString() +  " " + x.Cost);
//            }
        }
Пример #2
0
        static bool Prefix(ref PawnGroupKindWorker_Normal __instance, PawnGroupMakerParms parms, PawnGroupMaker groupMaker, List <Pawn> outPawns, bool errorOnZeroResults = true)
        {
            if (parms.faction == FactionColonies.getPlayerColonyFaction())
            {
                List <PawnKindDef> list = new List <PawnKindDef>();
                foreach (ThingDef def in Find.World.GetComponent <FactionFC>().raceFilter.AllowedThingDefs)
                {
                    list.Add(def.race.AnyPawnKind);
                }



                if (!__instance.CanGenerateFrom(parms, groupMaker))
                {
                    if (errorOnZeroResults)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Cannot generate pawns for ",
                            parms.faction,
                            " with ",
                            parms.points,
                            ". Defaulting to a single random cheap group."
                        }), false);
                    }
                    return(false);
                }
                bool             allowFood         = parms.raidStrategy == null || parms.raidStrategy.pawnsCanBringFood || (parms.faction != null && !parms.faction.HostileTo(Faction.OfPlayer));
                Predicate <Pawn> validatorPostGear = (parms.raidStrategy != null) ? ((Pawn p) => parms.raidStrategy.Worker.CanUsePawn(p, outPawns)) : (Predicate <Pawn>)null;
                bool             flag = false;
                foreach (PawnGenOption pawnGenOption in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms))
                {
                    PawnKindDef pawnkind = new PawnKindDef();
                    pawnkind = list.RandomElement();
                    pawnkind.techHediffsTags            = pawnGenOption.kind.techHediffsTags;
                    pawnkind.apparelTags                = pawnGenOption.kind.apparelTags;
                    pawnkind.isFighter                  = pawnGenOption.kind.isFighter;
                    pawnkind.combatPower                = pawnGenOption.kind.combatPower;
                    pawnkind.gearHealthRange            = pawnGenOption.kind.gearHealthRange;
                    pawnkind.weaponTags                 = pawnGenOption.kind.weaponTags;
                    pawnkind.apparelMoney               = pawnGenOption.kind.apparelMoney;
                    pawnkind.weaponMoney                = pawnGenOption.kind.weaponMoney;
                    pawnkind.apparelAllowHeadgearChance = pawnGenOption.kind.apparelAllowHeadgearChance;
                    pawnkind.techHediffsMoney           = pawnGenOption.kind.techHediffsMoney;
                    pawnkind.label = pawnGenOption.kind.label;


                    Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnkind, parms.faction, PawnGenerationContext.NonPlayer, parms.tile, false, false, false, false, true, true, 1f, false, true, allowFood, true, parms.inhabitants, false, false, false, 0f, null, 1f, null, validatorPostGear, null, null, null, null, null, null, null, null, null, null));
                    if (parms.forceOneIncap && !flag)
                    {
                        pawn.health.forceIncap           = true;
                        pawn.mindState.canFleeIndividual = false;
                        flag = true;
                    }
                    outPawns.Add(pawn);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }