protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map  = (Map)parms.target;
            IntVec3 root = default(IntVec3);

            if (!this.TryFindRootCell(map, out root))
            {
                return(false);
            }
            Thing   thing         = null;
            int     randomInRange = IncidentWorker_AmbrosiaSprout.CountRange.RandomInRange;
            int     num           = 0;
            IntVec3 intVec        = default(IntVec3);

            while (num < randomInRange && CellFinder.TryRandomClosewalkCellNear(root, map, 6, out intVec, (Predicate <IntVec3>)((IntVec3 x) => this.CanSpawnAt(x, map))))
            {
                Plant plant = intVec.GetPlant(map);
                if (plant != null)
                {
                    plant.Destroy(DestroyMode.Vanish);
                }
                Thing thing2 = GenSpawn.Spawn(ThingDefOf.PlantAmbrosia, intVec, map);
                if (thing == null)
                {
                    thing = thing2;
                }
                num++;
            }
            if (thing == null)
            {
                return(false);
            }
            base.SendStandardLetter(thing);
            return(true);
        }
예제 #2
0
 public override void Tick()
 {
     base.Tick();
     spawnticks--;
     if (spawnticks == 0)
     {
         foreach (IntVec3 current in GenAdj.AdjacentSquaresCardinal(this))
         {
             if (current.GetPlant() == null)
             {
                 //not a plant, spawn ivy
                 Plant newivy = (Plant)ThingMaker.MakeThing(ThingDef.Named("PurpleIvy"));
                 GenSpawn.Spawn(newivy, current);
             }
             else
             {
                 Plant plant = current.GetPlant();
                 if (plant.def.defName != "PurpleIvy")
                 {
                     plant.Destroy();
                     Plant newivy = (Plant)ThingMaker.MakeThing(ThingDef.Named("PurpleIvy"));
                     GenSpawn.Spawn(newivy, current);
                 }
                 else
                 {
                     //dont destroy other ivy
                 }
             }
         }
         spawnticks = 1200;
     }
 }
예제 #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 root;
            bool    result;

            if (!this.TryFindRootCell(map, out root))
            {
                result = false;
            }
            else
            {
                Thing thing         = null;
                int   randomInRange = IncidentWorker_AmbrosiaSprout.CountRange.RandomInRange;
                for (int i = 0; i < randomInRange; i++)
                {
                    IntVec3 intVec;
                    if (!CellFinder.TryRandomClosewalkCellNear(root, map, 6, out intVec, (IntVec3 x) => this.CanSpawnAt(x, map)))
                    {
                        break;
                    }
                    Plant plant = intVec.GetPlant(map);
                    if (plant != null)
                    {
                        plant.Destroy(DestroyMode.Vanish);
                    }
                    Thing thing2 = GenSpawn.Spawn(ThingDefOf.Plant_Ambrosia, intVec, map, WipeMode.Vanish);
                    if (thing == null)
                    {
                        thing = thing2;
                    }
                }
                if (thing == null)
                {
                    result = false;
                }
                else
                {
                    base.SendStandardLetter(thing, null, new string[0]);
                    result = true;
                }
            }
            return(result);
        }
        // Token: 0x0600295A RID: 10586 RVA: 0x00139AB0 File Offset: 0x00137EB0
        private void HarmRandomPlantInRadius(float radius)
        {
            IntVec3 c = this.parent.Position + (Rand.InsideUnitCircleVec3 * radius).ToIntVec3();

            if (!c.InBounds(this.parent.Map))
            {
                return;
            }
            Plant plant = c.GetPlant(this.parent.Map);
            bool  flag  = c.GetThingList(this.parent.Map).Any(x => x.def.defName.Contains("RRY_Plant_Neomorph_Fungus"));

            if (plant != null && !flag)
            {
                if (Rand.Value < this.LeaflessPlantKillChance && this.parent.Map.GooGrid().GetDepth(c) >= 1f)
                {
                    if (RRYautja.settings.SettingsHelper.latest.AllowNeomorphs)
                    {
                        Thing thing2;

                        if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Fungus))
                        {
                            thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Plant_Neomorph_Fungus_Hidden);
                        }
                        else
                        {
                            thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Plant_Neomorph_Fungus);
                        }
                        IntVec3 vec3 = plant.Position;
                        GenSpawn.Spawn(thing2, vec3, plant.Map, WipeMode.Vanish);
                    }
                    else
                    {
                        plant.Destroy();
                    }
                    //    GenSpawn.Spawn(ThingMaker.MakeThing(this.def), vec3, this.Map);
                }
            }
        }
예제 #5
0
 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;
     }
 }