Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
fixed a bug with traitsOnUnequip not actually replacing traits in tra…
Browse files Browse the repository at this point in the history
…itsOnEquip
  • Loading branch information
Taranchuk committed May 17, 2022
1 parent 3a91ec2 commit a3c7547
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
51 changes: 43 additions & 8 deletions Source/VFECore/VFECore/HarmonyPatches/Patch_Pawn_ApparelTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public static void Postfix(Pawn ___pawn, bool __result, Apparel ap, ref Apparel
{
if (___pawn.story?.traits != null)
{
if (extension.traitsOnUnequip != null)
if (extension.traitsOnEquip != null)
{
foreach (var traitDef in extension.traitsOnUnequip)
foreach (var traitDef in extension.traitsOnEquip)
{
var trait = ___pawn.story.traits.GetTrait(traitDef);
if (trait != null)
Expand All @@ -57,8 +57,18 @@ public static void Postfix(Pawn ___pawn, bool __result, Apparel ap, ref Apparel
}
}
}
if (extension.traitsOnUnequip != null)
{
foreach (var traitDef in extension.traitsOnUnequip)
{
if (!___pawn.story.traits.HasTrait(traitDef))
{
var trait = new Trait(traitDef);
___pawn.story.traits.GainTrait(trait);
}
}
}
}

}
}
}
Expand All @@ -77,14 +87,28 @@ public static void Postfix(Pawn ___pawn, Apparel ap)
{
if (___pawn.story?.traits != null)
{
if (extension.traitsOnUnequip != null)
if (___pawn.story?.traits != null)
{
foreach (var traitDef in extension.traitsOnUnequip)
if (extension.traitsOnEquip != null)
{
var trait = ___pawn.story.traits.GetTrait(traitDef);
if (trait != null)
foreach (var traitDef in extension.traitsOnEquip)
{
___pawn.story.traits.RemoveTrait(trait);
var trait = ___pawn.story.traits.GetTrait(traitDef);
if (trait != null)
{
___pawn.story.traits.RemoveTrait(trait);
}
}
}
if (extension.traitsOnUnequip != null)
{
foreach (var traitDef in extension.traitsOnUnequip)
{
if (!___pawn.story.traits.HasTrait(traitDef))
{
var trait = new Trait(traitDef);
___pawn.story.traits.GainTrait(trait);
}
}
}
}
Expand Down Expand Up @@ -132,6 +156,17 @@ public static void Postfix(Pawn_ApparelTracker __instance, Apparel newApparel, b
}
}
}
if (extension.traitsOnUnequip != null)
{
foreach (var traitDef in extension.traitsOnUnequip)
{
var trait = __instance.pawn.story.traits.GetTrait(traitDef);
if (trait != null)
{
__instance.pawn.story.traits.RemoveTrait(trait);
}
}
}
}
}
}
Expand Down

0 comments on commit a3c7547

Please sign in to comment.