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:
parent
251c1efce7
commit
bf8d1274cb
1 changed files with 20 additions and 5 deletions
|
|
@ -345,12 +345,11 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
||||||
_lastMoved = value;
|
_lastMoved = value;
|
||||||
|
|
||||||
// A move at or past the reset stamp supersedes it; drop it so the CompactInfo can collapse.
|
// 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;
|
DecayResetTime = default;
|
||||||
VerifyCompactInfo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2380,7 +2379,23 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
||||||
public DateTime DecayResetTime
|
public DateTime DecayResetTime
|
||||||
{
|
{
|
||||||
get => LookupCompactInfo()?.m_DecayReset ?? default;
|
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>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue