using ProjectM.Simulation; using Unity.Entities; using Unity.Mathematics; using UnityEngine; namespace ProjectM.Authoring { /// /// Authoring for the player ghost prefab. Bakes the gameplay components onto the entity and /// exposes movement tunables for designers. Ghost replication, GhostOwner and /// AutoCommandTarget are supplied by the GhostAuthoringComponent added on the same prefab /// GameObject. GetEntity(TransformUsageFlags.Dynamic) ensures a runtime-mutable /// LocalTransform exists. /// public class PlayerAuthoring : MonoBehaviour { [Min(0f)] public float MoveSpeed = 6f; [Min(0f)] public float TurnRateDegreesPerSec = 720f; private class PlayerBaker : Baker { public override void Bake(PlayerAuthoring authoring) { var entity = GetEntity(authoring, TransformUsageFlags.Dynamic); AddComponent(entity); AddComponent(entity, new PlayerMoveStats { MoveSpeed = authoring.MoveSpeed, TurnRateRadiansPerSec = math.radians(authoring.TurnRateDegreesPerSec) }); AddComponent(entity); AddComponent(entity); } } } }