载入中...
搜索中...
未找到
Rx.cpp
浏览该文件的文档.
1#include "rx/Rx.h"
3
6
7#include <simplesquirrel/simplesquirrel.hpp>
8
9#include <squirrel.h>
10
11#include <unordered_map>
12
13namespace eve::rx {
14
15// ---------------------------------------------------------------------------
16// Value conversion helpers.
17// ---------------------------------------------------------------------------
18int64_t Value::toInt() const {
19 switch (type) {
20 case Type::Int: return i;
21 case Type::Float: return static_cast<int64_t>(f);
22 case Type::Bool: return b ? 1 : 0;
23 case Type::String:
24 try {
25 return static_cast<int64_t>(std::stoll(s));
26 } catch (...) {
27 return 0;
28 }
29 default: return 0;
30 }
31}
32
33double Value::toFloat() const {
34 switch (type) {
35 case Type::Int: return static_cast<double>(i);
36 case Type::Float: return f;
37 case Type::Bool: return b ? 1.0 : 0.0;
38 case Type::String:
39 try {
40 return std::stod(s);
41 } catch (...) {
42 return 0.0;
43 }
44 default: return 0.0;
45 }
46}
47
48bool Value::toBool() const {
49 switch (type) {
50 case Type::Int: return i != 0;
51 case Type::Float: return f != 0.0;
52 case Type::Bool: return b;
53 case Type::String: return !s.empty();
54 case Type::Ptr: return p != nullptr;
55 default: return false;
56 }
57}
58
59std::string Value::toString() const {
60 switch (type) {
61 case Type::Int: return std::to_string(i);
62 case Type::Float: return std::to_string(f);
63 case Type::Bool: return b ? "true" : "false";
64 case Type::String: return s;
65 case Type::Ptr: return "ptr";
66 default: return "";
67 }
68}
69
70bool Value::equals(const Value& o) const {
71 if (type != o.type) return false;
72 switch (type) {
73 case Type::Int: return i == o.i;
74 case Type::Float: return f == o.f;
75 case Type::Bool: return b == o.b;
76 case Type::String: return s == o.s;
77 case Type::Ptr: return p == o.p;
78 default: return true;
79 }
80}
81
82} // namespace eve::rx
83
84// ---------------------------------------------------------------------------
85// ssq::detail specializations so Value can cross the Squirrel boundary in
86// bound method parameters / return values. Declared here so all bindings in
87// this TU instantiate against them.
88// ---------------------------------------------------------------------------
89namespace ssq {
90namespace detail {
91
92template <>
93inline void pushValue(HSQUIRRELVM vm, const eve::rx::Value& v) {
94 switch (v.type) {
95 case eve::rx::Value::Type::Nil: sq_pushnull(vm); break;
96 case eve::rx::Value::Type::Int: sq_pushinteger(vm, static_cast<SQInteger>(v.i)); break;
97 case eve::rx::Value::Type::Float: sq_pushfloat(vm, static_cast<SQFloat>(v.f)); break;
98 case eve::rx::Value::Type::Bool: sq_pushbool(vm, v.b ? SQTrue : SQFalse); break;
100 sq_pushstring(vm, v.s.c_str(), static_cast<SQInteger>(v.s.size()));
101 break;
102 case eve::rx::Value::Type::Ptr: sq_pushuserpointer(vm, v.p); break;
103 }
104}
105
106template <>
108 switch (sq_gettype(vm, index)) {
109 case OT_NULL: return eve::rx::Value::makeNil();
110 case OT_INTEGER: {
111 SQInteger i = 0;
112 sq_getinteger(vm, index, &i);
113 return eve::rx::Value::makeInt(static_cast<int64_t>(i));
114 }
115 case OT_FLOAT: {
116 SQFloat f = 0;
117 sq_getfloat(vm, index, &f);
118 return eve::rx::Value::makeFloat(static_cast<double>(f));
119 }
120 case OT_BOOL: {
121 SQBool b = SQFalse;
122 sq_getbool(vm, index, &b);
123 return eve::rx::Value::makeBool(b == SQTrue);
124 }
125 case OT_STRING: {
126 const SQChar* s = nullptr;
127 sq_getstring(vm, index, &s);
128 return eve::rx::Value::makeString(s ? s : "");
129 }
130 case OT_USERPOINTER: {
131 SQUserPointer p = nullptr;
132 sq_getuserpointer(vm, index, &p);
134 }
135 default: return eve::rx::Value::makeNil();
136 }
137}
138
139} // namespace detail
140} // namespace ssq
141
142namespace eve::rx {
143
144// ---------------------------------------------------------------------------
145// Script-facing aliases (Value-typed).
146// ---------------------------------------------------------------------------
152
153namespace {
154
155// Call a script function with the given Value args; returns its Value result.
156Value callScript(const ssq::Function& fn, const std::vector<Value>& args, bool wantResult) {
157 if (fn.isEmpty()) return Value::makeNil();
158 HSQUIRRELVM raw = fn.getHandle();
159 SQInteger top = sq_gettop(raw);
160 sq_pushobject(raw, fn.getRaw());
161 sq_pushroottable(raw);
162 for (const auto& a : args) ssq::detail::pushValue(raw, a);
163 // The payload is a runtime vector, so the shared helper's typed-argument form does not
164 // fit; the count is derived from the pushes instead -- the same rule (R-FACE-7). A
165 // subscriber or operator callback that threw used to be dropped in silence: the failed
166 // call read the same as one that returned nothing, and the stream simply stopped
167 // producing.
168 const SQInteger params = sq_gettop(raw) - top - 1; // receiver + arguments
170 if (SQ_SUCCEEDED(sq_call(raw, params, wantResult ? SQTrue : SQFalse, SQTrue))) {
171 if (wantResult && sq_gettop(raw) > top) result = ssq::detail::popValue<Value>(raw, -1);
172 } else {
173 script::reportScriptCallFailure(raw, "rx.script-callback");
174 }
175 sq_settop(raw, top);
176 return result;
177}
178
179std::function<void()> scriptCompleted(ssq::Function fn) {
180 return [fn]() { callScript(fn, {}, false); };
181}
182std::function<void(const Value&)> scriptNext(ssq::Function fn) {
183 return [fn](const Value& v) { callScript(fn, {v}, false); };
184}
185std::function<void(const std::string&)> scriptError(ssq::Function fn) {
186 return [fn](const std::string& e) { callScript(fn, {Value::makeString(e)}, false); };
187}
188
189bool isClosure(const ssq::Object& obj) {
190 if (obj.isEmpty()) return false;
191 auto t = obj.getType();
192 return t == ssq::Type::CLOSURE || t == ssq::Type::NATIVECLOSURE;
193}
194
195// Return a copy of obj if it is a usable closure, else an empty Object.
196ssq::Object asClosure(const ssq::Object& obj) {
197 if (isClosure(obj)) return obj;
198 return ssq::Object();
199}
200
201Observer<Value> makeObserver(ssq::Object next, ssq::Object error, ssq::Object done) {
203 ssq::Object n = asClosure(next);
204 ssq::Object e = asClosure(error);
205 ssq::Object c = asClosure(done);
206 if (!n.isEmpty()) o.onNext = scriptNext(n.toFunction());
207 if (!e.isEmpty()) o.onError = scriptError(e.toFunction());
208 if (!c.isEmpty()) o.onCompleted = scriptCompleted(c.toFunction());
209 return o;
210}
211
212Subscription* doSubscribe(ObservableV* obs, ssq::Object next, ssq::Object error, ssq::Object done) {
213 if (!obs) throw eve::Exception("Rx.subscribe: null observable");
214 return new Subscription(obs->subscribe(makeObserver(next, error, done)));
215}
216
217// map(fn) : ObservableV -> ObservableV via script function returning Value.
218ObservableV* doMap(ObservableV* self, ssq::Function fn) {
219 if (!self) throw eve::Exception("Rx.map: null observable");
222 in.onNext = [out, fn](const Value& v) { out.next(callScript(fn, {v}, true)); };
223 in.onError = detail::ForwardError<Value>{out};
224 in.onCompleted = detail::ForwardCompleted<Value>{out};
225 return self->subscribe(std::move(in));
226 });
227}
228
229ObservableV* doFilter(ObservableV* self, ssq::Function pred) {
230 if (!self) throw eve::Exception("Rx.filter: null observable");
231 return new AnonymousObservable<Value>([self, pred](Observer<Value> out) {
233 in.onNext = [out, pred](const Value& v) {
234 if (callScript(pred, {v}, true).toBool()) out.next(v);
235 };
236 in.onError = detail::ForwardError<Value>{out};
237 in.onCompleted = detail::ForwardCompleted<Value>{out};
238 return self->subscribe(std::move(in));
239 });
240}
241
242ObservableV* doTake(ObservableV* self, int n) {
243 if (!self) throw eve::Exception("Rx.take: null observable");
244 return new AnonymousObservable<Value>([self, n](Observer<Value> out) {
245 auto remaining = std::make_shared<int>(n);
247 in.onNext = [out, remaining](const Value& v) {
248 if (*remaining <= 0) return;
249 *remaining -= 1;
250 out.next(v);
251 if (*remaining == 0) out.completed();
252 };
253 in.onError = detail::ForwardError<Value>{out};
254 in.onCompleted = detail::ForwardCompleted<Value>{out};
255 return self->subscribe(std::move(in));
256 });
257}
258
259ObservableV* doSkip(ObservableV* self, int n) {
260 if (!self) throw eve::Exception("Rx.skip: null observable");
261 return new AnonymousObservable<Value>([self, n](Observer<Value> out) {
262 auto remaining = std::make_shared<int>(n);
264 in.onNext = [out, remaining](const Value& v) {
265 if (*remaining > 0) {
266 *remaining -= 1;
267 return;
268 }
269 out.next(v);
270 };
271 in.onError = detail::ForwardError<Value>{out};
272 in.onCompleted = detail::ForwardCompleted<Value>{out};
273 return self->subscribe(std::move(in));
274 });
275}
276
277ObservableV* doFirst(ObservableV* self) {
278 if (!self) throw eve::Exception("Rx.first: null observable");
280 auto done = std::make_shared<bool>(false);
282 in.onNext = [out, done](const Value& v) {
283 if (*done) return;
284 *done = true;
285 out.next(v);
286 out.completed();
287 };
288 in.onError = detail::ForwardError<Value>{out};
289 in.onCompleted = detail::ForwardCompleted<Value>{out};
290 return self->subscribe(std::move(in));
291 });
292}
293
294ObservableV* doDistinctUntilChanged(ObservableV* self) {
295 if (!self) throw eve::Exception("Rx.distinctUntilChanged: null observable");
297 auto last = std::make_shared<Value>();
298 auto has = std::make_shared<bool>(false);
300 in.onNext = [out, last, has](const Value& v) {
301 if (*has && last->equals(v)) return;
302 *has = true;
303 *last = v;
304 out.next(v);
305 };
306 in.onError = detail::ForwardError<Value>{out};
307 in.onCompleted = detail::ForwardCompleted<Value>{out};
308 return self->subscribe(std::move(in));
309 });
310}
311
312} // namespace
313
314// ---------------------------------------------------------------------------
315// Rx module.
316// ---------------------------------------------------------------------------
317class Rx : public Module {
318public:
320
321 SubjectV* newSubject() { return new SubjectV(); }
322 BehaviorSubjectV* newBehaviorSubject(const Value& initial) { return new BehaviorSubjectV(initial); }
324 ReactivePropertyV* newProperty(const Value& initial) { return new ReactivePropertyV(initial); }
325
326 // Event bridge: fromEvent(name) returns an Observable that forwards matching
327 // messages pushed by pump() (fed from an eve::platform_event::PlatformEvent queue).
328 ObservableV* fromEvent(const std::string& eventName) {
329 auto subject = std::make_shared<SubjectV>();
330 {
331 std::lock_guard<std::mutex> lock(mu_);
332 bridges_[eventName] = subject;
333 }
334 // Return a fresh observable that subscribes to the shared subject. The
335 // returned AnonymousObservable is owned by the script; the shared subject
336 // stays alive in bridges_ so pump() can keep feeding it.
338 return subject->subscribe(std::move(out));
339 });
340 }
341
343 if (!ev) return;
344 while (auto msg = ev->pollOwned()) {
345 std::string eventName = msg->name;
346 std::string data;
347 for (const auto& a : msg->args) {
349 data = a.s;
350 break;
351 }
352 }
353 std::shared_ptr<SubjectV> subject;
354 {
355 std::lock_guard<std::mutex> lock(mu_);
356 auto it = bridges_.find(eventName);
357 if (it != bridges_.end()) subject = it->second;
358 }
359 if (subject) subject->onNext(Value::makeString(data));
360 }
361 }
362
363private:
364 std::mutex mu_;
365 std::unordered_map<std::string, std::shared_ptr<SubjectV>> bridges_;
366};
367
369
370// ---------------------------------------------------------------------------
371// Squirrel binding.
372// ---------------------------------------------------------------------------
373namespace {
374
375using ObsFn = std::function<ObservableV*(ObservableV*)>;
376
377void bindCommon(ssq::Class& cls) {
378 cls.addFunc("subscribe",
379 std::function<Subscription*(ObservableV*, ssq::Object)>(
380 [](ObservableV* self, ssq::Object n) { return doSubscribe(self, n, {}, {}); }));
381 cls.addFunc("subscribe3",
382 std::function<Subscription*(ObservableV*, ssq::Object, ssq::Object, ssq::Object)>(
383 [](ObservableV* self, ssq::Object n, ssq::Object e, ssq::Object d) {
384 return doSubscribe(self, n, e, d);
385 }));
386 eve::script::bindPointerMethod(cls, "map", &doMap);
387 eve::script::bindPointerMethod(cls, "filter", &doFilter);
388 eve::script::bindPointerMethod(cls, "take", &doTake);
389 eve::script::bindPointerMethod(cls, "skip", &doSkip);
390 eve::script::bindPointerMethod(cls, "first", &doFirst);
391 eve::script::bindPointerMethod(cls, "distinctUntilChanged", &doDistinctUntilChanged);
392}
393
394} // namespace
395
396void Rx::expose(ssq::Table& table) {
397 auto cls = table.addClass(name, Rx::create, false);
398 expose(cls);
399
400 auto obs = table.addClass<ObservableV>(
401 "Observable", std::function<ObservableV*()>([]() -> ObservableV* { return nullptr; }), true);
402 bindCommon(obs);
403
404 auto subject = table.addClass<SubjectV>(
405 "Subject", std::function<SubjectV*()>([]() -> SubjectV* { return nullptr; }), true);
406 subject.addFunc("onNext", &SubjectV::onNext);
407 subject.addFunc("onError", &SubjectV::onError);
408 subject.addFunc("onCompleted", &SubjectV::onCompleted);
409 subject.addFunc("hasObservers", &SubjectV::hasObservers);
410 bindCommon(subject);
411
412 auto behavior = table.addClass<BehaviorSubjectV>(
413 "BehaviorSubject", std::function<BehaviorSubjectV*()>([]() -> BehaviorSubjectV* { return nullptr; }), true);
414 behavior.addFunc("onNext", &BehaviorSubjectV::onNext);
415 behavior.addFunc("onError", &BehaviorSubjectV::onError);
416 behavior.addFunc("onCompleted", &BehaviorSubjectV::onCompleted);
417 behavior.addFunc("hasObservers", &BehaviorSubjectV::hasObservers);
418 behavior.addFunc("getValue", &BehaviorSubjectV::getValue);
419 behavior.addFunc("setValue", &BehaviorSubjectV::setValue);
420 bindCommon(behavior);
421
422 auto replay = table.addClass<ReplaySubjectV>(
423 "ReplaySubject", std::function<ReplaySubjectV*()>([]() -> ReplaySubjectV* { return nullptr; }), true);
424 replay.addFunc("onNext", &ReplaySubjectV::onNext);
425 replay.addFunc("onError", &ReplaySubjectV::onError);
426 replay.addFunc("onCompleted", &ReplaySubjectV::onCompleted);
427 replay.addFunc("hasObservers", &ReplaySubjectV::hasObservers);
428 bindCommon(replay);
429
430 auto prop = table.addClass<ReactivePropertyV>(
431 "ReactiveProperty", std::function<ReactivePropertyV*()>([]() -> ReactivePropertyV* { return nullptr; }), true);
432 prop.addFunc("get", &ReactivePropertyV::get);
433 prop.addFunc("set", &ReactivePropertyV::set);
434 prop.addFunc("subscribe",
435 std::function<Subscription*(ReactivePropertyV*, ssq::Object)>(
436 [](ReactivePropertyV* self, ssq::Object n) {
437 if (!self) throw eve::Exception("Rx.subscribe: null property");
438 return doSubscribe(self->asObservable(), n, {}, {});
439 }));
440 prop.addFunc("subscribe3",
441 std::function<Subscription*(ReactivePropertyV*, ssq::Object, ssq::Object, ssq::Object)>(
442 [](ReactivePropertyV* self, ssq::Object n, ssq::Object e, ssq::Object d) {
443 if (!self) throw eve::Exception("Rx.subscribe: null property");
444 return doSubscribe(self->asObservable(), n, e, d);
445 }));
446
447 auto sub = table.addClass<Subscription>(
448 "Subscription", std::function<Subscription*()>([]() -> Subscription* { return nullptr; }), true);
451}
452
453void Rx::expose(ssq::Class& cls) {
454 cls.addFunc("getName", &Rx::getName);
455 cls.addFunc("newSubject", &Rx::newSubject);
456 cls.addFunc("newBehaviorSubject", &Rx::newBehaviorSubject);
457 cls.addFunc("newReplaySubject", &Rx::newReplaySubject);
458 cls.addFunc("newProperty", &Rx::newProperty);
459 cls.addFunc("fromEvent", &Rx::fromEvent);
460 cls.addFunc("pump", &Rx::pump);
461}
462
463} // namespace eve::rx
int subject
Definition AnimSmr.cpp:163
const std::string & s
struct SQVM * HSQUIRRELVM
glm::vec4 p[6]
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
std::string name
Definition ECS.cpp:154
double raw
std::uint32_t capacity
glm::vec3 n
Definition Grass.cpp:63
float v
std::int32_t c
Poco::JSON::Object::Ptr result
bool done
std::vector< RecipeParam > params
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
std::string error
Definition Package.cpp:174
float f
float d
int detail
float t
ScriptStructure out
The single Squirrel projection for common Result, Status and Value.
uint32_t index
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
EVENGINE_API_FOUNDATION public API.
Definition Module.h:48
virtual std::string getName() const =0
Returns the name.
EVENGINE_API_FOUNDATION public API.
std::unique_ptr< Message > pollOwned()
Pops the oldest message into an RAII handle, or returns null.
Internal: observable built directly from a subscribe function.
Definition Rx.h:258
Subject that replays the latest value to every new subscriber. setValue()/onNext() update the stored ...
Definition Rx.h:524
void onCompleted()
Stops replay and delivers a terminal completion.
Definition Rx.h:575
bool hasObservers() const
True while at least one live observer is registered.
Definition Rx.h:584
T getValue() const
Current stored value.
Definition Rx.h:547
void onNext(T v)
Alias of setValue().
Definition Rx.h:564
void onError(const std::string &e)
Stops replay and delivers a terminal error.
Definition Rx.h:566
void setValue(T v)
Stores a new value and pushes it to observers.
Definition Rx.h:553
Push-based stream source. Operators return a new (caller-owned) Observable; subscribe() returns a Sub...
Definition Rx.h:210
virtual Subscription subscribe(Observer< T > obs)=0
Subscribes with a full observer; returns a cancel handle.
Callback bundle pushed to a subscriber. Once error() or completed() fires the observer is stopped and...
Definition Rx.h:146
CompletedFn onCompleted
Completion callback (terminal).
Definition Rx.h:157
NextFn onNext
Value callback.
Definition Rx.h:153
ErrorFn onError
Error callback (terminal).
Definition Rx.h:155
Observable value backed by a BehaviorSubject. get() returns the current value; set() stores and pushe...
Definition Rx.h:654
T get() const
Current value.
Definition Rx.h:660
void set(T v)
Stores a new value and notifies subscribers.
Definition Rx.h:662
Subject that buffers up to capacity values (0 = unlimited) and replays the buffer to every new subscr...
Definition Rx.h:599
void onNext(T v)
Buffers and pushes a new value to observers.
Definition Rx.h:619
void onCompleted()
Delivers a terminal completion to observers.
Definition Rx.h:635
void onError(const std::string &e)
Delivers a terminal error to observers.
Definition Rx.h:631
bool hasObservers() const
True while at least one live observer is registered.
Definition Rx.h:639
ReactivePropertyV * newProperty(const Value &initial)
Definition Rx.cpp:324
ReplaySubjectV * newReplaySubject(int capacity=0)
Definition Rx.cpp:323
void pump(platform_event::PlatformEvent *ev)
Definition Rx.cpp:342
BehaviorSubjectV * newBehaviorSubject(const Value &initial)
Definition Rx.cpp:322
SubjectV * newSubject()
Definition Rx.cpp:321
ObservableV * fromEvent(const std::string &eventName)
Definition Rx.cpp:328
Multicast push-based stream: both an Observable and a push source. Thread-safe: onNext/onError/onComp...
Definition Rx.h:418
bool hasObservers() const
True while at least one live observer is registered.
Definition Rx.h:458
void onCompleted()
Pushes a terminal completion and stops the subject.
Definition Rx.h:452
void onNext(const T &v)
Pushes a value to every registered observer.
Definition Rx.h:445
void onError(const std::string &e)
Pushes a terminal error and stops the subject.
Definition Rx.h:447
RAII-style dispose handle for an active stream subscription. Disposing unsubscribes from the source; ...
Definition Rx.h:93
void dispose()
Runs the dispose callback once; idempotent.
Definition Rx.h:122
bool isDisposed() const
True once dispose() has run (or the handle was moved from).
Definition Rx.h:132
Runtime variant used by the script-facing (Squirrel) streams. The C++ core is templated (Observer<T>/...
Definition Rx.h:21
Type type
Definition Rx.h:26
bool toBool() const
Definition Rx.cpp:48
double toFloat() const
Definition Rx.cpp:33
static Value makeFloat(double v)
Constructs a floating-point value.
Definition Rx.h:43
static Value makeNil()
Constructs a nil value.
Definition Rx.h:34
bool b
Definition Rx.h:29
static Value makePtr(void *v)
Constructs a pointer value (borrowed, not owned).
Definition Rx.h:64
int64_t toInt() const
Converters (throw eve::Exception on type mismatch).
Definition Rx.cpp:18
std::string s
Definition Rx.h:30
static Value makeInt(int64_t v)
Constructs an integer value.
Definition Rx.h:36
bool equals(const Value &o) const
Value equality across the supported types.
Definition Rx.cpp:70
double f
Definition Rx.h:28
void * p
Definition Rx.h:31
static Value makeString(std::string v)
Constructs a string value (takes ownership).
Definition Rx.h:57
int64_t i
Definition Rx.h:27
static Value makeBool(bool v)
Constructs a boolean value.
Definition Rx.h:50
std::string toString() const
Definition Rx.cpp:59
SQInteger top
Definition Snapshot.cpp:115
Result< void > replay(const Trace &trace, IEnvironment &environment, double tolerance)
Reset and replay actual actions, checking all observations and failure evidence.
Definition Agent.cpp:259
Vec3 sub(Vec3 a, Vec3 b)
eve::Subscription Subscription
Compatibility alias for the common observer lifetime token.
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:73
Definition Rx.cpp:13
ReactiveProperty< Value > ReactivePropertyV
Definition Rx.cpp:151
Observable< Value > ObservableV
Definition Rx.cpp:150
Subject< Value > SubjectV
Definition Rx.cpp:147
BehaviorSubject< Value > BehaviorSubjectV
Definition Rx.cpp:148
ReplaySubject< Value > ReplaySubjectV
Definition Rx.cpp:149
void bindPointerMethod(ssq::Class &cls, const char *name, Pointer pointer, bool isStatic=false)
Binds a free/member function directly, without std::function or a heap wrapper.
std::string reportScriptCallFailure(HSQUIRRELVM vm, const char *what)
Report a failed engine-to-script call, consuming the VM's script error.
void pushValue(HSQUIRRELVM vm, const eve::rx::Value &v)
Definition Rx.cpp:93
eve::rx::Value popValue(HSQUIRRELVM vm, SQInteger index)
Definition Rx.cpp:107
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:21
SettlementPipeline::Stage fn