CorsixTH Lua Documentation

EntityMap Class

Declared on: line 21 of Lua/entity_map.lua.

Method Index

Member Index

function EntityMap:EntityMap(map)

An entity map is a structure is a 2 dimensional structure created from a game map, it has the same dimensions as the game map which intitalises it. The purpose of the map is store the location of entities in the map in real-time. Each cell given by an (x, y) coordinate is a table {humanoids ={}, objects = {}} where the tables of humanoids/objects may be empty or contain the entity/entities that currently exist in that tile.

Parameters:

NameTypeDescription
map ? ?

Declared on: line 26 of Lua/entity_map.lua.

function EntityMap:addEntity(x, y, entity)

Adds an entity to the entity map in a specified location @param x (integer) the x coordinate of the entity @param y (integer) the y coordinate of the entity @param entity (Entity) the entity to be added to the map in the (x, y) position

Parameters:

NameTypeDescription
x ? ?
y ? ?
entity ? ?

Declared on: line 47 of Lua/entity_map.lua.

function EntityMap:afterLoad(old, new)

Parameters:

NameTypeDescription
old ? ?
new ? ?

Declared on: line 238 of Lua/entity_map.lua.

function EntityMap:getAdjacentFreeTiles(x, y)

Returns a map of coordinates {{x1, y1}, ... {xn, yn}} of the adjacent tiles (no diagonals) which do not contain any humanoids or objects does NOT determine if the tile is reachable from (x, y) may even be in a different room @param x (integer) the x coordinate to obtain free tiles from @param y (integer) the y coordinate to obtain free tiles from

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 218 of Lua/entity_map.lua.

function EntityMap:getAdjacentSquares(x, y)

Returns a map of coordinates {{x1, y1}, ... {xn, yn}} directly adjacent to a given (x, y) coordinate - no diagonals @param x (integer) the x coordinate to obtain adjacent tiles from @param y (integer) the y coordinate to obtain adjacent tiles from @return (table) containing coordinates {x=integer, y=integer}

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 163 of Lua/entity_map.lua.

function EntityMap:getEntitiesAtCoordinate(x, y)

Returns a map of all entities (objects and humanoids) at a specified coordinate @param x (integer) the x coordinate to retrieve entities from @param y (integer) the y coordinate to retrieve entities from @return entity_map (table) containing the entities at the (x, y) coordinate

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 101 of Lua/entity_map.lua.

function EntityMap:getHumanoidsAtCoordinate(x, y)

Returns a table of all humanoids at a specified coordinate

Please note that when a humanoid moves, they will only be attached to one tile at the moment. When moving from tile to tile, they will only attach to the next tile after they has fully completed the animation for moving to the that next tile. Therefore, at the last frame of the transition animation from tile to tile, they will still attached to the previous one tile, on which they is no longer visually located. @param x (integer) the x coordinate to retrieve entities from @param y (integer) the y coordinate to retrieve entities from @return (table) containing the humanoids at the (x, y) coordinate

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 125 of Lua/entity_map.lua.

function EntityMap:getHumanoidsInSquareAndInAdjacentSquares(x, y)

Returns all humanoids in the squares directly adjacent to the given (x, y) coordinate - diagonals are not considered @param x (integer) the x coordinate to obtain adjacent patients from @param y (integer) the y coordinate to obtain adjacent patients from

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 187 of Lua/entity_map.lua.

function EntityMap:getObjectsAtCoordinate(x, y)

Returns a table of all objects at a specified coordinate @param x (integer) the x coordinate to retrieve entities from @param y (integer) the y coordinate to retrieve entities from @return (table) containing the objects at the (x, y) coordinate

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 152 of Lua/entity_map.lua.

function EntityMap:getPatientsInAdjacentSquares(x, y)

Returns all the entities which are patients in the squares directly adjacent to the given (x, y) coordinate - diagonals are not considered @param x (integer) the x coordinate to obtain adjacent patients from @param y (integer) the y coordinate to obtain adjacent patients from

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 202 of Lua/entity_map.lua.

function EntityMap:getRatsAtCoordinate(x, y)

Returns a table of all rats at a specified coordinate @param x (integer) the x coordinate to retrieve entities from @param y (integer) the y coordinate to retrieve entities from @return (table) containing the objects at the (x, y) coordinate

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 142 of Lua/entity_map.lua.

function EntityMap:removeEntity(x, y, entity)

Removes an entity from the entity map given specified location Assumes the entity already has been added in the (x, y) position or will cause the assertion that the entity is contained in the map to fail. @param x (integer) the x coordinate of the entity @param y (integer) the y coordinate of the entity @param entity (Entity) the entity to be removed from the map in the (x, y) position

Parameters:

NameTypeDescription
x ? ?
y ? ?
entity ? ?

Declared on: line 80 of Lua/entity_map.lua.