Ejemplo n.º 1
0
        public override void Tick()
        {
            base.Tick();
            ticksLeft--;
            if (ticksLeft <= 0)
            {
                this.Destroy();
            }

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

                        mote.progress = Mathf.Clamp01(result);
                        mote.offsetZ  = -0.5f;
                    }
                }
            }
        }
Ejemplo n.º 2
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 override void SubEffectTick(TargetInfo A, TargetInfo B)
 {
     if (this.mote == null)
     {
         this.mote = (MoteProgressBar)MoteMaker.MakeInteractionOverlay(this.def.moteDef, A, B);
         this.mote.exactScale.x = 0.68f;
         this.mote.exactScale.z = 0.12f;
     }
 }
Ejemplo n.º 4
0
        public override void Tick()
        {
            base.Tick();

            if (this.PodOwner != null && this.PodOwner.Dead)
            {
                ForceEndJobState();
                this.PodOwner = null;
            }

            if (this.PodOwner != null && this.JobState == PS_Conditioning_JobState.Waiting && !PS_ConditioningHelper.IsReconditioned(this.PodOwner))
            {
                ForceEndJobState();
                this.PodOwner = null;
            }

            if (this.JobState == PS_Conditioning_JobState.Waiting) // Do nothing if waiting
            {
                return;
            }

            if (!this.TryGetComp <CompPowerTrader>().PowerOn&& this.HasAnyContents) // Boot pawn if lose power
            {
                this.ForceEndJobState();
                this.EjectContents();
                return;
            }

            var pawn = (Pawn)innerContainer.FirstOrDefault();

            if (pawn != null)
            {
                this.ResetNeeds(pawn);
            }


            if (ProgressBarEffector != null)
            {
                MoteProgressBar mote = ((SubEffecter_ProgressBar)this.ProgressBarEffector?.children[0]).mote;
                if (mote != null)
                {
                    mote.progress = Mathf.Clamp01(1f - (this.CurrentTicksLeft / this.CurrentMaxTicks));
                    mote.offsetZ  = -0.5f;
                }
            }

            if (this.JobState != PS_Conditioning_JobState.Waiting)
            {
                this.CurrentTicksLeft--;
                if (this.CurrentTicksLeft <= 0)
                {
                    this.FinishConditioning();
                }
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public override void Tick()
 {
     if (this.CanExtractShell && this.MannedByColonist)
     {
         AERIALChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <AERIALChangeableProjectile>();
         if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1]))
         {
             this.ExtractShell();
         }
     }
     if (this.forcedTarget.IsValid && !this.CanSetForcedTarget)
     {
         this.ResetForcedTarget();
     }
     if (!this.CanToggleHoldFire)
     {
         this.holdFire = false;
     }
     if (this.forcedTarget.ThingDestroyed)
     {
         this.ResetForcedTarget();
     }
     if (this.Active && !this.stunner.Stunned && base.Spawned)
     {
         this.GunCompEq.verbTracker.VerbsTick();
         if (this.AttackVerb.state != VerbState.Bursting)
         {
             if (this.WarmingUp)
             {
                 this.burstWarmupTicksLeft--;
                 if (this.burstWarmupTicksLeft == 0)
                 {
                     this.BeginBurst();
                 }
             }
             else
             {
                 if (this.burstCooldownTicksLeft > 0)
                 {
                     this.burstCooldownTicksLeft--;
                     if (this.IsMortar)
                     {
                         if (this.progressBarEffecter == null)
                         {
                             this.progressBarEffecter = EffecterDefOf.ProgressBar.Spawn();
                         }
                         this.progressBarEffecter.EffectTick(this, TargetInfo.Invalid);
                         MoteProgressBar mote = ((SubEffecter_ProgressBar)this.progressBarEffecter.children[0]).mote;
                         mote.progress = 1f - (float)Math.Max(this.burstCooldownTicksLeft, 0) / (float)this.BurstCooldownTime().SecondsToTicks();
                         mote.offsetZ  = -0.8f;
                     }
                 }
                 if (this.burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10))
                 {
                     Log.Message("trystartshootsomething");
                     this.TryStartShootSomethingAERIAL(true);
                 }
             }
             this.top.TurretTopTick();
             return;
         }
     }
     else
     {
         Log.Message("resetcurrenttarget");
         this.ResetCurrentTarget();
     }
 }
Ejemplo n.º 7
0
        public override void CompTick()
        {
            base.CompTick();
            if (Operator == null)
            {
                return;
            }
            if (this.Stunned)
            {
                this.stunTicksLeft--;
                if (this.top != null && Operator != null)
                {
                    this.top.TurretTopTick();
                }
                return;
            }
            if (Operator?.Map == null)
            {
                return;
            }
            if (OperatorPawn == null && Building == null)
            {
                this.AttackVerb.caster = Operator;
                return;
            }
            else
            {
                if (this.AttackVerb.caster == null)
                {
                    this.AttackVerb.caster = Operator;
                }
            }
            if (OperatorPawn != null)
            {
                if (OperatorPawn.Downed || !OperatorPawn.Awake())
                {
                    return;
                }
            }
            if (this.CanExtractShell && this.MannedByColonist)
            {
                CompChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
                {
                    this.ExtractShell();
                }
            }

            if (this.forcedTarget.IsValid && !this.CanSetForcedTarget)
            {
                this.ResetForcedTarget();
            }
            if (this.forcedTarget.IsValid && !HasAmmo)
            {
                this.ResetForcedTarget();
            }
            if (!this.CanToggleHoldFire)
            {
                this.holdFire = false;
            }
            if (this.forcedTarget.ThingDestroyed)
            {
                this.ResetForcedTarget();
            }
            if (this.forcedTarget.IsValid)
            {
                if (!GenSight.LineOfSight(Operator.Position, this.forcedTarget.Cell, this.Operator.Map, true, null, 0, 0))
                {
                    return;
                }
            }
            //	Log.Message("tick Active: " + this.Active + ", Worn: " + (this.Wearer != null) + ", Wearer Spawned: " + Wearer.Spawned);
            if (this.Active && (this.Operator != null) && Operator.Spawned)
            {
                this.GunCompEq.verbTracker.VerbsTick();
                bool stunflag = !this.Stunned;
                if (stunflag && this.AttackVerb.state != VerbState.Bursting)
                {
                    if (this.WarmingUp)
                    {
                        this.burstWarmupTicksLeft--;
                        if (this.burstWarmupTicksLeft == 0)
                        {
                            //	Log.Message("WarmingUp complete, BeginBurst");
                            this.BeginBurst();
                        }
                    }
                    else
                    {
                        //	Log.Message("tick 2 1 b1: "+ this.burstCooldownTicksLeft);
                        if (this.burstCooldownTicksLeft > 0)
                        {
                            this.burstCooldownTicksLeft--;
                            if (this.IsMortar)
                            {
                                if (this.progressBarEffecter == null)
                                {
                                    this.progressBarEffecter = EffecterDefOf.ProgressBar.Spawn();
                                }
                                this.progressBarEffecter.EffectTick(Operator, TargetInfo.Invalid);
                                MoteProgressBar mote = ((SubEffecter_ProgressBar)this.progressBarEffecter.children[0]).mote;
                                mote.progress = 1f - (float)Math.Max(this.burstCooldownTicksLeft, 0) / (float)this.BurstCooldownTime().SecondsToTicks();
                                mote.offsetZ  = -0.8f;
                            }
                        }
                        //	if (Wearer.IsHashIntervalTick(10)) Log.Message("tick 2 1 b2 interval: "+ Wearer.IsHashIntervalTick(10));
                        if (this.burstCooldownTicksLeft <= 0 && Operator.IsHashIntervalTick(10) && HasAmmo)
                        {
                            this.TryStartShootSomething(true);
                        }
                    }
                    if (this.top != null && Operator != null)
                    {
                        this.top.TurretTopTick();
                    }
                    return;
                }
            }
            else
            {
                this.ResetCurrentTarget();
            }
        }
Ejemplo n.º 8
0
 // Token: 0x06004BB9 RID: 19385 RVA: 0x00197E80 File Offset: 0x00196080
 public override void Tick()
 {
     if (Flickable != null && !Flickable.SwitchIsOn)
     {
         return;
     }
     base.Tick();
     if (this.CanExtractShell && this.MannedByColonist)
     {
         CompChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
         if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
         {
             this.ExtractShell();
         }
     }
     if (this.forcedTarget.IsValid && !this.CanSetForcedTarget)
     {
         this.ResetForcedTarget();
     }
     if (!this.CanToggleHoldFire)
     {
         this.holdFire = false;
     }
     if (this.forcedTarget.ThingDestroyed)
     {
         this.ResetForcedTarget();
     }
     if (this.Active && (this.mannableComp == null || this.mannableComp.MannedNow) && base.Spawned)
     {
         this.GunCompEq.verbTracker.VerbsTick();
         if (!this.stunner.Stunned && this.AttackVerb.state != VerbState.Bursting)
         {
             if (burstWarmupTicksLeft > 0)
             {
                 this.burstWarmupTicksLeft--;
                 if (this.burstWarmupTicksLeft == 0)
                 {
                     this.BeginBurst();
                 }
             }
             else
             {
                 if (this.burstCooldownTicksLeft > 0)
                 {
                     this.burstCooldownTicksLeft--;
                     if (this.IsMortar)
                     {
                         if (this.progressBarEffecter == null)
                         {
                             this.progressBarEffecter = EffecterDefOf.ProgressBar.Spawn();
                         }
                         this.progressBarEffecter.EffectTick(this, TargetInfo.Invalid);
                         MoteProgressBar mote = ((SubEffecter_ProgressBar)this.progressBarEffecter.children[0]).mote;
                         mote.progress = 1f - (float)Math.Max(this.burstCooldownTicksLeft, 0) / (float)this.BurstCooldownTime().SecondsToTicks();
                         mote.offsetZ  = -0.8f;
                     }
                 }
                 if (this.burstCooldownTicksLeft <= 0)// && this.IsHashIntervalTick(TryStartShootSomethingIntervalTicks))
                 {
                     this.TryStartShootSomething(true);
                 }
             }
             this.top.TurretTopTick();
             return;
         }
     }
     else
     {
         this.ResetCurrentTarget();
     }
 }
Ejemplo n.º 9
0
 public override void NotifyTargetInRange(GlobalTargetInfo target)
 {
     base.NotifyTargetInRange(target);
     if (AttackVerb is Verb_ShootWorldRecoiled shootWorldRecoiled)
     {
         if (CanExtractShell && MannedByColonist)
         {
             CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
             if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell))
             {
                 ExtractShell();
             }
         }
         if (forcedWorldTarget.IsValid && !CanSetForcedTarget)
         {
             ResetForcedTarget();
         }
         if (!CanToggleHoldFire)
         {
             AccessTools.Field(typeof(Building_TurretGun), "holdFire")?.SetValue(this, false);
         }
         if (forcedWorldTarget.ThingDestroyed)
         {
             ResetForcedTarget();
         }
         if (Active && (mannableComp == null || mannableComp.MannedNow) && !stunner.Stunned && Spawned)
         {
             GunCompEq.verbTracker.VerbsTick();
             if (AttackVerb.state != VerbState.Bursting)
             {
                 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 - Math.Max(burstCooldownTicksLeft, 0) / (float)BurstCooldownTime().SecondsToTicks();
                             mote.offsetZ  = -0.8f;
                         }
                     }
                     if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10))
                     {
                         TryStartShootSomething(true);
                     }
                 }
                 top.TurretTopTick();
                 return;
             }
         }
         else
         {
             ResetCurrentTarget();
         }
         if (WarmingUp)
         {
             burstWarmupTicksLeft--;
             if (burstWarmupTicksLeft == 0)
             {
                 BeginBurst();
             }
         }
     }
 }