using UnityEngine; namespace Gley.TrafficSystem { public class Events { #region Density /// /// Triggered every time a vehicle is activated inside the scene. /// /// index of the vehicle public delegate void VehicleAdded(int vehicleIndex); public static VehicleAdded onVehicleAdded; public static void TriggerVehicleAddedEvent(int vehicleIndex) { if (onVehicleAdded != null) { onVehicleAdded(vehicleIndex); } } /// /// Triggered every time a vehicle is deactivated inside the scene. /// /// index of the vehicle public delegate void VehicleRemoved(int vehicleIndex); public static VehicleRemoved onVehicleRemoved; public static void TriggerVehicleRemovedEvent(int vehicleIndex) { if (onVehicleRemoved != null) { onVehicleRemoved(vehicleIndex); } } #endregion /// /// Triggered when a vehicle crashes into another object. /// public static event VehicleCrash onVehicleCrashed; public static void TriggerVehicleCrashEvent(int vehicleIndex, ObstacleTypes obstacleType, Collider other) { if (onVehicleCrashed != null) { onVehicleCrashed(vehicleIndex, obstacleType, other); } } /// /// Triggered every time a vehicle reaches the last point of its path. /// /// index of the vehicle public delegate void DestinationReached(int vehicleIndex); public static DestinationReached onDestinationReached; public static void TriggerDestinationReachedEvent(int vehicleIndex) { if (onDestinationReached != null) { onDestinationReached(vehicleIndex); } } /// /// Triggered every time a waypoint that has the Trigger Event option enabled is reached by a vehicle. /// /// The index of the vehicle that reached the waypoint. /// The waypoint index that triggered the event. /// The data set on that waypoint by Trigger Event option. public delegate void WaypointReached(int vehicleIndex, int waypointIndex, string data); public static WaypointReached onWaypointReached; public static void TriggerWaypointReachedEvent(int vehicleIndex, int waypointIndex, string data) { if (onWaypointReached != null) { onWaypointReached(vehicleIndex, waypointIndex, data); } } } }