public MapCondition_Migration()
        {
            animalPawnDef = MigrationUtilities.GetMigrationAnimalDef();

            migrationEnterVec = MigrationUtilities.FindMigrationEnterVec();
            migrationExitVec  = MigrationUtilities.FindMigrationExitVec(migrationEnterVec);

            ticksUntilNextWave = GenerateTicksUntilNexWave(true);
        }
 private int GenerateTicksUntilNexWave(bool first = false)
 {
     if (first)
     {
         return(0);
     }
     //Calculate the time until next migration waves.  Base time is 12-24 gamehours.  Harder difficulity increases the time between waves while easier difficulity decreases it.
     return(Rand.RangeInclusive(MigrationUtilities.DaysToTicks((0.50f * Find.Storyteller.difficulty.threatScale).Clamp(0.25f, 1.0f)), MigrationUtilities.DaysToTicks((1.0f * Find.Storyteller.difficulty.threatScale).Clamp(0.75f, 2.0f))));
 }
示例#3
0
        public override bool TryExecute(IncidentParms parms)
        {
            IntVec3     migrationEnterVec;
            IntVec3     migrationExitVec;
            PawnKindDef animalPawnDef;

            IncidentParms_MigrationWave ip = parms as IncidentParms_MigrationWave;

            if (ip != null)
            {
                animalPawnDef     = ip.animalPawnKindDef;
                migrationEnterVec = ip.enterVec;
                migrationExitVec  = ip.exitVec;
            }
            else
            { /*For some reason this was not passed the correct subclass of IncidentParms.
               * The incident was probably triggered by development console or the def for it has been changed.
               * Need to generate all the data ourself.*/
                migrationEnterVec = MigrationUtilities.FindMigrationEnterVec();
                migrationExitVec  = MigrationUtilities.FindMigrationExitVec(migrationEnterVec);
                animalPawnDef     = MigrationUtilities.GetMigrationAnimalDef();
            }

            float challengeModifier = MigrationUtilities.GetChallengeModifier();

            int minAnimals = (int)Math.Ceiling(10 * challengeModifier);
            int maxAnimals = (int)Math.Ceiling(20 * challengeModifier);


            int numberOfAnimals = Rand.RangeInclusive(minAnimals, maxAnimals);

            for (int i = 0; i < numberOfAnimals; i++)
            {
                IntVec3 animalSpawnLocation = MigrationUtilities.RandomStandableEdgeCellNear(migrationEnterVec, 20);

                Pawn animalPawn = PawnGenerator.GeneratePawn(animalPawnDef, null, Rand.RangeInclusive(1, 10) <= 4 ? true : false);
                GenSpawn.Spawn(animalPawn, animalSpawnLocation);
                animalPawn.jobs.StopAll();

                //find a random exit position
                IntVec3 animalExitLocation = MigrationUtilities.RandomStandableEdgeCellNear(migrationExitVec, 20);
                Job     animalJob          = new Job(JobDefOf.Goto, new TargetInfo(animalExitLocation));
                animalJob.exitMapOnArrival = true;

                animalPawn.jobs.StartJob(animalJob);

                //Make 'em crazy!
                //animalPawn.mindState.broken.StartBrokenState(BrokenStateDefOf.Berserk);
            }

            return(true);
        }