refactor(net): converge live session state reset
This commit is contained in:
parent
78a9223b65
commit
4f31a5085f
35 changed files with 1460 additions and 83 deletions
|
|
@ -454,6 +454,39 @@ public sealed class LocalPlayerState
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the character snapshot to its pre-login state. The object itself
|
||||
/// is process-lived because UI view models subscribe to it once; session
|
||||
/// replacement clears its contents instead of replacing the owner.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Retail: <c>CPlayerSystem::OnEndCharacterSession @ 0x00562870</c>
|
||||
/// calls <c>End @ 0x005606C0</c>, which invokes
|
||||
/// <c>PlayerModule::Clear @ 0x005D48A0</c>, then immediately calls
|
||||
/// <c>CPlayerSystem::Begin @ 0x0055D410</c>. Re-publishing invalidation
|
||||
/// events is acdream's process-lived-view adaptation.
|
||||
/// </remarks>
|
||||
public void Clear()
|
||||
{
|
||||
_health = null;
|
||||
_stamina = null;
|
||||
_mana = null;
|
||||
_attrs.Clear();
|
||||
_skills.Clear();
|
||||
_positions.Clear();
|
||||
_properties = new PropertyBundle();
|
||||
|
||||
// Process-lived views pull through this object and use these events as
|
||||
// their invalidation edge. Publish every category even when Clear is
|
||||
// repeated so a failed reset attempt can safely converge on retry.
|
||||
Changed?.Invoke(VitalKind.Health);
|
||||
Changed?.Invoke(VitalKind.Stamina);
|
||||
Changed?.Invoke(VitalKind.Mana);
|
||||
foreach (AttributeKind kind in Enum.GetValues<AttributeKind>())
|
||||
AttributeChanged?.Invoke(kind);
|
||||
CharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
private static uint SaturatingAdd(uint value, uint delta)
|
||||
=> uint.MaxValue - value < delta ? uint.MaxValue : value + delta;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue