R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::MapData Class Reference

Component storing information about the current map/level. More...

#include <MapData.hpp>

Inheritance diagram for ecs::MapData:
Inheritance graph
Collaboration diagram for ecs::MapData:
Collaboration graph

Public Member Functions

 MapData ()
 Default constructor. Initializes with empty map data.
 
 MapData (const std::string &mapId, float scrollSpeed, const std::string &backgroundSprite, const std::string &spawnScript)
 Constructor with basic parameters.
 
 MapData (const std::string &mapId, const std::string &name, float scrollSpeed, const std::string &backgroundSprite, const std::string &spawnScript, float duration, const std::string &nextMapId, const std::string &parallaxBackground="", float parallaxSpeedFactor=0.5f)
 Full constructor with all parameters.
 
 ~MapData () override=default
 
const std::string & getMapId () const
 Get the map unique identifier.
 
const std::string & getName () const
 Get the map display name.
 
float getScrollSpeed () const
 Get the scroll speed.
 
const std::string & getBackgroundSprite () const
 Get the background sprite path.
 
const std::string & getParallaxBackgroundSprite () const
 Get the parallax background sprite path.
 
float getParallaxSpeedFactor () const
 Get the parallax speed factor.
 
const std::string & getSpawnScript () const
 Get the spawn script path.
 
float getDuration () const
 Get the map duration.
 
const std::string & getNextMapId () const
 Get the next map ID.
 
float getElapsedTime () const
 Get the elapsed time on this map.
 
bool isCompleted () const
 Check if the map is completed.
 
void setMapId (const std::string &mapId)
 Set the map ID.
 
void setName (const std::string &name)
 Set the map name.
 
void setScrollSpeed (float speed)
 Set the scroll speed.
 
void setBackgroundSprite (const std::string &sprite)
 Set the background sprite.
 
void setParallaxBackgroundSprite (const std::string &sprite)
 Set the parallax background sprite.
 
void setParallaxSpeedFactor (float factor)
 Set the parallax speed factor.
 
void setSpawnScript (const std::string &script)
 Set the spawn script.
 
void setDuration (float duration)
 Set the map duration.
 
void setNextMapId (const std::string &nextMapId)
 Set the next map ID.
 
void updateElapsedTime (float deltaTime)
 Update the elapsed time.
 
void markCompleted ()
 Mark the map as completed.
 
void reset ()
 Reset the map state (elapsed time and completion).
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

std::string _mapId
 Unique map identifier.
 
std::string _name
 Display name.
 
float _scrollSpeed
 Horizontal scroll speed (px/s)
 
std::string _backgroundSprite
 Background asset path.
 
std::string _parallaxBackgroundSprite
 Parallax layer asset path (rendered on top, scrolls slower)
 
float _parallaxSpeedFactor
 Speed factor for parallax layer (0.5 = half speed)
 
std::string _spawnScript
 Lua script for spawn logic.
 
float _duration
 Map duration in seconds (0 = infinite)
 
std::string _nextMapId
 Next map to load after completion.
 
float _elapsedTime
 Time spent on this map.
 
bool _isCompleted
 Completion flag.
 

Detailed Description

Component storing information about the current map/level.

Contains all data needed to configure and manage a game map, including scrolling speed, background assets, spawn script, and custom metadata.

This component is typically attached to a singleton entity that manages the active map state.

Definition at line 24 of file MapData.hpp.

Constructor & Destructor Documentation

◆ MapData() [1/3]

ecs::MapData::MapData ( )
inline

Default constructor. Initializes with empty map data.

Definition at line 30 of file MapData.hpp.

◆ MapData() [2/3]

ecs::MapData::MapData ( const std::string &  mapId,
float  scrollSpeed,
const std::string &  backgroundSprite,
const std::string &  spawnScript 
)
inline

Constructor with basic parameters.

Parameters
mapIdUnique identifier for this map
scrollSpeedHorizontal scroll speed (pixels/second)
backgroundSpriteBackground sprite asset path
spawnScriptLua script path for spawn management

Definition at line 50 of file MapData.hpp.

◆ MapData() [3/3]

ecs::MapData::MapData ( const std::string &  mapId,
const std::string &  name,
float  scrollSpeed,
const std::string &  backgroundSprite,
const std::string &  spawnScript,
float  duration,
const std::string &  nextMapId,
const std::string &  parallaxBackground = "",
float  parallaxSpeedFactor = 0.5f 
)
inline

Full constructor with all parameters.

Parameters
mapIdUnique identifier for this map
nameDisplay name of the map
scrollSpeedHorizontal scroll speed (pixels/second)
backgroundSpriteBackground sprite asset path
spawnScriptLua script path for spawn management
durationMap duration in seconds (0 = infinite)
nextMapIdID of the next map to load after completion
parallaxBackgroundParallax layer sprite (rendered on top, scrolls slower)
parallaxSpeedFactorSpeed factor for parallax layer (0.5 = half speed)

Definition at line 76 of file MapData.hpp.

◆ ~MapData()

ecs::MapData::~MapData ( )
overridedefault

Member Function Documentation

◆ getBackgroundSprite()

const std::string & ecs::MapData::getBackgroundSprite ( ) const
inline

Get the background sprite path.

Returns
Background sprite asset path

Definition at line 118 of file MapData.hpp.

References _backgroundSprite.

◆ getDuration()

float ecs::MapData::getDuration ( ) const
inline

Get the map duration.

Returns
Duration in seconds (0 = infinite)

Definition at line 142 of file MapData.hpp.

References _duration.

Referenced by server::GameLogic::loadMap().

◆ getElapsedTime()

float ecs::MapData::getElapsedTime ( ) const
inline

Get the elapsed time on this map.

Returns
Elapsed time in seconds

Definition at line 154 of file MapData.hpp.

References _elapsedTime.

◆ getMapId()

const std::string & ecs::MapData::getMapId ( ) const
inline

Get the map unique identifier.

Returns
Map ID string

Definition at line 100 of file MapData.hpp.

References _mapId.

Referenced by server::GameLogic::loadMap().

◆ getName()

const std::string & ecs::MapData::getName ( ) const
inline

Get the map display name.

Returns
Map name string

Definition at line 106 of file MapData.hpp.

References _name.

Referenced by server::GameLogic::loadMap().

◆ getNextMapId()

const std::string & ecs::MapData::getNextMapId ( ) const
inline

Get the next map ID.

Returns
ID of the next map to load

Definition at line 148 of file MapData.hpp.

References _nextMapId.

◆ getParallaxBackgroundSprite()

const std::string & ecs::MapData::getParallaxBackgroundSprite ( ) const
inline

Get the parallax background sprite path.

Returns
Parallax background sprite asset path (rendered on top, scrolls slower)

Definition at line 124 of file MapData.hpp.

References _parallaxBackgroundSprite.

◆ getParallaxSpeedFactor()

float ecs::MapData::getParallaxSpeedFactor ( ) const
inline

Get the parallax speed factor.

Returns
Speed factor for parallax layer (0.5 = half speed of main background)

Definition at line 130 of file MapData.hpp.

References _parallaxSpeedFactor.

◆ getScrollSpeed()

float ecs::MapData::getScrollSpeed ( ) const
inline

Get the scroll speed.

Returns
Scroll speed in pixels/second

Definition at line 112 of file MapData.hpp.

References _scrollSpeed.

Referenced by server::GameLogic::loadMap().

◆ getSpawnScript()

const std::string & ecs::MapData::getSpawnScript ( ) const
inline

Get the spawn script path.

Returns
Lua script path for spawn management

Definition at line 136 of file MapData.hpp.

References _spawnScript.

Referenced by server::GameLogic::loadMap().

◆ getType()

ComponentType ecs::MapData::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for MapData component.

Implements ecs::IComponent.

Definition at line 241 of file MapData.hpp.

◆ isCompleted()

bool ecs::MapData::isCompleted ( ) const
inline

Check if the map is completed.

Returns
True if map is completed

Definition at line 160 of file MapData.hpp.

References _isCompleted.

◆ markCompleted()

void ecs::MapData::markCompleted ( )
inline

Mark the map as completed.

Definition at line 227 of file MapData.hpp.

References _isCompleted.

◆ reset()

void ecs::MapData::reset ( )
inline

Reset the map state (elapsed time and completion).

Definition at line 232 of file MapData.hpp.

References _elapsedTime, and _isCompleted.

◆ setBackgroundSprite()

void ecs::MapData::setBackgroundSprite ( const std::string &  sprite)
inline

Set the background sprite.

Parameters
spriteNew background sprite path

Definition at line 186 of file MapData.hpp.

References _backgroundSprite.

◆ setDuration()

void ecs::MapData::setDuration ( float  duration)
inline

Set the map duration.

Parameters
durationNew duration in seconds

Definition at line 210 of file MapData.hpp.

References _duration.

◆ setMapId()

void ecs::MapData::setMapId ( const std::string &  mapId)
inline

Set the map ID.

Parameters
mapIdNew map ID

Definition at line 168 of file MapData.hpp.

References _mapId.

◆ setName()

void ecs::MapData::setName ( const std::string &  name)
inline

Set the map name.

Parameters
nameNew map name

Definition at line 174 of file MapData.hpp.

References _name.

◆ setNextMapId()

void ecs::MapData::setNextMapId ( const std::string &  nextMapId)
inline

Set the next map ID.

Parameters
nextMapIdNew next map ID

Definition at line 216 of file MapData.hpp.

References _nextMapId.

◆ setParallaxBackgroundSprite()

void ecs::MapData::setParallaxBackgroundSprite ( const std::string &  sprite)
inline

Set the parallax background sprite.

Parameters
spriteNew parallax background sprite path

Definition at line 192 of file MapData.hpp.

References _parallaxBackgroundSprite.

◆ setParallaxSpeedFactor()

void ecs::MapData::setParallaxSpeedFactor ( float  factor)
inline

Set the parallax speed factor.

Parameters
factorNew speed factor (0.5 = half speed)

Definition at line 198 of file MapData.hpp.

References _parallaxSpeedFactor.

◆ setScrollSpeed()

void ecs::MapData::setScrollSpeed ( float  speed)
inline

Set the scroll speed.

Parameters
speedNew scroll speed in pixels/second

Definition at line 180 of file MapData.hpp.

References _scrollSpeed.

◆ setSpawnScript()

void ecs::MapData::setSpawnScript ( const std::string &  script)
inline

Set the spawn script.

Parameters
scriptNew Lua script path

Definition at line 204 of file MapData.hpp.

References _spawnScript.

◆ updateElapsedTime()

void ecs::MapData::updateElapsedTime ( float  deltaTime)
inline

Update the elapsed time.

Parameters
deltaTimeTime increment in seconds

Definition at line 222 of file MapData.hpp.

References _elapsedTime.

Referenced by ecs::MapSystem::update().

Member Data Documentation

◆ _backgroundSprite

std::string ecs::MapData::_backgroundSprite
private

Background asset path.

Definition at line 247 of file MapData.hpp.

Referenced by getBackgroundSprite(), and setBackgroundSprite().

◆ _duration

float ecs::MapData::_duration
private

Map duration in seconds (0 = infinite)

Definition at line 252 of file MapData.hpp.

Referenced by getDuration(), and setDuration().

◆ _elapsedTime

float ecs::MapData::_elapsedTime
private

Time spent on this map.

Definition at line 254 of file MapData.hpp.

Referenced by getElapsedTime(), reset(), and updateElapsedTime().

◆ _isCompleted

bool ecs::MapData::_isCompleted
private

Completion flag.

Definition at line 255 of file MapData.hpp.

Referenced by isCompleted(), markCompleted(), and reset().

◆ _mapId

std::string ecs::MapData::_mapId
private

Unique map identifier.

Definition at line 244 of file MapData.hpp.

Referenced by getMapId(), and setMapId().

◆ _name

std::string ecs::MapData::_name
private

Display name.

Definition at line 245 of file MapData.hpp.

Referenced by getName(), and setName().

◆ _nextMapId

std::string ecs::MapData::_nextMapId
private

Next map to load after completion.

Definition at line 253 of file MapData.hpp.

Referenced by getNextMapId(), and setNextMapId().

◆ _parallaxBackgroundSprite

std::string ecs::MapData::_parallaxBackgroundSprite
private

Parallax layer asset path (rendered on top, scrolls slower)

Definition at line 249 of file MapData.hpp.

Referenced by getParallaxBackgroundSprite(), and setParallaxBackgroundSprite().

◆ _parallaxSpeedFactor

float ecs::MapData::_parallaxSpeedFactor
private

Speed factor for parallax layer (0.5 = half speed)

Definition at line 250 of file MapData.hpp.

Referenced by getParallaxSpeedFactor(), and setParallaxSpeedFactor().

◆ _scrollSpeed

float ecs::MapData::_scrollSpeed
private

Horizontal scroll speed (px/s)

Definition at line 246 of file MapData.hpp.

Referenced by getScrollSpeed(), and setScrollSpeed().

◆ _spawnScript

std::string ecs::MapData::_spawnScript
private

Lua script for spawn logic.

Definition at line 251 of file MapData.hpp.

Referenced by getSpawnScript(), and setSpawnScript().


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