using Unity.Entities; using Unity.NetCode; using Unity.NetCode.Extensions; namespace Unity.MegaCity.Gameplay { /// /// Handles shooting on the server /// [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] public partial struct ShootingSystemServer : ISystem { public void OnCreate(ref SystemState state) { state.RequireForUpdate(); } public void OnUpdate(ref SystemState state) { var netTime = SystemAPI.GetSingleton(); var shootingJob = new ApplyingDamageAndPointsJob { DamagePerSecond = 50f, DeltaTime = SystemAPI.Time.DeltaTime, PredictingTick = netTime.ServerTick, healthLookup = SystemAPI.GetComponentLookup(), playerPointsLookUp = SystemAPI.GetComponentLookup(), playerNameLookup = SystemAPI.GetComponentLookup(), immunityLookup = SystemAPI.GetComponentLookup(), }; state.Dependency = shootingJob.Schedule(state.Dependency); } } }