Skip to main content

ScoreObserverComponent Class

Component that observes and caches the score value from a ScorePool. More...

Declaration

class helios::engine::mechanics::scoring::components::ScoreObserverComponent { ... }

Friends Index

classhelios::engine::mechanics::scoring::systems::ScoreObserverClearSystem

Public Constructors Index

ScoreObserverComponent ()=default
ScoreObserverComponent (const ScoreObserverComponent &other)

Copy constructor. More...

ScoreObserverComponent (ScoreObserverComponent &&) noexcept=default

Public Operators Index

ScoreObserverComponent &operator= (const ScoreObserverComponent &)=default
ScoreObserverComponent &operator= (ScoreObserverComponent &&) noexcept=default

Public Member Functions Index

boolisEnabled () const noexcept

Checks whether this component is enabled. More...

voidenable () noexcept

Enables this component. More...

voiddisable () noexcept

Disables this component. More...

voidsetScorePoolId (const helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId) noexcept

Sets the score pool to observe. More...

helios::engine::mechanics::scoring::types::ScorePoolIdscorePoolId () const noexcept

Returns the observed score pool ID. More...

voidsetScorePoolSnapshot (const helios::engine::mechanics::scoring::ScorePoolSnapshot &snapshot) noexcept

Sets the cached snapshot value. More...

ScorePoolRevisionscorePoolRevision () const noexcept

Returns the cached score pool revision. More...

doubletotalScore () const noexcept

Returns the cached total score. More...

boolhasUpdate () const noexcept

Checks if the value changed since last clear. More...

voidonAcquire () noexcept

Called when this entity is acquired from a pool. More...

voidonRelease () noexcept

Called when this entity is released back to a pool. More...

Private Member Functions Index

voidclearUpdate ()

Clears the update flag. More...

Private Member Attributes Index

helios::engine::mechanics::scoring::types::ScorePoolIdscorePoolId_ {helios::core::types::no_init}

ID of the score pool to observe. More...

boolhasUpdate_ = true

Flag indicating whether the value changed this frame. More...

helios::engine::mechanics::scoring::ScorePoolSnapshotsnapshot_

the current snapshot saved by this observer component. More...

boolisEnabled_ = true

Whether this component is enabled. More...

Description

Component that observes and caches the score value from a ScorePool.

Attached to UI entities to display score values. The ScoreObserverUpdateSystem updates this component's snapshot from the referenced ScorePool each frame. The hasUpdate flag indicates when the value has changed.

See Also

ScoreObserverUpdateSystem

See Also

ScoreObserverClearSystem

See Also

ScorePoolSnapshot

Definition at line 35 of file ScoreObserverComponent.ixx.

Friends

helios::engine::mechanics::scoring::systems::ScoreObserverClearSystem

Public Constructors

ScoreObserverComponent()

helios::engine::mechanics::scoring::components::ScoreObserverComponent::ScoreObserverComponent ()
default

ScoreObserverComponent()

helios::engine::mechanics::scoring::components::ScoreObserverComponent::ScoreObserverComponent (const ScoreObserverComponent & other)
inline

Copy constructor.

Parameters
other

The component to copy from.

Definition at line 105 of file ScoreObserverComponent.ixx.

106 scorePoolId_(other.scorePoolId_) {}

Reference ScoreObserverComponent.

ScoreObserverComponent()

helios::engine::mechanics::scoring::components::ScoreObserverComponent::ScoreObserverComponent (ScoreObserverComponent &&)
noexcept default

Definition at line 109 of file ScoreObserverComponent.ixx.

Reference ScoreObserverComponent.

Public Operators

operator=()

ScoreObserverComponent & helios::engine::mechanics::scoring::components::ScoreObserverComponent::operator= (const ScoreObserverComponent &)
default

Definition at line 108 of file ScoreObserverComponent.ixx.

Reference ScoreObserverComponent.

operator=()

ScoreObserverComponent & helios::engine::mechanics::scoring::components::ScoreObserverComponent::operator= (ScoreObserverComponent &&)
noexcept default

Definition at line 110 of file ScoreObserverComponent.ixx.

Reference ScoreObserverComponent.

Public Member Functions

disable()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::disable ()
inline noexcept

Disables this component.

Definition at line 94 of file ScoreObserverComponent.ixx.

94 void disable() noexcept {
95 isEnabled_ = false;
96 }

enable()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::enable ()
inline noexcept

Enables this component.

Definition at line 87 of file ScoreObserverComponent.ixx.

87 void enable() noexcept {
88 isEnabled_ = true;
89 }

hasUpdate()

bool helios::engine::mechanics::scoring::components::ScoreObserverComponent::hasUpdate ()
inline nodiscard noexcept

Checks if the value changed since last clear.

Returns

True if the value was updated this frame.

Definition at line 168 of file ScoreObserverComponent.ixx.

168 [[nodiscard]] bool hasUpdate() const noexcept {
169 return hasUpdate_;
170 }

isEnabled()

bool helios::engine::mechanics::scoring::components::ScoreObserverComponent::isEnabled ()
inline nodiscard noexcept

Checks whether this component is enabled.

Returns

True if enabled, false otherwise.

Definition at line 80 of file ScoreObserverComponent.ixx.

80 [[nodiscard]] bool isEnabled() const noexcept {
81 return isEnabled_;
82 }

onAcquire()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::onAcquire ()
inline noexcept

Called when this entity is acquired from a pool.

Clears the update flag and resets the cached snapshot.

Definition at line 177 of file ScoreObserverComponent.ixx.

177 void onAcquire() noexcept {
178 clearUpdate();
179 snapshot_ = {};
180 }

onRelease()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::onRelease ()
inline noexcept

Called when this entity is released back to a pool.

Clears the update flag and resets the cached snapshot.

Definition at line 187 of file ScoreObserverComponent.ixx.

187 void onRelease() noexcept {
188 clearUpdate();
189 snapshot_ = {};
190 }

scorePoolId()

helios::engine::mechanics::scoring::types::ScorePoolId helios::engine::mechanics::scoring::components::ScoreObserverComponent::scorePoolId ()
inline nodiscard noexcept

Returns the observed score pool ID.

Returns

The ScorePoolId.

Definition at line 126 of file ScoreObserverComponent.ixx.

127 return scorePoolId_;
128 }

Referenced by setScorePoolId.

scorePoolRevision()

ScorePoolRevision helios::engine::mechanics::scoring::components::ScoreObserverComponent::scorePoolRevision ()
inline nodiscard noexcept

Returns the cached score pool revision.

Returns

The revision of the last observed snapshot.

Definition at line 150 of file ScoreObserverComponent.ixx.

150 [[nodiscard]] ScorePoolRevision scorePoolRevision() const noexcept {
151 return snapshot_.revision;
152 }

setScorePoolId()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::setScorePoolId (const helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId)
inline noexcept

Sets the score pool to observe.

Parameters
scorePoolId

The ID of the pool to observe.

Definition at line 117 of file ScoreObserverComponent.ixx.

118 scorePoolId_ = scorePoolId;
119 }

References scorePoolId and setScorePoolId.

Referenced by setScorePoolId.

setScorePoolSnapshot()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::setScorePoolSnapshot (const helios::engine::mechanics::scoring::ScorePoolSnapshot & snapshot)
inline noexcept

Sets the cached snapshot value.

Sets hasUpdate to true if the value changes.

Parameters
snapshot

The snapshot to use for the next update.

Definition at line 137 of file ScoreObserverComponent.ixx.

138 if (snapshot_.revision == snapshot.revision) {
139 return;
140 }
141 snapshot_ = snapshot;
142 hasUpdate_ = true;
143 }

totalScore()

double helios::engine::mechanics::scoring::components::ScoreObserverComponent::totalScore ()
inline nodiscard noexcept

Returns the cached total score.

Returns

The current score value.

Definition at line 159 of file ScoreObserverComponent.ixx.

159 [[nodiscard]] double totalScore() const noexcept {
160 return snapshot_.totalScore;
161 }

Private Member Functions

clearUpdate()

void helios::engine::mechanics::scoring::components::ScoreObserverComponent::clearUpdate ()
inline

Clears the update flag.

Called by ScoreObserverClearSystem.

Definition at line 69 of file ScoreObserverComponent.ixx.

69 void clearUpdate() {
70 hasUpdate_ = false;
71 }

Private Member Attributes

hasUpdate_

bool helios::engine::mechanics::scoring::components::ScoreObserverComponent::hasUpdate_ = true

Flag indicating whether the value changed this frame.

Cleared by ScoreObserverClearSystem at frame end.

Definition at line 52 of file ScoreObserverComponent.ixx.

52 bool hasUpdate_ = true;

isEnabled_

bool helios::engine::mechanics::scoring::components::ScoreObserverComponent::isEnabled_ = true

Whether this component is enabled.

Definition at line 62 of file ScoreObserverComponent.ixx.

62 bool isEnabled_ = true;

scorePoolId_

helios::engine::mechanics::scoring::types::ScorePoolId helios::engine::mechanics::scoring::components::ScoreObserverComponent::scorePoolId_ {helios::core::types::no_init}

ID of the score pool to observe.

Definition at line 44 of file ScoreObserverComponent.ixx.

snapshot_

helios::engine::mechanics::scoring::ScorePoolSnapshot helios::engine::mechanics::scoring::components::ScoreObserverComponent::snapshot_

the current snapshot saved by this observer component.

Definition at line 57 of file ScoreObserverComponent.ixx.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.