载入中...
搜索中...
未找到
GameState.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
4
5
15#include "common/Result.h"
16
17#include <string>
18#include <string_view>
19#include <unordered_map>
20
21namespace eve::rpg {
22
23class RPGSaveSession;
24
27public:
29 GameState() = default;
30
32 void setSwitch(const std::string &name, bool on);
34 void switchOn(const std::string &name);
36 void switchOff(const std::string &name);
38 bool isSwitchOn(const std::string &name) const;
39
41 void setVariable(const std::string &name, double value);
43 double getVariable(const std::string &name) const;
45 void addVariable(const std::string &name, double delta);
46
48 void setSelfVariable(const std::string &scope, const std::string &name, double value);
50 double getSelfVariable(const std::string &scope, const std::string &name) const;
52 bool hasSelfVariable(const std::string &scope, const std::string &name) const;
53
64 void setSelfString(const std::string &scope, const std::string &name, std::string value);
70 [[nodiscard]] std::string getSelfString(const std::string &scope, const std::string &name) const;
72 [[nodiscard]] bool hasSelfString(const std::string &scope, const std::string &name) const;
74 void clearSelfString(const std::string &scope, const std::string &name);
75
77 void clear();
78
89 [[nodiscard]] eve::Result<std::string> snapshotJson() const;
90
101 [[nodiscard]] eve::Result<void> restoreSnapshotJson(std::string_view json);
102
104 static GameState &global();
105
106private:
107 friend class RPGSaveSession;
108 std::unordered_map<std::string, bool> switches_;
109 std::unordered_map<std::string, double> variables_;
110 std::unordered_map<std::string, std::unordered_map<std::string, double>> selfVariables_;
111 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> selfStrings_;
112};
113
114} // namespace eve::rpg
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_PLATFORM
Definition Export.h:107
JobScope scope
Object::Ptr value
Move-only, checked operation results for the common layer.
Share string attribute map operations through the Windows Foundation DLL.
Heightmap global
Move-only operation result carrying either a value or Status.
Definition Result.h:176
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:26
GameState()=default
Game state.
A non-owning save boundary for the persistent classic-RPG state owners.
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。