73cfe2943d
Structures (Turret/Wall/Pylon) reuse the combat spine: authoring bakes Health(GhostField)+DamageEvent buffer+a Destructible tag (no HitRadius -> no friendly projectile fire; no EffectiveCharacterStats -> clamp-to-0). HealthApplyDamageSystem destroys a Destructible at 0 (occupancy auto-frees). EnemyAISystem fortress-targets the weighted-nearest of players+structures via the shared EnemyAIMath.PickWeightedNearest (StructureAggroWeight TuningConfig knob, <1 prefers structures, squared factor; snapshot above the early-return so an undefended base is razed). Persistence v3: per-structure HP threaded through 5 sites (SaveData/PendingStructure/scan-guarded/BaseRestore same-ECB born-correct/WorldLauncher via SaveApply.ToPending); SaveService floor-gate [2,3] loads old saves. Loss feedback: proximity-gated StructureFeedbackSystem; CombatFeedbackSystem suppressed for structures. Pre-code review caught the DamageEvent-buffer crash blocker + 8 majors; post-code review clean. See DR-032. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
2.7 KiB
C#
64 lines
2.7 KiB
C#
using Unity.Entities;
|
|
|
|
namespace ProjectM.Simulation
|
|
{
|
|
/// <summary>
|
|
/// 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 a default <see cref="GoalProgress"/> / empty ledger to clients (no replication flicker). The
|
|
/// menu creates exactly one of these (with the <see cref="PendingSaveLedgerRow"/> 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.
|
|
/// </summary>
|
|
public struct PendingSave : IComponentData
|
|
{
|
|
public int GoalCharge;
|
|
public int GoalTarget;
|
|
|
|
/// <summary>0 = nothing staged (New Game); non-zero = apply the staged slice at director spawn.</summary>
|
|
public byte HasData;
|
|
}
|
|
|
|
/// <summary>One staged ledger row for a Continue session; copied into the director's StorageEntry buffer at spawn.</summary>
|
|
public struct PendingSaveLedgerRow : IBufferElementData
|
|
{
|
|
public ushort ItemId;
|
|
public int Count;
|
|
}
|
|
/// <summary>One staged player-built structure row for a Continue session (M7); BaseRestoreSystem replays it
|
|
/// charge-free into the freshly-streamed base. Mirrors <see cref="StructureSave"/> but as an unmanaged ECS
|
|
/// buffer element (staged in the ServerWorld before the subscene streams).</summary>
|
|
public struct PendingStructure : IBufferElementData
|
|
{
|
|
public byte Type;
|
|
public int CellX;
|
|
public int CellZ;
|
|
public byte Direction;
|
|
public uint RemainingTicks;
|
|
public byte ConveyorResId;
|
|
public int ConveyorCount;
|
|
public float HP; // EB-1: staged hit points (BaseRestoreSystem restores 0 -> baked Max)
|
|
}
|
|
|
|
/// <summary>One staged machine I/O row (M7), joined to the <see cref="PendingStructure"/> buffer by index.
|
|
/// Slot 0 = MachineInput, 1 = MachineOutput.</summary>
|
|
public struct PendingStructureIo : IBufferElementData
|
|
{
|
|
public int StructureIndex;
|
|
public byte Slot;
|
|
public byte ResourceId;
|
|
public int Count;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Host-only autosave request flag on the CycleDirector entity (added at spawn). The Bursted CyclePhaseSystem
|
|
/// sets <see cref="Pending"/>=1 on the Siege->Calm checkpoint; 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).
|
|
/// </summary>
|
|
public struct SaveRequest : IComponentData
|
|
{
|
|
public byte Pending;
|
|
}
|
|
}
|