fix: make the DecayResetTime setter allocation-safe and self-collapsing

Setting default no longer allocates a CompactInfo when none exists, and
clears the field with VerifyCompactInfo when one does; the LastMoved setter
now clears a superseded stamp through the property instead of inline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kamron Batman 2026-08-22 12:21:09 -07:00
parent 251c1efce7
commit bf8d1274cb

View file

@ -345,12 +345,11 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
_lastMoved = value;
// A move at or past the reset stamp supersedes it; drop it so the CompactInfo can collapse.
var info = LookupCompactInfo();
var reset = DecayResetTime;
if (info != null && info.m_DecayReset != default && info.m_DecayReset <= value)
if (reset != default && reset <= value)
{
info.m_DecayReset = default;
VerifyCompactInfo();
DecayResetTime = default;
}
}
}
@ -2380,7 +2379,23 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
public DateTime DecayResetTime
{
get => LookupCompactInfo()?.m_DecayReset ?? default;
private set => AcquireCompactInfo().m_DecayReset = value;
private set
{
if (value == default)
{
var info = LookupCompactInfo();
if (info != null && info.m_DecayReset != default)
{
info.m_DecayReset = default;
VerifyCompactInfo();
}
}
else
{
AcquireCompactInfo().m_DecayReset = value;
}
}
}
/// <summary>