/* Copyright 2025 Maciej Pawłowski This file is part of "Maciek's Big and Small unofficial addon - Anomaly". "Maciek's Big and Small unofficial addon - Anomaly" is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. "Maciek's Big and Small unofficial addon - Anomaly" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with "Maciek's Big and Small unofficial addon - Anomaly". If not, see . */ using System.Linq; using MBS_Anomaly; using RimWorld; namespace Verse.AI.Group; public class PsychicRitualToil_Megaphagy : PsychicRitualToil { public PsychicRitualRoleDef targetRole; public PsychicRitualRoleDef invokerRole; public FloatRange sizeTransferredFromQualityRange; protected PsychicRitualToil_Megaphagy() { } public PsychicRitualToil_Megaphagy(PsychicRitualRoleDef invokerRole, PsychicRitualRoleDef targetRole, FloatRange sizeTransferredFromQualityRange) { this.invokerRole = invokerRole; this.targetRole = targetRole; this.sizeTransferredFromQualityRange = sizeTransferredFromQualityRange; } public override void Start(PsychicRitual psychicRitual, PsychicRitualGraph parent) { Pawn pawn = psychicRitual.assignments.FirstAssignedPawn(invokerRole); Pawn pawn2 = psychicRitual.assignments.FirstAssignedPawn(targetRole); float size = sizeTransferredFromQualityRange.LerpThroughRange(psychicRitual.PowerPercent) * psychicRitual.assignments.FirstAssignedPawn(targetRole).BodySize; if (pawn != null && pawn2 != null) { ApplyOutcome(psychicRitual, pawn, pawn2, size); } } private void ApplyOutcome(PsychicRitual psychicRitual, Pawn invoker, Pawn target, float size) { // ReverseAgePawn(invoker, years, out var removedHediffs, out var pawnAgeDelta); // AgePawn(psychicRitual, target, years, out var gainedHediffs, out var diedOfOldAge, out var diedOfBrainDamage); size *= target.BodySize; HediffSizeOffset hediff; if (invoker.health.hediffSet.TryGetHediff(out hediff)) { hediff.SizeOffset += size; BigAndSmall.HumanoidPawnScaler.LazyGetCache(invoker); } else { hediff = (HediffSizeOffset)HediffMaker.MakeHediff(MBSADefs.MBSA_BodySizeTransferred, invoker); hediff.SizeOffset = size; } invoker.health.AddHediff(hediff); if (target.health.hediffSet.TryGetHediff(out hediff)) { hediff.SizeOffset -= size; BigAndSmall.HumanoidPawnScaler.LazyGetCache(target); } else { hediff = (HediffSizeOffset)HediffMaker.MakeHediff(MBSADefs.MBSA_BodySizeTransferred, target); hediff.SizeOffset = -size; } target.health.AddHediff(hediff); Hediff shock = HediffMaker.MakeHediff(HediffDefOf.DarkPsychicShock, target); target.health.AddHediff(shock); target.needs?.mood?.thoughts?.memories?.TryGainMemory(ThoughtDefOf.PsychicRitualVictim); foreach (Pawn item in psychicRitual.assignments.AllAssignedPawns.Except(target)) { target.needs?.mood?.thoughts?.memories?.TryGainMemory(ThoughtDefOf.UsedMeForPsychicRitual, item); } if (target.Dead) { PsychicRitualUtility.RegisterAsExecutionIfPrisoner(target, invoker); } PsychicRitualUtility.AddPsychicRitualGuiltToPawns(psychicRitual.def, psychicRitual.Map.mapPawns.FreeColonistsSpawned.Where((p) => p != target)); } public override void ExposeData() { base.ExposeData(); Scribe_Defs.Look(ref invokerRole, "invokerRole"); Scribe_Defs.Look(ref targetRole, "targetRole"); Scribe_Values.Look(ref sizeTransferredFromQualityRange, "sizeTransferredFromQualityRange"); } }