private static void MutatePawn(Pawn pawn, MutagenDef mutagen)
        {
            HediffSet hediffSet = pawn.health.hediffSet;

            if (!pawn.Spawned || !mutagen.CanInfect(pawn))
            {
                return;
            }

            pawn.health.AddHediff(MorphTransformationDefOf.FullRandomTF);
            IntermittentMagicSprayer.ThrowMagicPuffDown(pawn.Position.ToVector3(), pawn.Map);
        }
示例#2
0
        private void DoMutationAddedEffects(Pawn pawn)
        {
            IntermittentMagicSprayer.ThrowMagicPuffDown(pawn.Position.ToVector3(), pawn.MapHeld);
            var mDef  = hediff as MutationDef;
            var mTale = tale ?? mDef?.mutationTale;
            var mMem  = memory ?? mDef?.mutationMemory;

            if (mTale != null)
            {
                TaleRecorder.RecordTale(mTale, pawn);
            }
            if (mMem != null)
            {
                TryAddMemory(pawn, mMem);
            }
        }
        /// <summary>Throws the magic puff down.</summary>
        /// <param name="loc">The loc.</param>
        /// <param name="map">The map.</param>
        public static void ThrowMagicPuffDown(Vector3 loc, Map map)
        {
            if (map == null)
            {
                return;              //make sure we don't try an put smoke down if there's no map
            }
            if (!loc.ToIntVec3().ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = IntermittentMagicSprayer.NewBaseMagicPuff();

            moteThrown.exactPosition = loc + new Vector3(Rand.Range(-0.02f, 0.02f), 0f, Rand.Range(-0.02f, 0.02f));
            moteThrown.SetVelocity((float)Rand.Range(0, 359), Rand.Range(0.2f, 0.5f));
            GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);
        }
        /// <summary>Throws the magic puff up.</summary>
        /// <param name="loc">The loc.</param>
        /// <param name="map">The map.</param>
        public static void ThrowMagicPuffUp(Vector3 loc, Map map)
        {
            if (map == null)
            {
                return;
            }
            if (!loc.ToIntVec3().ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = IntermittentMagicSprayer.NewBaseMagicPuff();

            moteThrown.exactPosition  = loc;
            moteThrown.exactPosition += new Vector3(Rand.Range(-0.02f, 0.02f), 0f, Rand.Range(-0.02f, 0.02f));
            moteThrown.SetVelocity((float)Rand.Range(-10, 10), Rand.Range(1.2f, 1.5f));
            GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);
        }
        /// <summary>called every tick </summary>
        public void SteamSprayerTick()
        {
            if (sprayTicksLeft > 0)
            {
                sprayTicksLeft--;

                //Do spray effect
                if (Rand.Value < SprayThickness)
                {
                    IntermittentMagicSprayer.ThrowMagicPuffUp(parent.TrueCenter(), parent.Map);
                }

                //Push some heat
                if (Find.TickManager.TicksGame % 20 == 0)
                {
                    //GenTemperature.PushHeat(parent, 40 );
                }

                //Done spraying
                if (sprayTicksLeft <= 0)
                {
                    if (endSprayCallback != null)
                    {
                        endSprayCallback();
                    }

                    ticksUntilSpray = Rand.RangeInclusive(MinTicksBetweenSprays, MaxTicksBetweenSprays);
                }
            }
            else
            {
                ticksUntilSpray--;

                if (ticksUntilSpray <= 0)
                {
                    //Start spray
                    if (startSprayCallback != null)
                    {
                        startSprayCallback();
                    }

                    sprayTicksLeft = Rand.RangeInclusive(MinSprayDuration, MaxSprayDuration);
                }
            }
        }