using ProjectM.Simulation; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// Authoring for an upgrade pickup ghost prefab: a world object that grants one stat modifier to the /// first player that overlaps it (server-authoritative, applied by UpgradePickupSystem) and /// then despawns. Bake the prefab as an interpolated ghost (add a GhostAuthoringComponent) so clients /// see it appear and despawn. GetEntity(TransformUsageFlags.Dynamic) gives it a world transform. /// public class UpgradePickupAuthoring : MonoBehaviour { [Tooltip("Which stat the granted modifier targets.")] public StatTarget Target = StatTarget.Damage; [Tooltip("How the granted modifier combines.")] public ModOp Op = ModOp.Flat; [Tooltip("Modifier magnitude: flat amount, or fractional percent (0.1 = +10%).")] public float Value = 10f; [Tooltip("Overlap radius (world units) for the player pickup test.")] [Min(0f)] public float HitRadius = 1f; private class UpgradePickupBaker : Baker { public override void Bake(UpgradePickupAuthoring authoring) { var entity = GetEntity(authoring, TransformUsageFlags.Dynamic); AddComponent(entity, new UpgradePickup { Target = (byte)authoring.Target, Op = (byte)authoring.Op, Value = authoring.Value, SourceId = 0u, }); AddComponent(entity, new HitRadius { Value = authoring.HitRadius }); } } } }