supertux
Public Member Functions | Static Public Member Functions | Friends | List of all members
Sector Class Referencefinal

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

#include <sector.hpp>

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

Public Member Functions

 Sector (Level &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
 
Levelget_level () const
 
TileSetget_tileset () const override
 
bool in_worldmap () const override
 
void activate (const std::string &spawnpoint)
 activates this sector (change music, initialize player class, ...)
 
void activate (const Vector &player_pos)
 
void deactivate ()
 
void draw (DrawingContext &context) override
 
void update (float dt_sec) override
 
void save (Writer &writer)
 
void stop_looping_sounds ()
 stops all looping sounds in whole sector. More...
 
void pause_camera_interpolation ()
 Freeze camera position for this frame, preventing camera interpolation jumps and loops.
 
void play_looping_sounds ()
 continues the looping sounds in whole sector. More...
 
bool inside (const Rectf &rectangle) const
 tests if a given rectangle is inside the sector (a rectangle that is on top of the sector is considered inside)
 
bool is_free_of_tiles (const Rectf &rect, const bool ignoreUnisolid=false, uint32_t tiletype=Tile::SOLID) const
 Checks if the specified rectangle is free of (solid) tiles. More...
 
bool is_free_of_solid_tiles (float left, float top, float right, float bottom, bool ignore_unisolid) const
 Checks if the specified sector-relative rectangle is free of solid tiles. More...
 
bool is_free_of_statics (const Rectf &rect, const MovingObject *ignore_object=nullptr, const bool ignoreUnisolid=false) const
 Checks if the specified rectangle is free of both 1.) solid tiles and 2.) MovingObjects in COLGROUP_STATIC. More...
 
bool is_free_of_statics (float left, float top, float right, float bottom, bool ignore_unisolid) const
 Checks if the specified sector-relative rectangle is free of both: 1) Solid tiles. More...
 
bool is_free_of_movingstatics (const Rectf &rect, const MovingObject *ignore_object=nullptr) const
 Checks if the specified rectangle is free of both 1.) solid tiles and 2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING. More...
 
bool is_free_of_movingstatics (float left, float top, float right, float bottom) const
 Checks if the specified sector-relative rectangle is free of both: 1) Solid tiles. More...
 
bool is_free_of_specifically_movingstatics (const Rectf &rect, const MovingObject *ignore_object=nullptr) const
 Checks if the specified rectangle is free of MovingObjects in COLGROUP_MOVINGSTATIC. More...
 
bool is_free_of_specifically_movingstatics (float left, float top, float right, float bottom) const
 Checks if the specified sector-relative rectangle is free of ""MovingObject""s in ""COLGROUP_MOVINGSTATIC"". More...
 
CollisionSystem::RaycastResult get_first_line_intersection (const Vector &line_start, const Vector &line_end, bool ignore_objects, const CollisionObject *ignore_object) const
 
bool free_line_of_sight (const Vector &line_start, const Vector &line_end, bool ignore_objects=false, const MovingObject *ignore_object=nullptr) const
 
bool can_see_player (const Vector &eye) const
 
Playerget_nearest_player (const Vector &pos) const
 
Playerget_nearest_player (const Rectf &pos) const
 
std::vector< MovingObject * > get_nearby_objects (const Vector &center, float max_distance) const
 
Rectf get_active_region () const
 
int get_foremost_opaque_layer () const
 
int get_foremost_layer () const
 
Size get_editor_size () const
 returns the editor size (in tiles) of a sector
 
void resize_sector (const Size &old_size, const Size &new_size, const Size &resize_offset)
 resize all tilemaps with given size
 
void change_solid_tiles (uint32_t old_tile_id, uint32_t new_tile_id)
 globally changes solid tilemaps' tile ids
 
void set_gravity (float gravity)
 
float get_gravity () const
 
Cameraget_camera () const
 
std::vector< Player * > get_players () const
 
DisplayEffectget_effect () const
 
TextObjectget_text_object () const
 
Vector get_spawn_point_position (const std::string &spawnpoint)
 
- 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 Sectorget ()
 get currently activated sector. More...
 
static Sectorcurrent ()
 
- Static Public Member Functions inherited from GameObjectManager
static void register_class (ssq::VM &vm)
 

Friends

class CollisionSystem
 
class EditorSectorMenu
 

Additional Inherited Members

- Static Public Attributes inherited from GameObjectManager
static bool s_draw_solids_only = false
 
- 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 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 Level.

Sectors contain GameObjects, e.g. Badguys and Players. This class provides additional controlling functions for a sector, other than the ones listed at ${SRG_REF_GameObjectManager}. An instance under ""sector.settings"" is available from scripts and the console.

Member Function Documentation

◆ finish_construction()

void Sector::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()

static Sector& Sector::get ( )
inlinestatic

get currently activated sector.

◆ get_gravity()

float Sector::get_gravity ( ) const

Deprecated:
Use the ""gravity"" property instead! Returns the sector's gravity.
Parameters
float$gravity

◆ is_free_of_movingstatics() [1/2]

bool Sector::is_free_of_movingstatics ( const Rectf rect,
const MovingObject ignore_object = nullptr 
) const

Checks if the specified rectangle is free of both 1.) solid tiles and 2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING.

This includes badguys and players.

◆ is_free_of_movingstatics() [2/2]

bool Sector::is_free_of_movingstatics ( float  left,
float  top,
float  right,
float  bottom 
) const

Checks if the specified sector-relative rectangle is free of both: 1) Solid tiles.

2) ""MovingObject""s in ""COLGROUP_STATIC"", ""COLGROUP_MOVINGSTATIC"" or ""COLGROUP_MOVING"". This includes badguys and players.

Parameters
float$left
float$top
float$right
float$bottom

◆ is_free_of_solid_tiles()

bool Sector::is_free_of_solid_tiles ( float  left,
float  top,
float  right,
float  bottom,
bool  ignore_unisolid 
) const

Checks if the specified sector-relative rectangle is free of solid tiles.

Parameters
float$left
float$top
float$right
float$bottom
bool$ignore_unisolidIf ""true"", unisolid tiles will be ignored.

◆ is_free_of_specifically_movingstatics() [1/2]

bool Sector::is_free_of_specifically_movingstatics ( const Rectf rect,
const MovingObject ignore_object = nullptr 
) const

Checks if the specified rectangle is free of MovingObjects in COLGROUP_MOVINGSTATIC.

Note that this does not include moving badguys, or players

◆ is_free_of_specifically_movingstatics() [2/2]

bool Sector::is_free_of_specifically_movingstatics ( float  left,
float  top,
float  right,
float  bottom 
) const

Checks if the specified sector-relative rectangle is free of ""MovingObject""s in ""COLGROUP_MOVINGSTATIC"".

Note: This does not include moving badguys or players.

Parameters
float$left
float$top
float$right
float$bottom

◆ is_free_of_statics() [1/2]

bool Sector::is_free_of_statics ( const Rectf rect,
const MovingObject ignore_object = nullptr,
const bool  ignoreUnisolid = false 
) const

Checks if the specified rectangle is free of both 1.) solid tiles and 2.) MovingObjects in COLGROUP_STATIC.

Note that this does not include badguys or players.

◆ is_free_of_statics() [2/2]

bool Sector::is_free_of_statics ( float  left,
float  top,
float  right,
float  bottom,
bool  ignore_unisolid 
) const

Checks if the specified sector-relative rectangle is free of both: 1) Solid tiles.

2) ""MovingObject""s in ""COLGROUP_STATIC"". Note: This does not include badguys or players.

Parameters
float$left
float$top
float$right
float$bottom
bool$ignore_unisolidIf ""true"", unisolid tiles will be ignored.

◆ is_free_of_tiles()

bool Sector::is_free_of_tiles ( const Rectf rect,
const bool  ignoreUnisolid = false,
uint32_t  tiletype = Tile::SOLID 
) const

Checks if the specified rectangle is free of (solid) tiles.

Note that this does not include static objects, e.g. bonus blocks.

◆ play_looping_sounds()

void Sector::play_looping_sounds ( )

continues the looping sounds in whole sector.

◆ set_gravity()

void Sector::set_gravity ( float  gravity)

Deprecated:
Use the ""gravity"" property instead! Sets the sector's gravity.
Parameters
float$gravity

◆ stop_looping_sounds()

void Sector::stop_looping_sounds ( )

stops all looping sounds in whole sector.


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