62e48a3b0b
The 2026-08-06 audit found the shipping scene was still the abandoned co-op-Hades game with LANTERN combat bolted on, and that a third of the codebase was live code for a direction abandoned on 2026-07-13. Operator chose deletion over freezing: "everything is saved in source control if needed. I want the project to be clean." DELETED (~140 source files, Scripts 335->231, Tests 77->43): - Enemy variants + boss (H3). ChargerAuthoring / SpitterAuthoring / SwarmerAuthoring were attached to ZERO prefabs, so LungeState / SpitterState / SwarmerTag were never baked: ~272 lines of Bursted AI passes, BossAISystem (261 lines) and the whole MixBands escalation curve could not match a single chunk at runtime, while 734 lines of green tests certified them. Both shipping enemy prefabs were already byte-identical in stats. - Run/room lifecycle: RunDirector FSM, RunInfo/RunMap/RoomPlan/RoomTag, route select, portal interact, ready-check, room field/teardown. - Meta shop, prep loadout, boons (incl. KillRewardSystem and DashTrailDamageSystem, which existed only to serve boon flags). - Build palette + structures, shared storage, inventory/equipment (already recorded PAUSED in CLAUDE.md). - The HUD panels driving all of the above (HudSystem 1168 -> 610). KEPT deliberately: BaseGridMath + BaseAnchor (8 systems use PlotCenter for spawn rings, respawn and dynamic light), the resource ledger + StorageMath, the save system, region/relevancy. Three of these were in the delete set until I checked their consumers — worth remembering that the file-level manifest was wrong about them. Also folds in audit finding M5: PlayerClass was a second, server-only copy of the byte FrameId already replicates. It existed for the meta shop; with that gone, FrameId is the single frame identity. Harvest is now single-sink (ledger). HarvestMath keeps its shape so LANTERN's carried-vs-banked cargo split lands in one place, not two. 295/295 EditMode green, zero compile errors. Subscene re-bake and Play validation follow in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
91 lines
4.4 KiB
C#
91 lines
4.4 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Burst;
|
|
using Unity.Collections;
|
|
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
using Unity.Transforms;
|
|
|
|
namespace ProjectM.Server
|
|
{
|
|
/// <summary>
|
|
/// Server-only, one-shot spawner for the GLOBAL director ghost (mirrors SharedStorageSpawnSystem, but MINUS
|
|
/// the RegionTag — the director must stay global so GhostRelevancy keeps it relevant to every region). On its
|
|
/// first update it reads the baked <see cref="CycleDirectorSpawner"/> + NetworkTime, instantiates the ghost
|
|
/// — the shared-ledger / RunInfo / meta host (its old cycle/siege/goal/core state is retired, LANTERN purge) —
|
|
/// applies a menu-staged save born-correct, and places it at the base center (preserving the prefab's baked
|
|
/// LocalTransform scale — FromPosition would reset the replicated Scale GhostField), then destroys the
|
|
/// spawner so it idles.
|
|
/// </summary>
|
|
[BurstCompile]
|
|
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
|
public partial struct CycleDirectorSpawnSystem : ISystem
|
|
{
|
|
[BurstCompile]
|
|
public void OnCreate(ref SystemState state)
|
|
{
|
|
state.RequireForUpdate<CycleDirectorSpawner>();
|
|
state.RequireForUpdate<NetworkTime>();
|
|
}
|
|
|
|
[BurstCompile]
|
|
public void OnUpdate(ref SystemState state)
|
|
{
|
|
var serverTick = SystemAPI.GetSingleton<NetworkTime>().ServerTick;
|
|
if (!serverTick.IsValid)
|
|
return;
|
|
|
|
var spawnerEntity = SystemAPI.GetSingletonEntity<CycleDirectorSpawner>();
|
|
var spawner = SystemAPI.GetComponent<CycleDirectorSpawner>(spawnerEntity);
|
|
|
|
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
|
|
|
if (spawner.Prefab != Entity.Null)
|
|
{
|
|
var director = ecb.Instantiate(spawner.Prefab);
|
|
|
|
// Place at the base center, preserving the prefab's baked scale/rotation.
|
|
var xform = SystemAPI.GetComponent<LocalTransform>(spawner.Prefab);
|
|
if (SystemAPI.TryGetSingleton<BaseAnchor>(out var anchor))
|
|
xform.Position = BaseGridMath.PlotCenter(anchor);
|
|
ecb.SetComponent(director, xform);
|
|
|
|
// Born-correct load: if the menu staged a save (Continue), apply the ledger AT SPAWN so the
|
|
// director ghost never serializes an empty ledger to clients (no replication flicker).
|
|
//
|
|
// 2026-08-07 audit purge: this block also seeded RunRuntime (HostSalt), RouteCommand,
|
|
// PortalCommand, MetaCounters, MetaTierState and a born-correct RunInfo mirror. All of that was
|
|
// the superseded base/expedition run-FSM and meta shop; the director now hosts exactly one thing
|
|
// — the global resource ledger.
|
|
bool restoredLedger = false;
|
|
if (SystemAPI.TryGetSingletonEntity<PendingSave>(out var pendingEntity))
|
|
{
|
|
var pending = SystemAPI.GetComponent<PendingSave>(pendingEntity);
|
|
if (pending.HasData != 0)
|
|
{
|
|
var srcLedger = SystemAPI.GetBuffer<PendingSaveLedgerRow>(pendingEntity);
|
|
var destLedger = ecb.SetBuffer<StorageEntry>(director);
|
|
SaveApply.WriteLedger(srcLedger, destLedger);
|
|
restoredLedger = true; // a save restored the ledger -> do NOT seed starting Ore
|
|
}
|
|
ecb.DestroyEntity(pendingEntity);
|
|
}
|
|
|
|
// DR-042 C6c: NEW game only (no restored ledger) -> seed a little Ore so the build loop isn't a
|
|
// cold start with nothing to place. Appended BEFORE Playback so the ghost first-serializes WITH
|
|
// the seed (no empty-ledger replication flicker).
|
|
if (!restoredLedger)
|
|
ecb.AppendToBuffer(director, new StorageEntry { ItemId = ResourceId.Ore, Count = Tuning.StartingOre });
|
|
|
|
// Host-only autosave flag; SaveWriteSystem consumes it (RunDirectorSystem raises it on bank).
|
|
ecb.AddComponent(director, new SaveRequest { Pending = 0 });
|
|
}
|
|
|
|
// One-shot: remove the spawner so RequireForUpdate fails and the system idles.
|
|
ecb.DestroyEntity(spawnerEntity);
|
|
|
|
ecb.Playback(state.EntityManager);
|
|
ecb.Dispose();
|
|
}
|
|
}
|
|
}
|