载入中...
搜索中...
未找到
RPGSaveSession.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "common/Result.h"
11
12#include <map>
13#include <set>
14#include <string>
15#include <string_view>
16
17namespace eve::inventory {
18class Bag;
19class EquipmentSet;
20}
21
22namespace eve::rpg {
23
24class GameState;
25class Tracker;
26class RPGActor;
27class Party;
28
30enum class RPGSaveIdDomain {
31 Item,
32 Quest,
34 Skill,
35 Class,
36 Trait,
39};
40
49public:
51 RPGSaveSession() = default;
52
64 void bind(GameState &gameState, Tracker &tracker, RPGActor &actor, inventory::Bag &bag,
65 inventory::EquipmentSet &equipment) noexcept;
66
73 void bindParty(GameState &gameState, Tracker &tracker, Party &party, inventory::Bag &bag,
74 inventory::EquipmentSet &equipment) noexcept;
75
84 [[nodiscard]] eve::Result<void> setContentVersion(std::string_view contentVersion);
85
87 std::string getContentVersion() const { return contentVersion_; }
88
99 [[nodiscard]] eve::Result<void> allowCompatibleContentVersion(std::string_view contentVersion);
100
114 [[nodiscard]] eve::Result<void> addIdRenameMigration(std::string_view fromContentVersion,
115 RPGSaveIdDomain domain, std::string_view oldId,
116 std::string_view newId);
117
130 [[nodiscard]] eve::Result<void> addQuestAdditionMigration(std::string_view fromContentVersion,
131 std::string_view questId);
132
141 [[nodiscard]] eve::Result<void> allowSingleActorPartyMigration(
142 std::string_view fromContentVersion);
143
151 [[nodiscard]] eve::Result<std::string> snapshotJson() const;
152
162 [[nodiscard]] eve::Result<void> validateSnapshotJson(std::string_view json);
163
174 [[nodiscard]] eve::Result<void> restoreSnapshotJson(std::string_view json);
175
176private:
177 struct MigrationKey {
178 std::string fromContentVersion;
179 RPGSaveIdDomain domain = RPGSaveIdDomain::Item;
180 std::string oldId;
181
183 friend bool operator<(const MigrationKey &left, const MigrationKey &right) noexcept {
184 if (left.fromContentVersion != right.fromContentVersion)
185 return left.fromContentVersion < right.fromContentVersion;
186 if (left.domain != right.domain) return left.domain < right.domain;
187 return left.oldId < right.oldId;
188 }
189 };
190
191 [[nodiscard]] eve::Result<void> restoreSnapshotJsonImpl(std::string_view json, bool publish);
192
193 GameState *gameState_ = nullptr;
194 Tracker *tracker_ = nullptr;
195 RPGActor *actor_ = nullptr;
196 Party *party_ = nullptr;
197 inventory::Bag *bag_ = nullptr;
198 inventory::EquipmentSet *equipment_ = nullptr;
199 std::string contentVersion_;
200 std::set<std::string> compatibleContentVersions_;
201 std::map<MigrationKey, std::string> idRenameMigrations_;
202 std::map<std::string, std::set<std::string>> questAdditionMigrations_;
203 std::set<std::string> singleActorPartyMigrations_;
204};
205
206} // namespace eve::rpg
#define EVENGINE_API_PLATFORM
Definition Export.h:107
HexVec3 left
HexVec3 right
Move-only, checked operation results for the common layer.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
格子型物品容器(脚本可直接操作)。
Definition Bag.h:21
EVENGINE_API_FOUNDATION public API.
Definition Equipment.h:19
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:25
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
A non-owning save boundary for the persistent classic-RPG state owners.
RPGSaveSession()=default
Rpg save session.
std::string getContentVersion() const
Return an owning copy of the configured content contract identifier.
一份任务进度 + 本实例事件队列。
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.
一条目标:听哪个 notify、要多少次。target 空 = 只匹配 topic。
Definition QuestTypes.h:18