12#include <simplesquirrel/simplesquirrel.hpp>
30 throw Exception(
"Motion.loops: unknown mode '%s' (use restart|yoyo)", mode.c_str());
33Animation *requireAnimation(Animation *animation) {
34 if (!animation)
throw Exception(
"MotionSequence: Animation is null");
46class ScriptMotionFloatSink final :
public IMotionFloatSink {
48 explicit ScriptMotionFloatSink(ScriptProviderHandle
handle) : handle_(
std::move(
handle)) {}
51 [[nodiscard]]
const ScriptProviderHandle&
handle() const noexcept {
return handle_; }
59 ScriptProviderHandle handle_;
66double readMotionNumber(
const ssq::Object& table,
const char* field,
const char* what) {
67 if (
table.getType() != ssq::Type::TABLE)
throw Exception(
"%s must be a table (x/y/z or r/g/b/a)", what);
70 if (
type != ssq::Type::FLOAT &&
type != ssq::Type::INTEGER)
71 throw Exception(
"%s requires a numeric '%s'", what, field);
72 return value.toFloat();
82struct MotionVec2Traits {
83 using Value = MotionVec2;
84 using Desc = MotionRuntime::Vec2Desc;
85 using Sink = IMotionVec2Sink;
87 static constexpr bool kHasStyle =
true;
88 static constexpr const char* kType =
"MotionVec2";
90 static Value read(
const ssq::Object& table,
const char* what) {
91 return MotionVec2{float(readMotionNumber(table,
"x", what)), float(readMotionNumber(table,
"y", what))};
93 static std::vector<eve::ScriptArg> scriptArgs(
const Value&
value) {
104struct MotionVec3Traits {
105 using Value = MotionVec3;
106 using Desc = MotionRuntime::Vec3Desc;
107 using Sink = IMotionVec3Sink;
109 static constexpr bool kHasStyle =
true;
110 static constexpr const char* kType =
"MotionVec3";
112 static Value read(
const ssq::Object& table,
const char* what) {
113 return MotionVec3{float(readMotionNumber(table,
"x", what)), float(readMotionNumber(table,
"y", what)),
114 float(readMotionNumber(table,
"z", what))};
116 static std::vector<eve::ScriptArg> scriptArgs(
const Value&
value) {
128struct MotionColorTraits {
129 using Value = MotionColor;
130 using Desc = MotionRuntime::ColorDesc;
131 using Sink = IMotionColorSink;
133 static constexpr bool kHasStyle =
false;
134 static constexpr const char* kType =
"MotionColor";
136 static Value read(
const ssq::Object& table,
const char* what) {
137 return MotionColor{float(readMotionNumber(table,
"r", what)), float(readMotionNumber(table,
"g", what)),
138 float(readMotionNumber(table,
"b", what)), float(readMotionNumber(table,
"a", what))};
140 static std::vector<eve::ScriptArg> scriptArgs(
const Value&
value) {
150 return runtime.spawnColor(
desc);
154struct MotionQuatTraits {
155 using Value = MotionQuat;
156 using Desc = MotionRuntime::QuatDesc;
157 using Sink = IMotionQuatSink;
159 static constexpr bool kHasStyle =
false;
160 static constexpr const char* kType =
"MotionQuat";
162 static Value read(
const ssq::Object& table,
const char* what) {
163 return MotionQuat{float(readMotionNumber(table,
"x", what)), float(readMotionNumber(table,
"y", what)),
164 float(readMotionNumber(table,
"z", what)), float(readMotionNumber(table,
"w", what))};
166 static std::vector<eve::ScriptArg> scriptArgs(
const Value&
value) {
184template <
class Traits>
185class ScriptMotionSink final :
public Traits::Sink {
187 explicit ScriptMotionSink(ScriptProviderHandle
handle) : handle_(
std::move(
handle)) {}
190 [[nodiscard]]
const ScriptProviderHandle&
handle() const noexcept {
return handle_; }
193 const std::vector<eve::ScriptArg> args = Traits::scriptArgs(
value);
198 ScriptProviderHandle handle_;
208template <
class Adapter>
209struct ScriptMotionSinkStore {
214struct ScriptMotionSinkStores {
215 ScriptMotionSinkStore<ScriptMotionFloatSink>
floats;
216 ScriptMotionSinkStore<ScriptMotionSink<MotionVec2Traits>>
vec2s;
217 ScriptMotionSinkStore<ScriptMotionSink<MotionVec3Traits>>
vec3s;
218 ScriptMotionSinkStore<ScriptMotionSink<MotionColorTraits>>
colors;
219 ScriptMotionSinkStore<ScriptMotionSink<MotionQuatTraits>>
quats;
222ScriptMotionSinkStores& scriptMotionSinkStores() {
223 static ScriptMotionSinkStores stores;
227std::uint64_t& scriptMotionSinkSequence() {
236template <
class Adapter>
237Adapter* adoptScriptMotionSink(ScriptMotionSinkStore<Adapter>& store,
const ssq::Object& sink) {
238 const std::string
name =
"animation.motion-sink." + std::to_string(++scriptMotionSinkSequence());
240 if (!published.ok()) throwMotionError(published.error());
241 auto adapter = std::make_unique<Adapter>(published.value());
243 store.providerNames.push_back(
name);
244 store.adapters.push_back(std::move(
adapter));
249template <
class Adapter>
250void clearScriptMotionSinkStore(ScriptMotionSinkStore<Adapter>& store) {
254 .ignore(
"module teardown may already have dropped this motion sink provider");
256 store.providerNames.clear();
257 store.adapters.clear();
263 ScriptMotionSinkStores& stores = scriptMotionSinkStores();
264 clearScriptMotionSinkStore(stores.floats);
265 clearScriptMotionSinkStore(stores.vec2s);
266 clearScriptMotionSinkStore(stores.vec3s);
267 clearScriptMotionSinkStore(stores.colors);
268 clearScriptMotionSinkStore(stores.quats);
273class ScriptMotionHandle {
275 ScriptMotionHandle(MotionRuntime *runtime, MotionHandle
handle)
276 : runtime_(runtime), handle_(
handle) {}
278 bool isActive()
const {
return runtime_ && runtime_->isActive(handle_); }
280 float value()
const {
281 if (!runtime_)
throw Exception(
"Motion.value: no runtime");
282 auto result = runtime_->floatValue(handle_);
288 if (!runtime_)
throw Exception(
"Motion.complete: no runtime");
289 auto result = runtime_->complete(handle_);
294 if (!runtime_)
throw Exception(
"Motion.cancel: no runtime");
295 auto result = runtime_->cancel(handle_);
300 MotionRuntime *runtime_ =
nullptr;
301 MotionHandle handle_{};
304class ScriptMotionBuilder {
306 ScriptMotionBuilder(Animation *animation,
float from,
float to,
float duration)
307 : animation_(animation) {
308 if (!animation_)
throw Exception(
"MotionBuilder: Animation is null");
314 void ease(std::string
kind) { desc_.ease = std::move(
kind); }
315 void delay(
float seconds) { desc_.delay = seconds; }
316 void loops(
int count, std::string mode =
"restart") {
318 desc_.loopMode = parseLoopMode(mode);
320 void cancelOnError(
bool enabled) { desc_.cancelOnError =
enabled; }
321 void frequency(
int count) { desc_.frequency =
count; }
323 void seed(
int value) { desc_.seed =
static_cast<std::uint32_t
>(
value); }
334 void to(
const ssq::Object& sink) {
336 if (sink.getType() != ssq::Type::INSTANCE)
337 throw Exception(
"MotionBuilder.to: sink must be an instance implementing write(value)");
338 desc_.sink = adoptScriptMotionSink(scriptMotionSinkStores().
floats, sink);
342 ScriptMotionHandle* bind(
const ssq::Object& sink) {
347 ScriptMotionHandle*
run() {
350 auto spawned = animation_->motions().spawnFloat(desc_);
352 return new ScriptMotionHandle(&animation_->motions(),
spawned.value());
355 [[nodiscard]] MotionRuntime &runtime() {
357 return animation_->motions();
368 if (!animation_)
throw Exception(
"MotionBuilder: Animation is null");
369 if (consumed_)
throw Exception(
"MotionBuilder: already consumed (run/append)");
373 MotionRuntime::FloatDesc desc_{};
374 bool consumed_ =
false;
377class ScriptMotionSequenceHandle {
379 explicit ScriptMotionSequenceHandle(MotionSequenceHandle
handle) : handle_(
std::move(
handle)) {}
381 bool isActive()
const {
return handle_.isActive(); }
382 int childCount()
const {
return handle_.childCount(); }
385 auto result = handle_.complete();
390 auto result = handle_.cancel();
395 MotionSequenceHandle handle_;
398class ScriptMotionSequence {
400 explicit ScriptMotionSequence(Animation *animation)
401 : animation_(animation), sequence_(requireAnimation(animation)->motions()) {}
403 void append(ScriptMotionBuilder *builder) {
404 if (!builder)
throw Exception(
"MotionSequence.append: builder is null");
405 auto taken = builder->takeDesc();
406 if (!taken.ok()) throwMotionError(taken.error());
407 auto desc = std::move(taken).value();
408 MotionBuilder bridge(animation_->motions(),
desc.from,
desc.to,
desc.duration);
409 bridge.ease(
desc.ease).delay(
desc.delay).loops(
desc.loops,
desc.loopMode).cancelOnError(
desc.cancelOnError)
410 .style(
desc.style).frequency(
desc.frequency).dampingRatio(
desc.dampingRatio).seed(
desc.seed);
411 if (
desc.sink) bridge.to(*
desc.sink);
412 auto scheduled = sequence_.append(std::move(bridge));
416 void join(ScriptMotionBuilder *builder) {
417 if (!builder)
throw Exception(
"MotionSequence.join: builder is null");
418 auto taken = builder->takeDesc();
419 if (!taken.ok()) throwMotionError(taken.error());
420 auto desc = std::move(taken).value();
421 MotionBuilder bridge(animation_->motions(),
desc.from,
desc.to,
desc.duration);
422 bridge.ease(
desc.ease).delay(
desc.delay).loops(
desc.loops,
desc.loopMode).cancelOnError(
desc.cancelOnError)
423 .style(
desc.style).frequency(
desc.frequency).dampingRatio(
desc.dampingRatio).seed(
desc.seed);
424 if (
desc.sink) bridge.to(*
desc.sink);
425 auto scheduled = sequence_.join(std::move(bridge));
429 void insert(
float atSeconds, ScriptMotionBuilder *builder) {
430 if (!builder)
throw Exception(
"MotionSequence.insert: builder is null");
431 auto taken = builder->takeDesc();
432 if (!taken.ok()) throwMotionError(taken.error());
433 auto desc = std::move(taken).value();
434 MotionBuilder bridge(animation_->motions(),
desc.from,
desc.to,
desc.duration);
435 bridge.ease(
desc.ease).delay(
desc.delay).loops(
desc.loops,
desc.loopMode).cancelOnError(
desc.cancelOnError)
436 .style(
desc.style).frequency(
desc.frequency).dampingRatio(
desc.dampingRatio).seed(
desc.seed);
437 if (
desc.sink) bridge.to(*
desc.sink);
438 auto scheduled = sequence_.insert(atSeconds, std::move(bridge));
442 void appendInterval(
float seconds) {
443 auto scheduled = sequence_.appendInterval(seconds);
447 float cursor()
const {
return sequence_.cursor(); }
448 float duration()
const {
return sequence_.duration(); }
449 int itemCount()
const {
return sequence_.itemCount(); }
451 ScriptMotionSequenceHandle *
run() {
452 auto started = sequence_.run();
454 return new ScriptMotionSequenceHandle(std::move(
started).
value());
459 MotionSequence sequence_;
470template <
class Traits>
471class ScriptMotionBuilderT {
473 using Desc =
typename Traits::Desc;
474 using Value =
typename Traits::Value;
476 ScriptMotionBuilderT(Animation* animation, Value
from, Value
to,
float duration) : animation_(animation) {
477 if (!animation_)
throw Exception(
"%s: Animation is null", Traits::kType);
481 void ease(std::string
kind) { desc_.ease = std::move(
kind); }
482 void delay(
float seconds) { desc_.delay = seconds; }
483 void loops(
int count, std::string mode =
"restart") {
485 desc_.loopMode = parseLoopMode(mode);
487 void cancelOnError(
bool enabled) { desc_.cancelOnError =
enabled; }
488 void frequency(
int count) {
489 if constexpr (Traits::kHasStyle) desc_.frequency =
count;
492 if constexpr (Traits::kHasStyle) desc_.dampingRatio =
ratio;
495 if constexpr (Traits::kHasStyle) desc_.seed =
static_cast<std::uint32_t
>(
value);
504 void to(
const ssq::Object& sink) {
506 if (sink.getType() != ssq::Type::INSTANCE)
507 throw Exception(
"%s.to: sink must be an instance implementing write(...)", Traits::kType);
508 desc_.sink = adoptTraitsSink(sink);
511 ScriptMotionHandle* bind(
const ssq::Object& sink) {
516 ScriptMotionHandle*
run() {
519 auto spawned = Traits::spawn(animation_->motions(), desc_);
521 return new ScriptMotionHandle(&animation_->motions(),
spawned.value());
531 using Adapter = ScriptMotionSink<Traits>;
534 static ScriptMotionSinkStore<Adapter>& store() {
535 if constexpr (std::is_same_v<Traits, MotionVec2Traits>) {
536 return scriptMotionSinkStores().vec2s;
537 }
else if constexpr (std::is_same_v<Traits, MotionVec3Traits>) {
538 return scriptMotionSinkStores().vec3s;
539 }
else if constexpr (std::is_same_v<Traits, MotionColorTraits>) {
540 return scriptMotionSinkStores().colors;
542 return scriptMotionSinkStores().quats;
546 static typename Traits::Sink* adoptTraitsSink(
const ssq::Object& sink) {
547 return adoptScriptMotionSink(store(), sink);
551 if (!animation_)
throw Exception(
"%s: Animation is null", Traits::kType);
552 if (consumed_)
throw Exception(
"%s: builder already consumed (run/bind)", Traits::kType);
557 bool consumed_ =
false;
561template <
class Traits>
562void exposeMotionTraitsBuilder(ssq::Table& table,
const char* className) {
563 using Builder = ScriptMotionBuilderT<Traits>;
565 table.addClass<Builder>(className, std::function<Builder*()>([]() -> Builder* {
return nullptr; }),
true);
572 builder.addFunc(
"ease", [](Builder* self, std::string
kind) {
573 if (!self)
throw Exception(
"%s.ease: builder is null", Traits::kType);
574 self->ease(std::move(
kind));
576 builder.addFunc(
"delay", [](Builder* self,
float seconds) {
577 if (!self)
throw Exception(
"%s.delay: builder is null", Traits::kType);
578 self->delay(seconds);
580 builder.addFunc(
"loops", [](Builder* self,
int count, std::string mode) {
581 if (!self)
throw Exception(
"%s.loops: builder is null", Traits::kType);
582 self->loops(
count, std::move(mode));
584 builder.addFunc(
"cancelOnError", [](Builder* self,
bool enabled) {
585 if (!self)
throw Exception(
"%s.cancelOnError: builder is null", Traits::kType);
588 if constexpr (Traits::kHasStyle) {
589 builder.addFunc(
"stylePunch", &Builder::stylePunch);
590 builder.addFunc(
"styleShake", &Builder::styleShake);
591 builder.addFunc(
"frequency", [](Builder* self,
int count) {
592 if (!self)
throw Exception(
"%s.frequency: builder is null", Traits::kType);
593 self->frequency(
count);
595 builder.addFunc(
"dampingRatio", [](Builder* self,
float ratio) {
596 if (!self)
throw Exception(
"%s.dampingRatio: builder is null", Traits::kType);
597 self->dampingRatio(
ratio);
599 builder.addFunc(
"seed", [](Builder* self,
int value) {
600 if (!self)
throw Exception(
"%s.seed: builder is null", Traits::kType);
604 builder.addFunc(
"to", [](Builder* self,
const ssq::Object& sink) {
605 if (!self)
throw Exception(
"%s.to: builder is null", Traits::kType);
608 builder.addFunc(
"bind", [](Builder* self,
const ssq::Object& sink) -> ScriptMotionHandle* {
609 if (!self)
throw Exception(
"%s.bind: builder is null", Traits::kType);
610 return self->bind(sink);
612 builder.addFunc(
"run", [](Builder* self) -> ScriptMotionHandle* {
613 if (!self)
throw Exception(
"%s.run: builder is null", Traits::kType);
619void exposeNonFloatMotionBuilders(ssq::Table& table, ssq::Class& animationClass) {
620 exposeMotionTraitsBuilder<MotionVec2Traits>(table,
"MotionVec2Builder");
621 exposeMotionTraitsBuilder<MotionVec3Traits>(table,
"MotionVec3Builder");
622 exposeMotionTraitsBuilder<MotionColorTraits>(table,
"MotionColorBuilder");
623 exposeMotionTraitsBuilder<MotionQuatTraits>(table,
"MotionQuatBuilder");
625 animationClass.addFunc(
"newMotionVec2",
626 [](Animation* self,
const ssq::Object&
from,
const ssq::Object&
to,
627 float duration) -> ScriptMotionBuilderT<MotionVec2Traits>* {
628 if (!self)
throw Exception(
"newMotionVec2: Animation is null");
629 return new ScriptMotionBuilderT<MotionVec2Traits>(
630 self, MotionVec2Traits::read(
from,
"newMotionVec2 'from'"),
631 MotionVec2Traits::read(
to,
"newMotionVec2 'to'"),
duration);
633 animationClass.addFunc(
"newMotionVec3",
634 [](Animation* self,
const ssq::Object&
from,
const ssq::Object&
to,
635 float duration) -> ScriptMotionBuilderT<MotionVec3Traits>* {
636 if (!self)
throw Exception(
"newMotionVec3: Animation is null");
637 return new ScriptMotionBuilderT<MotionVec3Traits>(
638 self, MotionVec3Traits::read(
from,
"newMotionVec3 'from'"),
639 MotionVec3Traits::read(
to,
"newMotionVec3 'to'"),
duration);
641 animationClass.addFunc(
"newMotionColor",
642 [](Animation* self,
const ssq::Object&
from,
const ssq::Object&
to,
643 float duration) -> ScriptMotionBuilderT<MotionColorTraits>* {
644 if (!self)
throw Exception(
"newMotionColor: Animation is null");
645 return new ScriptMotionBuilderT<MotionColorTraits>(
646 self, MotionColorTraits::read(
from,
"newMotionColor 'from'"),
647 MotionColorTraits::read(
to,
"newMotionColor 'to'"),
duration);
649 animationClass.addFunc(
"newMotionQuat",
650 [](Animation* self,
const ssq::Object&
from,
const ssq::Object&
to,
651 float duration) -> ScriptMotionBuilderT<MotionQuatTraits>* {
652 if (!self)
throw Exception(
"newMotionQuat: Animation is null");
653 return new ScriptMotionBuilderT<MotionQuatTraits>(
654 self, MotionQuatTraits::read(
from,
"newMotionQuat 'from'"),
655 MotionQuatTraits::read(
to,
"newMotionQuat 'to'"),
duration);
662 auto motion = table.addClass<ScriptMotionHandle>(
663 "Motion", std::function<ScriptMotionHandle *()>([]() -> ScriptMotionHandle * {
return nullptr; }),
665 motion.addFunc(
"isActive", &ScriptMotionHandle::isActive);
666 motion.addFunc(
"value", &ScriptMotionHandle::value);
667 motion.addFunc(
"complete", &ScriptMotionHandle::complete);
668 motion.addFunc(
"cancel", &ScriptMotionHandle::cancel);
670 auto builder = table.addClass<ScriptMotionBuilder>(
672 std::function<ScriptMotionBuilder *()>([]() -> ScriptMotionBuilder * {
return nullptr; }),
true);
673 builder.addFunc(
"ease", &ScriptMotionBuilder::ease);
674 builder.addFunc(
"delay", &ScriptMotionBuilder::delay);
675 builder.addFunc(
"loops", &ScriptMotionBuilder::loops);
676 builder.addFunc(
"cancelOnError", &ScriptMotionBuilder::cancelOnError);
677 builder.addFunc(
"frequency", &ScriptMotionBuilder::frequency);
678 builder.addFunc(
"dampingRatio", &ScriptMotionBuilder::dampingRatio);
679 builder.addFunc(
"seed", &ScriptMotionBuilder::seed);
680 builder.addFunc(
"to", [](ScriptMotionBuilder* self,
const ssq::Object& sink) {
681 if (!self)
throw Exception(
"MotionBuilder.to: builder is null");
684 builder.addFunc(
"bind", [](ScriptMotionBuilder* self,
const ssq::Object& sink) -> ScriptMotionHandle* {
685 if (!self)
throw Exception(
"MotionBuilder.bind: builder is null");
686 return self->bind(sink);
688 builder.addFunc(
"run", &ScriptMotionBuilder::run);
690 auto seqHandle = table.addClass<ScriptMotionSequenceHandle>(
691 "MotionSequenceHandle",
692 std::function<ScriptMotionSequenceHandle *()>([]() -> ScriptMotionSequenceHandle * {
return nullptr; }),
694 seqHandle.addFunc(
"isActive", &ScriptMotionSequenceHandle::isActive);
695 seqHandle.addFunc(
"childCount", &ScriptMotionSequenceHandle::childCount);
696 seqHandle.addFunc(
"complete", &ScriptMotionSequenceHandle::complete);
697 seqHandle.addFunc(
"cancel", &ScriptMotionSequenceHandle::cancel);
699 auto seq = table.addClass<ScriptMotionSequence>(
701 std::function<ScriptMotionSequence *()>([]() -> ScriptMotionSequence * {
return nullptr; }),
true);
702 seq.addFunc(
"append", &ScriptMotionSequence::append);
703 seq.addFunc(
"join", &ScriptMotionSequence::join);
704 seq.addFunc(
"insert", &ScriptMotionSequence::insert);
705 seq.addFunc(
"appendInterval", &ScriptMotionSequence::appendInterval);
706 seq.addFunc(
"cursor", &ScriptMotionSequence::cursor);
707 seq.addFunc(
"duration", &ScriptMotionSequence::duration);
708 seq.addFunc(
"itemCount", &ScriptMotionSequence::itemCount);
709 seq.addFunc(
"run", &ScriptMotionSequence::run);
711 animationClass.addFunc(
713 std::function<ScriptMotionBuilder *(
Animation *,
float,
float,
float)>(
717 animationClass.addFunc(
719 std::function<ScriptMotionBuilder *(
Animation *,
float,
float,
float)>(
725 animationClass.addFunc(
727 std::function<ScriptMotionBuilder *(
Animation *,
float,
float,
float)>(
733 animationClass.addFunc(
735 std::function<ScriptMotionSequence *(
Animation *)>(
736 [](
Animation *self) -> ScriptMotionSequence * {
return new ScriptMotionSequence(self); }));
737 animationClass.addFunc(
738 "ensureMotionCapacity",
741 if (!self)
throw Exception(
"ensureMotionCapacity: Animation is null");
742 if (
count < 0)
throw Exception(
"ensureMotionCapacity: count must be >= 0");
743 self->ensureMotionCapacity(
static_cast<std::size_t
>(
count));
745 animationClass.addFunc(
746 "getMotionFloatCapacity",
749 if (!self)
throw Exception(
"getMotionFloatCapacity: Animation is null");
750 return static_cast<int>(self->getMotionFloatCapacity());
752 animationClass.addFunc(
753 "getMotionFloatFreeCount",
756 if (!self)
throw Exception(
"getMotionFloatFreeCount: Animation is null");
757 return static_cast<int>(self->getMotionFloatFreeCount());
761 exposeNonFloatMotionBuilders(table, animationClass);
#define EVENGINE_API_WORLD
std::function< void(b3JointId, const Numbers &)> write
std::function< Numbers(b3JointId)> read
Fluent LitMotion-style builder that commits into MotionRuntime.
Dense motion storage advanced by Animation::advance(SimulationStep).
ScriptMotionSinkStore< ScriptMotionSink< MotionColorTraits > > colors
std::vector< std::string > providerNames
ScriptMotionSinkStore< ScriptMotionSink< MotionQuatTraits > > quats
ScriptMotionSinkStore< ScriptMotionFloatSink > floats
ScriptMotionSinkStore< ScriptMotionSink< MotionVec3Traits > > vec3s
ScriptMotionSinkStore< ScriptMotionSink< MotionVec2Traits > > vec2s
std::vector< std::unique_ptr< Adapter > > adapters
Squirrel GC wrappers for Motion builder / handle / sequence.
Lean LitMotion-style sequence: Append / Join / Insert / AppendInterval.
LitMotion-style typed motion handles, values, and sink interfaces.
std::unique_ptr< gpgpu::Sequence > sequence
const eve::script::BindingContractRegistry & registry
Owning, renderer-independent dynamic values.
A structured explanation of a failed, degraded, or noteworthy result.
const std::string & message() const noexcept
Human-readable explanation.
EVENGINE_API_FOUNDATION public API.
Move-only operation result carrying either a value or Status.
static Result success(T value)
Construct a successful result owning value.
Named script objects that native systems drive through named methods.
static ScriptProviderRegistry & instance()
Process-lifetime registry; clearAll is the only reset.
Result< ScriptProviderHandle > publish(std::string name, const ssq::Object &instance)
Publish one live script instance under a stable name.
Result< void > call(const ScriptProviderHandle &handle, std::string_view method) const
Call method() on a published provider.
Animation module — tween factory + 2D sprite-sheet / Spine + 3D skeletal playback (player / state mac...
EVENGINE_API_WORLD void clearScriptMotionSinkAdapters()
释放所有**脚本 motion sink** 适配器,并撤回它们在 provider 注册表里的登记。
EVENGINE_API_WORLD void exposeMotionScriptBindings(ssq::Table &table, ssq::Class &animationClass)
Register Motion / MotionSequence script types and Animation factories.
MotionLoopMode
Loop behaviour after a cycle completes.
@ Restart
Jump back to start each cycle.
@ Yoyo
Alternate direction each cycle.
@ Punch
Finite damped sine punch about from.
@ Shake
Punch with per-axis deterministic random sign.
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
std::unordered_map< std::string, SkillDefinition > & table()
One argument passed to a script provider method.
static ScriptArg fromNumber(double value)
Generation-qualified identity of one published script provider.