using System.Collections.Generic; using UnityEngine; #if GLEY_TRAFFIC_SYSTEM using TrafficManager = Gley.TrafficSystem.Internal.TrafficManager; #endif namespace Gley.TrafficSystem { public delegate void TrafficLightsBehaviour(TrafficLightsColor currentRoadColor, GameObject[] redLightObjects, GameObject[] yellowLightObjects, GameObject[] greenLightObjects, string name); public delegate int SpawnWaypointSelector(List neighbors, Vector3 position, Vector3 direction, VehicleTypes vehicleType, bool useWaypointPriority); public delegate void ModifyTriggerSize(float currentSpeed, BoxCollider frontCollider, float maxSpeed, float minTriggerLength, float maxTriggerLength); public delegate void PlayerInTrigger(int vehicleIndex, Collider player); public delegate void DynamicObstacleInTrigger(int vehicleIndex, Collider obstacle); public delegate void BuildingInTrigger(int vehicleIndex, Collider building); public delegate void VehicleCrash(int vehicleIndex, ObstacleTypes obstacleType, Collider other); public class Delegates { /// /// Controls the behavior of the lights inside a traffic light intersection. /// /// new delegate method public static void SetTrafficLightsBehaviour(TrafficLightsBehaviour trafficLightsBehaviourDelegate) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.AllIntersectionsHandler?.SetTrafficLightsBehaviour(trafficLightsBehaviourDelegate); #endif } /// /// Controls the selection of a free waypoint to instantiate a new vehicle on. /// /// new delegate method public static void SetSpawnWaypointSelector(SpawnWaypointSelector spawnWaypointSelectorDelegate) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.WaypointManager?.SetSpawnWaypointSelector(spawnWaypointSelectorDelegate); #endif } /// /// Controls the dimension of the front trigger based on the vehicle's speed. /// /// new delegate method /// vehicle index to apply (-1 apply to all) public static void SetModifyTriggerSize(ModifyTriggerSize modifyTriggerSizeDelegate, int vehicleIndex = -1) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.AllVehiclesDataHandler?.ModifyTriggerSize(vehicleIndex, modifyTriggerSizeDelegate); #endif } /// /// Controls how the traffic vehicle reacts when a player car is in trigger. /// /// new delegate method public static void SetPlayerInTrigger(PlayerInTrigger playerInTriggerDelegate) { #if GLEY_TRAFFIC_SYSTEM Debug.Log("player in view"); TrafficManager.Instance.DrivingAI?.SetPlayerInTriggerDelegate(playerInTriggerDelegate); #endif } /// /// Controls how the traffic vehicle reacts when a dynamic obstacle is in the trigger. /// /// new delegate method public static void SetDynamicObstacleInTrigger(DynamicObstacleInTrigger dynamicObstacleInTriggerDelegate) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.DrivingAI?.SetDynamicObstacleInTriggerDelegate(dynamicObstacleInTriggerDelegate); #endif } /// /// Controls how the traffic vehicle reacts when a building is in the trigger. /// /// new delegate method public static void SetBuildingInTrigger(BuildingInTrigger buildingInTriggerDelegate) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.DrivingAI?.SetBuildingInTriggerDelegate(buildingInTriggerDelegate); #endif } /// /// Controls how the traffic vehicle reacts when it crashes into something. /// /// new delegate method public static void SetVehicleCrash(VehicleCrash vehicleCrashDelegate) { #if GLEY_TRAFFIC_SYSTEM TrafficManager.Instance.DrivingAI?.SetVehicleCrashDelegate(vehicleCrashDelegate); #endif } } }