using ProjectM.Simulation; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// MC-2 — marks a Husk prefab as a SPITTER variant (the ranged "reposition" question). Compose WITH /// on the prefab root: EnemyAuthoring bakes the common Husk components + the spit's /// damage/cooldown (EnemyStats.AttackDamage / AttackCooldownTicks), this bakes the server-only /// (zeroed NextShotTick = ready). Component-PRESENCE is the discriminator EnemyAISystem /// branches on (no enum); the Grunt + Charger passes exclude it via .WithNone<SpitterState>(). The /// actual spit projectile is a SEPARATE ghost configured by the SpitterProjectilePrefab subscene singleton. /// public class SpitterAuthoring : MonoBehaviour { [Min(0f), Tooltip("Distance the Spitter tries to hold from its target (band centre).")] public float PreferredRange = 9f; [Min(0f), Tooltip("Half-width dead-zone around PreferredRange where it holds and fires.")] public float RangeTolerance = 1.5f; [Min(0f), Tooltip("Muzzle speed of the spit (world units/second). Slow enough to be dodgeable at range.")] public float ProjectileSpeed = 11f; [Min(0f), Tooltip("If the target closes within this AND the Spitter can't retreat, it fires point-blank.")] public float CorneredRange = 3f; [Min(1), Tooltip("Telegraph wind-up before the spit fires (ticks). Keep >= ~24 (> interp delay) to stay dodgeable.")] public int WindupTicks = 26; private class SpitterBaker : Baker { public override void Bake(SpitterAuthoring authoring) { var entity = GetEntity(authoring, TransformUsageFlags.Dynamic); AddComponent(entity, new SpitterState { PreferredRange = authoring.PreferredRange, RangeTolerance = authoring.RangeTolerance, ProjectileSpeed = authoring.ProjectileSpeed, CorneredRange = authoring.CorneredRange, WindupTicks = authoring.WindupTicks, NextShotTick = 0, }); } } } }