46 lines
1.9 KiB
C#
46 lines
1.9 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring for a resource-node ghost prefab (ownerless interpolated — duplicate from UpgradePickup.prefab
|
|
/// so the GhostAuthoringComponent comes free). Bakes <see cref="ResourceNode"/> + <see cref="HitRadius"/>
|
|
/// (reused for the harvest hit test) + <see cref="RegionTag"/>{Expedition} so GhostRelevancy scopes the node
|
|
/// to expedition players. The field spawner overrides ResourceId (round-robin) and Position per instance.
|
|
/// </summary>
|
|
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<ResourceNodeAuthoring>
|
|
{
|
|
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 });
|
|
}
|
|
}
|
|
}
|
|
}
|