Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
network_identity.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <string>
6
24class NetworkIdentity : public Component {
25 private:
26 std::string uuid_;
27 std::string owner_uuid_;
28 bool dirty_{false};
29
30 public:
32 explicit NetworkIdentity(const std::string& uuid);
33
34 [[nodiscard]] const std::string& uuid() const noexcept;
35 void set_uuid(const std::string& uuid) noexcept;
36
37 [[nodiscard]] const std::string& owner_uuid() const noexcept;
38 void set_owner_uuid(const std::string& owner) noexcept;
39
40 void mark_dirty() noexcept;
41 void clear_dirty() noexcept;
42 [[nodiscard]] bool is_dirty() const noexcept;
43
44 // Component interface
45 void update(float /*dt*/) override {}
46 void on_serialize(std::vector<uint8_t>& /*out*/) const override;
47 void on_deserialize(const std::vector<uint8_t>& /*data*/,
48 size_t& /*offset*/) override;
49 std::string type_name() const override { return "NetworkIdentity"; }
50};
Base class for all components that can be attached to GameObjects.
Definition component.h:24
Component that gives a GameObject a network identity (UUID) and dirty flag.
Definition network_identity.h:24
bool is_dirty() const noexcept
const std::string & owner_uuid() const noexcept
void mark_dirty() noexcept
const std::string & uuid() const noexcept
void on_deserialize(const std::vector< uint8_t > &, size_t &) override
Deserializes the component's state from a byte array.
void update(float) override
Definition network_identity.h:45
std::string type_name() const override
Provides a consistent type name for the component.
Definition network_identity.h:49
void clear_dirty() noexcept
void set_owner_uuid(const std::string &owner) noexcept
void on_serialize(std::vector< uint8_t > &) const override
Serializes the component's state into a byte array.
void set_uuid(const std::string &uuid) noexcept
NetworkIdentity(const std::string &uuid)
Definition uuid.h:4