class Actor : Entity

An ‘Actor’ represents entities in the game, including the player, enemies, and items. Actors are composed of Components that define their state and behavior. For example, an actor may have a Sight component that determines their field of vision, explored tiles, and other related aspects.

level: Level?

The level the actor is on.

__new(self: Actor)

Constructor for an actor. Initializes and copies the actor’s fields from its prototype.

initialize(self: Actor) Component[]

Creates the components for the actor. Override this.

staticmethod fromComponents(components: Component[]) actor: Actor

Initializes an actor from a list of components.

Parameters:

components (Component[]) – A list of components to give to the new actor.

Returns:

actor (Actor) – The new actor.

getActions(self: Actor) totalActions: Action[]

Get a list of actions that the actor can perform.

Returns:

totalActions (Action[]) – A table of all actions.

getPosition(self: Actor, out?: Vector2) position?: Vector2

Returns the current position of the actor

Parameters:

out? (Vector2) – An optional out parameter. A new Vector2 will be allocated in it’s absence.

Returns:

position? (Vector2) – Returns a copy of the actor’s current position.

expectPosition(self: Actor, out: any) Vector2
getRange(self: Actor, actor: Actor, type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan") number

Get the range from this actor to another actor.

Parameters:

actor (Actor) – The other actor to get the range to.

Returns:

_1 (number) – The calculated range.

getRangeVec(self: Actor, vector: Vector2, type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan") number

Get the range from this actor to a given vector.

Parameters:
  • vector (Vector2) – The vector to get the range to.

  • type? ("4way" | "8way" | "chebyshev" | "euclidean" | "manhattan") – The type of range calculation to use.

Returns:

_1 (number) – The calculated range.