/**
* Base class for all concrete steering behaviors. They produce a force that describes
* where an agent should move and how fast it should travel to get there.
*
* Note: All built-in steering behaviors assume a {@link Vehicle#mass} of one. Different values can lead to an unexpected results.
*
* @author {@link https://github.com/Mugen87|Mugen87}
*/
class SteeringBehavior {
/**
* Constructs a new steering behavior.
*/
constructor() {
/**
* Whether this steering behavior is active or not.
* @type {Boolean}
* @default true
*/
this.active = true;
/**
* Can be used to tweak the amount that a steering force contributes to the total steering force.
* @type {Number}
* @default 1
*/
this.weight = 1;
}
/**
* Calculates the steering force for a single simulation step.
*
* @param {Vehicle} vehicle - The game entity the force is produced for.
* @param {Vector3} force - The force/result vector.
* @param {Number} delta - The time delta.
* @return {Vector3} The force/result vector.
*/
calculate( /* vehicle, force, delta */ ) {}
/**
* Transforms this instance into a JSON object.
*
* @return {Object} The JSON object.
*/
toJSON() {
return {
type: this.constructor.name,
active: this.active,
weight: this.weight
};
}
/**
* Restores this instance from the given JSON object.
*
* @param {Object} json - The JSON object.
* @return {SteeringBehavior} A reference to this steering behavior.
*/
fromJSON( json ) {
this.active = json.active;
this.weight = json.weight;
return this;
}
/**
* Restores UUIDs with references to GameEntity objects.
*
* @param {Map<String,GameEntity>} entities - Maps game entities to UUIDs.
* @return {SteeringBehavior} A reference to this steering behavior.
*/
resolveReferences( /* entities */ ) {}
}
export { SteeringBehavior };