Пример #1
0
 public static float ColonySize()
 {
     if (AbilityRequeriment_ColonyBiggerThan.forcedValue.HasValue)
     {
         return(AbilityRequeriment_ColonyBiggerThan.forcedValue.Value);
     }
     else
     {
         return(IncidentMakerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig).points);
     }
 }
        public override bool TryExecute(IncidentParms parms)
        {
            IntVec3 intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec))
            {
                return(false);
            }
            PawnKindDef pawnKindDef = (
                from a in Find.Map.Biome.AllWildAnimals
                where GenTemperature.SeasonAcceptableFor(a.race)
                select a).RandomElement();
            float   points  = IncidentMakerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig).points;
            int     num     = Rand.RangeInclusive(12, 24);
            int     num2    = Rand.RangeInclusive(90000, 150000);
            IntVec3 invalid = IntVec3.Invalid;

            if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(intVec, 10f, out invalid))
            {
                invalid = IntVec3.Invalid;
            }
            Pawn pawn = null;

            for (int i = 0; i < num; i++)
            {
                IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, 10);
                pawn = PawnGenerator.GeneratePawn(pawnKindDef, null);
                GenSpawn.Spawn(pawn, loc, Rot4.Random);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num2;
                if (invalid.IsValid)
                {
                    pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(invalid, 10);
                }
            }
            Find.LetterStack.ReceiveLetter("Migration", "A group of animals is migrating through your region.", LetterType.Good, intVec, null);
            return(true);
        }
Пример #3
0
        public void LaunchInvasion(string eventTitle, string eventText, float raidPointsFactor, int dropsNumber, LetterType letterType, IntVec3 spawnPosition)
        {
            this.invasionIsDone = true;

            // Get an indicative amount of points based on the colony wealth so it scales up well for late-game colonies.
            IncidentParms invasionParameters = IncidentMakerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig);

            invasionParameters.faction                 = Faction.OfMechanoids;
            invasionParameters.raidStrategy            = RaidStrategyDefOf.ImmediateAttack;
            invasionParameters.raidArrivalMode         = PawnsArriveMode.EdgeDrop;
            invasionParameters.raidNeverFleeIndividual = true;
            invasionParameters.raidPodOpenDelay        = 800;
            if (dropsNumber > 0)
            {
                invasionParameters.points *= (raidPointsFactor / dropsNumber);
                if (invasionParameters.points < 320)
                {
                    invasionParameters.points = 320;
                }
                for (int dropIndex = 0; dropIndex < dropsNumber; dropIndex++)
                {
                    IntVec3 dropPodSpawningPosition;
                    float   squadPoint = invasionParameters.points;
                    if (spawnPosition.IsValid)
                    {
                        invasionParameters.spawnCenter = spawnPosition;
                    }
                    else
                    {
                        RCellFinder.TryFindRandomPawnEntryCell(out invasionParameters.spawnCenter);
                    }
                    List <Pawn> mechanoidsList = new List <Pawn>();
                    while (squadPoint >= PawnKindDef.Named("Scyther").combatPower)
                    {
                        bool validDropPodCellIsFound = DropCellFinder.TryFindDropSpotNear(invasionParameters.spawnCenter, out dropPodSpawningPosition, false, true);
                        if (validDropPodCellIsFound)
                        {
                            Faction faction = Faction.OfMechanoids;
                            Pawn    squadMember;
                            if (Rand.Value < 0.6f)
                            {
                                squadMember = PawnGenerator.GeneratePawn(PawnKindDef.Named("Scyther"), faction);
                                squadPoint -= PawnKindDef.Named("Scyther").combatPower;
                            }
                            else
                            {
                                squadMember = PawnGenerator.GeneratePawn(PawnKindDef.Named("Centipede"), faction);
                                squadPoint -= (int)PawnKindDef.Named("Centipede").combatPower;
                            }
                            mechanoidsList.Add(squadMember);
                            DropPodUtility.MakeDropPodAt(dropPodSpawningPosition, new DropPodInfo
                            {
                                SingleContainedThing = squadMember,
                                openDelay            = 800,
                                leaveSlag            = true
                            });
                        }
                    }
                    StateGraph stateGraph = GraphMaker.AssaultColonyGraph(Faction.OfMechanoids, false, false);
                    BrainMaker.MakeNewBrain(Faction.OfMechanoids, stateGraph, mechanoidsList);
                }
            }
            Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType, this.Position);
        }