supertux
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Base::Sector Class Referenceabstract

A base for sector classes. More...

#include <sector_base.hpp>

Inheritance diagram for Base::Sector:
Inheritance graph
[legend]
Collaboration diagram for Base::Sector:
Collaboration graph
[legend]

Public Member Functions

 Sector (const std::string &type)
 
virtual void finish_construction (bool editable)
 Needs to be called after parsing to finish the construction of the Sector before using it. More...
 
virtual void draw (DrawingContext &context)=0
 
virtual void update (float dt_sec)=0
 
virtual TileSetget_tileset () const =0
 
virtual bool in_worldmap () const =0
 
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)
 
virtual std::string get_exposed_class_name () const override
 
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...
 

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
virtual MovingObjectadd_object_scripting (const std::string &class_name, const std::string &name, const Vector &pos, const std::string &direction, const std::string &data)
 Add a MovingObject from scripting. More...
 
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
 

Protected Attributes

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...
 

Additional Inherited Members

- Static Public Member Functions inherited from GameObjectManager
static void register_class (ssq::VM &vm)
 
- Static Public Attributes inherited from GameObjectManager
static bool s_draw_solids_only = false
 

Detailed Description

A base for sector classes.

Contains main properties and functions.

Member Function Documentation

◆ finish_construction()

void Sector::finish_construction ( bool  editable)
virtual

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

Reimplemented in Sector, and worldmap::WorldMapSector.


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