Building_VillagerCorpsesGenerator class.
Inheritance: Building
Example #1
0
        public void GenerateAnimalCorpses()
        {
            Log.Message("GenerateAnimalCorpses");
            int animalCorpsesNumber = Rand.Range(3, 7);

            for (int corpseIndex = 0; corpseIndex < animalCorpsesNumber; corpseIndex++)
            {
                Predicate <IntVec3> validator = delegate(IntVec3 cell)
                {
                    if (cell.Standable() == false)
                    {
                        return(false);
                    }
                    foreach (Thing thing in Find.ThingGrid.ThingsListAt(cell))
                    {
                        if (thing is Corpse)
                        {
                            return(false);
                        }
                    }
                    return(true);
                };

                IntVec3 spawnCell        = IntVec3.Invalid;
                bool    spawnCellIsFound = CellFinder.TryFindRandomCellNear(this.Position, 5, validator, out spawnCell);
                if (spawnCellIsFound)
                {
                    PawnKindDef animalKindDef;
                    float       animalKindSelector = Rand.Value;
                    if (animalKindSelector < 0.33f)
                    {
                        animalKindDef = PawnKindDef.Named("Muffalo");
                    }
                    else if (animalKindSelector < 0.66f)
                    {
                        animalKindDef = PawnKindDef.Named("Caribou");
                    }
                    else
                    {
                        animalKindDef = PawnKindDef.Named("Deer");
                    }
                    Building_VillagerCorpsesGenerator.SpawnPawnCorpse(spawnCell, animalKindDef, null, Rand.Range(5f, 20f) * GenDate.TicksPerDay);
                }
            }
        }
Example #2
0
        public void GenerateAnimalCorpses()
        {
            var animalCorpsesNumber = Rand.Range(3, 7);

            for (var corpseIndex = 0; corpseIndex < animalCorpsesNumber; corpseIndex++)
            {
                bool validator(IntVec3 cell)
                {
                    if (cell.Standable(Map) == false)
                    {
                        return(false);
                    }
                    foreach (Thing thing in Map.thingGrid.ThingsListAt(cell))
                    {
                        if (thing is Corpse)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }

                IntVec3 spawnCell        = IntVec3.Invalid;
                var     spawnCellIsFound = CellFinder.TryFindRandomCellNear(Position, Map, 5, validator, out spawnCell);
                if (spawnCellIsFound)
                {
                    PawnKindDef animalKindDef;
                    var         animalKindSelector = Rand.Value;
                    if (animalKindSelector < 0.33f)
                    {
                        animalKindDef = PawnKindDef.Named("Muffalo");
                    }
                    else if (animalKindSelector < 0.66f)
                    {
                        animalKindDef = PawnKindDef.Named("Caribou");
                    }
                    else
                    {
                        animalKindDef = PawnKindDef.Named("Deer");
                    }
                    Building_VillagerCorpsesGenerator.SpawnPawnCorpse(Map, spawnCell, animalKindDef, null, Rand.Range(5f, 20f) * GenDate.TicksPerDay);
                }
            }
        }