Files
Project-M/Assets/_Project/Scripts/Simulation/Economy/ResourceNode.cs
T
kronic 2da29783fd EB-2: felt spend - turrets burn a shared Charge pool, ledger-fed Fabricator mints it from Ore
Mined Ore now has an ongoing sink: a ledger-fed Fabricator converts Ore->Charge
(1 Ore -> 3 Charge / 30t) and turrets spend Charge per shot, soft-failing (no
shot, no cooldown burn) when the shared pool runs dry.

- ResourceId.Charge=4 rides the existing [GhostField] StorageEntry ledger (no new wire).
- TurretFireSystem: single ledger resolve + atomic spend / soft-fail / partial-refund.
- Fabricator.InputFromLedger (byte, server-only) feeds input from the shared ledger,
  read live in-loop so two machines split a finite pool; both modes deposit to ledger.
- HudSystem: violet Charge chip + global quiet-turret cue when siege && Charge==0.
- StorageMath.TotalOf backs the affordability read; catalog re-enables the Fabricator (4 entries).

See DR-033.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 19:14:52 -07:00

45 lines
1.9 KiB
C#

using Unity.Entities;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>Resource-type ids for harvested materials (a byte, not an enum, per the cross-assembly enum-in-Burst hazard).</summary>
public static class ResourceId
{
/// <summary>Unused / empty sentinel (aligns with StorageMath's 0-itemId no-op).</summary>
public const byte None = 0;
/// <summary>Magic energy — powers abilities / charging.</summary>
public const byte Aether = 1;
/// <summary>Raw ore — structures / building.</summary>
public const byte Ore = 2;
/// <summary>Biomass — misc / crafting.</summary>
public const byte Biomass = 3;
/// <summary>EB-2 turret munition ("Charge") — a ledger-only ammo currency a ledger-fed Fabricator mints from Ore.</summary>
public const byte Charge = 4;
}
/// <summary>
/// A harvestable resource node in the procedural expedition field — an ownerless INTERPOLATED ghost
/// (region-tagged Expedition) that clients see and shoot. The server-only ResourceHarvestSystem sweeps
/// projectiles against it; each hit deposits <see cref="HarvestPerHit"/> of <see cref="ResourceId"/> into
/// the GLOBAL resource ledger and decrements <see cref="Remaining"/>; the node despawns at &lt;= 0.
/// ResourceId/Remaining are [GhostField] so clients can tint by type and (later) show depletion;
/// HarvestPerHit is baked, server-only.
/// </summary>
public struct ResourceNode : IComponentData
{
/// <summary>Which resource this node yields (see <see cref="ResourceId"/>).</summary>
[GhostField] public byte ResourceId;
/// <summary>Remaining resource units; the node despawns when this reaches 0.</summary>
[GhostField] public int Remaining;
/// <summary>Units yielded per projectile hit (baked; server-only).</summary>
public float HarvestPerHit;
}
}