Skip to main content

CombatScoringSystem Class

System that processes death events and awards scores. More...

Declaration

class helios::engine::mechanics::scoring::systems::CombatScoringSystem { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) noexcept

Processes death events and issues score commands. More...

Private Static Attributes Index

static const helios::util::log::Logger &logger_ = ...

Description

System that processes death events and awards scores.

Listens for HealthDepletedEvent and checks if the killed entity has a ScoreValueComponent. If so, issues an UpdateScoreCommand to credit the attacker's score pool.

Definition at line 58 of file CombatScoringSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::mechanics::scoring::systems::CombatScoringSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::mechanics::scoring::systems::CombatScoringSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Processes death events and issues score commands.

Parameters
updateContext

The current frame's update context.

Definition at line 73 of file CombatScoringSystem.ixx.

74
75 for (auto& event : updateContext.readPass<HealthDepletedEvent>()) {
76
77 if (!event.damageContext()) {
78 continue;
79 }
80
81 const auto& attackContext = event.damageContext();
82
83 const auto interactionContext = attackContext->interactionContext;
84
85 const auto enemy = updateContext.find(event.source());
86 const auto instigator = updateContext.find(interactionContext.instigator);
87
88 if (!enemy || !instigator) {
89 continue;
90 }
91
92 auto* svc = enemy->get<ScoreValueComponent<KillReward>>();
93 if (!svc) {
94 continue;
95 }
96
97 auto* scc = instigator->get<ScorePoolComponent>();
98 if (!scc) {
99 continue;
100 }
101
102 auto scoreContext = ScoreValueContext{
103 .scoreTypeId = ScoreTypeId::id<KillReward>(),
104 .scorePoolId = scc->scorePoolId(),
105 .value = svc->score().value()
106 };
107
108 logger_.info(
109 std::format("Entity {0} killed. Reward: {1}",
110 instigator->entityHandle().entityId,
111 svc->score().value())
112 );
113
114 updateContext.queueCommand<UpdateScoreCommand>(
115 std::move(scoreContext)
116 );
117 }
118
119 }

References helios::engine::mechanics::scoring::types::ScoreTypeId::id and helios::engine::mechanics::scoring::types::ScoreTypeId::value.

Private Static Attributes

logger_

const helios::util::log::Logger& helios::engine::mechanics::scoring::systems::CombatScoringSystem::logger_
static

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.