Spawn Waypoint Selector
Description
Controls the selection of a free waypoint to instantiate a new vehicle on.
Declaration
public delegate int SpawnWaypointSelector(List<Vector2Int> neighbors, Vector3 position, Vector3 direction, VehicleTypes carType, bool useWaypointPriority);
Returns
int - a waypoint index
Parameters
Name
Description
neighbors
A list of the cell indexes that are neighbors to the player cell.
position
The player position.
direction
The player direction.
vehicleType
The vehicle type for which the waypoint is being selected.
useWaypointPriority
Specifies whether waypoint priority is enabled for selection or not.
Set Method
public static void SetSpawnWaypointSelector(SpawnWaypointSelector spawnWaypointSelectorDelegate)
Example
using Gley.TrafficSystem;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
private void Start()
{
Delegates.SetSpawnWaypointSelector(MyTrafficLightBehaviour);
}
public static int MySpawnWaypointSelector(List<Vector2Int> neighbors, Vector3 position, Vector3 direction, VehicleTypes vehicleType, bool useWaypointPriority)
{
//select a random cell
Vector2Int selectedNeighbor = neighbors[Random.Range(0, neighbors.Count)];
//return a random waypoint from that cell
return GetPossibleWaypoint(selectedNeighbor, vehicleType, useWaypointPriority);
}
}
Last updated