From 498a279de1fe10a551962a9439602de091133b14 Mon Sep 17 00:00:00 2001 From: MasterLaplace Date: Fri, 22 Nov 2024 15:46:34 -0500 Subject: [PATCH] feat: reorganise component and event identifiers for greater clarity and consistency --- Flakkari/Protocol/Components.hpp | 33 +++++++++---------- Flakkari/Protocol/Events.hpp | 55 +++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/Flakkari/Protocol/Components.hpp b/Flakkari/Protocol/Components.hpp index bb668666..655db7f3 100644 --- a/Flakkari/Protocol/Components.hpp +++ b/Flakkari/Protocol/Components.hpp @@ -96,21 +96,19 @@ enum class ComponentId : uint8_t { 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, + EVOLVE = 21, + HEALTH = 22, + ID = 23, + LEVEL = 24, + PARENT = 25, + TAG = 26, + TEMPLATE = 27, + TIMER = 28, + WEAPON = 29, MAX_COMPONENT }; -static_assert(static_cast(ComponentId::MAX_COMPONENT) <= 40, "ComponentId::MAX_COMPONENT is too big"); +static_assert(static_cast(ComponentId::MAX_COMPONENT) <= 30, "ComponentId::MAX_COMPONENT is too big"); class Components final { public: @@ -130,16 +128,15 @@ class Components final { case ComponentId::RIGIDBODY: return "RIGIDBODY"; case ComponentId::RIGIDBODY_3D: return "RIGIDBODY_3D"; case ComponentId::CHILD: return "CHILD"; + case ComponentId::EVOLVE: return "EVOLVE"; + case ComponentId::HEALTH: return "HEALTH"; + case ComponentId::ID: return "ID"; + case ComponentId::LEVEL: return "LEVEL"; case ComponentId::PARENT: return "PARENT"; case ComponentId::TAG: return "TAG"; - case ComponentId::SPAWNED: return "SPAWNED"; case ComponentId::TEMPLATE: return "TEMPLATE"; + case ComponentId::TIMER: return "TIMER"; 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"; } } diff --git a/Flakkari/Protocol/Events.hpp b/Flakkari/Protocol/Events.hpp index fec3be79..1b224353 100644 --- a/Flakkari/Protocol/Events.hpp +++ b/Flakkari/Protocol/Events.hpp @@ -24,11 +24,15 @@ namespace Flakkari::Protocol { namespace V_0 { enum class EventId : uint8_t { - MOVE_LEFT = 10, - MOVE_RIGHT = 11, - MOVE_UP = 12, - MOVE_DOWN = 13, - SHOOT = 14, + MOVE_LEFT = 0, + MOVE_RIGHT = 1, + MOVE_UP = 2, + MOVE_DOWN = 3, + SHOOT = 4, + MAX_EVENT +}; + +enum class EventAxisId : uint8_t { MAX_EVENT }; @@ -46,6 +50,10 @@ struct Event { V_0::EventState state; }; +struct EventAxis { + V_0::EventAxisId id; +}; + LPL_PACKED_END } /* namespace V_0 */ @@ -53,24 +61,28 @@ LPL_PACKED_END inline namespace V_1 { enum class EventId : uint8_t { - MOVE_LEFT = 10, - MOVE_RIGHT = 11, - MOVE_UP = 12, - MOVE_DOWN = 13, - MOVE_FRONT = 14, - MOVE_BACK = 15, - LOOK_LEFT = 16, - LOOK_RIGHT = 17, - LOOK_UP = 18, - LOOK_DOWN = 19, - SHOOT = 20, + MOVE_LEFT = 0, + MOVE_RIGHT = 1, + MOVE_UP = 2, + MOVE_DOWN = 3, + MOVE_FRONT = 4, + MOVE_BACK = 5, + SHOOT = 10, + MAX_EVENT +}; + +enum class EventAxisId : uint8_t { + LOOK_LEFT = 1, + LOOK_RIGHT = 2, + LOOK_UP = 3, + LOOK_DOWN = 4, + SHOOT = 5, MAX_EVENT }; enum class EventState : uint8_t { - NONE = 0, - PRESSED = 1, - RELEASED = 2, + PRESSED = 0, + RELEASED = 1, MAX_STATE }; @@ -81,6 +93,11 @@ struct Event { V_1::EventState state; }; +struct EventAxis { + V_1::EventAxisId id; + float value; +}; + LPL_PACKED_END } /* namespace V_1 */