Example #1
0
        // Token: 0x06003BF5 RID: 15349 RVA: 0x001C4174 File Offset: 0x001C2574
        public static Toil NPCWithProgressBar(this Toil toil, TargetIndex ind, Func <float> progressGetter, bool interpolateBetweenActorAndTarget = false, float offsetZ = -0.5f)
        {
            Effecter effecter = null;

            toil.AddPreTickAction(delegate
            {
                /*
                 * if (toil.actor.Faction != Faction.OfPlayer)
                 * {
                 *  return;
                 * }
                 */
                if (effecter == null)
                {
                    EffecterDef progressBar = EffecterDefOf.ProgressBar;
                    effecter = progressBar.Spawn();
                }
                else
                {
                    LocalTargetInfo target = toil.actor.CurJob.GetTarget(ind);
                    if (!target.IsValid || (target.HasThing && !target.Thing.Spawned))
                    {
                        effecter.EffectTick(toil.actor, TargetInfo.Invalid);
                    }
                    else if (interpolateBetweenActorAndTarget)
                    {
                        effecter.EffectTick(toil.actor.CurJob.GetTarget(ind).ToTargetInfo(toil.actor.Map), toil.actor);
                    }
                    else
                    {
                        effecter.EffectTick(toil.actor.CurJob.GetTarget(ind).ToTargetInfo(toil.actor.Map), TargetInfo.Invalid);
                    }
                    MoteProgressBar mote = ((SubEffecter_ProgressBar)effecter.children[0]).mote;
                    if (mote != null)
                    {
                        mote.progress = Mathf.Clamp01(progressGetter());
                        mote.offsetZ  = offsetZ;
                    }
                }
            });
            toil.AddFinishAction(delegate
            {
                if (effecter != null)
                {
                    effecter.Cleanup();
                    effecter = null;
                }
            });
            return(toil);
        }
Example #2
0
 public override void CompTick()
 {
     base.CompTick();
     // Throw smoke mote
     foreach (IntVec3 currentCell in damagedCells)
     {
         if (Props.smoke)
         {
             if (Rand.Value < Props.smokeChance)
             {
                 ThrowSmokeBlack(parent.Position.ToVector3Shifted(), 0.5f);
             }
         }
         if (Props.spark)
         {
             // Setup a new spark effect
             sparks = new Effecter(DefDatabase <EffecterDef> .GetNamed("ElectricShort"));
             // If we have a spark effecter
             if (sparks != null)
             {
                 if (Rand.Value < Props.sparkChance)
                 {
                     // Continue effect
                     sparks.EffectTick(parent.Position, parent);
                     sparks.Cleanup();
                     sparks = null;
                 }
             }
         }
     }
 }
Example #3
0
        public override void UsedThisTick()
        {
            base.UsedThisTick();
            lastUsedTick = Find.TickManager.TicksGame;
            if (effecter == null)
            {
                EffecterDef effecterDef = DefDatabase <EffecterDef> .GetNamedSilentFail("Drill");

                if (effecterDef == null)
                {
                    return;
                }
                effecter = effecterDef.Spawn();
            }
            else
            {
                effecter.EffectTick(this, this);
            }

            if (Find.TickManager.TicksGame % FilthRate == 0)
            {
                FilthMaker.MakeFilth(this.RandomAdjacentCell8Way(), MapHeld, FilthDef);
            }
            if (lastStartedTick + TicksUntilDamage < Find.TickManager.TicksGame)
            {
                lastStartedTick = Find.TickManager.TicksGame;
                Vein.TakeDamage(new DamageInfo(DamageDefOf.Crush, DamageRate));
            }
        }
Example #4
0
 public override void Tick()
 {
     if (def == null || (ticks++ > projDef.lifetime && (effecter == null || this.effecter.ticksLeft <= 0)))
     {
         if (effecter != null)
         {
             effecter.Cleanup();
         }
         Destroy(DestroyMode.Vanish);
     }
     if (effecter != null)
     {
         if (this.effecter.ticksLeft > 0)
         {
             var targetInfo = hitThing ?? new TargetInfo(IntVec3.FromVector3(b), launcher.Map, false);
             effecter.EffectTick(targetInfo, targetInfo);
             effecter.ticksLeft--;
         }
         else
         {
             this.effecter.Cleanup();
         }
     }
     if (this.ticksToDetonation > 0)
     {
         this.ticksToDetonation--;
         if (this.ticksToDetonation <= 0)
         {
             this.Explode();
         }
     }
 }
Example #5
0
        public static Toil WithEffect(this Toil toil, Func <EffecterDef> effecterDefGetter, Func <LocalTargetInfo> effectTargetGetter)
        {
            Effecter effecter = null;

            toil.AddPreTickAction(delegate
            {
                if (effecter == null)
                {
                    EffecterDef effecterDef = effecterDefGetter();
                    if (effecterDef != null)
                    {
                        effecter = effecterDef.Spawn();
                    }
                }
                else
                {
                    effecter.EffectTick(toil.actor, effectTargetGetter().ToTargetInfo(toil.actor.Map));
                }
            });
            toil.AddFinishAction(delegate
            {
                if (effecter != null)
                {
                    effecter.Cleanup();
                    effecter = null;
                }
            });
            return(toil);
        }
Example #6
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            if (Find.TickManager.TicksGame % 60 == 0)
            {
                //if (!werewolfFlagged && Pawn?.GetComp<CompWerewolf>() is CompWerewolf compWW && compWW.CurrentWerewolfForm != null)
                //{
                //    werewolfFlagged = true;
                //    baseRageDuration = null;
                //    rageRemaining = -999;
                //}

                if (Pawn.Spawned)
                {
                    if (effecter == null)
                    {
                        EffecterDef progressBar = EffecterDefOf.ProgressBar;
                        effecter = progressBar.Spawn();
                    }
                    else
                    {
                        LocalTargetInfo target = Pawn;
                        if (Pawn.Spawned)
                        {
                            effecter.EffectTick(Pawn, TargetInfo.Invalid);
                        }
                        MoteProgressBar mote = ((SubEffecter_ProgressBar)effecter.children[0]).mote;
                        if (mote != null)
                        {
                            float result = 1f - (float)(this.BaseRageDuration() - this.RageRemaining) / (float)this.BaseRageDuration();

                            mote.progress = Mathf.Clamp01(result);
                            mote.offsetZ  = -1.0f;
                        }
                    }
                }

                if (RageRemaining < 0 || !Pawn.Spawned || (Pawn.GetComp <CompWerewolf>() is CompWerewolf ww && !ww.IsTransformed))
                {
                    this.effecter.Cleanup();

                    //Log.Message("Rage ended");
                    severityAdjustment = -999.99f;
                    if (Pawn?.mindState?.mentalStateHandler?.CurState is MentalState_WerewolfFury fury)
                    {
                        fury.RecoverFromState();
                    }
                    if (Pawn?.GetComp <CompWerewolf>() is CompWerewolf compWerewolf)
                    {
                        if (compWerewolf.CurrentWerewolfForm != null)
                        {
                            compWerewolf.TransformBack();
                        }
                    }
                    return;
                }
                RageRemaining--;
            }
        }
 public void Tick(Pawn vehicle)
 {
     if (effecter == null)
     {
         effecter = def.Spawn();
     }
     effecter.EffectTick(vehicle, null);
 }
        public static void CoreAssignPawnDamage(Pawn p, int damage, Thing source, CompPower FencePowerComp,
                                                float drainPower)
        {
            // batteries
            CoreDrainPower(FencePowerComp, drainPower);

            int randomInRange;

            switch (damage)
            {
            case < 50:
                randomInRange = 1;
                break;

            case < 100:
                randomInRange = 2;
                break;

            case < 200:
                randomInRange = 3;
                break;

            default:
                randomInRange = 5;
                break;
            }

            var height = Rand.Value >= 0.666 ? BodyPartHeight.Middle : BodyPartHeight.Top;

            for (var i = 0; i < randomInRange; i++)
            {
                if (damage <= 0)
                {
                    break;
                }

                var num2 = Mathf.Max(1, Mathf.RoundToInt(Rand.Value * damage));
                damage -= num2;
                var dinfo = new DamageInfo(DamageDefOf.Burn, num2, -1, -1f, source);
                if (randomInRange > 2)
                {
                    dinfo = new DamageInfo(DamageDefOf.Flame, num2, -1, -1f, source);
                }

                dinfo.SetBodyRegion(height, BodyPartDepth.Outside);
                p.TakeDamage(dinfo);

                var sparks = new Effecter(DefDatabase <EffecterDef> .GetNamed("ConstructMetal"));
                // If we have a spark effecter

                for (var y = 0; y < randomInRange; y++)
                {
                    sparks.EffectTick(p, source);
                }

                sparks.Cleanup();
            }
        }
Example #9
0
 private void DoProgressBar()
 {
     if (cachedProgressBar == null)
     {
         cachedProgressBar = EffecterDefOf.ProgressBar.Spawn();
     }
     else
     {
         cachedProgressBar.EffectTick(parent, parent);
         var progressBarMote = ((SubEffecter_ProgressBar)cachedProgressBar.children[0]).mote;
         progressBarMote.progress = StateChangeProgress;
     }
 }
Example #10
0
 public override void Tick()
 {
     if (flightEffecter == null && def.pawnFlyer.flightEffecterDef != null)
     {
         flightEffecter = def.pawnFlyer.flightEffecterDef.Spawn();
         flightEffecter.Trigger(this, TargetInfo.Invalid);
     }
     else
     {
         flightEffecter?.EffectTick(this, TargetInfo.Invalid);
     }
     base.Tick();
 }
Example #11
0
 public override void CompTick()
 {
     if (!toggling)
     {
         return;
     }
     if (progressBar != null)
     {
         if (progressBar.ticksLeft <= 0)
         {
             progressBar.ticksLeft = 1;
         }
         var progress = locksToToggle.Where(t => t.State.IsState(assignedState)).Count();
         progressBar.EffectTick(parent, keyHolder?.Pawn ?? TargetInfo.Invalid);
         var mote = ((SubEffecter_ProgressBar)progressBar.children[0]).mote;
         if (mote != null)
         {
             mote.progress = Mathf.Clamp01((float)progress / locksToToggle.Count);
             mote.offsetZ  = CompProp.progressBarOffset;
         }
     }
     if (assignedState.IsLocked() && Door.Open)
     {
         return;
     }
     if (currLock == null)
     {
         currLock = GetNextLockToToggle();
     }
     if (currLock != null)
     {
         if (currLock.Toggling)
         {
             return;
         }
         currLock = GetNextLockToToggle();
         currLock?.StartToggle(keyHolder, progressBar != null);
         return;
     }
     else if (!LockComps.Any(t => t.Toggling))
     {
         if (progressBar != null)
         {
             progressBar.Cleanup();
             progressBar = null;
         }
         toggling = false;
         locksToToggle.Clear();
     }
 }
 // Token: 0x060051EF RID: 20975 RVA: 0x001B9ADC File Offset: 0x001B7CDC
 public override void Tick()
 {
     if (this.flightEffecter == null && this.def.pawnFlyer.flightEffecterDef != null)
     {
         this.flightEffecter = this.def.pawnFlyer.flightEffecterDef.Spawn();
         this.flightEffecter.Trigger(this, TargetInfo.Invalid);
     }
     else
     {
         Effecter effecter = this.flightEffecter;
         if (effecter != null)
         {
             effecter.EffectTick(this, TargetInfo.Invalid);
         }
     }
     base.Tick();
 }
Example #13
0
        private void DamagePawnFence(Pawn p)
        {
            // batteries
            fenceCore.CoreDrainPower(FencePowerComp, 150f);

            var num = Mathf.RoundToInt(GetFenceDamage() / (float)4);

            var height = Rand.Value >= 0.666 ? BodyPartHeight.Middle : BodyPartHeight.Top;
            var dinfo  = new DamageInfo(DamageDefOf.Stun, num, -1f, -1f, this);

            dinfo.SetBodyRegion(height, BodyPartDepth.Outside);
            p.TakeDamage(dinfo);

            var sparks = new Effecter(DefDatabase <EffecterDef> .GetNamed("ConstructMetal"));

            // If we have a spark effecter

            sparks.EffectTick(p, this);
            sparks.Cleanup();
        }
Example #14
0
        public void StartRefreshing(Pawn pawn, LocalTargetInfo targetInfo)
        {
            //if (pawn.ThingID != this.PodOwnerId)
            if (this.PodOwner != pawn)
            {
                return;
            }
            this.SaveNeeds(pawn.needs.AllNeeds);
            pawn.DeSpawn(DestroyMode.Vanish);
            if (this.TryAcceptThing(pawn))
            {
                this.CurrentTicksLeft = this.CurrentMaxTicks = this.TotalTicksPerAction;
                this.JobState         = PS_Conditioning_JobState.Refreshing;


                EffecterDef progressBar = EffecterDefOf.ProgressBar;
                ProgressBarEffector = progressBar.Spawn();
                ProgressBarEffector.EffectTick(targetInfo.ToTargetInfo(this.Map), TargetInfo.Invalid);
            }
        }
Example #15
0
        public void StartDeconditioning(Pawn pawn, PS_Conditioning_Data conData)
        {
            //if (pawn.ThingID != this.PodOwnerId)
            if (this.PodOwner != pawn)
            {
                return;
            }
            this.SaveNeeds(pawn.needs.AllNeeds);
            pawn.DeSpawn(DestroyMode.Vanish);
            if (this.TryAcceptThing(pawn))
            {
                this.CurrentMaxTicks  = this.TicksPerDay;
                this.CurrentTicksLeft = CurrentMaxTicks;
                this.JobState         = PS_Conditioning_JobState.Deconditioning;
                this.ConditioningData = conData;

                EffecterDef progressBar = EffecterDefOf.ProgressBar;
                ProgressBarEffector = progressBar.Spawn();
                var target = new TargetInfo(this);
                ProgressBarEffector.EffectTick(target, TargetInfo.Invalid);
            }
        }
        public void StartFixingBotched(Pawn pawn)
        {
            //if (pawn.ThingID != this.PodOwnerId)
            if (PodOwner != null && PodOwner != pawn)
            {
                return;
            }

            SaveNeeds(pawn.needs.AllNeeds);
            pawn.DeSpawn(DestroyMode.Vanish);
            if (TryAcceptThing(pawn))
            {
                CurrentTicksLeft = CurrentMaxTicks = TicksPerDay;
                JobState         = PS_Conditioning_JobState.FixingBotch;


                EffecterDef progressBar = EffecterDefOf.ProgressBar;
                ProgressBarEffector = progressBar.Spawn();
                var target = new TargetInfo(this);
                ProgressBarEffector.EffectTick(target, TargetInfo.Invalid);
            }
        }
 public void StunHandlerTick()
 {
     if (EMPAdaptedTicksLeft > 0)
     {
         EMPAdaptedTicksLeft--;
     }
     if (stunTicksLeft > 0)
     {
         stunTicksLeft--;
         if (showStunMote && (moteStun == null || moteStun.Destroyed))
         {
             moteStun = MoteMaker.MakeStunOverlay(parent);
         }
         Pawn pawn = parent as Pawn;
         if (pawn != null && pawn.Downed)
         {
             stunTicksLeft = 0;
         }
         if (moteStun != null)
         {
             moteStun.Maintain();
         }
         if (AffectedByEMP && stunFromEMP)
         {
             if (empEffecter == null)
             {
                 empEffecter = EffecterDefOf.DisabledByEMP.Spawn();
             }
             empEffecter.EffectTick(parent, parent);
         }
     }
     else if (empEffecter != null)
     {
         empEffecter.Cleanup();
         empEffecter = null;
         stunFromEMP = false;
     }
 }
        public override void CompTick()
        {
            base.CompTick();

            if (Coolingdown)
            {
                cooldownTicksRemaining -= 1;
            }

            if (!Coolingdown)
            {
                if (progressBar != null)
                {
                    progressBar.Cleanup();
                    progressBar = null;
                }
            }
            else
            {
                if (progressBar == null)
                {
                    EffecterDef progressBarDef = MeeseeksDefOf.CM_Meeseeks_Box_Effecter_Progress_Bar;
                    progressBar = progressBarDef.Spawn();
                }
                else
                {
                    progressBar.EffectTick(this.parent, TargetInfo.Invalid);

                    MoteProgressBar_Colored mote = ((SubEffecter_ProgressBar_Colored)progressBar.children[0]).mote;
                    if (mote != null)
                    {
                        mote.SetFilledColor(new Color(0.95f, 0.10f, 0.15f));
                        mote.progress = Mathf.Clamp01(((float)cooldownTicksRemaining / cooldownTicksTotal));
                        mote.offsetZ  = -0.5f;
                    }
                }
            }
        }
Example #19
0
        public void StartReconditioning(Pawn pawn, PS_Conditioning_Data conData)
        {
            if (this.PodOwner != null && this.PodOwner != pawn)//!string.IsNullOrEmpty(this.PodOwnerId) && pawn.ThingID != this.PodOwnerId)
            {
                Log.Error("PS_Buildings_ReconPod: Tried to start conditioning on a pawn that was not the owner");
                return;
            }
            this.SaveNeeds(pawn.needs.AllNeeds);
            pawn.DeSpawn(DestroyMode.Vanish);
            if (this.TryAcceptThing(pawn))
            {
                this.ConditioningData = conData;
                this.CurrentMaxTicks  = PS_ConditioningHelper.DaysToCondition(pawn) * this.TicksPerDay;
                this.CurrentTicksLeft = CurrentMaxTicks;
                this.JobState         = PS_Conditioning_JobState.Reconditioning;
                this.TryAssignPawn(pawn);

                EffecterDef progressBar = EffecterDefOf.ProgressBar;
                ProgressBarEffector = progressBar.Spawn();
                var target = new TargetInfo(this);
                ProgressBarEffector.EffectTick(target, TargetInfo.Invalid);
            }
        }
Example #20
0
 public override void Tick()
 {
     if (def == null || ticks++ > projDef.lifetime)
     {
         if (effecter != null)
         {
             effecter.Cleanup();
         }
         Destroy(DestroyMode.Vanish);
     }
     if (effecter != null)
     {
         var targetInfo = hitThing != null ? new TargetInfo(hitThing) : new TargetInfo(IntVec3.FromVector3(b), launcher.Map, false);
         effecter.EffectTick(hitThing, hitThing);
     }
     if (this.ticksToDetonation > 0)
     {
         this.ticksToDetonation--;
         if (this.ticksToDetonation <= 0)
         {
             this.Explode();
         }
     }
 }
Example #21
0
 public virtual void AbilityTick()
 {
     VerbTracker.VerbsTick();
     if (def.warmupMote != null && Casting)
     {
         Vector3 vector = pawn.DrawPos + def.moteDrawOffset;
         vector += (verb.CurrentTarget.CenterVector3 - vector) * def.moteOffsetAmountTowardsTarget;
         if (warmupMote == null || warmupMote.Destroyed)
         {
             warmupMote = MoteMaker.MakeStaticMote(vector, pawn.Map, def.warmupMote);
         }
         else
         {
             warmupMote.exactPosition = vector;
             warmupMote.Maintain();
         }
     }
     if (verb.WarmingUp)
     {
         if (!(def.targetWorldCell ? CanApplyOn(pawn.CurJob.globalTarget) : CanApplyOn(verb.CurrentTarget)))
         {
             if (def.targetWorldCell)
             {
                 pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
             }
             verb.WarmupStance?.Interrupt();
             verb.Reset();
             preCastActions.Clear();
         }
         else
         {
             for (int num = preCastActions.Count - 1; num >= 0; num--)
             {
                 if (preCastActions[num].ticksAwayFromCast >= verb.WarmupTicksLeft)
                 {
                     preCastActions[num].action(verb.CurrentTarget, verb.CurrentDestination);
                     preCastActions.RemoveAt(num);
                 }
             }
         }
     }
     if (pawn.Spawned && Casting)
     {
         if (def.warmupSound != null)
         {
             if (soundCast == null || soundCast.Ended)
             {
                 soundCast = def.warmupSound.TrySpawnSustainer(SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map), MaintenanceType.PerTick));
             }
             else
             {
                 soundCast.Maintain();
             }
         }
         if (!wasCastingOnPrevTick && def.warmupStartSound != null)
         {
             def.warmupStartSound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
         }
         if (def.warmupPreEndSound != null && verb.WarmupTicksLeft == def.warmupPreEndSoundSeconds.SecondsToTicks())
         {
             def.warmupPreEndSound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
         }
     }
     if (cooldownTicks > 0)
     {
         cooldownTicks--;
         if (cooldownTicks == 0 && def.sendLetterOnCooldownComplete)
         {
             Find.LetterStack.ReceiveLetter("AbilityReadyLabel".Translate(def.LabelCap), "AbilityReadyText".Translate(pawn, def.label), LetterDefOf.NeutralEvent, new LookTargets(pawn));
         }
     }
     for (int num2 = maintainedEffecters.Count - 1; num2 >= 0; num2--)
     {
         Effecter first = maintainedEffecters[num2].First;
         if (first.ticksLeft > 0)
         {
             TargetInfo second = maintainedEffecters[num2].Second;
             first.EffectTick(second, second);
             first.ticksLeft--;
         }
         else
         {
             first.Cleanup();
             maintainedEffecters.RemoveAt(num2);
         }
     }
     wasCastingOnPrevTick = Casting;
 }
Example #22
0
        // Token: 0x06002628 RID: 9768 RVA: 0x001222BC File Offset: 0x001206BC
        public override void Tick()
        {
            if (!base.Spawned)
            {
                return;
            }
            this.sustainer.Maintain();
            Vector3    vector      = base.Position.ToVector3Shifted();
            TargetInfo localTarget = new TargetInfo(this);

            Rand.PushState();
            if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), null, null, out IntVec3 result) && !filthTypes.NullOrEmpty())
            {
                FilthMaker.TryMakeFilth(result, base.Map, filthTypes.RandomElement());
            }
            if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
            {
                Vector3 loc = new Vector3(vector.x, 0f, vector.z);
                loc.y = AltitudeLayer.MoteOverhead.AltitudeFor();
                MoteMaker.ThrowDustPuffThick(loc, base.Map, Rand.Range(1.5f, 3f), Ext?.dustColor ?? new Color(1f, 1f, 1f, 2.5f));

                if (Ext != null && Ext.thowSparksinDust)
                {
                    if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 1f, 0.25f))
                    {
                        MoteMaker.ThrowMicroSparks(loc, base.Map);
                    }
                }
            }
            if (Ext?.effecter != null)
            {
                if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 0.5f, 0.25f))
                {
                    if (this.Effecter == null && Ext.effecter != null)
                    {
                        this.Effecter = new Effecter(Ext.effecter);
                    }
                    if (Effecter != null)
                    {
                        Effecter.EffectTick(localTarget, localTarget);
                    }
                    else
                    {
                        this.Effecter.EffectTick(localTarget, localTarget);
                    }
                }
            }
            if (Rand.MTBEventOccurs(TeleportSpawner.FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TeleportSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out IntVec3 c, 999999))
            {
                FilthMaker.TryMakeFilth(c, base.Map, TeleportSpawner.filthTypes.RandomElement <ThingDef>(), 1);
            }
            if (Rand.MTBEventOccurs(TeleportSpawner.DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
            {
                MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
                {
                    y = AltitudeLayer.MoteOverhead.AltitudeFor()
                }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
            }
            Rand.PopState();
            if (secondarySpawnTick > Find.TickManager.TicksGame)
            {
                return;
            }
            if (this.Effecter != null)
            {
                this.Effecter.Cleanup();
            }
            this.sustainer.End();
            Map     map      = base.Map;
            IntVec3 position = base.Position;

            if (Ext != null)
            {
                if (Ext.strikespreexplode)
                {
                    FireEvent(map, position);
                }
                if (Ext.explodesprespawn)
                {
                    GenExplosion.DoExplosion(position, map, Ext.blastradius, Ext.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
            }
            if (!this.innerContainer.NullOrEmpty())
            {
                //    Log.Message(string.Format("{0} to drop", innerContainer.ContentsString));
                this.innerContainer.TryDropAll(position, map, ThingPlaceMode.Near);
            }
            this.Destroy(DestroyMode.Vanish);
        }
Example #23
0
        public override void Tick()
        {
            if (!base.Spawned)
            {
                return;
            }
            sustainer.Maintain();
            Vector3    vector      = base.Position.ToVector3Shifted();
            TargetInfo localTarget = new TargetInfo(this);

            Rand.PushState();
            if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), null, null, out IntVec3 result) && !filthTypes.NullOrEmpty())
            {
                FilthMaker.TryMakeFilth(result, base.Map, filthTypes.RandomElement());
            }
            if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
            {
                Vector3 loc = new Vector3(vector.x, 0f, vector.z);
                loc.y = AltitudeLayer.MoteOverhead.AltitudeFor();
                MoteMaker.ThrowDustPuffThick(loc, base.Map, Rand.Range(1.5f, 3f), Ext.dustColor ?? new Color(1f, 1f, 1f, 2.5f));
                if (Ext.thowSparksinDust)
                {
                    if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 1f, 0.25f))
                    {
                        MoteMaker.ThrowMicroSparks(loc, base.Map);
                    }
                }
            }
            if (Ext.effecter != null)
            {
                if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 0.5f, 0.25f))
                {
                    if (this.Effecter == null && Ext.effecter != null)
                    {
                        this.Effecter = new Effecter(Ext.effecter);
                    }
                    if (Effecter != null)
                    {
                        Effecter.EffectTick(localTarget, localTarget);
                    }
                    else
                    {
                        this.Effecter.EffectTick(localTarget, localTarget);
                    }
                }
            }
            Rand.PopState();
            if (secondarySpawnTick > Find.TickManager.TicksGame)
            {
                return;
            }
            if (this.Effecter != null)
            {
                this.Effecter.Cleanup();
            }
            sustainer.End();
            Map     map      = base.Map;
            IntVec3 position = base.Position;

            Destroy();
            if (Ext.strikespreexplode)
            {
                FireEvent(map, position);
            }
            if (Ext.explodesprespawn)
            {
                GenExplosion.DoExplosion(position, map, Ext.blastradius, Ext.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            }
            Hive obj = null;

            if (spawnHive)
            {
                obj = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(this.Ext.HiveDef), position, map);
                obj.SetFaction(SpawnedFaction);
                obj.questTags = questTags;
                foreach (CompSpawner comp in obj.GetComps <CompSpawner>())
                {
                    if (comp.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly)
                    {
                        comp.TryDoSpawn();
                        break;
                    }
                }
            }
            List <Pawn> list = new List <Pawn>();

            if ((initialPoints > 0f))
            {
                initialPoints = Mathf.Max(initialPoints, this.Ext.HiveDef.GetCompProperties <CompProperties_SpawnerPawn>().spawnablePawnKinds.Min((PawnGenOption x) => x.Cost));
                float         pointsLeft = initialPoints;
                int           num        = 0;
                PawnGenOption result2;
                for (; pointsLeft > 0f; pointsLeft -= result2.Cost)
                {
                    num++;
                    if (num > 1000)
                    {
                        Log.Error("Too many iterations.");
                        break;
                    }
                    if (!this.Ext.HiveDef.GetCompProperties <CompProperties_SpawnerPawn>().spawnablePawnKinds.Where((PawnGenOption x) => x.Cost <= pointsLeft).TryRandomElementByWeight(x => x.selectionWeight, out result2))
                    {
                        break;
                    }
                    Pawn pawn = PawnGenerator.GeneratePawn(result2.kind, SpawnedFaction);
                    GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2), map);
                    pawn.mindState.spawnedByInfestationThingComp = spawnedByInfestationThingComp;
                    list.Add(pawn);
                }
            }
            if (list.Any())
            {
                this.MakeLord(lordJobType, list);
            }
        }
Example #24
0
        public override void Tick()
        {
            base.Tick();

            if (this.pawn == null && this.pawn?.Corpse?.InnerPawn == null)
            {
                return;
            }


            if (this.sustainer != null && !this.sustainer.Ended)
            {
                this.sustainer.Maintain();
            }
            else
            {
                //LongEventHandler.ExecuteWhenFinished(delegate
                //{
                SoundDef  def  = SoundDef.Named("FireBurning");
                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.pawn.Position, this.pawn.Map, false), MaintenanceType.PerTick);
                info.volumeFactor *= 2;
                //this.sustainer = def.TrySpawnSustainer(info); //SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info);
                this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info);
                //});
            }

            if (sunBurningEffect != null)
            {
                sunBurningEffect.EffectTick(this.pawn, this.pawn);
                if (Find.TickManager.TicksGame % 20 == 0)
                {
                    if (this.CurStageIndex > 1 && Rand.Value > 0.5f)
                    {
                        MoteMaker.ThrowSmoke(this.pawn.DrawPos, this.pawn.Map, 1f);
                    }
                    if (this.CurStageIndex > 1 && Rand.Value < (this.CurStageIndex * 0.31f))
                    {
                        MoteMaker.ThrowFireGlow(this.pawn.PositionHeld, this.pawn.Map, 1f);
                    }
                }
            }
            if (Find.TickManager.TicksGame % checkRate == 0)
            {
                if (pawn?.PositionHeld is IntVec3 pos && pos != default(IntVec3) && pos.Roofed(pawn?.MapHeld ?? Find.VisibleMap) == false &&
                    VampireUtility.IsDaylight(pawn))
                {
                    if (sunBurningEffect == null)
                    {
                        EffecterDef effecterDef = EffecterDefOf.RoofWork;
                        if (effecterDef != null)
                        {
                            sunBurningEffect = effecterDef.Spawn();
                        }
                    }

                    if (this.CurStageIndex > 1)
                    {
                        Burn();
                    }
                    this.Severity += 0.017f;
                }
                else
                {
                    curSunDamage   = 5;
                    this.Severity -= 0.2f;
                    if (sunBurningEffect != null)
                    {
                        sunBurningEffect = null;
                    }
                    if (pawn?.MentalStateDef == VampDefOf.ROMV_Rotschreck)
                    {
                        pawn.MentalState.RecoverFromState();
                    }
                    if (pawn?.CurJob?.def == VampDefOf.ROMV_DigAndHide)
                    {
                        pawn.jobs.StopAll();
                    }
                }
            }
Example #25
0
 public override void Tick()
 {
     base.Tick();
     if (CanExtractShell && MannedByColonist)
     {
         CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
         if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
         {
             ExtractShell();
         }
     }
     if (forcedTarget.IsValid && !CanSetForcedTarget)
     {
         ResetForcedTarget();
     }
     if (!CanToggleHoldFire)
     {
         holdFire = false;
     }
     if (forcedTarget.ThingDestroyed)
     {
         ResetForcedTarget();
     }
     if (Active && (mannableComp == null || mannableComp.MannedNow) && !stunner.Stunned && base.Spawned)
     {
         GunCompEq.verbTracker.VerbsTick();
         if (AttackVerb.state == VerbState.Bursting)
         {
             return;
         }
         if (WarmingUp)
         {
             burstWarmupTicksLeft--;
             if (burstWarmupTicksLeft == 0)
             {
                 BeginBurst();
             }
         }
         else
         {
             if (burstCooldownTicksLeft > 0)
             {
                 burstCooldownTicksLeft--;
                 if (IsMortar)
                 {
                     if (progressBarEffecter == null)
                     {
                         progressBarEffecter = EffecterDefOf.ProgressBar.Spawn();
                     }
                     progressBarEffecter.EffectTick(this, TargetInfo.Invalid);
                     MoteProgressBar mote = ((SubEffecter_ProgressBar)progressBarEffecter.children[0]).mote;
                     mote.progress = 1f - (float)Math.Max(burstCooldownTicksLeft, 0) / (float)BurstCooldownTime().SecondsToTicks();
                     mote.offsetZ  = -0.8f;
                 }
             }
             if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10))
             {
                 TryStartShootSomething(canBeginBurstImmediately: true);
             }
         }
         top.TurretTopTick();
     }
     else
     {
         ResetCurrentTarget();
     }
 }