AI Testing Simulator
Loading...
Searching...
No Matches
PathController Class Reference

This class handles the path system for an adversary in a game. It manages waypoints, line renderers, and interaction with the adversary view controller. More...

Inheritance diagram for PathController:

Public Member Functions

bool IsIgnoringWaypoints ()
 Determines if newly placed Waypoints whould ignore Waypoints based on wether the AdversaryController ignores waypoints.
 
bool IsBuilding ()
 Checks if the path is currently in building mode.
 
void Select (bool forward=false)
 Selects the path and enables building mode.
 
void AdjustHeights (bool selected)
 Adjusts the heights of the path and waypoints based on the selected state.
 
void Deselect (bool forward=false)
 Deselects the path and disables building mode.
 
void Destroy ()
 Destroys the path and its associated waypoints.
 
void Init (AdversaryViewController controller, Color color, Path path, bool building)
 Initializes the path controller with the specified parameters.
 
Location FindMouseTarget (Vector2 mousePosition)
 
void Update ()
 Updates the preview renderer without changing the model. Displays preview based on different collision types and building state. Does not change the Path model in any way.
 
void AddMoveToWaypoint (Vector2 position, Waypoint waypoint=null, bool addLaneChanges=true)
 Adds a waypoint to the end of the path, either generated or passed as an argument. Keeps waypointViewControllers and pathRenderer in sync.
 
int AddLaneChangeWaypoints (List< int > laneChanges, List< Vector2 > path, LinkedListNode<(WaypointViewController, int)>? node=null)
 Adds secondary waypoints for lane changes to the Path and waypointViewControllers. Inserts the generated waypoint and waypointViewController after the specified node, or at the end of both containers if no node is provided.
 
void UpdateAdjacentPaths (WaypointViewController waypointController)
 
void MoveWaypoint (WaypointViewController waypointController, float x, float y)
 Moves the specified waypoint to the new x and y coordinates, updating the path and secondary waypoints as needed.
 
void RemoveWaypoint (WaypointViewController controller, bool restorePath=true)
 Removes a waypoint from the path and optionally restores the path between the previous and next waypoints.
 
void AfterEdit ()
 Updates the adversary rotation and edge collider after a path edit.
 
void MoveFirstWaypoint (float x, float y)
 Moves the first waypoint to the specified x and y coordinates.
 
void SetColor (Color color)
 Sets the color of the path, preview, and waypoints.
 
void OnMouseDown ()
 Handles mouse down events on the path, allowing the user to interact with the waypoints and path.
 
WaypointViewController GetFirstWaypointController ()
 Returns the WaypointViewController for the first waypoint in the path.
 

Public Attributes

GameObject waypointPrefab
 

Properties

AdversaryViewController AdversaryViewController [get]
 
Path Path [get, set]
 

Detailed Description

This class handles the path system for an adversary in a game. It manages waypoints, line renderers, and interaction with the adversary view controller.

Member Function Documentation

◆ AddLaneChangeWaypoints()

int PathController.AddLaneChangeWaypoints ( List< int >  laneChanges,
List< Vector2 >  path,
LinkedListNode<(WaypointViewController, int)>?  node = null 
)
inline

Adds secondary waypoints for lane changes to the Path and waypointViewControllers. Inserts the generated waypoint and waypointViewController after the specified node, or at the end of both containers if no node is provided.

Parameters
laneChangesA list of integers representing lane change positions.
pathA list of Vector2 points representing the path.
nodeAn optional LinkedListNode containing a tuple of WaypointViewController and an integer, used to insert the new waypoint after this node. Default is null.
Returns
Returns the number of lane changes used in the path.

◆ AddMoveToWaypoint()

void PathController.AddMoveToWaypoint ( Vector2  position,
Waypoint  waypoint = null,
bool  addLaneChanges = true 
)
inline

Adds a waypoint to the end of the path, either generated or passed as an argument. Keeps waypointViewControllers and pathRenderer in sync.

Parameters
positionThe position to add the waypoint as a Vector2.
waypointAn optional Waypoint object to be added to the path.
addLaneChangesA boolean flag to indicate whether to add lane changes or not. Defaults to true.

◆ AdjustHeights()

void PathController.AdjustHeights ( bool  selected)
inline

Adjusts the heights of the path and waypoints based on the selected state.

Parameters
selectedTrue if heights should be adjusted, false otherwise.

◆ Deselect()

void PathController.Deselect ( bool  forward = false)
inline

Deselects the path and disables building mode.

Parameters
forwardIf true, calls the deselect method on the adversary view controller. Default is false.</param

◆ GetFirstWaypointController()

WaypointViewController PathController.GetFirstWaypointController ( )
inline

Returns the WaypointViewController for the first waypoint in the path.

Returns
The WaypointViewController of the first waypoint in the path.

◆ Init()

void PathController.Init ( AdversaryViewController  controller,
Color  color,
Path  path,
bool  building 
)
inline

Initializes the path controller with the specified parameters.

Parameters
controllerThe adversary view controller associated with this path.
colorThe color for the path.
pathThe Path for this controller.
buildingOptional parameter to set the initial building state. Default is true.

summary> Target of a click is either a waypoint or the mouse position itself, if waypoints are ignored /summary> param name="mousePosition">The position of the mouse in the game world

returns>A Location object representing the target of the click

◆ IsBuilding()

bool PathController.IsBuilding ( )
inline

Checks if the path is currently in building mode.

Returns
Returns true if building, otherwise false.

◆ IsIgnoringWaypoints()

bool PathController.IsIgnoringWaypoints ( )
inline

Determines if newly placed Waypoints whould ignore Waypoints based on wether the AdversaryController ignores waypoints.

Returns
Returns true if waypoints should be ignored, otherwise false.</returns

◆ MoveFirstWaypoint()

void PathController.MoveFirstWaypoint ( float  x,
float  y 
)
inline

Moves the first waypoint to the specified x and y coordinates.

Parameters
xThe x coordinate of the new location.
yThe y coordinate of the new location.

◆ MoveWaypoint()

void PathController.MoveWaypoint ( WaypointViewController  waypointController,
float  x,
float  y 
)
inline

Moves the specified waypoint to the new x and y coordinates, updating the path and secondary waypoints as needed.

Parameters
waypointControllerThe WaypointViewController instance to be moved.
xThe new x-coordinate of the waypoint.
yThe new y-coordinate of the waypoint.

◆ RemoveWaypoint()

void PathController.RemoveWaypoint ( WaypointViewController  controller,
bool  restorePath = true 
)
inline

Removes a waypoint from the path and optionally restores the path between the previous and next waypoints.

Parameters
controllerThe WaypointViewController associated with the waypoint to remove.
restorePathWhether to restore the path between the previous and next waypoints after removing the waypoint. Default is true.

◆ Select()

void PathController.Select ( bool  forward = false)
inline

Selects the path and enables building mode.

Parameters
forwardIf true, calls the select method on the adversary view controller. Default is false.

◆ SetColor()

void PathController.SetColor ( Color  color)
inline

Sets the color of the path, preview, and waypoints.

Parameters
colorThe Color to set for the path, preview, and waypoints.

The documentation for this class was generated from the following file: