Files
Project-M/Assets/_Project/Scripts/Authoring/Economy/BlightClutterAuthoring.cs
T
kronic bbf418e779 Hazard: destructible cover — carve-able rocks that genuinely block until broken
Phase 1.5 long-term #8, the LAST 1.5 item (design review wf_e14dd739-069:
both HIGHs + the distinct MEDs verified before the session limit ate the
duplicate verifiers; unverified leftovers reasoned-closed in the spec).

Cover = a BlightClutter ghost (Variant 4) with a baked Environment-layer
BoxCollider: the runtime ghost's collider joins BuildPhysicsWorld ->
blocks the player CC and the enemy sweep while alive, and the gap opens
the instant the entity dies. Both hit paths already break it (the
clutter chassis); 8 hits to carve.

Review folds:
- HIGH: the 07-07 anti-stuck nudge would phase enemies THROUGH cover
  after ~1.5s (it exists to prevent room soft-locks). The nudge is now
  COVER-AWARE: a SphereCast identifies the blocker; a live BlightClutter
  ghost suppresses the phase (no soft-lock possible - the blocker is
  destructible); static-geometry wedges still nudge.
- HIGH: yield==durability made tanky cover an economy faucet. Deposit
  is DECOUPLED from the decrement at both hit sites: ScrapPerHit=0 =
  breaks in Remaining hits, yields NOTHING; fractional POSITIVE yields
  still credit >=1 (the B1 immortal-sink test pinned this - zero means
  zero, positive floors to 1).
- MEDs: HitRadius 1.2 (visual core, not a shot-eating disc), NO cover
  in Boss rooms (no boss depenetration backstop), scatter keep-out >=7u
  from the room origin (player landing + portal), Variant=4 explicit
  (the clutter block's explosive reroll cannot leak).
- Old static layer removed: 8 WorldColliders_RoomCover colliders
  (subscene) + the RoomCover_Visuals root (Game.unity).

Verified live: 3 cover ghosts spawned with SOLID baked colliders;
BLOCK - NudgeUntilTick stayed 0 across 3.5s of forced zero-progress
(old code arms at 1.5s); DEPENETRATE - an enemy shoved inside a live
rock exited to 1.7u (backstop holds against ghost colliders); CARVE -
the rock died to the real sweep and the spot probed OPEN. 470/470
EditMode; console clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 16:15:38 -07:00

46 lines
2.1 KiB
C#

using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring for a Blight-clutter ghost prefab (ownerless interpolated — duplicate from ResourceNode.prefab
/// so the GhostAuthoringComponent comes free). Bakes <see cref="BlightClutter"/> + <see cref="HitRadius"/>
/// (reused for the harvest/clear sweep) + <see cref="RegionTag"/>{Expedition} so GhostRelevancy scopes it to
/// expedition players. The field spawner overrides Variant (round-robin) + Position per instance. Defaults are
/// inline here (mirrors ResourceNodeAuthoring), not in Tuning.
/// </summary>
public class BlightClutterAuthoring : MonoBehaviour
{
[Tooltip("Hit-points before the clutter shatters.")]
[Min(1)] public int Remaining = 2; // one-hit pop: both hit paths decrement by max(1,(int)ScrapPerHit)
[Tooltip("Scrap (Biomass) yielded per hit. 0 = DESTRUCTIBLE COVER semantics: breaks in Remaining hits, yields nothing (deposit is decoupled from the decrement at both hit sites).")]
[Min(0f)] public float ScrapPerHit = 2f;
[Tooltip("Hit radius (world units) for the clear sweep.")]
[Min(0f)] public float HitRadius = 1.0f;
[Tooltip("Default visual variant (the spawner round-robins this per piece).")]
public byte Variant = 0;
private class BlightClutterBaker : Baker<BlightClutterAuthoring>
{
public override void Bake(BlightClutterAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
AddComponent(entity, new BlightClutter
{
Remaining = authoring.Remaining,
Variant = authoring.Variant,
ScrapResourceId = ResourceId.Biomass,
ScrapPerHit = authoring.ScrapPerHit,
});
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
AddComponent(entity, new RegionTag { Region = RegionId.Expedition });
}
}
}
}