Skip to main content

HealthDepletedBehavior.ixx File

Bitmask flags controlling the response when health reaches zero. More...

Included Headers

#include <cstdint>

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemechanics

High-level gameplay systems and components for game logic. More...

namespacehealth

Health management system for game entities. More...

namespacetypes

Type definitions for the health system. More...

Description

Bitmask flags controlling the response when health reaches zero.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file HealthDepletedBehavior.ixx
3 * @brief Bitmask flags controlling the response when health reaches zero.
4 */
5module;
6
7#include <cstdint>
8
9export module helios.engine.mechanics.health.types.HealthDepletedBehavior;
10
11
13
14 /**
15 * @brief Bitmask enum describing what happens when an entity's health is depleted.
16 *
17 * Flags can be combined with the bitwise OR operator to trigger
18 * multiple effects simultaneously.
19 */
20 enum class HealthDepletedBehavior : uint16_t {
21
22 /**
23 * @brief No action on depletion.
24 */
25 None = 0,
26
27 /**
28 * @brief Queue the entity for despawning.
29 */
30 Despawn = 1 << 0,
31
32 /**
33 * @brief Attach a DeadTagComponent to the entity.
34 */
35 DeadTag = 1 << 1
36 };
37
38
39 /**
40 * @brief Bitwise OR operator for combining flags.
41 *
42 * @param lhs Left-hand side flag.
43 * @param rhs Right-hand side flag.
44 *
45 * @return Combined flags.
46 */
48 return static_cast<HealthDepletedBehavior>(
49 static_cast<uint16_t>(lhs) | static_cast<uint16_t>(rhs)
50 );
51 }
52
53
54 /**
55 * @brief Bitwise AND operator for testing flags.
56 *
57 * @param lhs Left-hand side flag.
58 * @param rhs Right-hand side flag.
59 *
60 * @return Intersection of both flags.
61 */
63 return static_cast<HealthDepletedBehavior>(
64 static_cast<uint16_t>(lhs) & static_cast<uint16_t>(rhs)
65 );
66 }
67
68 /**
69 * @brief Tests whether a specific flag is set in a mask.
70 *
71 * @param mask The bitmask to test.
72 * @param flag The flag to check for.
73 *
74 * @return True if the flag is set.
75 */
76 [[nodiscard]] constexpr bool hasHealthDepletedFlag(const HealthDepletedBehavior mask, const HealthDepletedBehavior flag) noexcept {
77 return (mask & flag) == flag;
78 }
79
80}
81

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.