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

System managing entity boundaries and screen limits. More...

#include <BoundarySystem.hpp>

Inheritance diagram for ecs::BoundarySystem:
Inheritance graph
Collaboration diagram for ecs::BoundarySystem:
Collaboration graph

Public Member Functions

 BoundarySystem (int screenWidth=1920, int screenHeight=1080)
 Constructs a BoundarySystem with specified screen dimensions.
 
 ~BoundarySystem () override=default
 Default destructor.
 
void update (Registry &registry, float deltaTime) override
 Checks entities against screen boundaries.
 
ComponentMask getComponentMask () const override
 Gets the component mask for this system.
 
void setScreenSize (int width, int height)
 Updates the screen dimensions.
 
- Public Member Functions inherited from ecs::ISystem
virtual ~ISystem ()=default
 Virtual destructor.
 

Private Attributes

int _screenWidth
 
int _screenHeight
 

Detailed Description

System managing entity boundaries and screen limits.

Handles entities going out of bounds and applies boundary constraints. Requires Transform component.

Definition at line 22 of file BoundarySystem.hpp.

Constructor & Destructor Documentation

◆ BoundarySystem()

ecs::BoundarySystem::BoundarySystem ( int  screenWidth = 1920,
int  screenHeight = 1080 
)

Constructs a BoundarySystem with specified screen dimensions.

Parameters
screenWidthWidth of the screen/game area (default: 1920)
screenHeightHeight of the screen/game area (default: 1080)

Definition at line 16 of file BoundarySystem.cpp.

◆ ~BoundarySystem()

ecs::BoundarySystem::~BoundarySystem ( )
overridedefault

Default destructor.

Member Function Documentation

◆ getComponentMask()

ComponentMask ecs::BoundarySystem::getComponentMask ( ) const
overridevirtual

Gets the component mask for this system.

Returns
ComponentMask requiring Transform component

Implements ecs::ISystem.

Definition at line 64 of file BoundarySystem.cpp.

Referenced by update().

◆ setScreenSize()

void ecs::BoundarySystem::setScreenSize ( int  width,
int  height 
)

Updates the screen dimensions.

Allows dynamic adjustment of boundary limits when screen is resized.

Parameters
widthNew screen width
heightNew screen height

Definition at line 59 of file BoundarySystem.cpp.

References _screenHeight, and _screenWidth.

◆ update()

void ecs::BoundarySystem::update ( Registry registry,
float  deltaTime 
)
overridevirtual

Checks entities against screen boundaries.

Checks entities against boundaries and marks out-of-bounds entities for destruction.

Destroys entities that have moved outside the screen bounds (with a 100-pixel margin). Typically used for projectiles and enemies.

Parameters
registryReference to the ECS registry
deltaTimeTime elapsed since last frame (in seconds)

Instead of destroying entities directly, this system adds a PendingDestroy component. The server will then:

  1. Send EntityDestroyed messages to clients
  2. Actually destroy the entities

This prevents interpolation bugs where clients try to interpolate to old positions.

Implements ecs::ISystem.

Definition at line 29 of file BoundarySystem.cpp.

References _screenHeight, _screenWidth, ecs::Registry::getComponent(), getComponentMask(), ecs::Registry::getEntitiesWithMask(), ecs::Transform::getPosition(), ecs::Registry::hasComponent(), LOG_WARNING, ecs::OutOfBounds, and ecs::Registry::setComponent().

Here is the call graph for this function:

Member Data Documentation

◆ _screenHeight

int ecs::BoundarySystem::_screenHeight
private

Definition at line 67 of file BoundarySystem.hpp.

Referenced by setScreenSize(), and update().

◆ _screenWidth

int ecs::BoundarySystem::_screenWidth
private

Definition at line 66 of file BoundarySystem.hpp.

Referenced by setScreenSize(), and update().


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