Skip to content

Commit

Permalink
Continue effect chain in case statCollection is null
Browse files Browse the repository at this point in the history
  • Loading branch information
m22spencer committed Jan 27, 2019
1 parent 9536166 commit ca60a0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/OnEffectEndNullFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ public void Activate()
"OnEffectEnd".Pre<StatisticEffect>();
}

public static bool OnEffectEnd_Pre(StatisticEffect __instance) {
public static bool OnEffectEnd_Pre(StatisticEffect __instance, object ___target) {
if (Spam) LogSpam($"OnEffectEnd has been invoked for {__instance.id}");
var collection = new Traverse(__instance)
.Property("statCollection")
.GetValue<StatCollection>();

var hasCollection = collection != null;
if (!hasCollection) LogWarning($"OnEffectEnd was called with null statCollection for {__instance.id}");
if (!hasCollection)
{
LogWarning($"OnEffectEnd was called with null statCollection for {__instance.id}");

return collection != null;
// Taken from the base function directly.
// Need to continue the effect chain as it updates pathing & FOW & other logic
(___target as ICombatant)?.OnEffectEnd(__instance);
}

return hasCollection;
}

public static void initStatisiticEffect_Pre(StatisticEffect __instance, EffectData effectData, StatCollection targetStatCollection) {
Expand Down

0 comments on commit ca60a0f

Please sign in to comment.