Files
Project-M/Assets/_Project/Scripts/Authoring/Automation/HarvesterAuthoring.cs
T
kronic ba303e5fd0 Hygiene B3: single-sourcing & magic-number consolidation
- StructureCatalogAuthoring: WallCostOre -> WallCostBiomass (it bakes a Biomass cost; [FormerlySerializedAs] preserves the scene value).
- Harvester/Fabricator authoring: resource-id byte defaults reference ResourceId.Ore/.Charge instead of magic 2/4.
- RegionMath.RegionBoundaryX (= ExpeditionOffsetX*0.5) single-sources the region-flip X used by HudSystem + OnboardingSystem (was 500f in 3 places).
- CharacterComponent.DefaultGroundedSharpness single-sources the CC sharpness 15f (GetDefault, DashSystem, PlayerDeathStateSystem, PlayerCharacterAuthoring).
- InventorySlot [InternalBufferCapacity] references Tuning.InventoryMaxSlots.
- ConnectionMode enum -> byte-const class (project convention; removes the latent enum-in-Burst trap); field + one Seed() param become byte.
- Tuning.ChargerWindupTicks single-sources the Charger telegraph windup (EnemyBaker + TuningConfig.Defaults; was a bare 30 that could drift).
- (TicksPerSecond deliberately NOT added: no seconds->ticks conversion site exists; the tick-count fields are per-authoring designer tunables, so a const would be unreferenced.)

451/451 EditMode tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 23:29:43 -07:00

43 lines
1.7 KiB
C#

using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring for a Harvester machine ghost prefab (duplicate a structure ghost so the ownerless interpolated
/// GhostAuthoringComponent comes free). Bakes <see cref="PlacedStructure"/>{Type=Harvester} + <see cref="Harvester"/>
/// stats + an empty <see cref="MachineOutput"/> buffer. BuildPlaceSystem stamps the Cell at placement; the
/// production system initializes the tick baseline on first encounter (NextTick/LastProcessedTick baked 0).
/// </summary>
public class HarvesterAuthoring : MonoBehaviour
{
[Tooltip("Resource id this generator produces (1=Aether, 2=Ore, 3=Biomass).")]
public byte OutputResourceId = ResourceId.Ore;
[Min(1)] public int Yield = 1;
[Min(1)] public int PeriodTicks = 60;
private class HarvesterBaker : Baker<HarvesterAuthoring>
{
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<MachineOutput>(entity);
}
}
}
}