载入中...
搜索中...
未找到
RTSCrowdSurfaceBindings.cpp
浏览该文件的文档.
2#include "rts/RTS.h"
4
6void exposeCrowdSurfaceBindings(ssq::Class& cls) {
7 const auto vm = cls.getHandle();
8 cls.addFunc("configureCrowdSurfaceTracking", [vm](RTS* self, ssq::Table input) -> ssq::Table {
10 try {
11 const auto integer = [&](const char* key) {
12 auto value = input.find(key);
13 if (value.getType() != ssq::Type::INTEGER)
14 throw ssq::TypeException("Tracking identity/budget requires exact integers");
15 return value.to<std::int64_t>();
16 };
17 const auto positive = [&](const char* key) {
18 auto value = integer(key);
19 if (value <= 0) throw ssq::TypeException("Tracking identities and revisions must be positive");
20 return static_cast<std::uint64_t>(value);
21 };
22 settings.surface = decltype(settings.surface)(positive("surfaceId"));
23 settings.movement = decltype(settings.movement)(positive("movementId"));
24 settings.movementRevision = positive("movementRevision");
25 settings.costModelRevision = positive("costModelRevision");
26 settings.clearanceRadius = input.get<float>("clearanceRadius");
27 settings.maxInflationChecks = integer("maxInflationChecks");
28 } catch (const std::exception& error) {
31 Diagnostic::error(DiagnosticCode::InvalidArgument, error.what(), "crowdSurfaceTracking")));
32 }
34 });
35 cls.addFunc("configureCrowdFlowNavigation", [vm](RTS* self, ssq::Table input) {
37 try {
38 const auto quota = [&](const char* key, int maximum) {
39 auto value = input.find(key);
40 if (value.getType() != ssq::Type::INTEGER)
41 throw ssq::TypeException("Flow quota requires exact integer");
42 auto count = value.to<std::int64_t>();
43 if (count < 1 || count > maximum) throw ssq::TypeException("Flow quota out of range");
44 return static_cast<int>(count);
45 };
46 settings.maxWorkPerTick = quota("maxWorkPerTick", 1000000);
47 settings.maxStartsPerTick = quota("maxStartsPerTick", 16);
48 } catch (const std::exception& error) {
51 Diagnostic::error(DiagnosticCode::InvalidArgument, error.what(), "crowdFlowNavigation")));
52 }
54 });
55 cls.addFunc("clearCrowdFlowNavigation", [](RTS* self) { self->clearCrowdFlowNavigation(); });
56 cls.addFunc("getCrowdFlowNavigationStatus", [vm](RTS* self) {
57 const auto state = self->getCrowdFlowNavigationStatus();
60 {"pendingGoals", Value(static_cast<std::int64_t>(state.pendingGoals))},
61 {"readyGoals", Value(static_cast<std::int64_t>(state.readyGoals))},
62 {"lastWork", Value(state.lastWork)},
63 {"lastStarts", Value(state.lastStarts)},
64 {"prepared", Value(std::to_string(state.prepared))},
65 {"cacheHits", Value(std::to_string(state.cacheHits))},
66 {"cachePressure", Value(state.cachePressure)}})),
67 [](Value value) { return value; });
68 });
69 cls.addFunc("clearCrowdSurfaceTracking", [](RTS* self) { self->clearCrowdSurfaceTracking(); });
70}
71} // namespace eve::rts::script_internal
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
SQObjectPtr key
Definition ECS.cpp:155
EvpackChunkInput input
Definition Evpack.cpp:170
float maximum[3]
OceanWakeSettings settings
std::string error
Definition Package.cpp:174
Object::Ptr value
RTS module owner and phase-one composition profile entry point.
int count
The single Squirrel projection for common Result, Status and Value.
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 Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.cpp:28
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::map< std::string, Value > Object
Definition Value.h:34
Owns RTS root entities and coordinates the phase-one systems.
Definition RTS.h:105
Result< void > configureCrowdFlowNavigation(CrowdFlowNavigationSettings settings)
Enable shared-field steering for eligible linked movement and constrained formation slots.
Result< void > configureCrowdSurfaceTracking(CrowdSurfaceTracking settings)
Configure automatic map-to-Crowd surface publication before simulation systems run.
CrowdFlowNavigationObservation getCrowdFlowNavigationStatus() const noexcept
Observe current work quotas/jobs without copying fields; owner thread only.
void clearCrowdSurfaceTracking() noexcept
Disable tracking and release its derived cache; retains the last published Crowd surface.
void clearCrowdFlowNavigation() noexcept
Disable shared-flow work and release jobs, retaining spending history; clear agent leases on next syn...
void exposeCrowdSurfaceBindings(ssq::Class &cls)
Compose checked automatic surface tracking bindings.
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.
Explicit shared-goal work quotas, consumed once per positive simulation tick.
Definition RTS.h:54
Runtime-owned map projection settings; configure once, rebuild only on source changes....
Definition RTS.h:45