Attack Boon Changes

This commit is contained in:
2026-07-13 18:30:41 -07:00
parent 972e0d5b4f
commit 24800f4bcb
34 changed files with 1306 additions and 112 deletions
@@ -42,5 +42,32 @@ namespace ProjectM.Simulation
if (mods[j].SourceId >= lo && mods[j].SourceId < hiExclusive) { mods.RemoveAtSwapBack(j); removed++; }
return removed;
}
/// <summary>Phase 1.7: guarantee EXACTLY ONE row per <paramref name="sourceId"/> in BOTH the replicated
/// <see cref="StatModifier"/> buffer and this server-only <see cref="TimedModifier"/> buffer (remove-then-add) so a
/// timed buff REFRESHES (re-stamps <paramref name="untilTick"/>) rather than stacking on a repeat grant. Used by
/// <c>KillRewardSystem</c> for Frenzy so successive kills extend the surge instead of compounding the modifier.</summary>
public static void Upsert(DynamicBuffer<StatModifier> mods, DynamicBuffer<TimedModifier> timed,
uint sourceId, byte target, byte op, float value, uint untilTick)
{
RemoveBySourceId(mods, sourceId);
for (int j = timed.Length - 1; j >= 0; j--)
if (timed[j].SourceId == sourceId) timed.RemoveAtSwapBack(j);
mods.Add(new StatModifier { Target = target, Op = op, Value = value, SourceId = sourceId });
timed.Add(new TimedModifier { SourceId = sourceId, UntilTick = untilTick });
}
/// <summary>Phase 1.7: remove every server-only <see cref="TimedModifier"/> row matching <paramref name="sourceId"/>
/// (the paired <see cref="StatModifier"/> is cleared separately — e.g. the Returning boon-band range-strip). This
/// closes the cross-run gap where a stale Frenzy timed row could outlive its StatModifier. Returns the count removed.</summary>
public static int RemoveBySourceId(DynamicBuffer<TimedModifier> timed, uint sourceId)
{
int removed = 0;
for (int j = timed.Length - 1; j >= 0; j--)
if (timed[j].SourceId == sourceId) { timed.RemoveAtSwapBack(j); removed++; }
return removed;
}
}
}