Files
Project-M/Assets/_Project/Scripts/Simulation/Building/StructureComponents.cs
T
kronic 835dace213 LANTERN purge B2: delete EB-2 turret defense
TurretFireSystem, TurretAuthoring, Turret.prefab, Turret component, turret cap,
B hotkey, HUD Charge chip + out-of-ammo cue, catalog entry, Tuning consts, tests
(-7, 452 green). StructureType.Turret byte + ResourceId.Charge stay reserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 14:40:12 -07:00

73 lines
3.3 KiB
C#

using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// 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.
/// </summary>
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;
}
/// <summary>
/// A built base structure occupying one grid cell. An ownerless INTERPOLATED ghost (RegionTag{Base},
/// world-owned, runtime-spawned by BuildPlaceSystem). <see cref="Type"/> is the only replicated field
/// (a cheap byte for client visual branching); <see cref="Cell"/> is server-only (clients derive it from
/// the replicated LocalTransform via <see cref="BaseGridMath.WorldToCell"/>, so it stays off the wire).
/// <see cref="NextTick"/> / <see cref="LastProcessedTick"/> are server-only raw NetworkTick values
/// (<see cref="TickUtil.NonZero"/>-guarded; 0 = inactive), kept for future timed structures (the turret
/// cooldown + production catch-up that used them are retired — LANTERN purge).
/// </summary>
public struct PlacedStructure : IComponentData
{
/// <summary>Structure type (see <see cref="StructureType"/>); the only replicated field.</summary>
[GhostField] public byte Type;
/// <summary>Occupied grid cell (server-only; clients derive it from LocalTransform).</summary>
public int2 Cell;
/// <summary>Next action tick (server-only). 0 = inactive.</summary>
public uint NextTick;
/// <summary>Last tick this structure was processed (server-only). Stamped at spawn.</summary>
public uint LastProcessedTick;
}
/// <summary>
/// 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).
/// </summary>
public struct StructureCatalogEntry : IBufferElementData
{
public byte Type;
public Entity Prefab;
public byte CostResourceId;
public int CostAmount;
}
/// <summary>Tag on the baked singleton carrying the <see cref="StructureCatalogEntry"/> buffer (the build cost/prefab table).</summary>
public struct StructureCatalog : IComponentData { }
/// <summary>
/// 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.)
/// </summary>
public struct RuntimePlacedTag : IComponentData { }
}