Files
Project-M/Assets/_Project/Scripts/Authoring/Economy/BlightClutterAuthoring.cs
T
kronic 53bc21143d Feel: breakable clutter reads as Hades-style barrels, one-hit pop
The BlightClutter destructible-ghost chain (per-room seeding, unified
DR-018-safe sweep, melee + projectile breaking, personal-inventory
drops) already existed end-to-end - the roadmap item's gap was FEEL:

- Visual: prefab Model mesh swapped SM_Env_Rock_Chunk_01 (read as
  scenery) -> SM_Prop_Barrel_01 (FantasyKingdom, same proven atlas
  material). Base-pivot barrel offset -1 on the Model child (scatter
  y=1 is the capsule plane - the base-pivot float gotcha).
- One-hit pop: prefab Remaining 8 -> 2 (both hit paths decrement by
  max(1,(int)ScrapPerHit)=2, so one swing/shot shatters); authoring
  default kept in sync.
- Density: MaxClutterPerRoom 6 -> 8.

Verified live: 8 barrels seeded in a combat room, grounded (screenshot);
an injected projectile through the real ResourceHarvestSystem sweep
popped one barrel in ONE hit (8 -> 7) and credited 2 Biomass; 466/466
EditMode, console clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 22:14:43 -07:00

46 lines
2.0 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 projectile hit — the 'minor scrap' trickle.")]
[Min(1f)] 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 });
}
}
}
}