载入中...
搜索中...
未找到
GameState.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
14#include "common/Result.h"
15
16#include <string>
17#include <string_view>
18#include <unordered_map>
19
20namespace eve::rpg {
21
22class RPGSaveSession;
23
26public:
28 GameState() = default;
29
31 void setSwitch(const std::string &name, bool on);
33 void switchOn(const std::string &name);
35 void switchOff(const std::string &name);
37 bool isSwitchOn(const std::string &name) const;
38
40 void setVariable(const std::string &name, double value);
42 double getVariable(const std::string &name) const;
44 void addVariable(const std::string &name, double delta);
45
47 void setSelfVariable(const std::string &scope, const std::string &name, double value);
49 double getSelfVariable(const std::string &scope, const std::string &name) const;
51 bool hasSelfVariable(const std::string &scope, const std::string &name) const;
52
63 void setSelfString(const std::string &scope, const std::string &name, std::string value);
69 [[nodiscard]] std::string getSelfString(const std::string &scope, const std::string &name) const;
71 [[nodiscard]] bool hasSelfString(const std::string &scope, const std::string &name) const;
73 void clearSelfString(const std::string &scope, const std::string &name);
74
76 void clear();
77
88 [[nodiscard]] eve::Result<std::string> snapshotJson() const;
89
100 [[nodiscard]] eve::Result<void> restoreSnapshotJson(std::string_view json);
101
103 static GameState &global();
104
105private:
106 friend class RPGSaveSession;
107 std::unordered_map<std::string, bool> switches_;
108 std::unordered_map<std::string, double> variables_;
109 std::unordered_map<std::string, std::unordered_map<std::string, double>> selfVariables_;
110 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> selfStrings_;
111};
112
113} // namespace eve::rpg
double value
#define EVENGINE_API_PLATFORM
Definition Export.h:107
JobScope scope
std::string name
Move-only, checked operation results for the common layer.
Heightmap global
Move-only operation result carrying either a value or Status.
Definition Result.h:155
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:25
GameState()=default
Game state.
A non-owning save boundary for the persistent classic-RPG state owners.
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。