载入中...
搜索中...
未找到
StoryEvent.cpp
浏览该文件的文档.
93 const std::unordered_set<std::string> stepFields = {"kind", "reference", "actorId", "x", "y", "duration"};
100 eve::DiagnosticCode::InvalidArgument, "story event must be an object", path, {}, "rpg.story-event"));
115 eve::DiagnosticCode::AlreadyExists, "duplicate story event id", path + ".id", {}, "rpg.story-event"));
151 !validText(actorId.asString(), true) || !x.isNumber() || !y.isNumber() || !duration.isNumber() ||
188bool StoryEventCatalogue::contains(const std::string& eventId) { return definitions().contains(eventId); }
202 eve::DiagnosticCode::NotFound, "story event is not registered", "eventId", {}, "rpg.story-event"));
205 const double completedValue = hasCompleted ? gameState->getSelfVariable(scope, "completed") : 0.0;
207 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation,
216 gameState->hasSelfVariable(scope, "cursor") ? gameState->getSelfVariable(scope, "cursor") : 0.0;
218 if (!std::isfinite(storedCursor) || std::floor(storedCursor) != storedCursor || storedCursor < 0.0 ||
242 return eve::Result<int>::failure(eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation,
247 gameState->hasSelfVariable(scope, "cursor") ? gameState->getSelfVariable(scope, "cursor") : 0.0;
249 gameState->hasSelfVariable(scope, "completed") ? gameState->getSelfVariable(scope, "completed") : 0.0;
269 if (!active_ || cursor_ < 0 || static_cast<std::size_t>(cursor_) >= definition_.steps.size()) return nullptr;
276int StoryEventSession::getStepCount() const { return static_cast<int>(definition_.steps.size()); }
全局游戏状态:开关(bool)、变量(数字)、独立变量(按作用域)。
Versioned, resumable presentation-event sequencing for RPG games.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
static Document parse(const std::string &text, std::string *error=nullptr)
Parse.
Definition Json.cpp:581
double getSelfVariable(const std::string &scope, const std::string &name) const
Returns the self variable.
Definition GameState.cpp:75
bool hasSelfVariable(const std::string &scope, const std::string &name) const
True when self variable.
Definition GameState.cpp:82
void setSelfVariable(const std::string &scope, const std::string &name, double value)
独立变量:scope(如 "map:1:event:3")下按名字存数字。
Definition GameState.cpp:71
static bool contains(const std::string &eventId)
Return whether an exact stable event id exists in the current catalogue.
Definition StoryEvent.cpp:188
static int count()
Return the committed definition count on the owning content thread.
Definition StoryEvent.cpp:187
static eve::Result< int > replaceFromJsonStrict(const std::string &json)
Validate and atomically replace every story-event definition.
Definition StoryEvent.cpp:58
static void clear()
Clear all definitions on the owning content thread without invoking callbacks.
Definition StoryEvent.cpp:186
static const StoryEventDefinition * find(const std::string &eventId)
Find one definition for immediate synchronous inspection.
Definition StoryEvent.cpp:189
int getStepIndex() const
Return the zero-based current cursor, or the step count after completion.
Definition StoryEvent.cpp:275
std::string getReference() const
Return an owning copy of the current dialogue/message reference.
Definition StoryEvent.cpp:282
double getDuration() const
Return the current wait/motion duration in seconds, or zero while inactive.
Definition StoryEvent.cpp:298
bool isActive() const
Return whether a current step is awaiting acknowledgement.
Definition StoryEvent.cpp:273
eve::Result< int > advance(GameState *gameState)
Acknowledge the current presentation command and persist the next cursor atomically.
Definition StoryEvent.cpp:236
double getY() const
Return the current move/camera Y coordinate, or zero while inactive.
Definition StoryEvent.cpp:294
bool isFinished() const
Return whether this session acknowledged its final step.
Definition StoryEvent.cpp:274
std::string getEventId() const
Return an owning copy of the current event id.
Definition StoryEvent.cpp:277
double getX() const
Return the current move/camera X coordinate, or zero while inactive.
Definition StoryEvent.cpp:290
std::string getActorId() const
Return an owning copy of the current move actor id.
Definition StoryEvent.cpp:286
eve::Result< void > begin(const std::string &eventId, GameState *gameState)
Begin or resume an event from its authoritative GameState cursor.
Definition StoryEvent.cpp:194
int getStepCount() const
Return the copied definition's total step count.
Definition StoryEvent.cpp:276
std::string getStepKind() const
Return the current command kind, or an empty string while inactive.
Definition StoryEvent.cpp:278
StoryEventStepKind
Closed set of UI-neutral presentation commands emitted by a story event.
Definition StoryEvent.h:17
@ Dialogue
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ AlreadyExists
@ InvariantViolation
@ ParseError
@ Conflict
@ Applied
One immutable, ordered and resumable story-event definition.
Definition StoryEvent.h:30
One immutable presentation command owned by a story-event definition.
Definition StoryEvent.h:20