Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Renderable Class Reference

Base class for renderable components in the engine. More...

#include <renderable.h>

Inheritance diagram for Renderable:
[legend]

Public Member Functions

 Renderable ()
 
 Renderable (int layer)
 
 ~Renderable () override=default
 
Renderableorder_in_layer (int layer)
 
int order_in_layer () const
 
void set_render_strategy (Component &component)
 
virtual IRenderingStrategyrender_strategy () const
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
Renderabledisable_draw () noexcept
 
Renderableenable_draw () noexcept
 
bool should_draw () const noexcept
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=default
 
bool active () const noexcept
 Checks if the component is active.
 
Componentactive (bool value) noexcept
 
bool marked_for_deletion () const noexcept
 Activates the component.
 
Componentmark_for_deletion () noexcept
 
virtual void update (float dt)=0
 
virtual void on_attach ()
 Called when the component is attached to a GameObject.
 
virtual void on_detach ()
 Called when the component is detached from a GameObject.
 
virtual void on_serialize (std::vector< uint8_t > &) const
 Serializes the component's state into a byte array.
 
virtual void on_deserialize (const std::vector< uint8_t > &, size_t &)
 Deserializes the component's state from a byte array.
 
const std::optional< std::reference_wrapper< GameObject > > & parent () const noexcept
 Gets the parent GameObject of this component.
 
std::optional< std::reference_wrapper< GameObject > > & parent () noexcept
 Gets the parent GameObject of this component.
 
Componentparent (GameObject &parent)
 
Componentparent (std::nullopt_t nullopt)
 
size_t add_on_attach (const std::function< void(Component &)> &action)
 Retrieves the type information of the component.
 
void remove_on_attach (size_t index)
 
size_t add_on_detach (const std::function< void(Component &)> &action)
 Adds an action to be performed when the component is attached.
 
void remove_on_detach (size_t index)
 

Protected Attributes

std::unique_ptr< IRenderingStrategyrender_strategy_
 
int ordering_layer_ = 0
 
bool draw {true}
 

Detailed Description

Base class for renderable components in the engine.

Renderable components are those that can be drawn on the screen using a rendering strategy. They hold a unique pointer to an IRenderingStrategy which defines how the component is rendered. This class extends the Component class and provides functionality to set and retrieve the rendering strategy.

Constructor & Destructor Documentation

◆ Renderable() [1/2]

Renderable::Renderable ( )
explicit

◆ Renderable() [2/2]

Renderable::Renderable ( int  layer)
explicit

◆ ~Renderable()

Renderable::~Renderable ( )
overridedefault

Member Function Documentation

◆ disable_draw()

Renderable & Renderable::disable_draw ( )
noexcept

◆ enable_draw()

Renderable & Renderable::enable_draw ( )
noexcept

◆ order_in_layer() [1/2]

int Renderable::order_in_layer ( ) const

◆ order_in_layer() [2/2]

Renderable & Renderable::order_in_layer ( int  layer)

◆ render_strategy()

virtual IRenderingStrategy & Renderable::render_strategy ( ) const
virtual

◆ set_render_strategy()

void Renderable::set_render_strategy ( Component component)

◆ should_draw()

bool Renderable::should_draw ( ) const
noexcept

◆ type_name()

std::string Renderable::type_name ( ) const
overridevirtual

Provides a consistent type name for the component.

Returns
A string representing the type name of the component. @CAUTION: All derived components must implement this method to ensure consistent serialization across different compilers and platforms.

Implements Component.

Reimplemented in Sprite, and Text.

Member Data Documentation

◆ draw

bool Renderable::draw {true}
protected

◆ ordering_layer_

int Renderable::ordering_layer_ = 0
protected

◆ render_strategy_

std::unique_ptr<IRenderingStrategy> Renderable::render_strategy_
protected

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