using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
///
/// Authoring placed once in the gameplay subscene. Bakes a
/// singleton holding the projectile ghost prefab entity, which the predicted AbilityFireSystem
/// instantiates whenever a player fires. The spawner itself carries no transform (it is a pure
/// data singleton) so it is baked with TransformUsageFlags.None, while the referenced
/// prefab is baked with TransformUsageFlags.Dynamic so the spawned projectile has a
/// runtime-mutable LocalTransform.
///
public class ProjectileSpawnerAuthoring : MonoBehaviour
{
[Tooltip("The projectile ghost prefab spawned when a player fires.")]
public GameObject ProjectilePrefab;
private class ProjectileSpawnerBaker : Baker
{
public override void Bake(ProjectileSpawnerAuthoring authoring)
{
// The spawner itself needs no transform; it is a data singleton.
var entity = GetEntity(authoring, TransformUsageFlags.None);
AddComponent(entity, new ProjectileSpawner
{
Prefab = GetEntity(authoring.ProjectilePrefab, TransformUsageFlags.Dynamic)
});
}
}
}
}