载入中...
搜索中...
未找到
Skill.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5// 技能系统:数据驱动的 SkillDefinition(消耗、冷却、读条时间、命中后授予的效果……)。
6//
7// 灵活性/可定制点:
8// - targetType 是自由字符串("self"/"single"/"area"/... 或游戏自定义值),
9// 引擎不解释其含义——具体的目标选取逻辑完全由脚本/游戏代码实现,
10// SkillSystem 只负责冷却/消耗/读条与授予效果的通用流程。
11// - extra 字段是任意 string->string 的自定义数据(动画名、投射物速度……),
12// 不需要为每个新技能特性修改引擎结构体。
13// - 消耗使用 common/resource 的 CostSpec,可以是内建的 "mana",也可以是
14// 任何自定义资源;RPG 不再维护一份私有 Cost 类型。
15
17#include "decision/Condition.h"
19
20#include <optional>
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25namespace eve::rpg {
26
29 std::string id;
30 float cooldown = 0.f;
31 float castTime = 0.f;
32 std::string targetType = "self";
34 std::optional<eve::resource::CostSpec> cost;
35 std::vector<std::string> grantedEffects;
36 std::vector<std::string> tags;
39 std::unordered_map<std::string, std::string> extra;
40
42 bool hasTag(const std::string &tag) const;
43};
44
47public:
54 [[nodiscard]] static eve::definitions::DefinitionRegistry &definitionRegistry();
55
56 static void registerSkill(const SkillDefinition &def);
65 static const SkillDefinition *find(const std::string &id);
67 static bool remove(const std::string &id);
69 static void clear();
71 static int count();
72
82 static int loadFromJson(const std::string &json, std::string *error = nullptr);
83};
84
85} // namespace eve::rpg
Pure, explainable condition trees shared by gameplay domains.
#define EVENGINE_API_PLATFORM
Definition Export.h:107
const std::string * tag
std::string error
Definition Package.cpp:60
Strongly typed, transaction-friendly resource cost protocol.
std::uint32_t count
Immutable condition AST node.
Definition Condition.h:195
Deterministic registry of topic-neutral, versioned JSON definitions.
Definition Definitions.h:58
EVENGINE_API_PLATFORM public API.
Definition Skill.h:46
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
SkillDefinition public API.
Definition Skill.h:28
std::vector< std::string > tags
Definition Skill.h:36
float castTime
0 = 瞬发
Definition Skill.h:31
bool hasTag(const std::string &tag) const
True when tag.
Definition Skill.cpp:61
std::string targetType
Definition Skill.h:32
std::vector< std::string > grantedEffects
命中/释放后施加给目标的效果 id 列表
Definition Skill.h:35
eve::decision::Condition castCondition
Side-effect-free condition tree required before this skill can cast.
Definition Skill.h:38
std::unordered_map< std::string, std::string > extra
游戏自定义附加数据
Definition Skill.h:39
std::optional< eve::resource::CostSpec > cost
Canonical resource cost; AttributeSet is an adapter, not a second cost model.
Definition Skill.h:34