using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
namespace ProjectM.Simulation
{
///
/// Structure type ids (a byte, not an enum, per the cross-assembly enum-in-Burst hazard). Ids 1-4 are
/// RETIRED (EB-2 turret defense + M7 automation machines, deleted in the LANTERN purge) and stay reserved
/// so PlacedStructure.Type's [GhostField] serializer + old save bytes never re-mean.
///
public static class StructureType
{
public const byte None = 0;
// RETIRED ids — reserved, do not reuse:
public const byte Turret = 1;
public const byte Harvester = 2;
public const byte Fabricator = 3;
public const byte Conveyor = 4;
// Live buildables:
public const byte Wall = 5;
public const byte Pylon = 6;
}
///
/// A built base structure occupying one grid cell. An ownerless INTERPOLATED ghost (RegionTag{Base},
/// world-owned, runtime-spawned by BuildPlaceSystem). is the only replicated field
/// (a cheap byte for client visual branching); is server-only (clients derive it from
/// the replicated LocalTransform via , so it stays off the wire).
/// / are server-only raw NetworkTick values
/// (-guarded; 0 = inactive), kept for future timed structures (the turret
/// cooldown + production catch-up that used them are retired — LANTERN purge).
///
public struct PlacedStructure : IComponentData
{
/// Structure type (see ); the only replicated field.
[GhostField] public byte Type;
/// Occupied grid cell (server-only; clients derive it from LocalTransform).
public int2 Cell;
/// Next action tick (server-only). 0 = inactive.
public uint NextTick;
/// Last tick this structure was processed (server-only). Stamped at spawn.
public uint LastProcessedTick;
}
///
/// One row of the build catalog: cost + prefab per structure type. Modeled on AbilityPrefabElement
/// (prefab baked via GetEntity, NEVER inside a blob — blobs don't remap entity refs).
///
public struct StructureCatalogEntry : IBufferElementData
{
public byte Type;
public Entity Prefab;
public byte CostResourceId;
public int CostAmount;
}
/// Tag on the baked singleton carrying the buffer (the build cost/prefab table).
public struct StructureCatalog : IComponentData { }
///
/// Marks a structure PLACED by a player at runtime (BuildPlaceSystem) or restored from a save — i.e. the
/// persistable set, as opposed to anything baked into the subscene. SaveWriteSystem scans only these and
/// BaseRestoreSystem re-adds the tag, so save/restore is the single source of truth for player builds.
/// Server-only (not replicated). (Re-homed here from the retired automation components — LANTERN purge.)
///
public struct RuntimePlacedTag : IComponentData { }
}