feat(runtime): define borrowed views commands and ordered events
Establish the J1 presentation-independent contract with instance-scoped clocks and generations, immutable borrowed views, typed generation-gated commands, normalized ordered diagnostics, and teardown acknowledgements. Route graphical startup plus press-time selection, movement, and combat through focused App adapters over the exact existing owners without adding a queue or mirrored world. Validated by the Release solution build, 13 Runtime tests, 3,838 App tests with three existing skips, and the complete 8,424-test Release suite with five existing skips. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
afebbe3eca
commit
854d9e9cd1
21 changed files with 2594 additions and 44 deletions
142
src/AcDream.Runtime/GameRuntimeViews.cs
Normal file
142
src/AcDream.Runtime/GameRuntimeViews.cs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
using AcDream.Core.Physics;
|
||||
|
||||
namespace AcDream.Runtime;
|
||||
|
||||
public readonly record struct RuntimeEntityIdentity(
|
||||
uint ServerGuid,
|
||||
uint LocalEntityId,
|
||||
ushort Incarnation);
|
||||
|
||||
public readonly record struct RuntimeEntitySnapshot(
|
||||
RuntimeEntityIdentity Identity,
|
||||
uint CellId,
|
||||
uint PhysicsState,
|
||||
Position? Position,
|
||||
bool IsMaterialized,
|
||||
bool IsSpatiallyVisible,
|
||||
bool IsHydrated);
|
||||
|
||||
public interface IRuntimeEntityVisitor
|
||||
{
|
||||
void Visit(in RuntimeEntitySnapshot entity);
|
||||
}
|
||||
|
||||
public interface IRuntimeEntityView
|
||||
{
|
||||
int Count { get; }
|
||||
|
||||
int MaterializedCount { get; }
|
||||
|
||||
bool TryGet(uint serverGuid, out RuntimeEntitySnapshot entity);
|
||||
|
||||
/// <summary>
|
||||
/// Visits the canonical owner synchronously without copying its mutable
|
||||
/// collection. The visitor must not retain references or mutate runtime
|
||||
/// ownership during the call.
|
||||
/// </summary>
|
||||
void Visit(IRuntimeEntityVisitor visitor);
|
||||
}
|
||||
|
||||
public readonly record struct RuntimeInventoryItemSnapshot(
|
||||
uint ObjectId,
|
||||
ushort Incarnation,
|
||||
string Name,
|
||||
uint ContainerId,
|
||||
int ContainerSlot,
|
||||
uint WielderId,
|
||||
uint EquipLocation,
|
||||
int StackSize,
|
||||
int Value);
|
||||
|
||||
public interface IRuntimeInventoryVisitor
|
||||
{
|
||||
void Visit(in RuntimeInventoryItemSnapshot item);
|
||||
}
|
||||
|
||||
public interface IRuntimeInventoryView
|
||||
{
|
||||
int ObjectCount { get; }
|
||||
|
||||
int ContainerCount { get; }
|
||||
|
||||
bool TryGet(uint objectId, out RuntimeInventoryItemSnapshot item);
|
||||
|
||||
/// <inheritdoc cref="IRuntimeEntityView.Visit"/>
|
||||
void Visit(IRuntimeInventoryVisitor visitor);
|
||||
}
|
||||
|
||||
public interface IRuntimeChatView
|
||||
{
|
||||
long Revision { get; }
|
||||
|
||||
int Count { get; }
|
||||
}
|
||||
|
||||
public readonly record struct RuntimeMovementSnapshot(
|
||||
bool HasController,
|
||||
uint LocalEntityId,
|
||||
Position Position,
|
||||
System.Numerics.Vector3 Velocity,
|
||||
bool IsAirborne,
|
||||
double SimulationTimeSeconds);
|
||||
|
||||
public interface IRuntimeMovementView
|
||||
{
|
||||
RuntimeMovementSnapshot Snapshot { get; }
|
||||
}
|
||||
|
||||
public enum RuntimePortalKind
|
||||
{
|
||||
None,
|
||||
Login,
|
||||
Portal,
|
||||
}
|
||||
|
||||
public readonly record struct RuntimePortalSnapshot(
|
||||
long Generation,
|
||||
RuntimePortalKind Kind,
|
||||
uint DestinationCell,
|
||||
bool IsReady,
|
||||
bool IsMaterialized,
|
||||
bool IsCompleted,
|
||||
bool IsCancelled,
|
||||
bool IsWorldVisible);
|
||||
|
||||
public interface IRuntimePortalView
|
||||
{
|
||||
RuntimePortalSnapshot Snapshot { get; }
|
||||
}
|
||||
|
||||
public readonly record struct RuntimeStateCheckpoint(
|
||||
RuntimeGenerationToken Generation,
|
||||
RuntimeLifecycleState Lifecycle,
|
||||
ulong FrameNumber,
|
||||
int EntityCount,
|
||||
int MaterializedEntityCount,
|
||||
int InventoryObjectCount,
|
||||
int InventoryContainerCount,
|
||||
long ChatRevision,
|
||||
int ChatCount,
|
||||
RuntimeMovementSnapshot Movement,
|
||||
RuntimePortalSnapshot Portal);
|
||||
|
||||
public interface IGameRuntimeView
|
||||
{
|
||||
RuntimeGenerationToken Generation { get; }
|
||||
|
||||
RuntimeLifecycleSnapshot Lifecycle { get; }
|
||||
|
||||
IGameRuntimeClock Clock { get; }
|
||||
|
||||
IRuntimeEntityView Entities { get; }
|
||||
|
||||
IRuntimeInventoryView Inventory { get; }
|
||||
|
||||
IRuntimeChatView Chat { get; }
|
||||
|
||||
IRuntimeMovementView Movement { get; }
|
||||
|
||||
IRuntimePortalView Portal { get; }
|
||||
|
||||
RuntimeStateCheckpoint CaptureCheckpoint();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue