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
| 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... | |
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.
- Parameters
-
lives Initial number of lives.
Definition at line 40 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 56 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 66 of file LivesComponent.ixx.
lives()
| inline nodiscard noexcept |
Returns the current life count.
- Returns
Remaining lives.
Definition at line 47 of file LivesComponent.ixx.
Referenced by LivesComponent.
livesRevision()
| inline nodiscard noexcept |
Returns the current lives revision.
- Returns
The LivesRevision value.
Definition at line 76 of file LivesComponent.ixx.
Private Member Attributes
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.