using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
///
/// Authoring for the baked singleton. Place this on a single
/// GameObject in the gameplay subscene; at runtime the server-only
/// TrainingDummySpawnSystem reads the singleton, instantiates dummies
/// laid out along +X from at intervals, then destroys
/// the singleton so it fires exactly once. The entity itself carries no transform
/// (TransformUsageFlags.None); only the referenced needs a
/// runtime-mutable LocalTransform (TransformUsageFlags.Dynamic).
///
public class TrainingDummySpawnerAuthoring : MonoBehaviour
{
[Tooltip("Training dummy prefab to instantiate. Must carry TrainingDummyAuthoring.")]
public GameObject DummyPrefab;
[Min(0)]
[Tooltip("How many dummies to spawn.")]
public int Count = 3;
[Min(0f)]
[Tooltip("World-unit spacing between consecutive dummies along +X.")]
public float Spacing = 3f;
[Tooltip("World-space position of the first dummy.")]
public Vector3 Origin = new Vector3(0, 0, 8);
private class TrainingDummySpawnerBaker : Baker
{
public override void Bake(TrainingDummySpawnerAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.None);
AddComponent(entity, new TrainingDummySpawner
{
Prefab = GetEntity(authoring.DummyPrefab, TransformUsageFlags.Dynamic),
Count = authoring.Count,
Spacing = authoring.Spacing,
Origin = authoring.Origin
});
}
}
}
}