NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
action_common.hpp
Go to the documentation of this file.
1
10#pragma once
12#include "NNL/utility/data.hpp"
13namespace nnl {
20
21namespace action {
34constexpr std::size_t kNumActionCategories = 4;
35
42constexpr std::size_t kMaxActionIndex = 0x3FFF;
43
51enum class ActionCategory {
53 kCombat = 1,
54 kDamage = 2,
56};
57
67struct Id {
70
71 operator u16() const noexcept {
72 return static_cast<u16>(nnl::utl::data::as_int(action_category) << 14 | action_index);
73 }
74};
75
76inline bool operator==(const Id& rhs, const Id& lhs) {
77 return rhs.action_category == lhs.action_category && rhs.action_index == lhs.action_index;
79}
80} // namespace action
82} // namespace nnl
83
84namespace std {
85template <>
86struct hash<nnl::action::Id> {
87 size_t operator()(const nnl::action::Id& id) const { return hash<size_t>{}(static_cast<nnl::u16>(id)); }
88};
89} // namespace std
Provides functions and classes for handling binary data.
Contains macros and definitions for fixed-width types.
u16 action_index
The index within the category.
Definition action_common.hpp:69
ActionCategory action_category
Type of the action.
Definition action_common.hpp:68
Represents a unique identifier for an action.
Definition action_common.hpp:67
constexpr std::size_t kNumActionCategories
Defines the number of action categories;.
Definition action_common.hpp:34
constexpr std::size_t kMaxActionIndex
Defines the maximum index of an action in a category;.
Definition action_common.hpp:42
ActionCategory
Defines the categories of actions.
Definition action_common.hpp:51
@ kMovement
Related to moving the entity.
Definition action_common.hpp:52
@ kCombat
Related to attacking behaviors.
Definition action_common.hpp:53
@ kDamage
Related to receiving damage.
Definition action_common.hpp:54
@ kCutscene
Related to scripted events or cutscenes.
Definition action_common.hpp:55
constexpr std::underlying_type< E >::type as_int(E e) noexcept
Converts an enum value to its underlying integer type.
Definition data.hpp:68
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
Contains structures and functions for working with game actions.
Definition action.hpp:31
Definition exception.hpp:56