supertux
Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
worldmap::WorldMap Class Referencefinal
Inheritance diagram for worldmap::WorldMap:
GameObjectManager Currenton< WorldMap >

Public Member Functions

 WorldMap (const std::string &filename, Savegame &savegame, const std::string &force_spawnpoint="")
 
void finish_construction ()
 
void setup ()
 
void leave ()
 
void draw (DrawingContext &context)
 
void update (float dt_sec)
 
void process_input (const Controller &controller)
 
Vector get_next_tile (const Vector &pos, const Direction &direction) const
 
int available_directions_at (const Vector &pos) const
 gets a bitfield of Tile::WORLDMAP_NORTH | Tile::WORLDMAP_WEST | ... More...
 
int tile_data_at (const Vector &pos) const
 returns a bitfield representing the union of all Tile::WORLDMAP_XXX values of all solid tiles at the given position
 
size_t level_count () const
 
size_t solved_level_count () const
 
void finished_level (Level *level)
 gets called from the GameSession when a level has been successfully finished
 
Savegameget_savegame () const
 
SpawnPointget_spawnpoint_by_name (const std::string &spawnpoint_name) const
 Get a spawnpoint by its name. More...
 
LevelTileat_level () const
 
SpecialTileat_special_tile () const
 
SpriteChangeat_sprite_change (const Vector &pos) const
 
Teleporterat_teleporter (const Vector &pos) const
 
bool path_ok (const Direction &direction, const Vector &pos, Vector *new_pos) const
 Check if it is possible to walk from pos into direction, if possible, write the new position to new_pos.
 
void save_state ()
 Save worldmap state to squirrel state table.
 
void load_state ()
 Load worldmap state from squirrel state table.
 
const std::string & get_title () const
 
void change (const std::string &filename, const std::string &force_spawnpoint="")
 switch to another worldmap. More...
 
void move_to_spawnpoint (const std::string &spawnpoint, bool pan=false, bool main_as_default=true)
 Moves Tux to the given spawnpoint. More...
 
void set_levels_solved (bool solved, bool perfect)
 Mark all levels as solved or unsolved.
 
void set_initial_fade_tilemap (const std::string &tilemap_name, int direction)
 Sets the name of the tilemap that should fade when worldmap is set up. More...
 
void set_initial_spawnpoint (const std::string &spawnpoint_name)
 Sets the initial spawnpoint on worldmap setup.
 
void run_script (const std::string &script, const std::string &sourcename)
 
void set_passive_message (const std::string &message, float time)
 
Cameraget_camera () const
 
- Public Member Functions inherited from GameObjectManager
GameObjectadd_object (std::unique_ptr< GameObject > object)
 Queue an object up to be added to the object list.
 
void clear_objects ()
 
template<typename T , typename... Args>
T & add (Args &&... args)
 
void update (float dt_sec)
 
void draw (DrawingContext &context)
 
const std::vector< std::unique_ptr< GameObject > > & get_objects () const
 
void flush_game_objects ()
 Commit the queued up additions and deletions to the object list.
 
float get_width () const
 
float get_height () const
 
float get_tiles_width () const
 returns the width (in tiles) of a worldmap
 
float get_tiles_height () const
 returns the height (in tiles) of a worldmap
 
template<class T >
GameObjectRange< T > get_objects_by_type () const
 
const std::vector< GameObject * > & get_objects_by_type_index (std::type_index type_idx) const
 
template<class T >
T & get_singleton_by_type () const
 
template<class T >
T * get_object_by_uid (const UID &uid) const
 
void request_name_resolve (const std::string &name, std::function< void(UID)> callback)
 Register a callback to be called once the given name can be resolsed to a UID. More...
 
template<class T >
T * get_object_by_name (const std::string &name) const
 
template<class T >
int get_object_count (std::function< bool(const T &)> predicate=nullptr) const
 Get total number of GameObjects of given type.
 
const std::vector< TileMap * > & get_solid_tilemaps () const
 

Static Public Attributes

static Color level_title_color
 
static Color message_color
 
static Color teleporter_message_color
 
- Static Public Attributes inherited from GameObjectManager
static bool s_draw_solids_only = false
 

Protected Member Functions

virtual bool before_object_add (GameObject &object) override
 Hook that is called before an object is added to the vector.
 
virtual void before_object_remove (GameObject &object) override
 Hook that is called before an object is removed from the vector.
 
- Protected Member Functions inherited from GameObjectManager
void process_resolve_requests ()
 
template<class T >
T * get_object_by_type () const
 

Friends

class WorldMapParser
 
class WorldMapState
 

Additional Inherited Members

- Static Public Member Functions inherited from Currenton< WorldMap >
static WorldMap * current ()
 

Member Function Documentation

§ available_directions_at()

int worldmap::WorldMap::available_directions_at ( const Vector pos) const

gets a bitfield of Tile::WORLDMAP_NORTH | Tile::WORLDMAP_WEST | ...

values, which indicates the directions Tux can move to when at the given position.

§ change()

void worldmap::WorldMap::change ( const std::string &  filename,
const std::string &  force_spawnpoint = "" 
)

switch to another worldmap.

filename is relative to data root path

§ get_spawnpoint_by_name()

SpawnPoint* worldmap::WorldMap::get_spawnpoint_by_name ( const std::string &  spawnpoint_name) const
inline

Get a spawnpoint by its name.

Parameters
nameThe name of the spawnpoint
Returns
spawnpoint corresponding to that name

§ move_to_spawnpoint()

void worldmap::WorldMap::move_to_spawnpoint ( const std::string &  spawnpoint,
bool  pan = false,
bool  main_as_default = true 
)

Moves Tux to the given spawnpoint.

Parameters
spawnpointName of the spawnpoint to move to
panPan the camera during to new spawnpoint
main_as_defaultMove Tux to main spawnpoint if specified spawnpoint can't be found

§ set_initial_fade_tilemap()

void worldmap::WorldMap::set_initial_fade_tilemap ( const std::string &  tilemap_name,
int  direction 
)
inline

Sets the name of the tilemap that should fade when worldmap is set up.


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