Core Game Loop Additions

This commit is contained in:
2026-06-03 22:41:27 -07:00
parent 79ff06a7df
commit 8e9b4412ce
70 changed files with 3084 additions and 2 deletions
@@ -0,0 +1,17 @@
using Unity.Entities;
namespace ProjectM.Simulation
{
/// <summary>
/// Tag marking the single GLOBAL shared-resource ledger — the entity whose [GhostField]
/// <see cref="StorageEntry"/> buffer holds harvested resources (Aether/ore/biomass) replicated to ALL
/// connections. It lives on the ownerless interpolated CycleDirector ghost, which carries NO
/// <see cref="RegionTag"/>, so GhostRelevancy (SetIsIrrelevant) keeps it relevant to players in EVERY
/// region — base AND expedition — unlike the region-tagged base storage container (which relevancy hides
/// from expedition players). Server systems resolve the ledger via
/// <c>GetSingletonEntity&lt;ResourceLedger&gt;()</c> then <c>GetBuffer&lt;StorageEntry&gt;()</c> — NEVER
/// <c>GetSingleton&lt;StorageEntry&gt;</c> (the base container owns a second StorageEntry buffer, so a
/// buffer-typed singleton query would throw "multiple instances").
/// </summary>
public struct ResourceLedger : IComponentData { }
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78ea3121ee0b2db4992b1a2c5dd8d34b
@@ -0,0 +1,21 @@
using Unity.Entities;
namespace ProjectM.Simulation
{
/// <summary>
/// Baked singleton holding the resource-node ghost prefab + field shape. ExpeditionFieldSystem reads it to
/// scatter <see cref="Count"/> nodes within <see cref="Radius"/> of the expedition region origin on each
/// Expedition phase entry (seeded by the cycle number). Mirrors <see cref="StorageSpawner"/>.
/// </summary>
public struct ResourceFieldSpawner : IComponentData
{
/// <summary>Baked resource-node ghost prefab to instantiate.</summary>
public Entity Prefab;
/// <summary>Number of nodes to scatter per expedition.</summary>
public int Count;
/// <summary>Scatter radius (world units) around the expedition region origin.</summary>
public float Radius;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 120cf21540ce86640b32921fa224b974
@@ -0,0 +1,41 @@
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>
/// 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;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d8504e2af2e9a694d9a7dc30c61cc69a