SteeringManager(vehicle)

This class is responsible for managing the steering of a single vehicle. The steering manager can manage multiple steering behaviors and combine their produced force into a single one used by the vehicle.

new SteeringManager(vehicle)

Constructs a new steering manager.

Parameters:
Name Type Description
vehicle Vehicle

The vehicle that owns this steering manager.

Author:

Members

readonly behaviors :Array.<SteeringBehavior>

A list of all steering behaviors.

vehicle :Vehicle

The vehicle that owns this steering manager.

Methods

add(behavior) → {SteeringManager}

Adds the given steering behavior to this steering manager.

Parameters:
Name Type Description
behavior SteeringBehavior

The steering behavior to add.

Returns:
SteeringManager -

A reference to this steering manager.

calculate(delta, result) → {Vector3}

Calculates the steering forces for all active steering behaviors and combines it into a single result force. This method is called in Vehicle#update.

Parameters:
Name Type Description
delta Number

The time delta.

result Vector3

The force/result vector.

Returns:
Vector3 -

The force/result vector.

clear() → {SteeringManager}

Clears the internal state of this steering manager.

Returns:
SteeringManager -

A reference to this steering manager.

fromJSON(json) → {SteeringManager}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
SteeringManager -

A reference to this steering manager.

registerType(type, constructor) → {SteeringManager}

Registers a custom type for deserialization. When calling SteeringManager#fromJSON the steering manager is able to pick the correct constructor in order to create custom steering behavior.

Parameters:
Name Type Description
type String

The name of the behavior type.

constructor function

The constructor function.

Returns:
SteeringManager -

A reference to this steering manager.

remove(behavior) → {SteeringManager}

Removes the given steering behavior from this steering manager.

Parameters:
Name Type Description
behavior SteeringBehavior

The steering behavior to remove.

Returns:
SteeringManager -

A reference to this steering manager.

resolveReferences(entities) → {SteeringManager}

Restores UUIDs with references to GameEntity objects.

Parameters:
Name Type Description
entities Map.<String, GameEntity>

Maps game entities to UUIDs.

Returns:
SteeringManager -

A reference to this steering manager.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.