CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
level_map Class Reference

#include <th_map.h>

Public Member Functions

 level_map ()=default
 
 ~level_map ()
 
bool set_size (int iWidth, int iHeight)
 
bool load_blank ()
 
bool load_from_th_file (const uint8_t *pData, size_t iDataLength, map_load_object_callback_fn fnObjectCallback, void *pCallbackToken)
 
void save (const std::string &filename)
 
void set_block_sheet (sprite_sheet *pSheet)
 Set the sprite sheet to be used for drawing the map.
 
void set_all_wall_draw_flags (uint8_t iFlags)
 Set the draw flags on all wall blocks.
 
void update_pathfinding ()
 
void update_shadows ()
 
void set_temperature_display (temperature_theme eTempDisplay)
 
temperature_theme get_temperature_display () const
 
void update_temperatures (uint16_t iAirTemperature, uint16_t iRadiatorTemperature)
 
int get_width () const
 Get the map width (in tiles)
 
int get_height () const
 Get the map height (in tiles)
 
int get_parcel_count () const
 Get the number of plots of land in this map.
 
int get_player_count () const
 
void set_player_count (int count)
 
bool get_player_camera_tile (int iPlayer, int *pX, int *pY) const
 
bool get_player_heliport_tile (int iPlayer, int *pX, int *pY) const
 
void set_player_camera_tile (int iPlayer, int iX, int iY)
 
void set_player_heliport_tile (int iPlayer, int iX, int iY)
 
int get_parcel_tile_count (int iParcelId) const
 Get the number of tiles inside a given parcel.
 
std::vector< std::pair< int, int > > set_parcel_owner (int iParcelId, int iOwner)
 Change the owner of a particular parcel.
 
int get_parcel_owner (int iParcelId) const
 Get the owner of a particular parcel of land.
 
bool are_parcels_adjacent (int iParcel1, int iParcel2)
 Query if two parcels are directly connected.
 
bool is_parcel_purchasable (int iParcelId, int iPlayer)
 Query if a given player is in a position to purchase a given parcel.
 
void draw (render_target *pCanvas, int iScreenX, int iScreenY, int iWidth, int iHeight, int iCanvasX, int iCanvasY) const
 Draw the map (and any attached animations)
 
drawablehit_test (int iTestX, int iTestY) const
 Perform a hit-test against the animations attached to the map.
 
map_tileget_tile (int iX, int iY)
 
const map_tileget_tile (int iX, int iY) const
 
const map_tileget_original_tile (int iX, int iY) const
 
map_tileget_tile_unchecked (int iX, int iY)
 
const map_tileget_tile_unchecked (int iX, int iY) const
 
const map_tileget_original_tile_unchecked (int iX, int iY) const
 
uint16_t get_tile_temperature (const map_tile *pNode) const
 
int get_tile_owner (const map_tile *pNode) const
 
void persist (lua_persist_writer *pWriter) const
 
void depersist (lua_persist_reader *pReader)
 
void set_overlay (map_overlay *pOverlay, bool bTakeOwnership)
 

Static Public Member Functions

template<typename T >
static void world_to_screen (T &x, T &y)
 Convert world (tile) coordinates to absolute screen coordinates.
 
template<typename T >
static void screen_to_world (T &x, T &y)
 Convert absolute screen coordinates to world (tile) coordinates.
 

Constructor & Destructor Documentation

◆ level_map()

level_map::level_map ( )
default

◆ ~level_map()

level_map::~level_map ( )

Member Function Documentation

◆ are_parcels_adjacent()

bool level_map::are_parcels_adjacent ( int  iParcel1,
int  iParcel2 
)

Query if two parcels are directly connected.

Parameters
iParcel1An integer between 0 and get_parcel_count() inclusive.
iParcel2An integer between 0 and get_parcel_count() inclusive.
Returns
true if there is a path between the two parcels which does not go into any other parcels. false otherwise.

◆ depersist()

void level_map::depersist ( lua_persist_reader pReader)

◆ draw()

void level_map::draw ( render_target pCanvas,
int  iScreenX,
int  iScreenY,
int  iWidth,
int  iHeight,
int  iCanvasX,
int  iCanvasY 
) const

Draw the map (and any attached animations)

Draws the world pixel rectangle (iScreenX, iScreenY, iWidth, iHeight) to the rectangle (iCanvasX, iCanvasY, iWidth, iHeight) on pCanvas. Note that world pixel coordinates are also known as absolute screen coordinates - they are not world (tile) coordinates, nor (relative) screen coordinates.

◆ get_height()

int level_map::get_height ( ) const
inline

Get the map height (in tiles)

◆ get_original_tile()

const map_tile * level_map::get_original_tile ( int  iX,
int  iY 
) const

◆ get_original_tile_unchecked()

const map_tile * level_map::get_original_tile_unchecked ( int  iX,
int  iY 
) const

◆ get_parcel_count()

int level_map::get_parcel_count ( ) const
inline

Get the number of plots of land in this map.

◆ get_parcel_owner()

int level_map::get_parcel_owner ( int  iParcelId) const

Get the owner of a particular parcel of land.

Parameters
iParcelIdAn integer between 0 and get_parcel_count() inclusive.
Returns
0 if the parcel is unowned, otherwise the number of the owning player.

◆ get_parcel_tile_count()

int level_map::get_parcel_tile_count ( int  iParcelId) const

Get the number of tiles inside a given parcel.

◆ get_player_camera_tile()

bool level_map::get_player_camera_tile ( int  iPlayer,
int pX,
int pY 
) const

◆ get_player_count()

int level_map::get_player_count ( ) const
inline

◆ get_player_heliport_tile()

bool level_map::get_player_heliport_tile ( int  iPlayer,
int pX,
int pY 
) const

◆ get_temperature_display()

temperature_theme level_map::get_temperature_display ( ) const
inline

◆ get_tile() [1/2]

map_tile * level_map::get_tile ( int  iX,
int  iY 
)

◆ get_tile() [2/2]

const map_tile * level_map::get_tile ( int  iX,
int  iY 
) const

◆ get_tile_owner()

int level_map::get_tile_owner ( const map_tile pNode) const

◆ get_tile_temperature()

uint16_t level_map::get_tile_temperature ( const map_tile pNode) const

◆ get_tile_unchecked() [1/2]

map_tile * level_map::get_tile_unchecked ( int  iX,
int  iY 
)

◆ get_tile_unchecked() [2/2]

const map_tile * level_map::get_tile_unchecked ( int  iX,
int  iY 
) const

◆ get_width()

int level_map::get_width ( ) const
inline

Get the map width (in tiles)

◆ hit_test()

drawable * level_map::hit_test ( int  iTestX,
int  iTestY 
) const

Perform a hit-test against the animations attached to the map.

If there is an animation at world pixel coordinates (iTestX, iTestY), then it is returned. Otherwise nullptr is returned. To perform a hit-test using world (tile) coordinates, get the tile itself and query the top 8 bits of map_tile::flags, or traverse the tile's animation lists.

◆ is_parcel_purchasable()

bool level_map::is_parcel_purchasable ( int  iParcelId,
int  iPlayer 
)

Query if a given player is in a position to purchase a given parcel.

Parameters
iParcelIdThe parcel of land to query. Should be an integer between 1 and get_parcel_count() inclusive.
iPlayerThe number of the player to perform the query on behalf of. Should be a strictly positive integer.
Returns
true if the parcel has a door to the outside, or is directly connected to a parcel already owned by the given player. false otherwise.

◆ load_blank()

bool level_map::load_blank ( )

◆ load_from_th_file()

bool level_map::load_from_th_file ( const uint8_t *  pData,
size_t  iDataLength,
map_load_object_callback_fn  fnObjectCallback,
void pCallbackToken 
)

◆ persist()

void level_map::persist ( lua_persist_writer pWriter) const

◆ save()

void level_map::save ( const std::string &  filename)

◆ screen_to_world()

template<typename T >
static void level_map::screen_to_world ( T &  x,
T &  y 
)
inlinestatic

Convert absolute screen coordinates to world (tile) coordinates.

◆ set_all_wall_draw_flags()

void level_map::set_all_wall_draw_flags ( uint8_t  iFlags)

Set the draw flags on all wall blocks.

This is typically called with THDF_Alpha50 to draw walls transparently, or with 0 to draw them opaque again.

◆ set_block_sheet()

void level_map::set_block_sheet ( sprite_sheet pSheet)

Set the sprite sheet to be used for drawing the map.

The sprites for map floor tiles, wall tiles, and map decorators all come from the given sheet.

◆ set_overlay()

void level_map::set_overlay ( map_overlay pOverlay,
bool  bTakeOwnership 
)

◆ set_parcel_owner()

std::vector< std::pair< int, int > > level_map::set_parcel_owner ( int  iParcelId,
int  iOwner 
)

Change the owner of a particular parcel.

Parameters
iParcelIdThe parcel of land to change ownership of. Should be an integer between 1 and get_parcel_count() inclusive (parcel 0 is the outside, and should never have its ownership changed).
iOwnerThe number of the player who should own the parcel, or zero if no player should own the parcel.
Returns
vSplitTiles A vector that contains tile coordinates where iParcelId is adjacent to another part of the hospital.

◆ set_player_camera_tile()

void level_map::set_player_camera_tile ( int  iPlayer,
int  iX,
int  iY 
)

◆ set_player_count()

void level_map::set_player_count ( int  count)

◆ set_player_heliport_tile()

void level_map::set_player_heliport_tile ( int  iPlayer,
int  iX,
int  iY 
)

◆ set_size()

bool level_map::set_size ( int  iWidth,
int  iHeight 
)

◆ set_temperature_display()

void level_map::set_temperature_display ( temperature_theme  eTempDisplay)

◆ update_pathfinding()

void level_map::update_pathfinding ( )

◆ update_shadows()

void level_map::update_shadows ( )

◆ update_temperatures()

void level_map::update_temperatures ( uint16_t  iAirTemperature,
uint16_t  iRadiatorTemperature 
)

◆ world_to_screen()

template<typename T >
static void level_map::world_to_screen ( T &  x,
T &  y 
)
inlinestatic

Convert world (tile) coordinates to absolute screen coordinates.


The documentation for this class was generated from the following files: