using ProjectM.Simulation; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// Authoring for a Harvester machine ghost prefab (duplicate a structure ghost so the ownerless interpolated /// GhostAuthoringComponent comes free). Bakes {Type=Harvester} + /// stats + an empty buffer. BuildPlaceSystem stamps the Cell at placement; the /// production system initializes the tick baseline on first encounter (NextTick/LastProcessedTick baked 0). /// public class HarvesterAuthoring : MonoBehaviour { [Tooltip("Resource id this generator produces (1=Aether, 2=Ore, 3=Biomass).")] public byte OutputResourceId = 2; // Ore [Min(1)] public int Yield = 1; [Min(1)] public int PeriodTicks = 60; private class HarvesterBaker : Baker { public override void Bake(HarvesterAuthoring authoring) { var entity = GetEntity(authoring, TransformUsageFlags.Dynamic); AddComponent(entity, new PlacedStructure { Type = StructureType.Harvester, Cell = default, NextTick = 0u, LastProcessedTick = 0u, }); AddComponent(entity, new Harvester { ResourceId = authoring.OutputResourceId, Yield = authoring.Yield, PeriodTicks = authoring.PeriodTicks, }); AddBuffer(entity); } } } }