コード例 #1
0
        /// <summary>called every once and a while</summary>
        public override void TickRare()
        {
            if (!Spawned || !LoadedModManager.GetMod <PawnmorpherMod>().GetSettings <PawnmorpherSettings>().enableMutagenMeteor)
            {
                return;
            }

            IEnumerable <Thing> enumerable = GenRadial.RadialDistinctThingsAround(Position, Map, 2.5f, true);

            var mutagen = MutagenDefOf.defaultMutagen;

            foreach (Thing thing in enumerable)
            {
                if (thing is Pawn pawn)
                {
                    MutatePawn(pawn, mutagen);
                }
                else if (thing is Plant plant)
                {
                    if (Rand.Value >= _p)
                    {
                        continue;
                    }

                    PMPlantUtilities.TryMutatePlant(plant);
                }
            }
        }
コード例 #2
0
        private void SubstitutePlant([NotNull] Plant plant)
        {
            var plantDef = PMPlantUtilities.GetMutantVersionOf(plant);

            var pos = plant.Position;
            var map = plant.Map;

            if (plantDef != null) //spawn a new plant
            {
                var newPlant = (Plant)GenSpawn.Spawn(plantDef, pos, map);
                newPlant.Growth = plant.Growth * 1.3f; // Make the new plant a little more mature then the one that was substituted.
            }

            plant.Kill();
        }
コード例 #3
0
        private void MutateInRadius(float radius, HediffDef hediff)
        {
            IntVec3 c = parent.Position + (Rand.InsideUnitCircleVec3 * radius).ToIntVec3();

            if (!c.InBounds(parent.Map))
            {
                return;
            }

            foreach (Pawn pawn in _pawnsCache)
            {
                float distanceTo = pawn.Position.DistanceTo(parent.Position);
                if (distanceTo < radius) //make pawns closer to the mutagenic ship mutate faster
                {                        //also increase the effect as the radius increases
                    float rHat = distanceTo / radius;
                    float baseMRate;
                    if (rHat <= EPSILON)
                    {
                        baseMRate = BASE_BUILDUP_RATE;
                    }
                    else
                    {
                        baseMRate = A / (Mathf.Pow(rHat, DISTANCE_POW));
                    }

                    MutatePawn(pawn, baseMRate);
                }
            }



            Plant plant = c.GetPlant(parent.Map);

            if (plant != null && !plant.def.IsMutantPlant()) //don't harm mutant plants
            {
                if (!plant.LeaflessNow)
                {
                    plant.MakeLeafless(Plant.LeaflessCause.Poison);
                }
                else if (Rand.Value < 0.3f) //30% chance
                {
                    PMPlantUtilities.TryMutatePlant(plant);
                }
            }
        }