Unravel Engine C++ Reference
Loading...
Searching...
No Matches
animation_component_bindings.cpp
Go to the documentation of this file.
2#include "script_bindings.h"
3
4#include "../script_interop.h"
5
8
9namespace unravel
10{
11namespace
12{
13
14
15void internal_m2n_animation_blend(entt::entity id, int layer, hpp::uuid guid, float seconds, bool loop, bool phase_sync)
16{
18 {
19 auto& ctx = engine::context();
20 auto& am = ctx.get_cached<asset_manager>();
21
22 auto asset = am.get_asset<animation_clip>(guid);
23 comp->get_player().blend_to(layer, asset, animation_player::seconds_t(seconds), loop, phase_sync);
24 }
25}
26
27void internal_m2n_animation_play(entt::entity id)
28{
30 {
31 comp->get_player().play();
32 }
33}
34
35void internal_m2n_animation_pause(entt::entity id)
36{
38 {
39 comp->get_player().pause();
40 }
41}
42
43void internal_m2n_animation_resume(entt::entity id)
44{
46 {
47 comp->get_player().resume();
48 }
49}
50
51void internal_m2n_animation_stop(entt::entity id)
52{
54 {
55 comp->get_player().stop();
56 }
57}
58
59void internal_m2n_animation_set_speed(entt::entity id, float speed)
60{
62 {
63 comp->set_speed(speed);
64 }
65}
66
67auto internal_m2n_animation_get_speed(entt::entity id) -> float
68{
70 {
71 return comp->get_speed();
72 }
73 return 1.0f;
74}
75
76} // namespace
77
79{
80 APPLOG_TRACE("{}", __func__);
81 auto reg = dotnet::internal_call_registry("Unravel.Core.AnimationComponent");
82 reg.add_internal_call("internal_m2n_animation_blend", dotnet_internal_call(internal_m2n_animation_blend));
83 reg.add_internal_call("internal_m2n_animation_play", dotnet_internal_call(internal_m2n_animation_play));
84 reg.add_internal_call("internal_m2n_animation_pause", dotnet_internal_call(internal_m2n_animation_pause));
85 reg.add_internal_call("internal_m2n_animation_resume", dotnet_internal_call(internal_m2n_animation_resume));
86 reg.add_internal_call("internal_m2n_animation_stop", dotnet_internal_call(internal_m2n_animation_stop));
87 reg.add_internal_call("internal_m2n_animation_set_speed", dotnet_internal_call(internal_m2n_animation_set_speed));
88 reg.add_internal_call("internal_m2n_animation_get_speed", dotnet_internal_call(internal_m2n_animation_get_speed));
89}
90
91} // namespace unravel
animation_clip::seconds_t seconds_t
#define APPLOG_TRACE(...)
Definition logging.h:17
auto safe_get_component(entt::entity id) -> T *
void register_animation_component_script_bindings()
static auto context() -> rtti::context &
Definition engine.cpp:111