载入中...
搜索中...
未找到
LevelSystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
14#include "common/Result.h"
15
16#include <cstdint>
17#include <string>
18#include <vector>
19
20namespace eve::rpg {
21
22class RPGActor;
23
26public:
30 [[nodiscard]] int levelsGained() const noexcept { return nextLevel_ - previousLevel_; }
31
32private:
33 RPGActor *actor_ = nullptr;
34 int previousLevel_ = 0;
35 double previousXp_ = 0.0;
36 double previousXpToNext_ = 0.0;
37 int nextLevel_ = 0;
38 double nextXp_ = 0.0;
39 double nextXpToNext_ = 0.0;
40 friend class LevelSystem;
41};
42
45 class RPGActor *actor = nullptr;
47 int newLevel = 0;
48};
49
55public:
57 static int getLevel(RPGActor *actor);
59 static double getXp(RPGActor *actor);
61 static double getXpToNext(RPGActor *actor);
63 static void setXpToNext(RPGActor *actor, double value);
65 static void setLevel(RPGActor *actor, int level);
66
77 [[nodiscard]] static eve::Result<void> restoreProgression(RPGActor *actor, int level, double xp,
78 double xpToNext);
79
85 static bool gainXp(RPGActor *actor, double amount, double xpGrowth = 1.2);
86
93 [[nodiscard]] static eve::Result<PreparedProgressionGain>
94 prepareGainXp(RPGActor *actor, double amount, double xpGrowth = 1.2);
102 [[nodiscard]] static eve::Result<int> commitGainXp(PreparedProgressionGain prepared);
103
105 static void pollLevelUps(std::vector<LevelUpEvent> &out);
106};
107
108} // namespace eve::rpg
double value
#define EVENGINE_API_PLATFORM
Definition Export.h:107
int level
Move-only, checked operation results for the common layer.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
成长系统:读写 RPGActor::Progression 并驱动升级事件。 @thread 调用线程应与 RPGActor 的 ECS 线程一致。
Definition LevelSystem.h:54
Move-only progression gain prepared against one actor revision.
Definition LevelSystem.h:25
int levelsGained() const noexcept
Number of level transitions contained in this prepared candidate.
Definition LevelSystem.h:30
PreparedProgressionGain()=default
Constructs a PreparedProgressionGain.
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
升级事件。
Definition LevelSystem.h:44
class RPGActor * actor
Definition LevelSystem.h:45