载入中...
搜索中...
未找到
RPGSaveSession.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "common/Result.h"
11
12#include <map>
13#include <memory>
14#include <set>
15#include <string>
16#include <string_view>
17
18namespace eve::inventory {
19class Bag;
20class EquipmentSet;
21}
22
23namespace eve::rpg {
24
25class GameState;
26class Tracker;
27class RPGActor;
28class Party;
29
31enum class RPGSaveIdDomain {
32 Item,
33 Quest,
35 Skill,
36 Class,
37 Trait,
40};
41
50public:
53 public:
56 PreparedRestore &operator=(PreparedRestore &&) noexcept;
58 PreparedRestore &operator=(const PreparedRestore &) = delete;
59
60 private:
61 friend class RPGSaveSession;
62 struct Impl;
63 explicit PreparedRestore(std::unique_ptr<Impl> state);
64 std::unique_ptr<Impl> state_;
65 };
66
68 RPGSaveSession() = default;
69
81 void bind(GameState &gameState, Tracker &tracker, RPGActor &actor, inventory::Bag &bag,
82 inventory::EquipmentSet &equipment) noexcept;
83
90 void bindParty(GameState &gameState, Tracker &tracker, Party &party, inventory::Bag &bag,
91 inventory::EquipmentSet &equipment) noexcept;
92
101 [[nodiscard]] eve::Result<void> setContentVersion(std::string_view contentVersion);
102
104 std::string getContentVersion() const { return contentVersion_; }
105
116 [[nodiscard]] eve::Result<void> allowCompatibleContentVersion(std::string_view contentVersion);
117
131 [[nodiscard]] eve::Result<void> addIdRenameMigration(std::string_view fromContentVersion,
132 RPGSaveIdDomain domain, std::string_view oldId,
133 std::string_view newId);
134
147 [[nodiscard]] eve::Result<void> addQuestAdditionMigration(std::string_view fromContentVersion,
148 std::string_view questId);
149
158 [[nodiscard]] eve::Result<void> allowSingleActorPartyMigration(
159 std::string_view fromContentVersion);
160
168 [[nodiscard]] eve::Result<std::string> snapshotJson() const;
169
177 [[nodiscard]] eve::Result<PreparedRestore> prepareRestoreSnapshotJson(std::string_view json);
178
186 void commitPrepared(PreparedRestore prepared) noexcept;
187
197 [[nodiscard]] eve::Result<void> validateSnapshotJson(std::string_view json);
198
209 [[nodiscard]] eve::Result<void> restoreSnapshotJson(std::string_view json);
210
211private:
212 struct MigrationKey {
213 std::string fromContentVersion;
214 RPGSaveIdDomain domain = RPGSaveIdDomain::Item;
215 std::string oldId;
216
218 friend bool operator<(const MigrationKey &left, const MigrationKey &right) noexcept {
219 if (left.fromContentVersion != right.fromContentVersion)
220 return left.fromContentVersion < right.fromContentVersion;
221 if (left.domain != right.domain) return left.domain < right.domain;
222 return left.oldId < right.oldId;
223 }
224 };
225
226
227 GameState *gameState_ = nullptr;
228 Tracker *tracker_ = nullptr;
229 RPGActor *actor_ = nullptr;
230 Party *party_ = nullptr;
231 inventory::Bag *bag_ = nullptr;
232 inventory::EquipmentSet *equipment_ = nullptr;
233 std::string contentVersion_;
234 std::set<std::string> compatibleContentVersions_;
235 std::map<MigrationKey, std::string> idRenameMigrations_;
236 std::map<std::string, std::set<std::string>> questAdditionMigrations_;
237 std::set<std::string> singleActorPartyMigrations_;
238};
239
240} // namespace eve::rpg
#define EVENGINE_API_PLATFORM
Definition Export.h:107
HexVec3 left
HexVec3 right
std::string domain
Move-only, checked operation results for the common layer.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:26
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
Validated owning RPG state that can be published without another fallible parse.
PreparedRestore(PreparedRestore &&) noexcept
A non-owning save boundary for the persistent classic-RPG state owners.
一份任务进度 + 本实例事件队列。
Definition Tracker.h:26
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
constexpr int Party
Definition Battle.h:31
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
RPGSaveIdDomain
Definition-reference field kinds supported by direct RPG save ID migrations.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
一条目标:听哪个 notify、要多少次。target 空 = 只匹配 topic。
Definition QuestTypes.h:18