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);
public interface IRuntimeEntityVisitor
{
void Visit(in RuntimeEntitySnapshot entity);
}
public interface IRuntimeEntityView
{
int Count { get; }
bool TryGet(uint serverGuid, out RuntimeEntitySnapshot entity);
///
/// Visits the canonical owner synchronously without copying its mutable
/// collection. The visitor must not retain references or mutate runtime
/// ownership during the call.
///
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);
///
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();
}