supertux
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
worldmap::WorldMapSector Class Referencefinal

Represents one of (potentially) multiple, separate parts of a WorldMap. More...

#include <worldmap_sector.hpp>

Inheritance diagram for worldmap::WorldMapSector:
Inheritance graph
[legend]
Collaboration diagram for worldmap::WorldMapSector:
Collaboration graph
[legend]

Public Member Functions

 WorldMapSector (WorldMap &parent)
 
void finish_construction (bool editable) override
 Needs to be called after parsing to finish the construction of the Sector before using it. More...
 
std::string get_exposed_class_name () const override
 
void setup ()
 
void leave ()
 
void draw (DrawingContext &context) override
 
void update (float dt_sec) override
 
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
 
SpawnPointget_spawnpoint_by_name (const std::string &spawnpoint_name) const
 Get a spawnpoint by its name. More...
 
template<class T >
T * at_object () const
 
template<class T >
T * at_object (const Vector &pos) const
 
bool path_ok (const Direction &direction, const Vector &old_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 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...
 
bool in_worldmap () const override
 
float get_tux_x () const
 Returns Tux's X position on the worldmap.
 
float get_tux_y () const
 Returns Tux's Y position on the worldmap.
 
void set_sector (const std::string &sector)
 Changes the current sector of the worldmap to a specified new sector. More...
 
void spawn (const std::string &sector, const std::string &spawnpoint)
 Changes the current sector of the worldmap to a specified new sector, moving Tux to the specified spawnpoint. More...
 
void move_to_spawnpoint (const std::string &spawnpoint)
 Moves Tux to the specified spawnpoint. More...
 
void move_to_spawnpoint (const std::string &spawnpoint, bool pan)
 
std::string get_filename () const
 Gets the path to the worldmap file. More...
 
void set_title_level (const std::string &filename)
 Overrides the "Title Screen Level" property for the world with ""filename"". More...
 
TileSetget_tileset () const override
 
WorldMapget_worldmap () const
 
Cameraget_camera () const
 
Tuxget_tux () const
 
Vector get_tux_pos () const
 
- Public Member Functions inherited from Base::Sector
 Sector (const std::string &type)
 
void set_name (const std::string &name)
 
const std::string & get_name () const
 
void set_init_script (const std::string &init_script)
 
void run_script (const std::string &script, const std::string &sourcename)
 
- Public Member Functions inherited from GameObjectManager
 GameObjectManager (bool undo_tracking=false)
 
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.
 
void set_ambient_light (float red, float green, float blue)
 Sets the sector's ambient light to the specified color. More...
 
void fade_to_ambient_light (float red, float green, float blue, float fadetime)
 Fades to a specified ambient light color in ""fadetime"" seconds. More...
 
float get_ambient_red () const
 Returns the red channel of the ambient light color.
 
float get_ambient_green () const
 Returns the green channel of the ambient light color.
 
float get_ambient_blue () const
 Returns the blue channel of the ambient light color.
 
void set_music (const std::string &music)
 Sets the sector's music. More...
 
void add_object (const std::string &class_name, const std::string &name, float pos_x, float pos_y, const std::string &direction, const std::string &data)
 Adds a ""MovingObject"" to the manager. More...
 
float get_width () const
 
float get_height () const
 
float get_editor_width () const
 
float get_editor_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 move_object (const UID &uid, GameObjectManager &other)
 Move an object to another GameObjectManager. More...
 
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 resolved 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
 
const std::vector< TileMap * > & get_all_tilemaps () const
 
void update_solid (TileMap *solid)
 
void toggle_undo_tracking (bool enabled)
 Toggle object change tracking for undo/redo. More...
 
bool undo_tracking_enabled () const
 
void set_undo_stack_size (int size)
 Set undo stack size. More...
 
void undo_stack_cleanup ()
 Remove old object changes that exceed the undo stack size limit. More...
 
void undo ()
 Undo/redo changes to GameObjects in the manager. More...
 
void redo ()
 
void save_object_change (GameObject &object, const std::string &data)
 Save object change in the undo stack with given data. More...
 
void clear_undo_stack ()
 Clear undo/redo stacks. More...
 
bool has_object_changes () const
 Indicate if there are any object changes in the undo stack. More...
 
void on_editor_save ()
 Called on editor level save. More...
 

Static Public Member Functions

static void register_class (ssq::VM &vm)
 
static WorldMapSectorcurrent ()
 
- Static Public Member Functions inherited from GameObjectManager
static void register_class (ssq::VM &vm)
 

Protected Member Functions

MovingObjectadd_object_scripting (const std::string &class_name, const std::string &name, const Vector &pos, const std::string &direction, const std::string &data) override
 Add a MovingObject from scripting. More...
 
void draw_status (DrawingContext &context)
 
- Protected Member Functions inherited from Base::Sector
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 update_tilemaps ()
 
void process_resolve_requests ()
 
void try_process_resolve_requests ()
 Same as process_resolve_requests(), but those it can't find will be kept in the buffer.
 
template<class T >
T * get_object_by_type () const
 

Friends

class WorldMapSectorParser
 
class WorldMapState
 

Additional Inherited Members

- Static Public Attributes inherited from GameObjectManager
static bool s_draw_solids_only = false
 
- Protected Attributes inherited from Base::Sector
std::string m_name
 
std::string m_init_script
 
std::unique_ptr< SquirrelEnvironmentm_squirrel_environment
 
- Protected Attributes inherited from GameObjectManager
bool m_initialized
 An initial flush_game_objects() call has been initiated. More...
 

Detailed Description

Represents one of (potentially) multiple, separate parts of a WorldMap.

WorldMap variant of Sector, utilizing only its base features. This class provides additional controlling functions for a worldmap sector, other than the ones listed at ${SRG_REF_GameObjectManager}. An instance under ""worldmap.settings"" is available from scripts and the console.

Member Function Documentation

◆ add_object_scripting()

MovingObject & worldmap::WorldMapSector::add_object_scripting ( const std::string &  class_name,
const std::string &  name,
const Vector &  pos,
const std::string &  direction,
const std::string &  data 
)
overrideprotectedvirtual

Add a MovingObject from scripting.

Reimplemented from GameObjectManager.

◆ available_directions_at()

int worldmap::WorldMapSector::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.

◆ finish_construction()

void worldmap::WorldMapSector::finish_construction ( bool  editable)
overridevirtual

Needs to be called after parsing to finish the construction of the Sector before using it.

Reimplemented from Base::Sector.

◆ get_filename()

std::string worldmap::WorldMapSector::get_filename ( ) const

Gets the path to the worldmap file.

Useful for saving worldmap-specific data.

◆ get_spawnpoint_by_name()

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

Get a spawnpoint by its name.

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

◆ move_to_spawnpoint()

void worldmap::WorldMapSector::move_to_spawnpoint ( const std::string &  spawnpoint)

Moves Tux to the specified spawnpoint.

Parameters
string$spawnpoint

◆ set_initial_fade_tilemap()

void worldmap::WorldMapSector::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.

◆ set_sector()

void worldmap::WorldMapSector::set_sector ( const std::string &  sector)

Changes the current sector of the worldmap to a specified new sector.

Parameters
string$sector

◆ set_title_level()

void worldmap::WorldMapSector::set_title_level ( const std::string &  filename)

Overrides the "Title Screen Level" property for the world with ""filename"".

The newly set level will be used for the title screen, after exiting the world.

Parameters
string$filename

◆ setup()

void worldmap::WorldMapSector::setup ( )

Perform scripting related actions.

◆ spawn()

void worldmap::WorldMapSector::spawn ( const std::string &  sector,
const std::string &  spawnpoint 
)

Changes the current sector of the worldmap to a specified new sector, moving Tux to the specified spawnpoint.

Parameters
string$sector
string$spawnpoint

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