From bd4538906f245df71277a9fbbf774686ac9a44ef Mon Sep 17 00:00:00 2001 From: MasterLaplace Date: Sat, 16 Nov 2024 23:54:13 -0500 Subject: [PATCH] feat: add version 1 component IDs and string conversion method --- Flakkari/Protocol/Components.hpp | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/Flakkari/Protocol/Components.hpp b/Flakkari/Protocol/Components.hpp index 64e225ef..165fa02f 100644 --- a/Flakkari/Protocol/Components.hpp +++ b/Flakkari/Protocol/Components.hpp @@ -78,6 +78,75 @@ class Components final { } /* namespace V_0 */ +namespace V_1 { + +enum class ComponentId : uint8_t { + // 0 - 9: 2D components + CONTROL = 0, + MOVABLE = 1, + TRANSFORM = 2, + COLLIDER = 3, + RIGIDBODY = 4, + // 10 - 19: 3D components + CONTROL_3D = 10, + MOVABLE_3D = 11, + TRANSFORM_3D = 12, + BOXCOLLIDER = 13, + SPHERECOLLIDER = 14, + RIGIDBODY_3D = 15, + // 20 - 29: Common components + CHILD = 20, + PARENT = 21, + TAG = 22, + SPAWNED = 23, + TEMPLATE = 24, + WEAPON = 25, + LEVEL = 26, + EVOLVE = 27, + HEALTH = 28, + // 30 - 39: Network components + NETWORK_EVENT = 30, + NETWORK_IP = 31, + MAX_COMPONENT +}; + +static_assert(static_cast(ComponentId::MAX_COMPONENT) <= 40, "ComponentId::MAX_COMPONENT is too big"); + +class Components final { +public: + static std::string component_to_string(ComponentId id) + { + switch (id) + { + case ComponentId::CONTROL: return "CONTROL"; + case ComponentId::CONTROL_3D: return "CONTROL_3D"; + case ComponentId::MOVABLE: return "MOVABLE"; + case ComponentId::MOVABLE_3D: return "MOVABLE_3D"; + case ComponentId::TRANSFORM: return "TRANSFORM"; + case ComponentId::TRANSFORM_3D: return "TRANSFORM_3D"; + case ComponentId::COLLIDER: return "COLLIDER"; + case ComponentId::BOXCOLLIDER: return "BOXCOLLIDER"; + case ComponentId::SPHERECOLLIDER: return "SPHERECOLLIDER"; + case ComponentId::RIGIDBODY: return "RIGIDBODY"; + case ComponentId::RIGIDBODY_3D: return "RIGIDBODY_3D"; + case ComponentId::CHILD: return "CHILD"; + case ComponentId::PARENT: return "PARENT"; + case ComponentId::TAG: return "TAG"; + case ComponentId::SPAWNED: return "SPAWNED"; + case ComponentId::TEMPLATE: return "TEMPLATE"; + case ComponentId::WEAPON: return "WEAPON"; + case ComponentId::LEVEL: return "LEVEL"; + case ComponentId::EVOLVE: return "EVOLVE"; + case ComponentId::HEALTH: return "HEALTH"; + case ComponentId::NETWORK_EVENT: return "NETWORK_EVENT"; + case ComponentId::NETWORK_IP: return "NETWORK_IP"; + default: return "UNKNOWN"; + } + } +}; + +} /* namespace V_1 */ + } // namespace Flakkari::Protocol #endif /* !COMPONENTS_HPP_ */