Files
Project-M/Assets/_Project/Scripts/Authoring/Automation/HarvesterAuthoring.cs
T
kronic 21a4c71413 Hygiene B4c: clean dedup helpers (knockback, bakers, editor rig)
- KnockbackUtil.Stamp: shared knockback-stamp used by AbilityFireSystem + MeleeComboSystem (guard + planar normalize + write; speed passed in).
- BakerStructureExt: AddPlacedStructure/AddDamageable extensions on Baker<T>; rewired Turret/Structure/Harvester/Conveyor/Fabricator bakers (baked data + serialized fields unchanged).
- EnemyPrefabBakeExt.AddEnemyPrefabPool: shared prefab-buffer bake for ZoneEnemyDirector/WaveDirector authoring (fields stay flat — no serialization change).
- Editor AnimRigUtil (HasParam + root-yaw overlay clip) shared by PlayerRigTools/EnemyRigTools; EnemyRigTools.MakeMat now GUID-preserving (CopySerialized over existing) — the composite AnimatorController copy left as-is with a caveat comment.

466/466 EditMode tests pass, 0 warnings.

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

37 lines
1.5 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);
this.AddPlacedStructure(entity, StructureType.Harvester);
AddComponent(entity, new Harvester
{
ResourceId = authoring.OutputResourceId,
Yield = authoring.Yield,
PeriodTicks = authoring.PeriodTicks,
});
AddBuffer<MachineOutput>(entity);
}
}
}
}