public override void ForEach(IBaseObjectCallback <IVehicle> baseObjectCallback) { foreach (var entity in GetAllEntities()) { using var entityRef = new VehicleRef(entity); if (!entityRef.Exists) { continue; } entityRef.DebugCountUp(); baseObjectCallback.OnBaseObject(entity); entityRef.DebugCountDown(); } }
public override void OnVehicleDestroyEvent(IVehicle vehicle) { base.OnVehicleDestroyEvent(vehicle); if (!VehicleDestroyAsyncDelegateHandlers.HasEvents()) { return; } var vehicleReference = new VehicleRef(vehicle); Task.Run(async() => { vehicleReference.DebugCountUp(); await VehicleDestroyAsyncDelegateHandlers.CallAsync(@delegate => @delegate(vehicle)); vehicleReference.DebugCountDown(); vehicleReference.Dispose(); }); }
public override void OnPlayerLeaveVehicleEvent(IVehicle vehicle, IPlayer player, byte seat) { base.OnPlayerLeaveVehicleEvent(vehicle, player, seat); if (!PlayerLeaveVehicleAsyncEventHandler.HasEvents()) { return; } var playerReference = new PlayerRef(player); var vehicleReference = new VehicleRef(vehicle); Task.Run(async() => { playerReference.DebugCountUp(); vehicleReference.DebugCountUp(); await PlayerLeaveVehicleAsyncEventHandler.CallAsync(@delegate => @delegate(vehicle, player, seat)); vehicleReference.DebugCountDown(); playerReference.DebugCountDown(); playerReference.Dispose(); vehicleReference.Dispose(); }); }