Exemple #1
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));
     }
 }
Exemple #2
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));
     }
 }
Exemple #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map = (Map)parms.target;
            PawnKindDef pawnKindDef;

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out pawnKindDef))
            {
                return(false);
            }
            IntVec3 intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, null))
            {
                return(false);
            }
            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, parms.points * 1f);
            Rot4        rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
            }
            Find.LetterStack.ReceiveLetter("LetterLabelManhunterPackArrived".Translate(), "ManhunterPackArrived".Translate(new object[]
            {
                pawnKindDef.GetLabelPlural(-1)
            }), LetterDefOf.ThreatBig, list[0], null, null);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
            return(true);
        }
Exemple #4
0
        public override void Generate(Map map, GenStepParams parms)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false);
            IntVec3       root;

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && map.reachability.CanReachMapEdge(x, traverseParams) && x.GetRoom(map, RegionType.Set_Passable).CellCount >= this.MinRoomCells, map, out root))
            {
                float       points = (parms.siteCoreOrPart == null) ? this.defaultPointsRange.RandomInRange : parms.siteCoreOrPart.parms.threatPoints;
                PawnKindDef animalKind;
                if (parms.siteCoreOrPart != null && parms.siteCoreOrPart.parms.animalKind != null)
                {
                    animalKind = parms.siteCoreOrPart.parms.animalKind;
                }
                else if (!ManhunterPackGenStepUtility.TryGetAnimalsKind(points, map.Tile, out animalKind))
                {
                    return;
                }
                List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, points);
                for (int i = 0; i < list.Count; i++)
                {
                    IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 10);
                    GenSpawn.Spawn(list[i], loc, map, Rot4.Random, WipeMode.Vanish, false);
                    list[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                }
            }
        }
Exemple #5
0
 protected override List <Pawn> GeneratePawns(IncidentParms parms)
 {
     if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(AdjustedPoints(parms.points), parms.target.Tile, out PawnKindDef animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(AdjustedPoints(parms.points), -1, out animalKind))
     {
         Log.Error("Could not find any valid animal kind for " + def + " incident.");
         return(new List <Pawn>());
     }
     return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, parms.target.Tile, AdjustedPoints(parms.points)));
 }
Exemple #6
0
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            PawnKindDef animalKind;
            List <Pawn> result;

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, parms.target.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, -1, out animalKind))
            {
                Log.Error("Could not find any valid animal kind for " + this.def + " incident.", false);
                result = new List <Pawn>();
            }
            else
            {
                result = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, parms.target.Tile, parms.points);
            }
            return(result);
        }
        private IEnumerable <Pawn> GenerateAmbushPawns()
        {
            IEnumerable <Pawn> result;

            if (this.manhunters)
            {
                PawnKindDef animalKind;
                if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, base.Map.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.points, -1, out animalKind))
                {
                    result = Enumerable.Empty <Pawn>();
                }
                else
                {
                    result = 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)
                {
                    result = Enumerable.Empty <Pawn>();
                }
                else
                {
                    result = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
                    {
                        groupKind = PawnGroupKindDefOf.Combat,
                        tile      = base.Map.Tile,
                        faction   = faction,
                        points    = this.points
                    }, true);
                }
            }
            return(result);
        }
        public override void Generate(Map map)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false);
            IntVec3       root;

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && map.reachability.CanReachMapEdge(x, traverseParams) && x.GetRoom(map, RegionType.Set_Passable).CellCount >= this.MinRoomCells, map, out root))
            {
                float       randomInRange = this.pointsRange.RandomInRange;
                PawnKindDef animalKind;
                if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(randomInRange, map.Tile, out animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(randomInRange, -1, out animalKind))
                {
                    return;
                }
                List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, randomInRange);
                for (int i = 0; i < list.Count; i++)
                {
                    IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 10);
                    GenSpawn.Spawn(list[i], loc, map, Rot4.Random, false);
                    list[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null);
                }
            }
        }
        private IEnumerable <Pawn> GenerateAmbushPawns()
        {
            if (ambushType == SignalActionAmbushType.Manhunters)
            {
                if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(points, base.Map.Tile, out PawnKindDef animalKind) && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(points, -1, out animalKind))
                {
                    return(Enumerable.Empty <Pawn>());
                }
                return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, base.Map.Tile, points));
            }
            Faction faction = (ambushType != SignalActionAmbushType.Mechanoids) ? (base.Map.ParentFaction ?? Find.FactionManager.RandomEnemyFaction(allowHidden: false, allowDefeated: false, allowNonHumanlike: false)) : Faction.OfMechanoids;

            if (faction == null)
            {
                return(Enumerable.Empty <Pawn>());
            }
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
            pawnGroupMakerParms.tile      = base.Map.Tile;
            pawnGroupMakerParms.faction   = faction;
            pawnGroupMakerParms.points    = Mathf.Max(points, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            return(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms));
        }