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>
116 lines
7.0 KiB
C#
116 lines
7.0 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring for the player ghost prefab. As of M3 the numeric tunables live in data
|
|
/// (<see cref="CharacterStatsDefinition"/> / <see cref="AbilityDefinition"/> ScriptableObjects);
|
|
/// this authoring only selects which definitions the player uses and bakes the light id refs, the
|
|
/// (empty) replicated modifier buffer, and the zeroed effective-stat components that
|
|
/// StatRecomputeSystem fills each predicted tick. Health is seeded from the character definition's
|
|
/// MaxHealth (single source). Ghost replication, <c>GhostOwner</c> and AutoCommandTarget come from
|
|
/// the GhostAuthoringComponent on the same prefab GameObject; <c>GetEntity(TransformUsageFlags.Dynamic)</c>
|
|
/// ensures a runtime-mutable LocalTransform exists.
|
|
/// </summary>
|
|
public class PlayerAuthoring : MonoBehaviour
|
|
{
|
|
[Tooltip("Character-stats definition (move speed, turn rate, max health). Single source of those values.")]
|
|
public CharacterStatsDefinition Character;
|
|
|
|
[Header("Fallbacks (used only if a definition above is unassigned)")]
|
|
[Min(0f)] public float FallbackMaxHealth = 100f;
|
|
|
|
/// <summary>Projectile hit-test radius for the player as a damageable target, in world units.</summary>
|
|
[Min(0f)] public float HitRadius = 0.6f;
|
|
|
|
[Min(1)]
|
|
[Tooltip("Ticks the player stays down before respawning at base (~60 ticks/sec).")]
|
|
public int RespawnDelayTicks = 180;
|
|
|
|
[Min(0)]
|
|
[Tooltip("Ticks of post-respawn damage immunity (~60 ticks/sec).")]
|
|
public int RespawnInvulnTicks = 120;
|
|
|
|
private class PlayerBaker : Baker<PlayerAuthoring>
|
|
{
|
|
public override void Bake(PlayerAuthoring authoring)
|
|
{
|
|
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
|
|
|
// Re-bake when the referenced definition's serialized values change.
|
|
if (authoring.Character != null) DependsOn(authoring.Character);
|
|
|
|
byte characterId = authoring.Character != null
|
|
? (byte)authoring.Character.Id : (byte)FrameKind.Default;
|
|
float maxHealth = authoring.Character != null
|
|
? authoring.Character.MaxHealth : authoring.FallbackMaxHealth;
|
|
|
|
AddComponent<PlayerTag>(entity);
|
|
AddComponent<PlayerFacing>(entity);
|
|
AddComponent<PlayerInput>(entity);
|
|
|
|
// Data-driven stat ref (replaces M2's inlined PlayerMoveStats values); the ability model is the
|
|
// 4-socket kit below (the legacy AbilityRef/DefaultAbility/EffectiveAbilityStats bakes are deleted).
|
|
AddComponent(entity, new CharacterStatsRef { Id = characterId });
|
|
|
|
// Effective stats: zeroed at bake, recomputed every predicted tick by StatRecomputeSystem.
|
|
AddComponent(entity, new EffectiveCharacterStats());
|
|
|
|
// Empty replicated modifier stack (grown by upgrades/pickups/debug hook, server-authoritative).
|
|
AddBuffer<StatModifier>(entity);
|
|
// 2026-08-07 audit purge: the replicated personal InventorySlot bag and the EquipmentSlot loadout
|
|
// went with the shell (CLAUDE.md already recorded inventory/equipment as PAUSED). Harvest now
|
|
// credits the shared ledger directly.
|
|
// Server-only expiry tracker for timed buffs (paired with a StatModifier by SourceId; not replicated).
|
|
AddBuffer<TimedModifier>(entity);
|
|
|
|
// Combat: server-authoritative health (Current replicated for display), the player's
|
|
// damageable hit radius, predicted cooldown state, and the per-tick damage inbox.
|
|
AddComponent(entity, new Health { Current = maxHealth, Max = maxHealth });
|
|
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
|
AddBuffer<DamageEvent>(entity);
|
|
// MC-1 dash: predicted dash window (derived from PlayerInput.Dash) + cooldown gate, baked idle/ready.
|
|
AddComponent<DashState>(entity);
|
|
AddComponent(entity, new DashCooldown { NextTick = 0 });
|
|
AddComponent<BlinkState>(entity); // LANTERN Blink: predicted blink window (Movement-archetype Spark), baked idle
|
|
// MC-4 melee combo: predicted, owner-replicated combo anchor (Step/SwingStartTick/LockUntilTick), baked idle/zero.
|
|
AddComponent<MeleeCombo>(entity);
|
|
AddComponent<MeleeCleavePending>(entity); // 07-20 G2.1: server-only scheduled cleave (baked zeroed, not replicated)
|
|
AddComponent<ConeContactPending>(entity); // 07-21 G6: server-only scheduled Cone-socket slam (baked zeroed, not replicated)
|
|
|
|
// Death gate (enableable, derived from Health by PlayerDeathStateSystem) baked DISABLED = alive;
|
|
// plus the server-only respawn timer.
|
|
AddComponent<Dead>(entity);
|
|
SetComponentEnabled<Dead>(entity, false);
|
|
// Dev god-mode gate (enableable, server-only) baked DISABLED so toggling it is a bit flip, never structural.
|
|
AddComponent<DebugGodMode>(entity);
|
|
SetComponentEnabled<DebugGodMode>(entity, false);
|
|
|
|
AddComponent(entity, new RespawnState { RespawnTick = 0, DelayTicks = authoring.RespawnDelayTicks, InvulnTicks = authoring.RespawnInvulnTicks });
|
|
AddComponent(entity, new RespawnInvuln { UntilTick = 0 });
|
|
|
|
// 2026-08-07 audit purge: PlayerReady (ready-check), BoonOffer/BoonEffects (Phase-1.7 boons) and
|
|
// DashTrailState (Blade Dash) were baked onto every player ghost for the superseded base/expedition
|
|
// loop. All four are gone; the ghost archetype shrinks accordingly.
|
|
// LANTERN Phase 1 (Step 1): 4-socket kit data model — THE ability model (the legacy single
|
|
// AbilityRef/AbilityCooldown path is deleted). AbilitySocket = cold per-socket loadout
|
|
// (EquipmentSlot-modelled, 4 empty rows; GoInGameServerSystem seeds the frame loadout at spawn);
|
|
// SocketCooldown = hot owner-predicted per-socket cooldown; FrameId = replicated frame/class signal
|
|
// (baked 0, written server-side at frame select).
|
|
var sockets = AddBuffer<AbilitySocket>(entity);
|
|
for (int sk = 0; sk < SocketId.Count; sk++)
|
|
sockets.Add(new AbilitySocket { SparkId = 0 });
|
|
AddComponent<SocketCooldown>(entity);
|
|
AddComponent<FrameId>(entity);
|
|
// Step 1b: per-socket effective-stats buffer (4 rows), folded each predicted tick by StatRecomputeSystem.
|
|
var effSockets = AddBuffer<EffectiveSocketStats>(entity);
|
|
for (int sk2 = 0; sk2 < SocketId.Count; sk2++)
|
|
effSockets.Add(new EffectiveSocketStats());
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|