载入中...
搜索中...
未找到
RTSScriptInternal.h
浏览该文件的文档.
1#pragma once
2#include "common/Value.h"
3#include "rts/RTSSystems.h"
4namespace ssq {
5class Class;
6}
8inline Result<SubjectRef> parseScriptSubject(std::string_view text, std::string_view path) {
9 const auto parsed = PersistentId::parse(text);
10 if (!parsed)
12 DiagnosticCode::InvalidArgument, "RTS script identity must be a canonical UUID", std::string(path)));
14}
15
20inline Result<std::vector<SubjectRef>> parseScriptSubjects(const std::vector<std::string>& texts) {
21 std::vector<SubjectRef> subjects;
22 subjects.reserve(texts.size());
23 for (std::size_t index = 0; index < texts.size(); ++index) {
24 auto subject = parseScriptSubject(texts[index], "subjects[" + std::to_string(index) + "]");
25 if (!subject) return Result<std::vector<SubjectRef>>::failure(subject.status());
26 subjects.push_back(std::move(subject).takeValue());
27 }
28 return Result<std::vector<SubjectRef>>::success(std::move(subjects));
29}
30
32 Value::Array orderIds;
33 orderIds.reserve(receipt.orderIds.size());
34 for (auto& id : receipt.orderIds) orderIds.emplace_back(std::move(id));
35 return Value(Value::Object{{"requested", static_cast<std::int64_t>(receipt.requested)},
36 {"accepted", static_cast<std::int64_t>(receipt.accepted)},
37 {"orderIds", Value(std::move(orderIds))}});
38}
39
40// Private binding registration; the owning RTS class controls lifetime and VM.
41void exposeFormationBindings(ssq::Class& cls);
42} // namespace eve::rts::script_internal
int subject
Definition AnimSmr.cpp:163
HSQOBJECT cls
Definition ECS.cpp:21
std::string text
std::string path
Definition PlayHost.cpp:110
Deterministic phase-one RTS systems and their ECS contracts.
uint32_t index
Owning, renderer-independent dynamic values.
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static SubjectRef fromPersistentId(PersistentId id) noexcept
Wrap a persistent identity without changing its bytes.
Definition SubjectRef.h:32
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:151
Value fanOutValue(FanOutReceipt receipt)
Result< std::vector< SubjectRef > > parseScriptSubjects(const std::vector< std::string > &texts)
Parse script UUID strings into stable subjects. @cost Linear in subject count; allocates one output v...
Result< SubjectRef > parseScriptSubject(std::string_view text, std::string_view path)
void exposeFormationBindings(ssq::Class &cls)
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:14
Receipt containing all order ids accepted by command fan-out.
Definition RTSSystems.h:202
std::vector< std::string > orderIds
Definition RTSSystems.h:205