载入中...
搜索中...
未找到
SettlementAdapter.h
浏览该文件的文档.
1#pragma once
2
13#include "rpg/RPGActor.h"
14#include "rpg/StatusTypes.h"
16
17#include <optional>
18#include <string>
19#include <string_view>
20
21#include "common/Export.h"
22
23namespace eve::rpg {
24
39 const StatusTickEvent& tick, SubjectRef source, SubjectRef target, SimulationTick simulationTick);
40
49public:
51 struct Config {
53 std::string healthAttribute = "hp";
55 std::string maxHealthAttribute = "hp";
56 std::string shieldAttribute = "shield";
57 std::string armorAttribute = "armor";
58 std::string resistancePrefix = "resistance.";
59 std::string criticalChanceAttribute = "critical_chance";
60 std::string criticalMultiplierAttribute = "critical_multiplier";
61 std::string sourceMultiplierAttribute = "damage_multiplier";
63 bool emitLifeTransitions = true;
64 };
65
69
73
76
78 [[nodiscard]] const SubjectRef& targetRef() const noexcept { return targetRef_; }
79
81 [[nodiscard]] eve::Result<void> validate(settlement::SettlementContext& context) override;
83 [[nodiscard]] eve::Result<void> sourceModifiers(settlement::SettlementContext& context) override;
85 [[nodiscard]] eve::Result<void> targetMitigation(settlement::SettlementContext& context) override;
87 [[nodiscard]] eve::Result<void> armorShield(settlement::SettlementContext& context) override;
89 [[nodiscard]] eve::Result<void> clamp(settlement::SettlementContext& context) override;
91 [[nodiscard]] eve::Result<settlement::PreparedApply> prepareApply(
96
97private:
98 [[nodiscard]] bool isDamage(const settlement::SettlementContext& context) const noexcept;
99 [[nodiscard]] bool isHealing(const settlement::SettlementContext& context) const noexcept;
108 [[nodiscard]] static const eve::Value* contextValue(const settlement::SettlementContext& context,
109 std::string_view key) noexcept;
110 [[nodiscard]] static std::optional<double> numberValue(const eve::Value* value) noexcept;
111 [[nodiscard]] static std::optional<bool> boolValue(const eve::Value* value) noexcept;
112 [[nodiscard]] static std::optional<std::string> stringValue(const eve::Value* value);
113 [[nodiscard]] eve::Result<double> readBase(std::string_view name) const;
114 [[nodiscard]] eve::Result<double> readFinal(std::string_view name, double fallback = 0.0) const;
115 [[nodiscard]] eve::Result<double> readSourceFinal(std::string_view name, double fallback = 0.0) const;
116
117 RPGActor& target_;
118 SubjectRef targetRef_;
119 RPGActor* source_ = nullptr;
120 SubjectRef sourceRef_;
121 Config config_;
122};
123
124} // namespace eve::rpg
LogicalId target
SQObjectPtr key
Definition ECS.cpp:155
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_PLATFORM
Definition Export.h:107
Poco::JSON::Object::Ptr result
Object::Ptr value
std::string_view source
SimulationTick tick
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
Settles damage/healing against one RPG actor's Vitals and AttributeSet.
const SubjectRef & targetRef() const noexcept
Stable identity checked for the target side of the request.
RPGSettlementAdapter & operator=(const RPGSettlementAdapter &)=delete
RPGSettlementAdapter(const RPGSettlementAdapter &)=delete
Domain-owned policy hooks used by the common settlement pipeline.
Definition Settlement.h:497
Mutable calculation frame visible to policy and custom stage code.
Definition Settlement.h:338
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
eve::Result< settlement::SettlementRequest > makeStatusTickSettlementRequest(const StatusTickEvent &tick, SubjectRef source, SubjectRef target, SimulationTick simulationTick)
Project one configured RPG status tick into the canonical settlement request.
detail::StrongUint64< detail::SimulationTickTag > SimulationTick
Deterministic simulation time step; it is not wall-clock time.
Definition Time.h:31
Domain-neutral, deterministic settlement pipeline.
Attribute names used by the RPG policy.
Complete observable outcome of one successful settlement.
Definition Settlement.h:163