载入中...
搜索中...
未找到
SettlementAdapter.h
浏览该文件的文档.
1#pragma once
2
12#include "rpg/RPGActor.h"
13#include "rpg/StatusTypes.h"
15
16#include <optional>
17#include <string>
18#include <string_view>
19
20#include "common/Export.h"
21
22namespace eve::rpg {
23
38 const StatusTickEvent& tick, SubjectRef source, SubjectRef target, SimulationTick simulationTick);
39
48public:
50 struct Config {
52 std::string healthAttribute = "hp";
54 std::string maxHealthAttribute = "hp";
55 std::string shieldAttribute = "shield";
56 std::string armorAttribute = "armor";
57 std::string resistancePrefix = "resistance.";
58 std::string criticalChanceAttribute = "critical_chance";
59 std::string criticalMultiplierAttribute = "critical_multiplier";
60 std::string sourceMultiplierAttribute = "damage_multiplier";
62 bool emitLifeTransitions = true;
63 };
64
68
72
75
77 [[nodiscard]] const SubjectRef& targetRef() const noexcept { return targetRef_; }
78
80 [[nodiscard]] eve::Result<void> validate(settlement::SettlementContext& context) override;
82 [[nodiscard]] eve::Result<void> sourceModifiers(settlement::SettlementContext& context) override;
84 [[nodiscard]] eve::Result<void> targetMitigation(settlement::SettlementContext& context) override;
86 [[nodiscard]] eve::Result<void> armorShield(settlement::SettlementContext& context) override;
88 [[nodiscard]] eve::Result<void> clamp(settlement::SettlementContext& context) override;
90 [[nodiscard]] eve::Result<settlement::PreparedApply> prepareApply(
95
96private:
97 [[nodiscard]] bool isDamage(const settlement::SettlementContext& context) const noexcept;
98 [[nodiscard]] bool isHealing(const settlement::SettlementContext& context) const noexcept;
107 [[nodiscard]] static const eve::Value* contextValue(const settlement::SettlementContext& context,
108 std::string_view key) noexcept;
109 [[nodiscard]] static std::optional<double> numberValue(const eve::Value* value) noexcept;
110 [[nodiscard]] static std::optional<bool> boolValue(const eve::Value* value) noexcept;
111 [[nodiscard]] static std::optional<std::string> stringValue(const eve::Value* value);
112 [[nodiscard]] eve::Result<double> readBase(std::string_view name) const;
113 [[nodiscard]] eve::Result<double> readFinal(std::string_view name, double fallback = 0.0) const;
114 [[nodiscard]] eve::Result<double> readSourceFinal(std::string_view name, double fallback = 0.0) const;
115
116 RPGActor& target_;
117 SubjectRef targetRef_;
118 RPGActor* source_ = nullptr;
119 SubjectRef sourceRef_;
120 Config config_;
121};
122
123} // namespace eve::rpg
LogicalId target
double value
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::uint32_t key
std::string name
SimulationTick tick
const UnitySourceAsset & source
const VegetationPresetContext & context
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
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 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