Exemplo n.º 1
0
 private IEnumerable <Pawn> GenerateAmbushPawns()
 {
     if (this.manhunters)
     {
         PawnKindDef animalKind;
         if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, base.Map.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, -1, out animalKind))
         {
             return(Enumerable.Empty <Pawn>());
         }
         return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, base.Map.Tile, this.points));
     }
     else
     {
         Faction faction;
         if (this.mechanoids)
         {
             faction = Faction.OfMechanoids;
         }
         else
         {
             faction = (base.Map.ParentFaction ?? Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Undefined));
         }
         if (faction == null)
         {
             return(Enumerable.Empty <Pawn>());
         }
         PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();
         pawnGroupMakerParms.tile    = base.Map.Tile;
         pawnGroupMakerParms.faction = faction;
         pawnGroupMakerParms.points  = this.points;
         return(PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, pawnGroupMakerParms, true));
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <TargetInfo> list        = new List <TargetInfo>();
            ThingDef          shipPartDef = def.mechClusterBuilding;
            IntVec3           intVec      = FindDropPodLocation(map, (IntVec3 spot) => CanPlaceAt(spot));

            if (intVec == IntVec3.Invalid)
            {
                return(false);
            }
            float       points = Mathf.Max(parms.points * 0.9f, 300f);
            List <Pawn> list2  = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = Faction.OfMechanoids,
                points    = points
            }).ToList();
            Thing thing = ThingMaker.MakeThing(shipPartDef);

            thing.SetFaction(Faction.OfMechanoids);
            LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                thing
            }, Faction.OfMechanoids, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2);
            DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>());
            foreach (Pawn item in list2)
            {
                item.TryGetComp <CompCanBeDormant>()?.ToSleep();
            }
            list.AddRange(list2.Select((Pawn p) => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map);
            list.Add(new TargetInfo(intVec, map));
            SendStandardLetter(parms, list);
            return(true);

            bool CanPlaceAt(IntVec3 loc)
            {
                CellRect cellRect = GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size);

                if (loc.Fogged(map) || !cellRect.InBounds(map))
                {
                    return(false);
                }
                if (!DropCellFinder.SkyfallerCanLandAt(loc, map, shipPartDef.Size))
                {
                    return(false);
                }
                foreach (IntVec3 item2 in cellRect)
                {
                    RoofDef roof = item2.GetRoof(map);
                    if (roof != null && roof.isNatural)
                    {
                        return(false);
                    }
                }
                return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North));
            }
        }
Exemplo n.º 3
0
        protected virtual SignalAction_Ambush MakeAmbushSignalAction(CellRect rectToDefend, IntVec3 root, GenStepParams parms)
        {
            SignalAction_Ambush signalAction_Ambush = (SignalAction_Ambush)ThingMaker.MakeThing(ThingDefOf.SignalAction_Ambush);

            if (parms.sitePart != null)
            {
                signalAction_Ambush.points = parms.sitePart.parms.threatPoints;
            }
            else
            {
                signalAction_Ambush.points = defaultPointsRange.RandomInRange;
            }
            int num = Rand.RangeInclusive(0, 2);

            if (num == 0)
            {
                signalAction_Ambush.ambushType = SignalActionAmbushType.Manhunters;
            }
            else if (num == 1 && PawnGroupMakerUtility.CanGenerateAnyNormalGroup(Faction.OfMechanoids, signalAction_Ambush.points))
            {
                signalAction_Ambush.ambushType = SignalActionAmbushType.Mechanoids;
            }
            else
            {
                signalAction_Ambush.ambushType = SignalActionAmbushType.Normal;
            }
            return(signalAction_Ambush);
        }
 protected override void GeneratePawns(PawnGroupMakerParms parms, PawnGroupMaker groupMaker, List <Pawn> outPawns, bool errorOnZeroResults = true)
 {
     if (!CanGenerateFrom(parms, groupMaker))
     {
         if (errorOnZeroResults)
         {
             Log.Error("Cannot generate pawns for " + parms.faction + " with " + parms.points + ". Defaulting to a single random cheap group.");
         }
     }
     else
     {
         bool             allowFood         = parms.raidStrategy == null || parms.raidStrategy.pawnsCanBringFood || (parms.faction != null && !parms.faction.HostileTo(Faction.OfPlayer));
         Predicate <Pawn> validatorPostGear = (parms.raidStrategy != null) ? ((Predicate <Pawn>)((Pawn p) => parms.raidStrategy.Worker.CanUsePawn(p, outPawns))) : null;
         bool             flag = false;
         foreach (PawnGenOption item in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms))
         {
             Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(item.kind, parms.faction, PawnGenerationContext.NonPlayer, parms.tile, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: true, 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood, allowAddictions: true, parms.inhabitants, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, 0f, null, 1f, null, validatorPostGear));
             if (parms.forceOneIncap && !flag)
             {
                 pawn.health.forceIncap           = true;
                 pawn.mindState.canFleeIndividual = false;
                 flag = true;
             }
             outPawns.Add(pawn);
         }
     }
 }
 protected override void GeneratePawns(PawnGroupMakerParms parms, PawnGroupMaker groupMaker, List <Pawn> outPawns, bool errorOnZeroResults = true)
 {
     if (!this.CanGenerateFrom(parms, groupMaker))
     {
         if (errorOnZeroResults)
         {
             Log.Error("Cannot generate pawns for " + parms.faction + " with " + parms.points + ". Defaulting to a single random cheap group.");
         }
     }
     else
     {
         bool flag  = parms.raidStrategy == null || parms.raidStrategy.pawnsCanBringFood || (parms.faction != null && !parms.faction.HostileTo(Faction.OfPlayer));
         bool flag2 = false;
         foreach (PawnGenOption item in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms))
         {
             PawnKindDef           kind        = item.kind;
             Faction               faction     = parms.faction;
             int                   tile        = parms.tile;
             bool                  allowFood   = flag;
             bool                  inhabitants = parms.inhabitants;
             PawnGenerationRequest request     = new PawnGenerationRequest(kind, faction, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, true, 1f, false, true, allowFood, inhabitants, false, false, false, null, null, null, null, null, null, null);
             Pawn                  pawn        = PawnGenerator.GeneratePawn(request);
             if (parms.forceOneIncap && !flag2)
             {
                 pawn.health.forceIncap           = true;
                 pawn.mindState.canFleeIndividual = false;
                 flag2 = true;
             }
             outPawns.Add(pawn);
         }
     }
 }
 public override IEnumerable <PawnKindDef> GeneratePawnKindsExample(PawnGroupMakerParms parms, PawnGroupMaker groupMaker)
 {
     foreach (PawnGenOption item in PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms))
     {
         yield return(item.kind);
     }
 }
Exemplo n.º 7
0
 private IEnumerable <Pawn> GenerateAmbushPawns()
 {
     if (this.ambushType == SignalActionAmbushType.Manhunters)
     {
         PawnKindDef animalKind;
         if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, base.Map.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, -1, out animalKind))
         {
             return(Enumerable.Empty <Pawn>());
         }
         return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, base.Map.Tile, this.points));
     }
     else
     {
         Faction faction;
         if (this.ambushType == SignalActionAmbushType.Mechanoids)
         {
             faction = Faction.OfMechanoids;
         }
         else
         {
             faction = (base.Map.ParentFaction ?? Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Undefined));
         }
         if (faction == null)
         {
             return(Enumerable.Empty <Pawn>());
         }
         return(PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
         {
             groupKind = PawnGroupKindDefOf.Combat,
             tile = base.Map.Tile,
             faction = faction,
             points = Mathf.Max(this.points, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat))
         }, true));
     }
 }
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced               = true;
            raidParms.faction              = parms.faction;
            raidParms.raidStrategy         = XenomorphDefOf.RRY_PowerCut;
            raidParms.raidArrivalMode      = XenomorphDefOf.RRY_DropThroughRoofNearPower;
            raidParms.spawnCenter          = spawnSpot;
            raidParms.generateFightersOnly = true;
            raidParms.points               = Mathf.Max((raidParms.points / 5) * IncidentWorker_PowerCut.RaidPointsFactorRange.RandomInRange, 500f);
            raidParms.pawnGroupMakerSeed   = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, true);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, XenomorphDefOf.RRY_DropThroughRoofNearPower, XenomorphDefOf.RRY_PowerCut, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

            base.SendStandardLetter(parms, null);
            QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), 0, 0);

            Find.Storyteller.incidentQueue.Add(qi);
            return(true);
        }
        private List <Pawn> GenerateCaravanPawns(Faction faction)
        {
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.faction = faction;
            pawnGroupMakerParms.points  = TraderCaravanUtility.GenerateGuardPoints();
            return(PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Trader, pawnGroupMakerParms, true).ToList());
        }
Exemplo n.º 10
0
        private IEnumerable <Pawn> GeneratePawns(Map map)
        {
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.tile    = map.Tile;
            pawnGroupMakerParms.faction = Faction.OfMechanoids;
            pawnGroupMakerParms.points  = this.pointsRange.RandomInRange;
            return(PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, pawnGroupMakerParms, true));
        }
Exemplo n.º 11
0
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph);

            if (faction == null)
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced               = true;
            raidParms.faction              = faction;
            raidParms.raidStrategy         = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode      = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter          = spawnSpot;
            raidParms.generateFightersOnly = true;
            raidParms.points               = Mathf.Max(raidParms.points * IncidentWorker_PowerCutP1.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed   = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

            base.SendStandardLetter();
            QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), 0, 0);

            Find.Storyteller.incidentQueue.Add(qi);

            @int                              = Rand.Int;
            raidParms                         = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);
            raidParms.forced                  = true;
            raidParms.faction                 = faction;
            raidParms.raidStrategy            = XenomorphDefOf.RRY_PowerCut;
            raidParms.raidArrivalMode         = XenomorphDefOf.RRY_DropThroughRoofNearPower;
            raidParms.spawnCenter             = spawnSpot;
            raidParms.generateFightersOnly    = true;
            raidParms.points                  = Mathf.Max((raidParms.points / 5) * IncidentWorker_PowerCutP1.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed      = new int?(@int);
            defaultPawnGroupMakerParms        = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);
            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            pawnKinds                         = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

            qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_PowerCutP1.RaidDelay.RandomInRange, 0);
            Find.Storyteller.incidentQueue.Add(qi);


            return(true);
        }
Exemplo n.º 12
0
 private List <Pawn> GenerateCaravanPawns(Faction faction)
 {
     return(PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
     {
         groupKind = PawnGroupKindDefOf.Trader,
         faction = faction,
         points = TraderCaravanUtility.GenerateGuardPoints(),
         dontUseSingleUseRocketLaunchers = true
     }, true).ToList <Pawn>());
 }
Exemplo n.º 13
0
 private IEnumerable <Pawn> GeneratePawns(Map map)
 {
     return(PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
     {
         groupKind = PawnGroupKindDefOf.Combat,
         tile = map.Tile,
         faction = Faction.OfMechanoids,
         points = this.pointsRange.RandomInRange
     }, true));
 }
Exemplo n.º 14
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Faction faction;

            if (CaravanIncidentUtility.CanFireIncidentWhichWantsToGenerateMapAt(parms.target.Tile))
            {
                return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out faction));
            }
            return(false);
        }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            Faction faction;

            return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out faction));
        }
Exemplo n.º 16
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            parms.points *= IncidentPointsFactorRange.RandomInRange;
            Caravan caravan = (Caravan)parms.target;

            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction))
            {
                return(false);
            }
            List <ThingCount> demands = GenerateDemands(caravan);

            if (demands.NullOrEmpty())
            {
                return(false);
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms);

            defaultPawnGroupMakerParms.generateFightersOnly            = true;
            defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
            List <Pawn> attackers = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList();

            if (attackers.Count == 0)
            {
                Log.Error("Caravan demand incident couldn't generate any enemies even though min points have been checked. faction=" + defaultPawnGroupMakerParms.faction + "(" + ((defaultPawnGroupMakerParms.faction == null) ? "null" : defaultPawnGroupMakerParms.faction.def.ToString()) + ") parms=" + parms);
                return(false);
            }
            CameraJumper.TryJumpAndSelect(caravan);
            DiaNode   diaNode   = new DiaNode(GenerateMessageText(parms.faction, attackers.Count, demands, caravan));
            DiaOption diaOption = new DiaOption("CaravanDemand_Give".Translate());

            diaOption.action = delegate
            {
                ActionGive(caravan, demands, attackers);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            DiaOption diaOption2 = new DiaOption("CaravanDemand_Fight".Translate());

            diaOption2.action = delegate
            {
                ActionFight(caravan, attackers);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            string      text               = "CaravanDemandTitle".Translate(parms.faction.Name);
            WindowStack windowStack        = Find.WindowStack;
            DiaNode     nodeRoot           = diaNode;
            Faction     faction            = parms.faction;
            bool        delayInteractivity = true;
            string      title              = text;

            windowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction, delayInteractivity, radioMode: false, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, text, parms.faction));
            return(true);
        }
Exemplo n.º 17
0
 private int GetMechanoidsCount(Site site, SiteCoreOrPartParams parms)
 {
     return(PawnGroupMakerUtility.GeneratePawnKindsExample(new PawnGroupMakerParms
     {
         tile = site.Tile,
         faction = Faction.OfMechanoids,
         groupKind = PawnGroupKindDefOf.Combat,
         points = parms.threatPoints,
         seed = new int?(SleepingMechanoidsSitePartUtility.GetPawnGroupMakerSeed(parms))
     }).Count <PawnKindDef>());
 }
        private int GetMechanoidsCount(Site site, SiteCoreOrPartParams parms)
        {
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.tile      = site.Tile;
            pawnGroupMakerParms.faction   = Faction.OfMechanoids;
            pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
            pawnGroupMakerParms.points    = parms.threatPoints;
            pawnGroupMakerParms.seed      = SleepingMechanoidsSitePartUtility.GetPawnGroupMakerSeed(parms);
            return(PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms).Count());
        }
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            if (!PawnGroupMakerUtility.TryGetRandomFactionForNormalPawnGroup(parms.points, out parms.faction, null, false, false, false, true))
            {
                return(new List <Pawn>());
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms, false);

            defaultPawnGroupMakerParms.generateFightersOnly = true;
            return(PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList <Pawn>());
        }
 private int GetEnemiesCount(Site site, SiteCoreOrPartParams parms)
 {
     return(PawnGroupMakerUtility.GeneratePawnKindsExample(new PawnGroupMakerParms
     {
         tile = site.Tile,
         faction = site.Faction,
         groupKind = PawnGroupKindDefOf.Settlement,
         points = parms.threatPoints,
         inhabitants = true,
         seed = new int?(SitePartWorker_Outpost.GetPawnGroupMakerSeed(parms))
     }).Count <PawnKindDef>());
 }
Exemplo n.º 21
0
        private int GetEnemiesCount(Site site, SiteCoreOrPartParams parms)
        {
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.tile        = site.Tile;
            pawnGroupMakerParms.faction     = site.Faction;
            pawnGroupMakerParms.groupKind   = PawnGroupKindDefOf.Settlement;
            pawnGroupMakerParms.points      = parms.threatPoints;
            pawnGroupMakerParms.inhabitants = true;
            pawnGroupMakerParms.seed        = OutpostSitePartUtility.GetPawnGroupMakerSeed(parms);
            return(PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms).Count());
        }
Exemplo n.º 22
0
 protected int GetEnemiesCount(Site site, SitePartParams parms)
 {
     return(PawnGroupMakerUtility.GeneratePawnKindsExample(new PawnGroupMakerParms
     {
         tile = site.Tile,
         faction = site.Faction,
         groupKind = PawnGroupKindDefOf.Settlement,
         points = parms.threatPoints,
         inhabitants = true,
         seed = OutpostSitePartUtility.GetPawnGroupMakerSeed(parms)
     }).Count());
 }
        protected List <Pawn> SpawnPawns(IncidentParms parms)
        {
            Map         map  = (Map)parms.target;
            List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDef, parms, ensureCanGenerateAtLeastOnePawn: true), warnOnZeroResults: false).ToList();

            foreach (Pawn item in list)
            {
                IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 5);
                GenSpawn.Spawn(item, loc, map);
            }
            return(list);
        }
 public override bool CanGenerateFrom(PawnGroupMakerParms parms, PawnGroupMaker groupMaker)
 {
     if (!base.CanGenerateFrom(parms, groupMaker))
     {
         return(false);
     }
     if (!PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms).Any())
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 25
0
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction, null, false, false, false, true))
            {
                Log.Error("Could not find any valid faction for " + this.def + " incident.", false);
                return(new List <Pawn>());
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms, false);

            defaultPawnGroupMakerParms.generateFightersOnly            = true;
            defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
            return(PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>());
        }
Exemplo n.º 26
0
        protected List <Pawn> SpawnPawns(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms, false);
            List <Pawn>         list = PawnGroupMakerUtility.GeneratePawns(this.PawnGroupKindDef, defaultPawnGroupMakerParms, false).ToList <Pawn>();

            foreach (Pawn current in list)
            {
                IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 5, null);
                GenSpawn.Spawn(current, loc, map);
            }
            return(list);
        }
Exemplo n.º 27
0
        public static IEnumerable <PawnGenOption> ChoosePawnGenOptionsByPoints(float points, List <PawnGenOption> options, PawnGroupMakerParms parms)
        {
            float num = PawnGroupMakerUtility.MaxAllowedPawnGenOptionCost(parms.faction, points, parms.raidStrategy);
            List <PawnGenOption> list  = new List <PawnGenOption>();
            List <PawnGenOption> list2 = new List <PawnGenOption>();
            float num2 = points;
            bool  flag = false;

            while (true)
            {
                list.Clear();
                for (int i = 0; i < options.Count; i++)
                {
                    PawnGenOption pawnGenOption = options[i];
                    if (!(pawnGenOption.Cost > num2) && !(pawnGenOption.Cost > num) && (!parms.generateFightersOnly || pawnGenOption.kind.isFighter) && (parms.raidStrategy == null || parms.raidStrategy.Worker.CanUsePawnGenOption(pawnGenOption, list2)) && (!flag || !pawnGenOption.kind.factionLeader))
                    {
                        list.Add(pawnGenOption);
                    }
                }
                if (list.Count != 0)
                {
                    float desireToSuppressCount = PawnGroupMakerUtility.DesireToSuppressCountPerRaidPointsCurve.Evaluate(points);
                    Func <PawnGenOption, float> weightSelector = delegate(PawnGenOption gr)
                    {
                        float num3 = gr.selectionWeight;
                        if (desireToSuppressCount > 0.0)
                        {
                            float b = (float)(num3 * (gr.Cost / 100.0));
                            num3 = Mathf.Lerp(num3, b, desireToSuppressCount);
                        }
                        return(num3);
                    };
                    PawnGenOption pawnGenOption2 = list.RandomElementByWeight(weightSelector);
                    list2.Add(pawnGenOption2);
                    num2 -= pawnGenOption2.Cost;
                    if (pawnGenOption2.kind.factionLeader)
                    {
                        flag = true;
                    }
                    continue;
                }
                break;
            }
            if (list2.Count == 1 && num2 > points / 2.0)
            {
                Log.Warning("Used only " + (points - num2) + " / " + points + " points generating for " + parms.faction);
            }
            return(list2);
        }
        private IEnumerable <Pawn> GeneratePawns(GenStepParams parms, Map map)
        {
            float points = (parms.siteCoreOrPart == null) ? this.defaultPointsRange.RandomInRange : parms.siteCoreOrPart.parms.threatPoints;
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
            pawnGroupMakerParms.tile      = map.Tile;
            pawnGroupMakerParms.faction   = Faction.OfMechanoids;
            pawnGroupMakerParms.points    = points;
            if (parms.siteCoreOrPart != null)
            {
                pawnGroupMakerParms.seed = new int?(SleepingMechanoidsSitePartUtility.GetPawnGroupMakerSeed(parms.siteCoreOrPart.parms));
            }
            return(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, true));
        }
Exemplo n.º 29
0
        public override IEnumerable <PawnKindDef> GeneratePawnKindsExample(PawnGroupMakerParms parms, PawnGroupMaker groupMaker)
        {
            using (IEnumerator <PawnGenOption> enumerator = PawnGroupMakerUtility.ChoosePawnGenOptionsByPoints(parms.points, groupMaker.options, parms).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    PawnGenOption p = enumerator.Current;
                    yield return(p.kind);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_00d4:
            /*Error near IL_00d5: Unexpected return in MoveNext()*/;
        }
Exemplo n.º 30
0
        protected override bool TryResolveRaidFaction(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (parms.faction != null)
            {
                return(true);
            }
            float num = parms.points;

            if (num <= 0f)
            {
                num = 999999f;
            }
            return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, false), true, true, true, true) || PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, true), true, true, true, true));
        }