using Unity.Entities;
namespace ProjectM.Simulation
{
///
/// Server-world, UNMANAGED bridge holding a save slice the menu staged for a "Continue" session, applied
/// AT SPAWN by the server CycleDirectorSpawnSystem so the director ghost is BORN correct — it never
/// serializes an empty ledger to clients (no replication flicker). The menu creates exactly one of these
/// (with the buffer) in the freshly created ServerWorld BEFORE the
/// gameplay subscene streams in; the spawn system consumes + destroys it. Unmanaged so the Bursted spawn
/// system reads it without a managed bridge.
///
public struct PendingSave : IComponentData
{
/// v6: persisted run counters to restore into MetaCounters + the born-correct RunInfo HUD mirror.
public int RunsCompleted;
public int MaxDepthReached;
/// 0 = nothing staged (New Game); non-zero = apply the staged slice at director spawn.
public byte HasData;
}
/// One staged ledger row for a Continue session; copied into the director's StorageEntry buffer at spawn.
public struct PendingSaveLedgerRow : IBufferElementData
{
public ushort ItemId;
public int Count;
}
/// One staged PERMANENT meta tier for a Continue session (v6) — copied VERBATIM into the director's
/// replicated MetaTierState buffer at spawn (unknown ids preserved for round-trip; clamping happens only at
/// seed/shop/spend). The buffer is added UNCONDITIONALLY at staging (empty OK) — the Bursted spawn system
/// GetBuffers it inside the HasData block and a missing buffer would throw on any Continue.
public struct PendingMetaRow : IBufferElementData
{
public byte ClassId;
public byte UpgradeId;
public byte Tier;
}
/// One staged player-built structure row for a Continue session; BaseRestoreSystem replays it
/// charge-free into the freshly-streamed base. Mirrors but as an unmanaged ECS
/// buffer element (staged in the ServerWorld before the subscene streams).
public struct PendingStructure : IBufferElementData
{
public byte Type;
public int CellX;
public int CellZ;
public float HP; // EB-1: staged hit points (BaseRestoreSystem restores 0 -> baked Max)
}
///
/// Host-only autosave request flag on the director entity (added at spawn). RunDirectorSystem sets
/// =1 on the terminal bank; the managed SaveWriteSystem reads it, writes the JSON save,
/// and clears it. A plain byte => Burst-safe (no managed/string/file touch in the sim loop).
///
public struct SaveRequest : IComponentData
{
public byte Pending;
}
}