载入中...
搜索中...
未找到
RpgDialect.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "common/Result.h"
11#include "common/Value.h"
12
13#include <cstdint>
14#include <functional>
15#include <memory>
16#include <string>
17#include <vector>
18
19namespace eve::dnut {
20class StepKindRegistry;
21}
22
23namespace eve::inventory {
24class Bag;
25class EquipmentSet;
26} // namespace eve::inventory
27
28namespace eve::rpg {
29
30class GameState;
31class Party;
32class RPGActor;
33
35enum class StoryMoveStatus : std::uint8_t {
37 Arrived,
42};
43
57 std::string actorId;
67 RPGActor* actor = nullptr;
69 double x = 0.0;
70 double y = 0.0;
72 bool hasDuration = false;
74 double duration = 0.0;
75};
76
93using StoryMoveHandler = std::function<eve::Result<StoryMoveStatus>(const StoryMoveRequest&)>;
94
96enum class StoryAnimationStatus : std::uint8_t {
100 Playing,
103};
104
123 std::string targetId;
133 RPGActor* actor = nullptr;
135 std::string clip;
137 bool loop = false;
139 bool hold = false;
140};
141
158using StoryAnimationHandler = std::function<eve::Result<StoryAnimationStatus>(const StoryAnimationRequest&)>;
159
218
231
241public:
250 [[nodiscard]] static eve::Result<int> replaceFromDnutStrict(const std::string& source, const std::string& path);
252 static void clear();
254 static int count();
256 static bool contains(const std::string& storyId);
258 [[nodiscard]] static std::vector<std::string> storyIds();
259};
260
276public:
284 RpgStorySession& operator=(RpgStorySession&&) noexcept;
286 RpgStorySession& operator=(const RpgStorySession&) = delete;
287
294 [[nodiscard]] eve::Result<void> begin(const std::string& storyId, RpgStoryBinding* binding);
295
309 [[nodiscard]] eve::Result<void> begin(const std::string& storyId, GameState* gameState, Party* party,
310 eve::inventory::Bag* bag, eve::inventory::EquipmentSet* equipment);
311
321 [[nodiscard]] eve::Result<void> advance();
322
324 [[nodiscard]] eve::Result<void> select(const std::string& routeLabel);
325
327 [[nodiscard]] eve::Result<void> resume(eve::Value result);
328
330 void stop();
331
333 [[nodiscard]] bool isActive() const;
335 [[nodiscard]] bool isBlocked() const;
337 [[nodiscard]] bool isWaitingStep() const;
339 [[nodiscard]] std::string getStoryId() const;
341 [[nodiscard]] std::string getStepKind() const;
347 [[nodiscard]] const eve::Value& getStepPayload() const;
349 [[nodiscard]] std::vector<std::string> getChoiceLabels() const;
350
352 [[nodiscard]] eve::Result<void> captureState(eve::Value& out) const;
360 [[nodiscard]] eve::Result<void> restoreState(const std::string& storyId, const eve::Value& in,
362
363private:
364 class Impl;
365 std::unique_ptr<Impl> impl_;
366};
367
368} // namespace eve::rpg
#define EVENGINE_API_PLATFORM
Definition Export.h:107
eve::action::ActionVfxBinding binding
std::string path
Definition PlayHost.cpp:110
float begin
Move-only, checked operation results for the common layer.
std::uint32_t count
const UnitySourceAsset & source
Owning, renderer-independent dynamic values.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Canonical step vocabulary owner and runtime handler router.
格子型物品容器(脚本可直接操作)。
Definition Bag.h:21
EVENGINE_API_FOUNDATION public API.
Definition Equipment.h:19
EVENGINE_API_FOUNDATION public API.
Definition Json.h:38
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:25
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
Strict process-local catalogue of .dnut story assets.
Definition RpgDialect.h:240
Caller-owned cursor over one published .dnut story.
Definition RpgDialect.h:275
RpgStorySession(RpgStorySession &&) noexcept
Rpg story session.
~RpgStorySession()
Rpg story session.
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
constexpr int Party
Definition Battle.h:31
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
std::function< eve::Result< StoryMoveStatus >(const StoryMoveRequest &)> StoryMoveHandler
Host movement controller invoked by the move step.
Definition RpgDialect.h:93
StepKindRegistry & rpgStoryStepRegistry()
Process-local step vocabulary for the RPG story dialect.
StoryAnimationStatus
Terminal state of one requested animation playback.
Definition RpgDialect.h:96
@ Unavailable
The target or the clip cannot be played, so the animation step fails.
@ Finished
The clip was applied instantaneously, so the step completes inline.
@ Playing
Playback was accepted and is still running; the host acknowledges the step when it ends.
std::function< eve::Result< StoryAnimationStatus >(const StoryAnimationRequest &)> StoryAnimationHandler
Host animation controller invoked by the animation step.
Definition RpgDialect.h:158
StoryMoveStatus
Terminal state of one requested actor move.
Definition RpgDialect.h:35
@ Arrived
The actor is already at the destination, so the step completes inline.
@ Unreachable
The destination cannot be reached, so the move step fails.
@ Travelling
The move was accepted and is still running; the host acknowledges the step when it ends.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Borrowed domain objects an RPG story step runs against.
Definition RpgDialect.h:169
eve::inventory::EquipmentSet * equipment
Equipment set used by equipment steps, or nullptr when unavailable.
Definition RpgDialect.h:177
GameState * gameState
Owner of switches, variables and per-story completion facts.
Definition RpgDialect.h:171
Party * party
Party used to resolve actor=<memberId> when no custom resolver is set.
Definition RpgDialect.h:173
std::function< RPGActor *(const std::string &actorId)> resolveActor
Optional actor resolver that overrides party member lookup.
Definition RpgDialect.h:184
eve::inventory::Bag * bag
Bag used by item and equipment steps, or nullptr when unavailable.
Definition RpgDialect.h:175
StoryMoveHandler moveActor
Optional movement controller for move steps.
Definition RpgDialect.h:200
StoryAnimationHandler playAnimation
Optional animation controller for animation steps.
Definition RpgDialect.h:216
One animation step request, expressed in the host's own animation space.
Definition RpgDialect.h:121
bool loop
Authored loop flag; false when the step omits it.
Definition RpgDialect.h:137
std::string targetId
Authored target=<id> verbatim; the host's own subject space.
Definition RpgDialect.h:123
RPGActor * actor
Target resolved through the binding, or nullptr.
Definition RpgDialect.h:133
bool hold
Authored hold flag; false when the step omits it.
Definition RpgDialect.h:139
std::string clip
Authored clip=<uri> verbatim; opaque to the engine.
Definition RpgDialect.h:135
One move step request, expressed in the host's own movement space.
Definition RpgDialect.h:55
bool hasDuration
Whether the authored step carried a duration field at all.
Definition RpgDialect.h:72
double x
Requested destination.
Definition RpgDialect.h:69
std::string actorId
Authored actor=<id> verbatim; the host's own subject space.
Definition RpgDialect.h:57
double duration
Authored travel time in seconds; only meaningful when hasDuration.
Definition RpgDialect.h:74
RPGActor * actor
Actor resolved through the binding, or nullptr.
Definition RpgDialect.h:67