Skip to content

Commit

Permalink
feat: reorganise component and event identifiers for greater clarity …
Browse files Browse the repository at this point in the history
…and consistency
  • Loading branch information
MasterLaplace committed Nov 22, 2024
1 parent 094f5b4 commit 498a279
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 37 deletions.
33 changes: 15 additions & 18 deletions Flakkari/Protocol/Components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(ComponentId::MAX_COMPONENT) <= 40, "ComponentId::MAX_COMPONENT is too big");
static_assert(static_cast<uint8_t>(ComponentId::MAX_COMPONENT) <= 30, "ComponentId::MAX_COMPONENT is too big");

class Components final {
public:
Expand All @@ -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";
}
}
Expand Down
55 changes: 36 additions & 19 deletions Flakkari/Protocol/Events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand All @@ -46,31 +50,39 @@ struct Event {
V_0::EventState state;
};

struct EventAxis {
V_0::EventAxisId id;
};

LPL_PACKED_END

} /* namespace V_0 */

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
};

Expand All @@ -81,6 +93,11 @@ struct Event {
V_1::EventState state;
};

struct EventAxis {
V_1::EventAxisId id;
float value;
};

LPL_PACKED_END

} /* namespace V_1 */
Expand Down

0 comments on commit 498a279

Please sign in to comment.