Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Empty file.
Binary file modified RimWorldOfMagic/.vs/RimWorldOfMagic/v17/.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions RimWorldOfMagic/RimWorldOfMagic/AutoCast/Scripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,9 @@ public static void Evaluate(CompAbilityUserMagic casterComp, TMAbilityDef abilit
{
bool tatteredApparel = false;
//List<Thought_Memory> targetPawnThoughts = null;
//targetPawn.needs.mood.thoughts.GetDistinctMoodThoughtGroups(targetPawnThoughts);
//targetPawn.needs?.mood?.thoughts.GetDistinctMoodThoughtGroups(targetPawnThoughts);
//Log.Message("target pawn is " + targetPawn.LabelShort);
//List<Thought_Memory> targetPawnThoughts = targetPawn.needs.mood.thoughts.memories.Memories;
//List<Thought_Memory> targetPawnThoughts = targetPawn.needs?.mood?.thoughts.memories.Memories;
//for (int i = 0; i < targetPawnThoughts.Count; i++)
//{

Expand Down
4 changes: 2 additions & 2 deletions RimWorldOfMagic/RimWorldOfMagic/Building_TMHeater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public override void Tick()
for (int i = 0; i < pList.Count; i++)
{
Pawn p = pList[i];
if (p.needs != null && p.needs.joy != null)
if (p.needs != null && p.needs?.joy != null)
{
Need joy = p.needs.TryGetNeed(TorannMagicDefOf.Joy);
Need joy = p.needs?.TryGetNeed(TorannMagicDefOf.Joy);
if(joy != null)
{
joy.CurLevel += Rand.Range(.01f, .02f);
Expand Down
20 changes: 10 additions & 10 deletions RimWorldOfMagic/RimWorldOfMagic/CompAbilityUserMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ public Need_Mana Mana
{
if (!this.Pawn.DestroyedOrNull() && !this.Pawn.Dead)
{
return base.Pawn.needs.TryGetNeed<Need_Mana>();
return base.Pawn.needs?.TryGetNeed<Need_Mana>();
}
return null;
}
Expand Down Expand Up @@ -5404,18 +5404,18 @@ public void ResolveWarlockEmpathy()
{
if (Rand.Chance(otherPawn.GetStatValue(StatDefOf.PsychicSensitivity, false) - .3f))
{
ThoughtHandler pawnThoughtHandler = this.Pawn.needs.mood.thoughts;
ThoughtHandler pawnThoughtHandler = this.Pawn.needs?.mood.thoughts;
List<Thought> pawnThoughts = new List<Thought>();
pawnThoughtHandler.GetAllMoodThoughts(pawnThoughts);
List<Thought> otherThoughts = new List<Thought>();
otherPawn.needs.mood.thoughts.GetAllMoodThoughts(otherThoughts);
otherPawn.needs?.mood.thoughts.GetAllMoodThoughts(otherThoughts);
List<Thought_Memory> memoryThoughts = new List<Thought_Memory>();
memoryThoughts.Clear();
float oldMemoryOffset = 0;
if (Rand.Chance(.3f)) //empathy absorbed by warlock
{
ThoughtDef empathyThought = ThoughtDef.Named("WarlockEmpathy");
memoryThoughts = this.Pawn.needs.mood.thoughts.memories.Memories;
memoryThoughts = this.Pawn.needs?.mood.thoughts.memories.Memories;
for (int i = 0; i < memoryThoughts.Count; i++)
{
if (memoryThoughts[i].def.defName == "WarlockEmpathy")
Expand All @@ -5429,22 +5429,22 @@ public void ResolveWarlockEmpathy()
{
oldMemoryOffset = -30;
}
this.Pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(memoryThoughts[i].def);
this.Pawn.needs?.mood.thoughts.memories.RemoveMemoriesOfDef(memoryThoughts[i].def);
}
}
Thought transferThought = otherThoughts.RandomElement();
float newOffset = Mathf.RoundToInt(transferThought.CurStage.baseMoodEffect / 2);
empathyThought.stages.FirstOrDefault().baseMoodEffect = newOffset + oldMemoryOffset;

this.Pawn.needs.mood.thoughts.memories.TryGainMemory(empathyThought, null);
this.Pawn.needs?.mood.thoughts.memories.TryGainMemory(empathyThought, null);
Vector3 drawPosOffset = this.Pawn.DrawPos;
drawPosOffset.z += .3f;
TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ArcaneCircle, drawPosOffset, this.Pawn.Map, newOffset / 20, .2f, .1f, .1f, Rand.Range(100, 200), 0, 0, Rand.Range(0, 360));
}
else //empathy bleeding to other pawn
{
ThoughtDef empathyThought = ThoughtDef.Named("PsychicEmpathy");
memoryThoughts = otherPawn.needs.mood.thoughts.memories.Memories;
memoryThoughts = otherPawn.needs?.mood.thoughts.memories.Memories;
for (int i = 0; i < memoryThoughts.Count; i++)
{
if (memoryThoughts[i].def.defName == "PsychicEmpathy")
Expand All @@ -5458,14 +5458,14 @@ public void ResolveWarlockEmpathy()
{
oldMemoryOffset = -30;
}
otherPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(memoryThoughts[i].def);
otherPawn.needs?.mood.thoughts.memories.RemoveMemoriesOfDef(memoryThoughts[i].def);
}
}
Thought transferThought = pawnThoughts.RandomElement();
float newOffset = Mathf.RoundToInt(transferThought.CurStage.baseMoodEffect / 2);
empathyThought.stages.FirstOrDefault().baseMoodEffect = newOffset + oldMemoryOffset;

otherPawn.needs.mood.thoughts.memories.TryGainMemory(empathyThought, null);
otherPawn.needs?.mood.thoughts.memories.TryGainMemory(empathyThought, null);
Vector3 drawPosOffset = otherPawn.DrawPos;
drawPosOffset.z += .3f;
TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ArcaneCircle, drawPosOffset, otherPawn.Map, newOffset / 20, .2f, .1f, .1f, Rand.Range(100, 200), 0, 0, Rand.Range(0, 360));
Expand Down Expand Up @@ -5861,7 +5861,7 @@ public void ResolveMana()
hediff.Severity = 1f;
base.Pawn.health.AddHediff(hediff, null, null);
}
this.Pawn.needs.AddOrRemoveNeedsAsAppropriate();
this.Pawn.needs?.AddOrRemoveNeedsAsAppropriate();
}
}
public void ResolveMagicPowers()
Expand Down
8 changes: 4 additions & 4 deletions RimWorldOfMagic/RimWorldOfMagic/CompAbilityUserMight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ public Need_Stamina Stamina
{
if (!base.Pawn.DestroyedOrNull() && base.Pawn.needs != null)
{
return base.Pawn.needs.TryGetNeed<Need_Stamina>();
return base.Pawn.needs?.TryGetNeed<Need_Stamina>();
}
return null;
}
Expand Down Expand Up @@ -4335,21 +4335,21 @@ private void ResolveSustainedSkills()
{
this.bondedPet.health.RemoveHediff(this.bondedPet.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_RangerBondHD, false));
}
this.Pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.RangerPetDied, null);
this.Pawn.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.RangerPetDied, null);
this.bondedPet = null;
}
else if (this.bondedPet.Faction != null && this.bondedPet.Faction != this.Pawn.Faction)
{
//sold? punish evil
this.Pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.RangerSoldBondedPet, null);
this.Pawn.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.RangerSoldBondedPet, null);
this.bondedPet = null;
}
else if(!this.bondedPet.health.hediffSet.HasHediff(TorannMagicDefOf.TM_RangerBondHD))
{
HealthUtility.AdjustSeverity(this.bondedPet, TorannMagicDefOf.TM_RangerBondHD, .5f);
}
}
if(this.Pawn.needs.mood.thoughts.memories.NumMemoriesOfDef(ThoughtDef.Named("RangerSoldBondedPet")) > 0)
if(this.Pawn.needs?.mood?.thoughts.memories.NumMemoriesOfDef(ThoughtDef.Named("RangerSoldBondedPet")) > 0)
{
if(this.animalBondingDisabled == false)
{
Expand Down
4 changes: 2 additions & 2 deletions RimWorldOfMagic/RimWorldOfMagic/CompPolymorph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ public void ApplyDamage(Pawn pawn)
{
if (pawn.story?.traits != null && pawn.story.traits.HasTrait(TraitDefOf.Transhumanist))
{
pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.Polymorphed_Transhumanist, this.spawner);
pawn.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.Polymorphed_Transhumanist, this.spawner);
}
else if(this.spawner == this.original)
{
//do not give bad thoughts
}
else
{
pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.Polymorphed, this.spawner);
pawn.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.Polymorphed, this.spawner);
}
}
catch(NullReferenceException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override void PostInitialize()

public override void HediffActionTick()
{
Need rest = this.Pawn.needs.rest;
Need rest = this.Pawn.needs?.rest;
if (rest != null)
{
rest.CurLevel += .0065f;
Expand Down
20 changes: 10 additions & 10 deletions RimWorldOfMagic/RimWorldOfMagic/FlyingObject_SpiritOfLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,17 +788,17 @@ public void UpdateAction(SoLAction withAction = SoLAction.Pending)
p = TM_Calc.FindNearbyPawn(this.pawn, 10);
if (p != null && p.needs != null && TM_Calc.HasLoSFromTo(this.pawn.Position, p, this.pawn, 0, 10))
{
if ((this.pawn.CurJobDef.joyKind != null || this.pawn.CurJobDef == JobDefOf.Wait_Wander || this.pawn.CurJobDef == JobDefOf.GotoWander) && this.pawn.needs.joy.CurLevelPercentage < .5f)
if ((this.pawn.CurJobDef.joyKind != null || this.pawn.CurJobDef == JobDefOf.Wait_Wander || this.pawn.CurJobDef == JobDefOf.GotoWander) && this.pawn.needs?.joy.CurLevelPercentage < .5f)
{
this.delayCount = 0;
Action_JoyBurst(this.pawn.DrawPos, out destTarget);
}
else if (p.needs.joy != null && (p.CurJobDef.joyKind != null || p.CurJobDef == JobDefOf.Wait_Wander || p.CurJobDef == JobDefOf.GotoWander) && p.needs.joy.CurLevelPercentage < .5f)
else if (p.needs?.joy != null && (p.CurJobDef.joyKind != null || p.CurJobDef == JobDefOf.Wait_Wander || p.CurJobDef == JobDefOf.GotoWander) && p.needs?.joy.CurLevelPercentage < .5f)
{
this.delayCount = 0;
Action_JoyBurst(p.DrawPos, out destTarget);
}
else if (this.delayCount > 3 && p.needs.mood != null && p.needs.mood.thoughts != null && p.needs.mood.thoughts.memories != null && p.needs.mood.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_BrightDayTD) == null)
else if (this.delayCount > 3 && p.needs?.mood != null && p.needs?.mood?.thoughts != null && p.needs?.mood?.thoughts.memories != null && p.needs?.mood?.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_BrightDayTD) == null)
{
this.delayCount = 0;
Action_GotoTarget(p.DrawPos, speed_jog, out destTarget);
Expand Down Expand Up @@ -841,7 +841,7 @@ public void UpdateAction(SoLAction withAction = SoLAction.Pending)
if(this.assignedTarget != null && this.assignedTarget is Pawn p)
{
ActualLightCost(6f);
p.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_BrightDayTD);
p.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_BrightDayTD);
Action_CircleTarget(this.assignedTarget, out destTarget);
queuedAction = SoLAction.Returning;
}
Expand Down Expand Up @@ -958,18 +958,18 @@ public void Action_Sleeping(out Vector3 destTarget)
this.speed = speed_hover;
this.solAction = SoLAction.Sleeping;
this.delayCount++;
if(delayCount > 10 && EnergyChance && pawn.needs.mood != null && pawn.needs.mood.thoughts != null)
if(delayCount > 10 && EnergyChance && pawn.needs?.mood != null && pawn.needs?.mood?.thoughts != null)
{
this.delayCount = 0;
if (pawn.needs.mood.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_PleasantDreamsTD) == null)
if (pawn.needs?.mood?.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_PleasantDreamsTD) == null)
{
ActualLightCost(5f);
pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_PleasantDreamsTD);
pawn.needs?.mood?.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_PleasantDreamsTD);
}
if(pawn.needs.mood.thoughts.memories.GetFirstMemoryOfDef(ThoughtDefOf.SleepDisturbed) != null)
if(pawn.needs?.mood?.thoughts.memories.GetFirstMemoryOfDef(ThoughtDefOf.SleepDisturbed) != null)
{
ActualLightCost(3f);
pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleepDisturbed);
pawn.needs?.mood?.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleepDisturbed);
}
}
destTarget = GetCasterOffset_Rand;
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public void Action_JoyBurst(Vector3 center, out Vector3 destTarget)
for(int i = 0; i < affectedPawns.Count; i++)
{
Pawn p = affectedPawns[i];
if(p.needs != null && p.needs.joy != null)
if(p.needs != null && p.needs?.joy != null)
{
p.needs.joy.CurLevel += Rand.Range(.2f, .4f) * LightPotency;
}
Expand Down
2 changes: 1 addition & 1 deletion RimWorldOfMagic/RimWorldOfMagic/Gizmo_EnergyStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRen
if (isSpirit)
{
rect2.y = rect.y + yShift;
Need_Spirit nd = pawn.needs.TryGetNeed(TorannMagicDefOf.TM_SpiritND) as Need_Spirit;
Need_Spirit nd = pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_SpiritND) as Need_Spirit;
try
{
fillPercent = nd.CurLevel / nd.MaxLevel;
Expand Down
6 changes: 3 additions & 3 deletions RimWorldOfMagic/RimWorldOfMagic/Golems/CompGolem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public override void PostExposeData()

public LocalTargetInfo AbilityTarget => abilityTarget;
public TM_GolemAbility ActiveAbility => activeAbility;
public Need_GolemEnergy Energy => Pawn.needs.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
public Need_GolemEnergy Energy => Pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
public bool HasEnergyForAbilities => Energy.CurEnergyPercent > minEnergyPctForAbilities;

public ThingOwner GetDirectlyHeldThings()
Expand Down Expand Up @@ -399,7 +399,7 @@ protected virtual void ApplyNeeds()
{
if (Pawn.needs != null)
{
Need_GolemEnergy need_ge = Pawn.needs.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
Need_GolemEnergy need_ge = Pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
if (need_ge != null)
{
CompGolemEnergyHandler cgeh = InnerWorkstation.Energy;
Expand Down Expand Up @@ -857,7 +857,7 @@ public void StartAbility(TM_GolemAbility ability, LocalTargetInfo target)

public void DecreaseNeed(NeedDef need, float amount)
{
Need_GolemEnergy n = Pawn.needs.TryGetNeed(need) as Need_GolemEnergy;
Need_GolemEnergy n = Pawn.needs?.TryGetNeed(need) as Need_GolemEnergy;
if(n != null)
{
n.CurLevel -= (n.ActualNeedCost(amount) * EnergyCostModifier);
Expand Down
4 changes: 2 additions & 2 deletions RimWorldOfMagic/RimWorldOfMagic/Golems/GolemAbilityWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static bool CanUseAbility(Pawn p, TM_GolemAbilityDef ability)
float eff = 1f;
if (p.needs != null)
{
Need n = p.needs.TryGetNeed(ability.requiredNeed);
Need_GolemEnergy n_ge = p.needs.TryGetNeed(ability.requiredNeed) as Need_GolemEnergy;
Need n = p.needs?.TryGetNeed(ability.requiredNeed);
Need_GolemEnergy n_ge = p.needs?.TryGetNeed(ability.requiredNeed) as Need_GolemEnergy;

if(n_ge != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override Job TryGiveJob(Pawn pawn)
if (pg != null && pg.Drafted && !pg.rangedToggle)
{
CompGolem Golem = pawn.TryGetComp<CompGolem>();
Need_GolemEnergy energy = pawn.needs.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
Need_GolemEnergy energy = pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
Thing threat = Golem.ActiveThreat;
if (threat != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override ThinkNode DeepCopy(bool resolve = true)

public override float GetPriority(Pawn pawn)
{
Need_GolemEnergy energy = pawn.needs.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
Need_GolemEnergy energy = pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
if (energy == null)
{
return 0f;
Expand Down Expand Up @@ -66,7 +66,7 @@ public override float GetPriority(Pawn pawn)
protected override Job TryGiveJob(Pawn pawn)
{
CompGolem Golem = pawn.TryGetComp<CompGolem>();
Need_GolemEnergy energy = pawn.needs.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
Need_GolemEnergy energy = pawn.needs?.TryGetNeed(TorannMagicDefOf.TM_GolemEnergy) as Need_GolemEnergy;
if (energy == null || Golem == null || energy.CurLevelPercentage >= Golem.energyPctShouldRest || energy.CurLevelPercentage > maxLevelPercentage)
{
return null;
Expand Down
Loading