using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
///
/// Authoring for the projectile ghost prefab fired by the player's primary ability. Bakes the
/// baked-once tunables (, ,
/// ) onto the entity; the replicated Direction/SpawnId
/// and the integrated DistanceTravelled are left at their default 0 and written at spawn
/// time by AbilityFireSystem. Ghost replication and GhostOwner are supplied by the
/// GhostAuthoringComponent added on the same prefab GameObject (not added here, nor is Health).
/// GetEntity(TransformUsageFlags.Dynamic) ensures a runtime-mutable LocalTransform exists.
///
public class ProjectileAuthoring : MonoBehaviour
{
[Min(0f)] public float Speed = 25f;
[Min(0f)] public float Damage = 20f;
[Min(0f)] public float Range = 20f;
private class ProjectileBaker : Baker
{
public override void Bake(ProjectileAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
// Direction / SpawnId / DistanceTravelled default to 0 — set at spawn by AbilityFireSystem.
AddComponent(entity, new Projectile
{
Speed = authoring.Speed,
Damage = authoring.Damage,
Range = authoring.Range
});
}
}
}
}