public override void TickRare() { base.TickRare(); this.SpreadTick--; if (this.growthPercent >= 1) { //check things in cell and react CheckThings(Position); } if (this.SpreadTick == 0) { //Pick a random direction cell IntVec3 dir = new IntVec3(); dir = GenAdj.RandomAdjSquareCardinal(Position); //If in bounds if (dir.InBounds()) { //If we find a tasty floor lets eat it nomnomnom TerrainDef terrain = dir.GetTerrain(); if (terrain != null) { //Only eat floor if not natural if (terrain.defName != "Sand" && terrain.defName != "Soil" && terrain.defName != "MarshyTerrain" && terrain.defName != "SoilRich" && terrain.defName != "Mud" && terrain.defName != "Marsh" && terrain.defName != "Gravel" && terrain.defName != "RoughStone" && terrain.defName != "WaterDeep" && terrain.defName != "WaterShallow" && terrain.defName != "RoughHewnRock") { //And by eat i mean replace - TODO can you damage floors over time? //Replace with soil - TODO for now, maybe change to regen tile later if possible Find.TerrainGrid.SetTerrain(dir, TerrainDef.Named("Soil")); //if theres no ivy here if (!IvyInCell(dir)) { if (dir.GetPlant() == null) { //no plant, move on } else { //Found plant, Kill it Plant plant = dir.GetPlant(); plant.Destroy(); } //Spawn more Ivy SpawnIvy(dir); } } //Its natural floor else if (terrain.defName != "WaterDeep" && terrain.defName != "WaterShallow" && terrain.defName != "MarshyTerrain") { //if theres no ivy here if (!IvyInCell(dir)) { if (dir.GetPlant() == null) { //no plant, move on } else { //Found plant, Kill it Plant plant = dir.GetPlant(); plant.Destroy(); } //Spawn more Ivy SpawnIvy(dir); } } //its water or something I dont know of else { } } } SpreadTick = OrigSpreadTick; } if (this.MutateTry == true) { Random random = new Random(); int MutateRate = random.Next(1, 200); if (MutateRate == 3 || MutateRate == 23) { Building_GasPump GasPump = (Building_GasPump)ThingMaker.MakeThing(ThingDef.Named("GasPump")); GasPump.SetFactionDirect(factionDirect); if (hasNoBuildings(Position)) { GenSpawn.Spawn(GasPump, Position); } this.MutateTry = false; //Find.History.AddGameEvent("Gas here", GameEventType.BadNonUrgent, true, Position, string.Empty); } else if (MutateRate == 4 || MutateRate == 24) { Building_EggSac EggSac = (Building_EggSac)ThingMaker.MakeThing(ThingDef.Named("EggSac")); EggSac.SetFactionDirect(factionDirect); if (hasNoBuildings(Position)) { GenSpawn.Spawn(EggSac, Position); } this.MutateTry = false; //Find.History.AddGameEvent("Egg here", GameEventType.BadNonUrgent, true, Position, string.Empty); } else if (MutateRate == 5) { Building_Turret GenMortar = (Building_Turret)ThingMaker.MakeThing(ThingDef.Named("Turret_GenMortarSeed")); GenMortar.SetFactionDirect(factionDirect); if (hasNoBuildings(Position)) { GenSpawn.Spawn(GenMortar, Position); } this.MutateTry = false; //Find.History.AddGameEvent("Mortar here", GameEventType.BadNonUrgent, true, Position, string.Empty); } else if (MutateRate == 6) { Building_Turret GenTurret = (Building_Turret)ThingMaker.MakeThing(ThingDef.Named("GenTurretBase")); GenTurret.SetFactionDirect(factionDirect); if (hasNoBuildings(Position)) { GenSpawn.Spawn(GenTurret, Position); } this.MutateTry = false; //Find.History.AddGameEvent("Turret here", GameEventType.BadNonUrgent, true, Position, string.Empty); } else { this.MutateTry = false; } } if (stuckPawn != null) { int damageAmountBase = 1; DamageInfo damageInfo = new DamageInfo(this.dmgdef, damageAmountBase, this, null, null); stuckPawn.TakeDamage(damageInfo); stuckPawn = null; } if (stuckCorpse != null) { stuckCorpse.Destroy(); stuckCorpse = null; } }