载入中...
搜索中...
未找到
RTSEffects.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "common/Result.h"
11#include "common/SubjectRef.h"
12#include "common/Time.h"
14
15#include <cstddef>
16#include <cstdint>
17#include <string>
18#include <string_view>
19#include <vector>
20
21namespace eve::rts {
22
24enum class RTSEffectKind : std::uint8_t { Morale, Suppression, ProductionLock };
25
28 double morale = 100.0;
29 std::uint32_t suppression = 0;
30 bool productionLocked = false;
31 std::uint32_t commandInterrupts = 0;
32};
33
36 std::string id;
37 std::string source;
38 double duration = 0.0;
39 double period = 0.0;
40 double magnitude = 0.0;
41 double speedMultiplier = 1.0;
42 double damageMultiplier = 1.0;
44 double healingPerSecond = 0.0;
47 std::vector<std::string> tags;
48};
49
56
62
75
78public:
85 [[nodiscard]] eve::Result<RTSEffectUpdate> advance(const eve::SimulationStep& step);
87 [[nodiscard]] std::size_t count() const noexcept;
89 [[nodiscard]] RTSEffectSnapshot snapshot() const;
91 [[nodiscard]] eve::Result<void> restore(const RTSEffectSnapshot& snapshot);
93 void restoreSchedulerTick(eve::SimulationTick tick) noexcept { container_.restoreSchedulerTick(tick); }
97 [[nodiscard]] double multiplier(std::string_view field) const noexcept;
99 [[nodiscard]] double additive(std::string_view field) const noexcept;
101 [[nodiscard]] RTSEffectTarget& target() noexcept { return target_; }
103 [[nodiscard]] const RTSEffectTarget& target() const noexcept { return target_; }
104
105private:
106 effects::EffectContainer container_;
107 RTSEffectExecutor executor_;
108 RTSEffectTarget target_;
109};
110
119public:
121 [[nodiscard]] eve::Result<void> bindSubject(eve::SubjectRef subject);
125 [[nodiscard]] eve::Result<void> remove(effects::EffectHandle handle);
127 [[nodiscard]] eve::Result<RTSEffectUpdate> advance(const eve::SimulationStep& step);
129 [[nodiscard]] std::size_t count() const noexcept { return adapter_.count(); }
131 [[nodiscard]] RTSEffectSnapshot snapshot() const { return adapter_.snapshot(); }
133 [[nodiscard]] eve::Result<void> restore(const RTSEffectSnapshot& value) { return adapter_.restore(value); }
135 void restoreSchedulerTick(eve::SimulationTick tick) noexcept { adapter_.restoreSchedulerTick(tick); }
137 [[nodiscard]] RTSEffectTarget& target() noexcept { return adapter_.target(); }
139 [[nodiscard]] const RTSEffectTarget& target() const noexcept { return adapter_.target(); }
141 [[nodiscard]] double multiplier(std::string_view field) const noexcept { return adapter_.multiplier(field); }
143 [[nodiscard]] double additive(std::string_view field) const noexcept { return adapter_.additive(field); }
144
145private:
146 RTSEffectAdapter adapter_;
147 eve::SubjectRef subject_;
148};
149
150} // namespace eve::rts
LogicalId target
double value
int subject
Definition AnimSmr.cpp:163
Owning effect storage and lifecycle-only executor.
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::unique_ptr< ParticleEffect > effect
PrimitiveHandle handle
Move-only, checked operation results for the common layer.
std::uint32_t count
Stable reference to a runtime gameplay subject.
LogicalId definition
SimulationTick tick
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:314
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
Owns active effect instances and their deterministic lifecycle events.
RTS adapter that keeps the common container as the sole instance owner.
Definition RTSEffects.h:77
RTSEffectTarget & target() noexcept
Access the adapter-owned RTS target state.
Definition RTSEffects.h:101
const RTSEffectTarget & target() const noexcept
Read the adapter-owned RTS target state.
Definition RTSEffects.h:103
void restoreSchedulerTick(eve::SimulationTick tick) noexcept
Align the contained lifecycle scheduler with an owning world checkpoint.
Definition RTSEffects.h:93
Entity-local RTS effect component backed by the canonical adapter.
Definition RTSEffects.h:118
eve::Result< void > restore(const RTSEffectSnapshot &value)
Atomically restore the canonical effect lifecycle and RTS target projection.
Definition RTSEffects.h:133
RTSEffectSnapshot snapshot() const
Capture the canonical effect lifecycle and RTS target projection.
Definition RTSEffects.h:131
RTSEffectTarget & target() noexcept
Return the mutable RTS target state owned by this component.
Definition RTSEffects.h:137
double multiplier(std::string_view field) const noexcept
Return a composed active status multiplier.
Definition RTSEffects.h:141
void restoreSchedulerTick(eve::SimulationTick tick) noexcept
Align the lifecycle scheduler with an owning world checkpoint.
Definition RTSEffects.h:135
double additive(std::string_view field) const noexcept
Return a composed active additive status value.
Definition RTSEffects.h:143
std::size_t count() const noexcept
Return active effect count.
Definition RTSEffects.h:129
const RTSEffectTarget & target() const noexcept
Return the read-only RTS target state owned by this component.
Definition RTSEffects.h:139
RTS executor for morale, suppression and production-lock semantics.
Definition RTSEffects.h:64
eve::Result< RTSEffectUpdate > settle(RTSEffectTarget &target, effects::EffectUpdateSummary lifecycle) const
Settle common periodic triggers using RTS-specific policies.
eve::Result< void > applyImmediate(RTSEffectTarget &target, const effects::EffectInstance &effect) const
Apply immediate production-lock semantics to a staged target.
eve::Result< void > validate(const RTSEffectTarget &target) const
Validate the target state before a staged application.
RTSEffectKind
RTS-specific interpretation of an effect instance.
Definition RTSEffects.h:24
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Generation-qualified local reference to a canonical effect instance.
One owned runtime effect fact.
Independent policy dimensions used when applying an effect definition.
Definition EffectTypes.h:53
Summary returned by the lifecycle executor after one simulation step.
Typed RTS definition projected to the common lifecycle schema.
Definition RTSEffects.h:35
effects::EffectPolicy policy
Definition RTSEffects.h:45
std::vector< std::string > tags
Definition RTSEffects.h:47
Serializable in-memory RTS effect snapshot.
Definition RTSEffects.h:58
effects::EffectContainer effects
Definition RTSEffects.h:59
Mutable RTS state affected by the domain executor.
Definition RTSEffects.h:27
std::uint32_t commandInterrupts
Definition RTSEffects.h:31
std::uint32_t suppression
Definition RTSEffects.h:29
Result of one RTS lifecycle step and domain settlement.
Definition RTSEffects.h:51
effects::EffectUpdateSummary lifecycle
Definition RTSEffects.h:52
std::uint32_t commandInterrupts
Definition RTSEffects.h:54