public Saveable_ExecutionLog GetLog(AbilityDef ability) { foreach (Saveable_ExecutionLog l in this.executionLogs) { if (l.ability == ability) return l; } Saveable_ExecutionLog newLog = new Saveable_ExecutionLog(); newLog.ability = ability; this.executionLogs.Add(newLog); return newLog; }
public override ThinkResult TryIssueJobPackage(Pawn pawn) { Saveable_Caster cachePawn = MapComponent_Ability.GetOrCreate().GetPawnHabilty(pawn); if (cachePawn.whaitingForThinkNode) { cachePawn.whaitingForThinkNode = false; Saveable_ExecutionLog log = cachePawn.GetLog(cachePawn.currentAbility); log.numberOfExecution++; log.ticksSinceExecution = 0; return(new ThinkResult(new Job(cachePawn.currentAbility.effect.StartJob(cachePawn.effectState)), this)); } return(ThinkResult.NoJob); }
public override bool Sucess(AbilityDef ability, Saveable_Caster pawn) { Saveable_ExecutionLog log = pawn.GetLog(ability); int ticks = this.initial + log.numberOfExecution * this.between; if (this.minimum > 0) { ticks = Math.Max(this.minimum, ticks); } if (this.maximum > 0) { ticks = Math.Min(this.maximum, ticks); } return(log.ticksSinceExecution >= ticks); }
public Saveable_ExecutionLog GetLog(AbilityDef ability) { foreach (Saveable_ExecutionLog l in this.executionLogs) { if (l.ability == ability) { return(l); } } Saveable_ExecutionLog newLog = new Saveable_ExecutionLog(); newLog.ability = ability; this.executionLogs.Add(newLog); return(newLog); }
public override void MapComponentTick() { base.MapComponentTick(); if (this.pawnCache == null) { this.pawnCache = new List <Saveable_Caster>(); } if (Find.TickManager.TicksGame % MapComponent_Ability.longTickOffet == 0) { foreach (Saveable_Caster value in this.pawnCache.ToArray()) { try { Pawn pawn = value.pawn; if (pawn == null) { this.RemovePawn(value); continue; } if (pawn.Dead) { if (value.corpse == null) { List <Thing> things = Find.ListerThings.ThingsMatching(new ThingRequest() { group = ThingRequestGroup.Corpse }); if (things == null) { this.RemovePawn(value); continue; } foreach (Corpse c in things) { if (c.innerPawn == pawn) { value.corpse = c; this.InjectTab(value.corpse.def); break; } } if (value.corpse == null) { this.RemovePawn(value); continue; } } if (value.corpse.Destroyed) { this.RemovePawn(value); continue; } } else { this.InjectTab(value.pawn.def); value.corpse = null; } this.NormalTick(value); if ((pawn.Dead) || (pawn.Downed)) { AbilityDef toStartAbility; List <Thing> targets; IExposable state; if (this.TryStartNextAbility(value, out toStartAbility, out targets, out state)) { Saveable_ExecutionLog log = value.GetLog(toStartAbility); log.numberOfExecution++; log.ticksSinceExecution = 0; toStartAbility.effect.ExecuteWhileIncapacitated(value, targets, state); } } else if ((pawn.CurJob == null) || ((pawn.CurJob.def.defName != "AbilityEffect_JobDef") && (pawn.CurJob.def.defName != "AbilityEffect_JobDef_Interruptable"))) { AbilityDef toStartAbility; List <Thing> targets; IExposable state; if (this.TryStartNextAbility(value, out toStartAbility, out targets, out state)) { value.whaitingForThinkNode = true; value.currentAbility = toStartAbility; value.currentTargets = targets == null ? null : targets.Select(i => new Saveable_Target() { target = i }).ToList(); value.effectState = state; pawn.jobs.EndCurrentJob(JobCondition.InterruptOptional); } } } catch (Exception e) { Log.Notify_Exception(e); } } } else { foreach (Saveable_Caster value in this.pawnCache) { try { this.NormalTick(value); } catch (Exception e) { Log.Notify_Exception(e); } } } int indexMote = 0; while (indexMote < this.completingMotes.Count) { if (this.completingMotes[indexMote].Tick()) { indexMote++; } else { this.completingMotes.RemoveAt(indexMote); } } }