using ProjectM.Simulation; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// Authoring for the home-base mining field (). Place ONE in the gameplay /// subscene. = the SAME ResourceNode ghost prefab the expedition uses; the server /// system overrides each instance to RegionTag{Base} + ResourceId.Ore and scatters them in the /// [, ] annulus around the base plot center. Defaults are /// sized to the baked 32x32 plot (square corner reach ~22.6) inside the ~28.7 boundary ring, so nodes form a /// reachable perimeter ring that never sits on a build cell. /// public class BaseFieldSpawnerAuthoring : MonoBehaviour { [Tooltip("Resource-node ghost prefab (ResourceNodeAuthoring + GhostAuthoring). Reuse the expedition node prefab.")] public GameObject NodePrefab; [Tooltip("Live base-node target; the field refills toward this each respawn pass.")] [Min(1)] public int TargetCount = 10; [Tooltip("Inner scatter radius — clears the build plot corner reach (~22.6) + spawn ring.")] [Min(0f)] public float InnerRadius = 23.5f; [Tooltip("Outer scatter radius — stays inside the walkable boundary ring (~28.7).")] [Min(0f)] public float OuterRadius = 27f; [Tooltip("Server ticks (@60) between top-up passes.")] [Min(1)] public int RespawnIntervalTicks = 600; private class BaseFieldSpawnerBaker : Baker { public override void Bake(BaseFieldSpawnerAuthoring authoring) { var entity = GetEntity(authoring, TransformUsageFlags.None); AddComponent(entity, new BaseFieldSpawner { Prefab = authoring.NodePrefab != null ? GetEntity(authoring.NodePrefab, TransformUsageFlags.Dynamic) : Entity.Null, TargetCount = authoring.TargetCount, InnerRadius = authoring.InnerRadius, OuterRadius = authoring.OuterRadius, RespawnIntervalTicks = authoring.RespawnIntervalTicks, }); AddComponent(entity, new BaseFieldRuntime { Epoch = 0, NextSpawnTick = 0u }); } } } }