import Entities from 'WTF-Adventure/WTF-Adventure/client/controllers/entities.js'
Entities
Entities in the game:
- Character - parent class for:
- Chest - open to reveal an item
- Item - weapons, health, magic, armor
- Projectile - entities that can be thrown (magic, weapons, arrows, mob attacks)
Constructor Summary
Public Constructor | ||
public |
constructor(instance: Game) Default constructor |
Member Summary
Public Members | ||
public |
Keeps track of entities that need to be cleaned up |
|
public |
An array of an entity type instances |
|
public |
The instance of the game |
|
public |
An array of game grid maps |
|
public |
An instance of the game renderer |
|
public |
An array of sprites |
Method Summary
Public Methods | ||
public |
Add a new entity to the map grid |
|
public |
clearPlayers(exception: {id: Number, type: String}): * Removes players from the game map, will only work for entities of type player |
|
public |
Create a new entity |
|
public |
Check to see if an entity with this ID exists or not |
|
public |
forEachEntity(callback: Function): * Apply a callback for every entity in the array |
|
public |
forEachEntityAround(x: Number, y: Number, radius: Number, callback: Function): * Apply a callback for every entity in the radius of an area on the map grid as long as the radius is not out of bounds in the grid |
|
public |
Returns the entity object based off the ID if it exists, otherwise returns null |
|
public |
getAll(): * Return all entities |
|
public |
Return all the sprites with the given name |
|
public |
Checks whether or not this entity ID is a player |
|
public |
loadEntities(): * Load the entities in the game for the current game map |
|
public |
registerDuality(entity: Chest | NPC | Item | Mob | Projectile | Player): * Register this entity on the grid twice |
|
public |
Figure out which part of the grid to add an entity to |
|
public |
removeItem(item: *): * Remove an item from the game |
|
public |
unregisterPosition(entity: Chest | NPC | Item | Mob | Projectile | Player): * Remove this entity from the game map |
|
public |
update(): * Update the sprites |
Public Constructors
Public Members
public decrepit: Chest | NPC | Item | Mob | Projectile | Player source
Keeps track of entities that need to be cleaned up
Public Methods
public addEntity(entity: Chest | NPC | Item | Mob | Projectile | Player): * source
Add a new entity to the map grid
Return:
* | null |
public clearPlayers(exception: {id: Number, type: String}): * source
Removes players from the game map, will only work for entities of type player
Return:
* | null |
public create(info: {id: Number, type: 'chest'|'npc'|'item'|'mob'|'projectile'|'player'}): * source
Create a new entity
Params:
Name | Type | Attribute | Description |
info | {id: Number, type: 'chest'|'npc'|'item'|'mob'|'projectile'|'player'} | information about the entity we need to create |
Return:
* | null |
public exists(id: Number): Boolean source
Check to see if an entity with this ID exists or not
Params:
Name | Type | Attribute | Description |
id | Number | the id of the entity |
public forEachEntity(callback: Function): * source
Apply a callback for every entity in the array
Params:
Name | Type | Attribute | Description |
callback | Function | the function to apply, the entity is passed into it |
Return:
* | null |
public forEachEntityAround(x: Number, y: Number, radius: Number, callback: Function): * source
Apply a callback for every entity in the radius of an area on the map grid as long as the radius is not out of bounds in the grid
Return:
* | null |
public get(id: Number): Chest | NPC | Item | Mob | Projectile | Player | null source
Returns the entity object based off the ID if it exists, otherwise returns null
Params:
Name | Type | Attribute | Description |
id | Number | the id of the entity |
public getSprite(name: String): Chest | NPC | Item | Mob | Projectile | Player source
Return all the sprites with the given name
Params:
Name | Type | Attribute | Description |
name | String | the name of the sprite |
public isPlayer(id: Number): Boolean source
Checks whether or not this entity ID is a player
Params:
Name | Type | Attribute | Description |
id | Number | the id of the entity |
public loadEntities(): * source
Load the entities in the game for the current game map
Return:
* | null |
public registerDuality(entity: Chest | NPC | Item | Mob | Projectile | Player): * source
Register this entity on the grid twice
Return:
* | null |
public registerPosition(entity: Chest | NPC | Item | Mob | Player): * source
Figure out which part of the grid to add an entity to
Return:
* | null |
public removeItem(item: *): * source
Remove an item from the game
Params:
Name | Type | Attribute | Description |
item | * | the item to remove from the map grid |
Return:
* | null |