using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
///
/// Authoring for a resource-node ghost prefab (ownerless interpolated — duplicate from UpgradePickup.prefab
/// so the GhostAuthoringComponent comes free). Bakes +
/// (reused for the harvest hit test) + {Expedition} so GhostRelevancy scopes the node
/// to expedition players. The field spawner overrides ResourceId (round-robin) and Position per instance.
///
public class ResourceNodeAuthoring : MonoBehaviour
{
public enum ResourceKind : byte { Aether = 1, Ore = 2, Biomass = 3 }
[Tooltip("Default resource type (the spawner round-robins this per node).")]
public ResourceKind Kind = ResourceKind.Aether;
[Tooltip("Total resource units in the node before it depletes.")]
[Min(1)] public int Amount = 30;
[Tooltip("Units harvested per projectile hit.")]
[Min(1f)] public float HarvestPerHit = 5f;
[Tooltip("Hit radius (world units) for the harvest sweep.")]
[Min(0f)] public float HitRadius = 1.2f;
private class ResourceNodeBaker : Baker
{
public override void Bake(ResourceNodeAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
AddComponent(entity, new ResourceNode
{
ResourceId = (byte)authoring.Kind,
Remaining = authoring.Amount,
HarvestPerHit = authoring.HarvestPerHit,
});
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
AddComponent(entity, new RegionTag { Region = RegionId.Expedition });
}
}
}
}