Interface IMovementController
Inherited Members
Namespace: RTSEngine.Movement
Assembly: cs.temp.dll.dll
Syntax
public interface IMovementController : IMonoBehaviour
Properties
Data
Get or set the defining properties of the movement controller such as speed, acceleration and stopping distance.
Declaration
MovementControllerData Data { get; set; }
Property Value
Type | Description |
---|---|
MovementControllerData |
Destination
The current target position that the unit is moving towards. This is used to determine when the movement should stop when the unit approaches its destination.
Declaration
Vector3 Destination { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Enabled
When set to false, the unit is not expected to handle movement path calculations and pathfinding.
Declaration
bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsActive
Used by the IMovementComponent instance to handle stopping or pausing pathfinding for the unit, in the case where the game is paused for example. If Enabled is set to false, enabling this would not have any effect.
Declaration
bool IsActive { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
LastSource
Holds the last movement source data of the last successful movement for which a successful path has been generated.
Declaration
MovementSource LastSource { get; }
Property Value
Type | Description |
---|---|
MovementSource |
NavigationAreaMask
The navigation mesh area mask in which the unit can move.
Declaration
LayerMask NavigationAreaMask { get; }
Property Value
Type | Description |
---|---|
LayerMask |
NextPathTarget
The position of the next corner of the unit's active path.
Declaration
Vector3 NextPathTarget { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Radius
The size that the unit occupies in the navigation mesh while moving.
Declaration
float Radius { get; }
Property Value
Type | Description |
---|---|
System.Single |
Methods
Disable()
Called by the IMovementComponent instance when the unit is disabled.
Declaration
void Disable()
Init(IGameManager, IMovementComponent, MovementControllerData)
Initialization method called by the IMovementComponent instance to set the initial properties of the movement controller.
Declaration
void Init(IGameManager gameMgr, IMovementComponent mvtComponent, MovementControllerData data)
Parameters
Type | Name | Description |
---|---|---|
IGameManager | gameMgr | IGameManager instance of the currently active game. |
IMovementComponent | mvtComponent | IMovementComponent instance of the unit that called the initialization method. |
MovementControllerData | data | Initial movement controller data including speed, acceleration and stopping distance values. |
Launch()
Starts the unit movement using the last calculated path from the Prepare() method.
Declaration
void Launch()
Prepare(Vector3, MovementSource)
Attempts to calculate a valid path for the specified destination position. If the path calculation is successful, you need to call OnPathPrepared() on the IMovementComponent instance of the unit and provide the same MovementSource data as its sole parameter. While you have the option to modify the MovementSource struct when calling OnPathPrepared(), it is recommended to pass the same back. If the path calculation failed, you need to call OnPathFailure() on the IMovementComponent instance of the unit. You do not have to make either of those two calls directly through this method. Path calculation might take some time to finish so you can always call either of those two methods later. However, make sure that one of them is eventually called as the movement component will be expecting a response after it attempts to preapre a path for the movement.
Declaration
void Prepare(Vector3 destination, MovementSource source)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | destination | Vector3 that represents the movement's target position. |
MovementSource | source |