LivesComponent Class
Tracks the remaining lives of an entity. More...
Declaration
Public Constructors Index
| LivesComponent (const size_t lives) noexcept | |
|
Constructs a LivesComponent with an initial life count. More... | |
Public Member Functions Index
| void | reset () noexcept |
|
Resets this component to an initial state. More... | |
| size_t | lives () const noexcept |
|
Returns the current life count. More... | |
| size_t | decrease () noexcept |
|
Decreases the life count by one and increments the revision. More... | |
| size_t | increase () noexcept |
|
Increases the life count by one and increments the revision. More... | |
| LivesRevision | livesRevision () const noexcept |
|
Returns the current lives revision. More... | |
Private Member Attributes Index
| size_t | lives_ |
|
Current number of remaining lives. More... | |
| LivesRevision | livesRevision_ {1} |
|
Monotonically increasing revision counter. More... | |
| size_t | defaultLives_ |
|
Number of default lives this component starts with. More... | |
Description
Tracks the remaining lives of an entity.
Each modification increments an internal LivesRevision counter so that observer systems can detect changes without polling the value.
Definition at line 21 of file LivesComponent.ixx.
Public Constructors
LivesComponent()
| inline explicit noexcept |
Constructs a LivesComponent with an initial life count.
Constructs a LivesComponent with an initial life count. The default lives for this component will be initially set to this value.
- Parameters
-
lives Initial number of lives.
Definition at line 48 of file LivesComponent.ixx.
Reference lives.
Public Member Functions
decrease()
| inline noexcept |
Decreases the life count by one and increments the revision.
- Returns
The new life count after decrement.
Definition at line 72 of file LivesComponent.ixx.
increase()
| inline noexcept |
Increases the life count by one and increments the revision.
- Returns
The new life count after increment.
Definition at line 85 of file LivesComponent.ixx.
lives()
| inline nodiscard noexcept |
Returns the current life count.
- Returns
Remaining lives.
Definition at line 63 of file LivesComponent.ixx.
Referenced by helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::hasLifeLeft and LivesComponent.
livesRevision()
| inline nodiscard noexcept |
Returns the current lives revision.
- Returns
The LivesRevision value.
Definition at line 95 of file LivesComponent.ixx.
reset()
| inline noexcept |
Resets this component to an initial state.
Definition at line 53 of file LivesComponent.ixx.
Private Member Attributes
defaultLives_
|
Number of default lives this component starts with.
Definition at line 36 of file LivesComponent.ixx.
lives_
|
Current number of remaining lives.
Definition at line 26 of file LivesComponent.ixx.
livesRevision_
|
Monotonically increasing revision counter.
Definition at line 31 of file LivesComponent.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.