-
class Actor:
Entity¶ 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.
-
__new(self:
Actor)¶ Constructor for an actor. Initializes and copies the actor’s fields from its prototype.
-
staticmethod fromComponents(components:
Component[]): (actor:Actor)¶ Initializes an actor from a list of components.
-
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
-
expectPosition(self:
Actor, out?:Vector2): (position:Vector2)¶ Returns the current position of the actor, erroring if it doesn’t have one.
-
getRange(
self:Actor,
actor:Actor,
type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan"
): (range:number)¶ Get the range from this actor to another actor. Expects position on both actors and errors otherwise.
- Parameters:
actor (
Actor) – The other actor to get the range to.type? ("4way" | "8way" | "chebyshev" | "euclidean" | "manhattan") – Optional distance type.
- Returns:
range (
number) – The calculated range.
-
getRangeVec(
self:Actor,
vector:Vector2,
type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan"
): (range: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:
range (
number) – The calculated range.
Other members:
Inherited from
Entity:addRelation(),clone(),componentCache,components,ensure(),expect(),get(),getName(),getRelation(),getRelations(),give(),has(),hasRelation(),relations,remove(),removeAllRelations(),removeRelation()Inherited from
Object:_serializationBlacklist,adopt(),assertType(),className,deepcopy(),deserialize(),extend(),instanceOf(),is(),isInstance(),mixin(),prettyprint(),serializationBlacklist,serialize()-
__new(self: