using Unity.Burst; using Unity.Entities; using Unity.NetCode; using Unity.Physics; using static Unity.Entities.SystemAPI; namespace Unity.MegaCity.Gameplay { /// /// Handles shooting /// [UpdateInGroup(typeof(PredictedSimulationSystemGroup))] public partial struct ShootingSystem : ISystem { public void OnCreate(ref SystemState state) { state.RequireForUpdate(); state.RequireForUpdate(); state.RequireForUpdate(); } [BurstCompile] public void OnUpdate(ref SystemState state) { var netTime = GetSingleton(); if (!netTime.IsFirstTimeFullyPredictingTick) return; var laserJob = new LaserJob { CollisionHistory = GetSingleton(), PhysicsWorld = GetSingleton().PhysicsWorld, DeltaTime = Time.DeltaTime, PredictingTick = netTime.ServerTick, healthLookup = GetComponentLookup() }; state.Dependency = laserJob.ScheduleParallel(state.Dependency); } } }