载入中...
搜索中...
未找到
RTSRelocationBindings.cpp
浏览该文件的文档.
2#include "rts/RTS.h"
4
6
7void exposeRelocationBindings(ssq::Class& cls) {
8 cls.addFunc("relocateUnits", [vm = cls.getHandle()](RTS* self, ssq::Array units, int maxChecks) -> ssq::Table {
9 UnitRelocationBatch batch;
10 batch.maxChecks = maxChecks;
11 try {
12 if (units.size() > 1024) throw ssq::TypeException("Relocation batches support at most 1024 units");
13 batch.units.reserve(units.size());
14 for (std::size_t index = 0; index < units.size(); ++index) {
15 auto entry = units.get<ssq::Table>(index);
16 auto subject = parseScriptSubject(entry.get<std::string>("subject"), "relocateUnits.subject");
17 if (!subject) return script::projectStatusResult(vm, subject.status());
18 batch.units.push_back({subject.value(), {entry.get<float>("x"), entry.get<float>("y")}});
19 }
20 } catch (const std::exception& error) {
23 }
24 return script::projectResult(vm, self->relocateUnits(batch),
25 [](std::size_t count) { return Value(static_cast<std::int64_t>(count)); });
26 });
27}
28
29} // namespace eve::rts::script_internal
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
std::string error
Definition Package.cpp:174
RTS module owner and phase-one composition profile entry point.
int count
The single Squirrel projection for common Result, Status and Value.
std::vector< UnitCandidate > units
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.cpp:28
Owns RTS root entities and coordinates the phase-one systems.
Definition RTS.h:105
Result< std::size_t > relocateUnits(const UnitRelocationBatch &batch)
Atomically relocate owned units; preserves orders and invalidates derived navigation routes....
void exposeRelocationBindings(ssq::Class &cls)
Compose explicit, atomic placement operations at the movement binding boundary.
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.