Esempio 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));
     }
 }
Esempio n. 2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map        = (Map)parms.target;
            PawnKindDef animalKind = parms.pawnKind;

            if ((animalKind == null && !ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out animalKind)) || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, parms.points) == 0)
            {
                return(false);
            }
            IntVec3 result = parms.spawnCenter;

            if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }
            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals_NewTmp(animalKind, map.Tile, parms.points * 1f, parms.pawnCount);
            Rot4        rot  = Rot4.FromAngleFlat((map.Center - result).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(result, map, 10);
                QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag);
                pawn.health.AddHediff(HediffDefOf.Scaria);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
            }
            SendStandardLetter("LetterLabelManhunterPackArrived".Translate(), "ManhunterPackArrived".Translate(animalKind.GetLabelPlural()), LetterDefOf.ThreatBig, parms, list[0]);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important);
            return(true);
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors);

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && map.reachability.CanReachMapEdge(x, traverseParams) && x.GetRoom(map).CellCount >= MinRoomCells, map, out var result))
            {
                float       points = ((parms.sitePart != null) ? parms.sitePart.parms.threatPoints : defaultPointsRange.RandomInRange);
                PawnKindDef animalKind;
                if (parms.sitePart != null && parms.sitePart.parms.animalKind != null)
                {
                    animalKind = parms.sitePart.parms.animalKind;
                }
                else if (!ManhunterPackGenStepUtility.TryGetAnimalsKind(points, map.Tile, out animalKind))
                {
                    return;
                }
                List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals_NewTmp(animalKind, map.Tile, points);
                for (int i = 0; i < list.Count; i++)
                {
                    IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(result, map, 10);
                    GenSpawn.Spawn(list[i], loc, map, Rot4.Random);
                    list[i].health.AddHediff(HediffDefOf.Scaria);
                    list[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                }
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
                }
            }
        }
Esempio n. 6
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));
     }
 }
        public static void ManhunterResults()
        {
            List <PawnKindDef> candidates = (from k in DefDatabase <PawnKindDef> .AllDefs
                                             where k.RaceProps.Animal && k.canArriveManhunter
                                             orderby - k.combatPower
                                             select k).ToList <PawnKindDef>();
            List <float> list = new List <float>();

            for (int i = 0; i < 30; i++)
            {
                list.Add(20f * Mathf.Pow(1.25f, (float)i));
            }
            DebugTables.MakeTablesDialog <float, PawnKindDef>(list, (float points) => points.ToString("F0") + " pts", candidates, (PawnKindDef candidate) => candidate.defName + " (" + candidate.combatPower.ToString("F0") + ")", delegate(float points, PawnKindDef candidate)
            {
                float num  = candidates.Sum((PawnKindDef k) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(k, points));
                float num2 = ManhunterPackIncidentUtility.ManhunterAnimalWeight(candidate, points);
                string result;
                if (num2 == 0f)
                {
                    result = "0%";
                }
                else
                {
                    result = string.Format("{0}%, {1}", (num2 * 100f / num).ToString("F0"), Mathf.Max(Mathf.RoundToInt(points / candidate.combatPower), 1));
                }
                return(result);
            }, "");
        }
 public static bool TryGetAnimalsKind(float points, int tile, out PawnKindDef animalKind)
 {
     if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(points, tile, out animalKind))
     {
         return(ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(points, -1, out animalKind));
     }
     return(true);
 }
 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_NewTmp(animalKind, parms.target.Tile, AdjustedPoints(parms.points)));
 }
Esempio n. 10
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            PawnKindDef pawnKindDef = default(PawnKindDef);

            if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, -1, out pawnKindDef))
            {
                return(false);
            }
            return(base.TryExecuteWorker(parms));
        }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            PawnKindDef animalKind;

            return(ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(AdjustedPoints(parms.points), -1, out animalKind));
        }
Esempio n. 12
0
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            PawnKindDef animalKind = default(PawnKindDef);

            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 " + base.def + " incident.");
                return(new List <Pawn>());
            }
            return(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, parms.target.Tile, parms.points));
        }
Esempio n. 13
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            Map         map = (Map)parms.target;
            PawnKindDef pawnKindDef;
            IntVec3     intVec;

            return(ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out pawnKindDef) && RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, null));
        }
Esempio n. 14
0
        public static List <Pawn> GenerateAnimals(PawnKindDef animalKind, int tile, float points)
        {
            int         animalsCount = ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, points);
            List <Pawn> list         = new List <Pawn>();

            for (int i = 0; i < animalsCount; i++)
            {
                PawnGenerationRequest request = new PawnGenerationRequest(animalKind, null, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
                Pawn item = PawnGenerator.GeneratePawn(request);
                list.Add(item);
            }
            return(list);
        }
Esempio n. 15
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            Map     map = (Map)parms.target;
            IntVec3 result;

            if (ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out var _))
            {
                return(RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal));
            }
            return(false);
        }
Esempio n. 16
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);
                }
            }
        }
Esempio n. 19
0
        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_NewTmp(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>());
            }
            return(PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile = base.Map.Tile,
                faction = faction,
                points = Mathf.Max(points, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat))
            }));
        }
Esempio n. 20
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            PawnKindDef pawnKindDef;

            return(ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, -1, out pawnKindDef) && base.TryExecuteWorker(parms));
        }
Esempio n. 21
0
 private int GetAnimalsCount(SiteCoreOrPartParams parms)
 {
     return(ManhunterPackIncidentUtility.GetAnimalsCount(parms.animalKind, parms.threatPoints));
 }
Esempio n. 22
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            PawnKindDef pawnKindDef;

            return(base.CanFireNowSub(parms) && ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(this.AdjustedPoints(parms.points), -1, out pawnKindDef));
        }
Esempio n. 23
0
 internal float <> m__1(PawnKindDef k)
 {
     return(ManhunterPackIncidentUtility.ManhunterAnimalWeight(k, this.points));
 }
Esempio n. 24
0
 public static bool TryFindManhunterAnimalKind(float points, int tile, out PawnKindDef animalKind)
 {
     return((from k in DefDatabase <PawnKindDef> .AllDefs
             where k.RaceProps.Animal && k.canArriveManhunter && (tile == -1 || Find.World.tileTemperatures.SeasonAndOutdoorTemperatureAcceptableFor(tile, k.race))
             select k).TryRandomElementByWeight((PawnKindDef k) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(k, points), out animalKind));
 }