State()

Base class for representing a state in context of State-driven agent design.

new State()

Author:

Methods

enter(owner)

This method is called once during a state transition when the StateMachine makes this state active.

Parameters:
Name Type Description
owner GameEntity

The game entity that represents the execution context of this state.

execute(owner)

This method is called per simulation step if this state is active.

Parameters:
Name Type Description
owner GameEntity

The game entity that represents the execution context of this state.

exit(owner)

This method is called once during a state transition when the StateMachine makes this state inactive.

Parameters:
Name Type Description
owner GameEntity

The game entity that represents the execution context of this state.

fromJSON(json) → {State}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
State -

A reference to this state.

onMessage(owner, telegram) → {Boolean}

This method is called when messaging between game entities occurs.

Parameters:
Name Type Description
owner GameEntity

The game entity that represents the execution context of this state.

telegram Telegram

A data structure containing the actual message.

Returns:
Boolean -

Whether the message was processed or not.

resolveReferences(entities) → {State}

Restores UUIDs with references to GameEntity objects.

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

Maps game entities to UUIDs.

Returns:
State -

A reference to this state.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.