载入中...
搜索中...
未找到
Skill.h
浏览该文件的文档.
1#pragma once
2
3// 技能系统:数据驱动的 SkillDefinition(消耗、冷却、读条时间、命中后授予的效果……)。
4//
5// 灵活性/可定制点:
6// - targetType 是自由字符串("self"/"single"/"area"/... 或游戏自定义值),
7// 引擎不解释其含义——具体的目标选取逻辑完全由脚本/游戏代码实现,
8// SkillSystem 只负责冷却/消耗/读条与授予效果的通用流程。
9// - extra 字段是任意 string->string 的自定义数据(动画名、投射物速度……),
10// 不需要为每个新技能特性修改引擎结构体。
11// - 消耗的属性同样是字符串,可以是内建的 "mana",也可以是任何自定义资源。
12
13#include <string>
14#include <unordered_map>
15#include <vector>
16
17namespace eve::rpg {
18
20 std::string attribute;
21 double amount = 0.0;
22};
23
25 std::string id;
26 float cooldown = 0.f;
27 float castTime = 0.f;
28 std::string targetType = "self";
29 std::vector<SkillCostSpec> costs;
30 std::vector<std::string> grantedEffects;
31 std::vector<std::string> tags;
32 std::unordered_map<std::string, std::string> extra;
33
34 bool hasTag(const std::string &tag) const;
35};
36
38public:
39 static void registerSkill(const SkillDefinition &def);
40 static const SkillDefinition *find(const std::string &id);
41 static bool remove(const std::string &id);
42 static void clear();
43 static int count();
44
54 static int loadFromJson(const std::string &json, std::string *error = nullptr);
55};
56
57} // namespace eve::rpg
std::string error
static const SkillDefinition * find(const std::string &id)
Definition Skill.cpp:28
static int loadFromJson(const std::string &json, std::string *error=nullptr)
从 JSON 数组批量注册技能定义,返回成功注册数量。元素形如: { "id": "fireball", "cooldown": 4, "castTime": 1....
Definition Skill.cpp:67
static void registerSkill(const SkillDefinition &def)
Definition Skill.cpp:23
static bool remove(const std::string &id)
Definition Skill.cpp:34
static void clear()
Definition Skill.cpp:36
static int count()
Definition Skill.cpp:38
RPG 模块入口:属性 / 效果 / 状态 / 技能 / 结算五套系统的脚本绑定与帧调度点。
std::string attribute
Definition Skill.h:20
std::vector< std::string > tags
Definition Skill.h:31
float castTime
0 = 瞬发
Definition Skill.h:27
std::vector< SkillCostSpec > costs
Definition Skill.h:29
bool hasTag(const std::string &tag) const
Definition Skill.cpp:12
std::string targetType
Definition Skill.h:28
std::vector< std::string > grantedEffects
命中/释放后施加给目标的效果 id 列表
Definition Skill.h:30
std::unordered_map< std::string, std::string > extra
游戏自定义附加数据
Definition Skill.h:32