Files
Project-M/Assets/_Project/Scripts/Authoring/Economy/ClutterFieldSpawnerAuthoring.cs
T
2026-06-04 21:49:03 -07:00

40 lines
1.6 KiB
C#

using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring for the baked <see cref="ClutterFieldSpawner"/> singleton (mirrors ResourceFieldSpawnerAuthoring).
/// Place once in the gameplay subscene and assign the Blight-clutter ghost prefab; ExpeditionFieldSystem
/// scatters the clutter each expedition alongside the resource field. Carries no transform.
/// </summary>
public class ClutterFieldSpawnerAuthoring : MonoBehaviour
{
[Tooltip("Blight-clutter ghost prefab. Must carry BlightClutterAuthoring + a GhostAuthoringComponent (ownerless, interpolated).")]
public GameObject ClutterPrefab;
[Tooltip("Number of clutter pieces per expedition.")]
[Min(1)] public int Count = 14;
[Tooltip("Scatter radius (world units) around the expedition origin.")]
[Min(1f)] public float Radius = 14f;
private class ClutterFieldSpawnerBaker : Baker<ClutterFieldSpawnerAuthoring>
{
public override void Bake(ClutterFieldSpawnerAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.None);
AddComponent(entity, new ClutterFieldSpawner
{
Prefab = authoring.ClutterPrefab != null
? GetEntity(authoring.ClutterPrefab, TransformUsageFlags.Dynamic)
: Entity.Null,
Count = authoring.Count,
Radius = authoring.Radius,
});
}
}
}
}