载入中...
搜索中...
未找到
RTSScriptInternal.h
浏览该文件的文档.
1#pragma once
2#include "common/Value.h"
3#include "rts/RTSSystems.h"
5namespace ssq {
6class Class;
7}
8namespace eve::definitions {
9class DefinitionRegistry;
10}
12inline Result<SubjectRef> parseScriptSubject(std::string_view text, std::string_view path) {
13 const auto parsed = PersistentId::parse(text);
14 if (!parsed)
16 DiagnosticCode::InvalidArgument, "RTS script identity must be a canonical UUID", std::string(path)));
18}
19
24inline Result<std::vector<SubjectRef>> parseScriptSubjects(const std::vector<std::string>& texts) {
25 std::vector<SubjectRef> subjects;
26 subjects.reserve(texts.size());
27 for (std::size_t index = 0; index < texts.size(); ++index) {
28 auto subject = parseScriptSubject(texts[index], "subjects[" + std::to_string(index) + "]");
29 if (!subject) return Result<std::vector<SubjectRef>>::failure(subject.status());
30 subjects.push_back(std::move(subject).takeValue());
31 }
32 return Result<std::vector<SubjectRef>>::success(std::move(subjects));
33}
34
36 Value::Array orderIds;
37 orderIds.reserve(receipt.orderIds.size());
38 for (auto& id : receipt.orderIds) orderIds.emplace_back(std::move(id));
39 return Value(Value::Object{{"requested", static_cast<std::int64_t>(receipt.requested)},
40 {"accepted", static_cast<std::int64_t>(receipt.accepted)},
41 {"orderIds", Value(std::move(orderIds))}});
42}
43
44Result<RTSEffectDefinition> resolveEffectDefinition(definitions::DefinitionRegistry& registry, std::string_view id,
45 SubjectRef source, double durationOverride = -1.0);
47 ecs::EntityHandle target,
49
50// Private binding registration; the owning RTS class controls lifetime and VM.
51void exposeFormationBindings(ssq::Class& cls);
53void exposeRelocationBindings(ssq::Class& cls);
55void exposeCrowdSurfaceBindings(ssq::Class& cls);
56void exposeEconomyBindings(ssq::Class& cls);
57void exposeStageBindings(ssq::Class& cls);
58} // namespace eve::rts::script_internal
LogicalId target
int subject
Definition AnimSmr.cpp:163
HSQOBJECT cls
Definition ECS.cpp:39
std::string path
Definition PlayHost.cpp:111
const eve::script::BindingContractRegistry & registry
Deterministic phase-one RTS systems and their ECS contracts.
std::string text
std::string_view source
uint32_t index
Owning, renderer-independent dynamic values.
glm::vec3 point
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
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
Deterministic registry of topic-neutral, versioned JSON definitions.
Definition Definitions.h:58
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:150
RTS unit domain root.
Definition RTSTypes.h:501
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 exposeCrowdSurfaceBindings(ssq::Class &cls)
Compose checked automatic surface tracking bindings.
void exposeRelocationBindings(ssq::Class &cls)
Compose explicit, atomic placement operations at the movement binding boundary.
void exposeStageBindings(ssq::Class &cls)
void exposeFormationBindings(ssq::Class &cls)
void exposeEconomyBindings(ssq::Class &cls)
Result< std::unique_ptr< transaction::ITransactionParticipant > > stageAbility(Unit &caster, AbilitySpec spec, ecs::EntityHandle target, WorldPosition point)
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:21
Typed ability policy; lifecycle effects remain owned by the canonical effect container.
Definition RTSTypes.h:138
Receipt containing all order ids accepted by command fan-out.
Definition RTSSystems.h:203
std::vector< std::string > orderIds
Definition RTSSystems.h:206
Two-dimensional deterministic RTS world position.
Definition RTSTypes.h:53