initial commit
first working version
a little late since i didn't expect this to be big enough to require source control 😵💫
This commit is contained in:
commit
f390de6ce3
14 changed files with 1117 additions and 0 deletions
96
Source/MBS_Anomaly/PsychicRitualToil_Megaphagy.cs
Normal file
96
Source/MBS_Anomaly/PsychicRitualToil_Megaphagy.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<HediffSizeOffset>(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<HediffSizeOffset>(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");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue