refactor(world): establish live entity composition seams
This commit is contained in:
parent
db5a11707d
commit
d68c83d1a5
5 changed files with 357 additions and 21 deletions
49
src/AcDream.App/World/LiveWorldOriginState.cs
Normal file
49
src/AcDream.App/World/LiveWorldOriginState.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
namespace AcDream.App.World;
|
||||
|
||||
/// <summary>
|
||||
/// Session-scoped owner of the landblock origin used to translate retail
|
||||
/// full-cell coordinates into the current streamed world coordinate system.
|
||||
/// A placeholder can exist before the first authoritative player position;
|
||||
/// <see cref="IsKnown"/> distinguishes it from a server-confirmed origin.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This owner is update/render-thread confined with the rest of live world
|
||||
/// mutation. It intentionally exposes no cross-thread snapshot contract.
|
||||
/// </remarks>
|
||||
internal sealed class LiveWorldOriginState
|
||||
{
|
||||
public int CenterX { get; private set; }
|
||||
public int CenterY { get; private set; }
|
||||
public bool IsKnown { get; private set; }
|
||||
|
||||
public void SetPlaceholder(int centerX, int centerY)
|
||||
{
|
||||
CenterX = centerX;
|
||||
CenterY = centerY;
|
||||
IsKnown = false;
|
||||
}
|
||||
|
||||
public bool TryInitialize(int centerX, int centerY)
|
||||
{
|
||||
if (IsKnown)
|
||||
return false;
|
||||
|
||||
CenterX = centerX;
|
||||
CenterY = centerY;
|
||||
IsKnown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Recenter(int centerX, int centerY)
|
||||
{
|
||||
CenterX = centerX;
|
||||
CenterY = centerY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the accepted-origin lifetime while retaining the last coordinates
|
||||
/// as the next placeholder. Consumers must gate them on
|
||||
/// <see cref="IsKnown"/> until the next accepted player position.
|
||||
/// </summary>
|
||||
public void Reset() => IsKnown = false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue