载入中...
搜索中...
未找到
RPGGameSaveParticipant.cpp
浏览该文件的文档.
2
4
5#include <utility>
6
7namespace eve::rpg {
8namespace {
9
10class PreparedRPGGameRestore final : public IPreparedGameRestore {
11public:
12 PreparedRPGGameRestore(RPGSaveSession& session, RPGSaveSession::PreparedRestore prepared)
13 : session_(session), prepared_(std::move(prepared)) {}
14 void commit() noexcept override { session_.commitPrepared(std::move(prepared_)); }
15
16private:
17 RPGSaveSession& session_;
18 RPGSaveSession::PreparedRestore prepared_;
19};
20
21} // namespace
22
24
25std::string_view RPGGameSaveParticipant::saveKey() const noexcept { return "rpg"; }
26
28 auto json = session_->snapshotJson();
29 if (!json.ok()) return Result<Value>::failure(json.status());
30 return Value::fromJson(json.value());
31}
32
34 auto json = state.toJson();
35 if (!json.ok()) return Result<std::unique_ptr<IPreparedGameRestore>>::failure(json.status());
36 auto prepared = session_->prepareRestoreSnapshotJson(json.value());
37 if (!prepared.ok()) return Result<std::unique_ptr<IPreparedGameRestore>>::failure(prepared.status());
38 std::unique_ptr<IPreparedGameRestore> result =
39 std::make_unique<PreparedRPGGameRestore>(*session_, std::move(prepared).takeValue());
40 return Result<std::unique_ptr<IPreparedGameRestore>>::success(std::move(result));
41}
42
43} // namespace eve::rpg
Poco::JSON::Object::Ptr result
Transactional composition of persistent RPG state owners.
std::optional< InteractionSession > session
Definition Tactics.cpp:39
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
EVENGINE_API_FOUNDATION public API.
Definition Json.h:39
Result< Value > capture() const override
Capture an independent owning snapshot of this domain.
Result< std::unique_ptr< IPreparedGameRestore > > prepare(const Value &state) override
RPGGameSaveParticipant(RPGSaveSession &session) noexcept
The bound session must outlive this adapter and any game-save transaction.
std::string_view saveKey() const noexcept override
Stable unique participant key within the game-save schema.
A non-owning save boundary for the persistent classic-RPG state owners.
eve::Result< std::string > snapshotJson() const
Capture every bound participant into one deterministic versioned JSON document.
eve::Result< PreparedRestore > prepareRestoreSnapshotJson(std::string_view json)
Parse, migrate and validate every RPG participant without publishing live state.
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
Result< VehiclePhysicsStatus > commit(physics::World &world, physics::ForceBatch &batch, std::shared_ptr< VehicleWheelRuntime > &runtime, std::vector< VehicleEntity::SuspensionState::WheelState > candidate, const SimulationStep &step)