private void ForceEndJobState() { this.JobState = PS_Conditioning_JobState.Waiting; this.CurrentTicksLeft = 0f; if (ProgressBarEffector != null) { ProgressBarEffector.Cleanup(); ProgressBarEffector = null; } }
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); } }
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 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); } }
private void FinishConditioning() { var pawn = (Pawn)this.innerContainer.FirstOrDefault(); if (pawn == null) { Log.Error("PS_Bulding_ReconPod: Finsihed conditioning put held pawn is null"); this.EjectContents(); this.ForceEndJobState(); return; } switch (this.JobState) { case PS_Conditioning_JobState.Waiting: return; case PS_Conditioning_JobState.Reconditioning: if (RoleForSucessOrHandleFail(pawn)) { PS_ConditioningHelper.DoConditioning(pawn, this, this.ConditioningData); this.TryAssignPawn(pawn); pawn.needs.mood.thoughts.memories.TryGainMemory(DefDatabase <ThoughtDef> .GetNamed("PS_Thoughts_Memory_Reconditioned")); PS_ConditioningHelper.DirtyNeedFall(pawn); PS_ConditioningHelper.SetCurrentNeedLevel(pawn, PS_ConditioningHelper.GetCurrentNeedLevel(pawn) + 1f); Messages.Message(string.Format("PS_Messages_CompletedReconditioning".Translate(), pawn.LabelShort), new LookTargets(pawn), MessageTypeDefOf.TaskCompletion); } this.Open(); break; case PS_Conditioning_JobState.Refreshing: PS_ConditioningHelper.SetCurrentNeedLevel(pawn, PS_ConditioningHelper.GetCurrentNeedLevel(pawn) + 0.6f); PS_ConditioningHelper.DirtyNeedFall(pawn); this.Open(); break; case PS_Conditioning_JobState.Deconditioning: var lastConditioning = (PS_ConditioningHelper.GetConditioningDataFromHediff(pawn)?.Count() ?? 0) <= 1; PS_ConditioningHelper.UndoConditioning(pawn, this, this.ConditioningData); if (lastConditioning) { pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(DefDatabase <ThoughtDef> .GetNamed("PS_Thoughts_Memory_Reconditioned")); pawn.needs.mood.thoughts.memories.TryGainMemory(DefDatabase <ThoughtDef> .GetNamed("PS_Thoughts_Memory_Deconditioned")); this.TryUnassignPawn(pawn); } else { PS_ConditioningHelper.DirtyNeedFall(pawn); PS_ConditioningHelper.SetCurrentNeedLevel(pawn, PS_ConditioningHelper.GetCurrentNeedLevel(pawn) + 1f); } this.Open(); Messages.Message(string.Format("PS_Messages_CompletedDeconditioning".Translate(), pawn.LabelShort), new LookTargets(pawn), MessageTypeDefOf.TaskCompletion); break; case PS_Conditioning_JobState.FixingBotch: PS_ConditioningHelper.RemoveBotch(pawn); pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(DefDatabase <ThoughtDef> .GetNamed("PS_Thoughts_Memory_BotchedConditioned")); if (PS_ConditioningHelper.IsReconditioned(pawn)) { PS_ConditioningHelper.DirtyNeedFall(pawn); PS_ConditioningHelper.SetCurrentNeedLevel(pawn, PS_ConditioningHelper.GetCurrentNeedLevel(pawn) + 1f); } this.Open(); Messages.Message(string.Format("PS_Messages_CompletedFixingBotched".Translate(), pawn.LabelShort), new LookTargets(pawn), MessageTypeDefOf.TaskCompletion); break; } if (ProgressBarEffector != null) { ProgressBarEffector.Cleanup(); ProgressBarEffector = null; } this.JobState = PS_Conditioning_JobState.Waiting; // Move hediff to brain if it's not, fix for old version if (!this.CheckedHediffPart) { var hediff = pawn.health.hediffSet.GetHediffs <PS_Hediff_Reconditioned>().FirstOrDefault(); if (hediff != null) { var currentPart = hediff.Part; var brain = pawn.RaceProps.body.AllParts.Where(x => x.def.defName == "Brain").FirstOrDefault(); if (brain != null && currentPart != brain) { hediff.Part = brain; } } this.CheckedHediffPart = true; } }