| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | // The controller class is an interface between the agent and its control law. |
| | 5 | | public class IController { |
| | 6 | | // Agent that the controller is controlling. |
| | 7 | | protected Agent _agent; |
| | 8 | |
|
| 814 | 9 | | public IController(Agent agent) { |
| 407 | 10 | | _agent = agent; |
| 407 | 11 | | } |
| | 12 | |
|
| | 13 | | // Plan the next optimal control to intercept the target. |
| 50 | 14 | | public Vector3 Plan() { |
| 50 | 15 | | Transformation relativeTransformation = |
| | 16 | | _agent.GetRelativeTransformation(_agent.GetTargetModel()); |
| 50 | 17 | | return PlanImpl(relativeTransformation); |
| 50 | 18 | | } |
| | 19 | |
|
| | 20 | | // Plan the next optimal control to the waypoint. |
| 357 | 21 | | public Vector3 PlanToWaypoint(Vector3 waypoint) { |
| 357 | 22 | | Transformation relativeTransformation = _agent.GetRelativeTransformationToWaypoint(waypoint); |
| 357 | 23 | | return PlanImpl(relativeTransformation); |
| 357 | 24 | | } |
| | 25 | |
|
| | 26 | | // Controller-dependent implementation of the control law. |
| 0 | 27 | | protected virtual Vector3 PlanImpl(in Transformation relativeTransformation) { |
| 0 | 28 | | return Vector3.zero; |
| 0 | 29 | | } |
| | 30 | | } |