public virtual void AbilityTick() { VerbTracker.VerbsTick(); if (def.warmupMote != null && verb.WarmingUp) { if (warmupMote == null || warmupMote.Destroyed) { warmupMote = MoteMaker.MakeStaticMote(pawn.DrawPos + def.moteDrawOffset, pawn.Map, def.warmupMote); } else { warmupMote.Maintain(); } } if (verb.WarmingUp && !CanApplyOn(verb.CurrentTarget)) { verb.WarmupStance?.Interrupt(); verb.Reset(); } 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)); } } }
protected void MeditationTick() { pawn.skills.Learn(SkillDefOf.Intellectual, 0.0180000011f); pawn.GainComfortFromCellIfPossible(); if (pawn.needs.joy != null) { JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None); } if (pawn.IsHashIntervalTick(100)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Meditating); } if (!ModsConfig.RoyaltyActive) { return; } pawn.psychicEntropy.Notify_Meditated(); if (pawn.HasPsylink && pawn.psychicEntropy.PsychicSensitivity > float.Epsilon) { if (psyfocusMote == null || psyfocusMote.Destroyed) { psyfocusMote = MoteMaker.MakeAttachedOverlay(pawn, ThingDefOf.Mote_PsyfocusPulse, Vector3.zero); } psyfocusMote.Maintain(); if (sustainer == null || sustainer.Ended) { sustainer = SoundDefOf.MeditationGainPsyfocus.TrySpawnSustainer(SoundInfo.InMap(pawn, MaintenanceType.PerTick)); } sustainer.Maintain(); pawn.psychicEntropy.GainPsyfocus(Focus.Thing); } }
protected override IEnumerable <Toil> MakeNewToils() { if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Bestowing cermonies are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 5464564); yield break; } AddFailCondition(() => Bestower.GetLord() == null || Bestower.GetLord().CurLordToil == null || !(Bestower.GetLord().CurLordToil is LordToil_BestowingCeremony_Wait)); yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); Toil waitToil = Toils_General.Wait(471); waitToil.AddPreInitAction(delegate { Messages.Message("MessageBestowingCeremonyStarted".Translate(pawn.Named("PAWN")), Bestower, MessageTypeDefOf.PositiveEvent); }); waitToil.AddPreInitAction(delegate { if (!AnalyzeThroneRoom(Bestower, pawn)) { Messages.Message("BestowingCeremonyThroneroomRequirementsNotSatisfied".Translate(pawn.Named("PAWN"), pawn.royalty.GetTitleAwardedWhenUpdating(Bestower.Faction, pawn.royalty.GetFavor(Bestower.Faction)).label.Named("TITLE")), pawn, MessageTypeDefOf.NegativeEvent); ((LordJob_BestowingCeremony)Bestower.GetLord().LordJob).MakeCeremonyFail(); } }); waitToil.AddPreInitAction(delegate { SoundDefOf.Bestowing_Start.PlayOneShot(pawn); }); waitToil.tickAction = delegate { pawn.rotationTracker.FaceTarget(Bestower); if (mote == null || mote.Destroyed) { Vector3 loc = (pawn.TrueCenter() + Bestower.TrueCenter()) / 2f; mote = MoteMaker.MakeStaticMote(loc, pawn.Map, ThingDefOf.Mote_Bestow); } mote.Maintain(); if ((sound == null || sound.Ended) && waitToil.actor.jobs.curDriver.ticksLeftThisToil <= 307) { sound = SoundDefOf.Bestowing_Warmup.TrySpawnSustainer(SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map), MaintenanceType.PerTick)); } if (sound != null) { sound.Maintain(); } }; waitToil.handlingFacing = false; waitToil.socialMode = RandomSocialMode.Off; waitToil.WithProgressBarToilDelay(TargetIndex.A); yield return(waitToil); yield return(Toils_General.Do(delegate { CeremonyJob.FinishCeremony(pawn); MoteMaker.MakeStaticMote((pawn.TrueCenter() + Bestower.TrueCenter()) / 2f, pawn.Map, ThingDefOf.Mote_PsycastAreaEffect, 2f); SoundDefOf.Bestowing_Finished.PlayOneShot(pawn); })); }
public override void CompPostTick(ref float severityAdjustment) { if (!parent.pawn.Awake() || parent.pawn.health == null || parent.pawn.health.InPainShock || !parent.pawn.Spawned) { return; } if (!Props.hideMoteWhenNotDrafted || parent.pawn.Drafted) { if (Props.mote != null && (mote == null || mote.Destroyed)) { mote = MoteMaker.MakeAttachedOverlay(parent.pawn, Props.mote, Vector3.zero); } if (mote != null) { mote.Maintain(); } } List <Pawn> list = null; list = parent.pawn.Map.mapPawns.PawnsInFaction(parent.pawn.Faction); foreach (Pawn item in list) { if (item.Dead || item.health == null || item == parent.pawn || !(item.Position.DistanceTo(parent.pawn.Position) <= Props.range) || !Props.targetingParameters.CanTarget(item) || ((Props.affectSameDef) && (item.def != parent.pawn.def))) { continue; } Hediff hediff = item.health.hediffSet.GetFirstHediffOfDef(Props.hediff); if (hediff == null) { hediff = item.health.AddHediff(Props.hediff, item.health.hediffSet.GetBrain()); hediff.Severity = Props.initialSeverity; HediffComp_Link hediffComp_Link = hediff.TryGetComp <HediffComp_Link>(); if (hediffComp_Link != null) { hediffComp_Link.drawConnection = true; hediffComp_Link.other = parent.pawn; } } HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp <HediffComp_Disappears>(); if (hediffComp_Disappears == null) { Log.Error("HediffComp_GiveHediffsInRange has a hediff in props which does not have a HediffComp_Disappears"); } else { hediffComp_Disappears.ticksToDisappear = 5; } } }
public override void AbilityTick() { base.AbilityTick(); if (pawn.Spawned && base.Casting) { if (moteCast == null || moteCast.Destroyed) { moteCast = MoteMaker.MakeAttachedOverlay(pawn, ThingDefOf.Mote_CastPsycast, MoteCastOffset, MoteCastScale, base.verb.verbProps.warmupTime - MoteCastFadeTime); } else { moteCast.Maintain(); } } }
public override void AbilityTick() { base.AbilityTick(); if (moteCast != null && !moteCast.Destroyed && base.verb.WarmingUp) { moteCast.Maintain(); } if (base.verb.WarmingUp) { if (soundCast == null || soundCast.Ended) { soundCast = SoundDefOf.PsycastCastLoop.TrySpawnSustainer(SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map), MaintenanceType.PerTick)); } else { soundCast.Maintain(); } } }
public override void CompTick() { CompPowerTrader comp = parent.GetComp <CompPowerTrader>(); if (comp != null && !comp.PowerOn) { return; } CompSendSignalOnCountdown comp2 = parent.GetComp <CompSendSignalOnCountdown>(); if (comp2 != null && comp2.ticksLeft <= 0) { return; } CompInitiatable comp3 = parent.GetComp <CompInitiatable>(); if (comp3 != null && !comp3.Initiated) { return; } if (Props.emissionInterval != -1 && !Props.maintain) { if (ticksSinceLastEmitted >= Props.emissionInterval) { Emit(); ticksSinceLastEmitted = 0; } else { ticksSinceLastEmitted++; } } else if (mote == null) { Emit(); } if (Props.maintain && mote != null) { mote.Maintain(); } }
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 void StunHandlerTick() { if (EMPAdaptedTicksLeft > 0) { EMPAdaptedTicksLeft--; } if (stunTicksLeft > 0) { stunTicksLeft--; if (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(); } } }
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; }