using Unity.Entities;
namespace ProjectM.Simulation
{
///
/// Shared harvest-yield deposit routing used by BOTH the projectile-sweep harvest (ResourceHarvestSystem) and
/// the melee-cone harvest (MeleeComboSystem), so the two can't drift. (They previously did: the melee path
/// hard-coded a stack cap and silently ignored per-item limits.) All yield credits the shared
/// directly.
///
/// HISTORY (2026-08-07 audit purge): yield used to route to a PERSONAL InventorySlot bag for expedition-region
/// targets and spill to the ledger. The inventory/equipment layer was already marked PAUSED in CLAUDE.md and
/// belonged to the superseded base/expedition direction, so it was deleted along with the shell; harvest is now
/// single-sink. When LANTERN's carried-vs-banked cargo distinction lands (Phase 2), reintroduce the second sink
/// here rather than at the two call sites — that is the whole point of this class.
///
public static class HarvestMath
{
///
/// Routes one harvested yield to the shared ledger. Returns true if the yield landed somewhere; callers use
/// this to avoid consuming a target for zero credit (e.g. no ledger singleton present).
/// is only touched when is true.
///
public static bool DepositYield(byte yieldId, int amount, DynamicBuffer ledger, bool haveLedger)
{
if (amount <= 0 || !haveLedger)
return false;
StorageMath.Deposit(ledger, yieldId, amount);
return true;
}
}
}