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

Component that gives a GameObject a network identity (UUID) and dirty flag. More...

#include <network_identity.h>

Inheritance diagram for NetworkIdentity:
[legend]

Public Member Functions

 NetworkIdentity ()
 
 NetworkIdentity (const std::string &uuid)
 
const std::string & uuid () const noexcept
 
void set_uuid (const std::string &uuid) noexcept
 
const std::string & owner_uuid () const noexcept
 
void set_owner_uuid (const std::string &owner) noexcept
 
void mark_dirty () noexcept
 
void clear_dirty () noexcept
 
bool is_dirty () const noexcept
 
void update (float) override
 
void on_serialize (std::vector< uint8_t > &) const override
 Serializes the component's state into a byte array.
 
void on_deserialize (const std::vector< uint8_t > &, size_t &) override
 Deserializes the component's state from a byte array.
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
- 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 on_attach ()
 Called when the component is attached to a GameObject.
 
virtual void on_detach ()
 Called when the component is detached from a GameObject.
 
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)
 

Detailed Description

Component that gives a GameObject a network identity (UUID) and dirty flag.

Attach this to any GameObject that should be replicated. Systems or user code should call mark_dirty() when the object's networked state changes.

Usage:

Constructor & Destructor Documentation

◆ NetworkIdentity() [1/2]

NetworkIdentity::NetworkIdentity ( )

◆ NetworkIdentity() [2/2]

NetworkIdentity::NetworkIdentity ( const std::string &  uuid)
explicit

Member Function Documentation

◆ clear_dirty()

void NetworkIdentity::clear_dirty ( )
noexcept

◆ is_dirty()

bool NetworkIdentity::is_dirty ( ) const
noexcept

◆ mark_dirty()

void NetworkIdentity::mark_dirty ( )
noexcept

◆ on_deserialize()

void NetworkIdentity::on_deserialize ( const std::vector< uint8_t > &  ,
size_t &   
)
overridevirtual

Deserializes the component's state from a byte array.

Parameters
dataThe byte array containing the serialized state.
offsetThe current offset in the byte array from which to start reading. This offset will be updated as bytes are read.
Returns
void

Reimplemented from Component.

◆ on_serialize()

void NetworkIdentity::on_serialize ( std::vector< uint8_t > &  ) const
overridevirtual

Serializes the component's state into a byte array.

Parameters
outA vector to which the serialized bytes will be appended.
Returns
A vector of bytes representing the serialized state of the component.

Reimplemented from Component.

◆ owner_uuid()

const std::string & NetworkIdentity::owner_uuid ( ) const
noexcept

◆ set_owner_uuid()

void NetworkIdentity::set_owner_uuid ( const std::string &  owner)
noexcept

◆ set_uuid()

void NetworkIdentity::set_uuid ( const std::string &  uuid)
noexcept

◆ type_name()

std::string NetworkIdentity::type_name ( ) const
inlineoverridevirtual

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.

◆ update()

void NetworkIdentity::update ( float  )
inlineoverridevirtual

Implements Component.

◆ uuid()

const std::string & NetworkIdentity::uuid ( ) const
noexcept

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