Skip to content

Commit

Permalink
feat: add version 1 component IDs and string conversion method
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterLaplace committed Nov 17, 2024
1 parent b904c8c commit bd45389
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Flakkari/Protocol/Components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(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_ */

0 comments on commit bd45389

Please sign in to comment.