35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring placed once in the gameplay subscene. Bakes a <see cref="ProjectileSpawner"/>
|
|
/// 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 <c>TransformUsageFlags.None</c>, while the referenced
|
|
/// prefab is baked with <c>TransformUsageFlags.Dynamic</c> so the spawned projectile has a
|
|
/// runtime-mutable LocalTransform.
|
|
/// </summary>
|
|
public class ProjectileSpawnerAuthoring : MonoBehaviour
|
|
{
|
|
[Tooltip("The projectile ghost prefab spawned when a player fires.")]
|
|
public GameObject ProjectilePrefab;
|
|
|
|
private class ProjectileSpawnerBaker : Baker<ProjectileSpawnerAuthoring>
|
|
{
|
|
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)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|