using ProjectM.Simulation; using Unity.Burst; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; namespace ProjectM.Server { /// /// MC-2 — integrates hostile Spitter projectiles () server-only in the plain /// (the spits are ownerless INTERPOLATED ghosts, not predicted — like the /// Husks that fire them). Advances each spit along its locked Direction at Speed*dt, accumulates /// DistanceTravelled, and STORES = Speed*dt so /// can rebuild the exact swept segment it traversed this tick /// (cur - Direction*LastStep) WITHOUT re-reading a delta in that separate system (the DR-018 swept-tunnelling /// discipline — a fresh delta in the damage pass is the trap). Ordered [UpdateAfter(EnemyAISystem)] (the /// spawner) so a spit moves the same tick it is born. Writes LocalTransform (replicated via the stock variant); /// structural-free. dt is the server fixed step here, exactly as reads it. /// [BurstCompile] [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] [UpdateInGroup(typeof(SimulationSystemGroup))] [UpdateAfter(typeof(EnemyAISystem))] public partial struct EnemyProjectileMoveSystem : ISystem { [BurstCompile] public void OnCreate(ref SystemState state) { state.RequireForUpdate(); } [BurstCompile] public void OnUpdate(ref SystemState state) { float dt = SystemAPI.Time.DeltaTime; // server fixed step in the plain group, same as EnemyAISystem foreach (var (xform, proj) in SystemAPI.Query, RefRW>()) { float step = proj.ValueRO.Speed * dt; float3 dir = new float3(proj.ValueRO.Direction.x, 0f, proj.ValueRO.Direction.y); float3 from = xform.ValueRO.Position; float3 pos = from + dir * step; pos.y = from.y; // hold the movement plane xform.ValueRW.Position = pos; proj.ValueRW.LastStep = step; proj.ValueRW.DistanceTravelled = proj.ValueRO.DistanceTravelled + step; } } } }