Unravel Engine C++ Reference
Loading...
Searching...
No Matches
script_component.cpp
Go to the documentation of this file.
2
5
7#include <engine/engine.h>
8#include <engine/events.h>
10#include <monopp/mono_field_invoker.h>
11#include <monopp/mono_property_invoker.h>
12
15
25#include <graphics/texture.h>
26
27namespace unravel
28{
29
30namespace
31{
32 struct script_component_loader_context
33 {
34 std::vector<script_component::script_object> script_objects;
35
36 auto get_script_object(size_t hash) -> script_component::script_object*
37 {
38 for(auto& obj : script_objects)
39 {
40 if(obj.scoped->object.get_type().get_hash() == hash)
41 {
42 return &obj;
43 }
44 }
45 return nullptr;
46 }
47 };
48
49 thread_local script_component_loader_context* script_component_loader_ctx{};
50}
51
53{
54 entt::meta_factory<script_component>{}
55 .type("script_component"_hs)
57 entt::attribute{"name", "script_component"},
58 entt::attribute{"category", "SCRIPTING"},
59 entt::attribute{"pretty_name", "Script"},
60 })
61 .func<&component_meta<script_component>::exists>("component_exists"_hs)
62 .func<&component_meta<script_component>::add>("component_add"_hs)
63 .func<&component_meta<script_component>::save>("component_save"_hs)
64 .func<&component_meta<script_component>::load>("component_load"_hs)
65 .func<&component_meta<script_component>::remove>("component_remove"_hs);
66}
67
68template<typename Archive, typename T>
70{
71 template<typename Invoker>
72 static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase& arbase,
73 const mono::mono_object& obj,
74 const Invoker& invoker) -> bool
75 {
76 auto& ar = static_cast<Archive&>(arbase);
77 auto val = invoker.get_value(obj);
78 return try_save(ar, ser20::make_nvp(invoker.get_name(), val));
79 }
80
81 static auto try_save_mono_field(ser20::detail::OutputArchiveBase& arbase,
82 const mono::mono_object& obj,
83 const mono::mono_field& field) -> bool
84 {
85 auto invoker = mono::make_field_invoker<T>(field);
86 return try_save_mono_invoker(arbase, obj, invoker);
87 }
88
89 static auto try_save_mono_property(ser20::detail::OutputArchiveBase& arbase,
90 const mono::mono_object& obj,
91 const mono::mono_property& prop) -> bool
92 {
93 auto invoker = mono::make_property_invoker<T>(prop);
94 return try_save_mono_invoker(arbase, obj, invoker);
95 }
96};
97
98template<typename Archive>
99struct mono_saver<Archive, entt::entity>
100{
101 template<typename Invoker>
102 static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase& arbase,
103 const mono::mono_object& obj,
104 const Invoker& invoker) -> bool
105 {
106 auto& ar = static_cast<Archive&>(arbase);
107 auto val = invoker.get_value(obj);
108
109 auto& ctx = engine::context();
110 auto& ec = ctx.get_cached<ecs>();
111 auto& scene = ec.get_scene();
113 e.handle = scene.create_handle(val);
114
115 return try_save(ar, ser20::make_nvp(invoker.get_name(), e));
116 }
117
118 static auto try_save_mono_field(ser20::detail::OutputArchiveBase& arbase,
119 const mono::mono_object& obj,
120 const mono::mono_field& field) -> bool
121 {
122 auto invoker = mono::make_field_invoker<entt::entity>(field);
123 return try_save_mono_invoker(arbase, obj, invoker);
124 }
125
126 static auto try_save_mono_property(ser20::detail::OutputArchiveBase& arbase,
127 const mono::mono_object& obj,
128 const mono::mono_property& prop) -> bool
129 {
130 auto invoker = mono::make_property_invoker<entt::entity>(prop);
131 return try_save_mono_invoker(arbase, obj, invoker);
132 }
133};
134
135template<typename Archive, typename T>
136struct mono_saver<Archive, asset_handle<T>>
137{
138 template<typename Invoker>
139 static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase& arbase,
140 const mono::mono_object& obj,
141 const Invoker& invoker) -> bool
142 {
143 auto& ar = static_cast<Archive&>(arbase);
144
145 auto val = invoker.get_value(obj);
146
147 asset_handle<T> asset{};
148 if(val)
149 {
150 const auto& invoker_type = invoker.get_type();
151 auto guid_property = invoker_type.get_property("uid");
152 auto mutable_uid_property = mono::make_property_invoker<hpp::uuid>(guid_property);
153 auto uid = mutable_uid_property.get_value(val);
154
155 auto& ctx = engine::context();
156 auto& am = ctx.get_cached<asset_manager>();
157 asset = am.get_asset<T>(uid);
158 }
159
160 return try_save(ar, ser20::make_nvp(invoker.get_name(), asset));
161 }
162
163 static auto try_save_mono_field(ser20::detail::OutputArchiveBase& arbase,
164 const mono::mono_object& obj,
165 const mono::mono_field& field) -> bool
166 {
167 auto invoker = mono::make_field_invoker<mono::mono_object>(field);
168 return try_save_mono_invoker(arbase, obj, invoker);
169 }
170
171 static auto try_save_mono_property(ser20::detail::OutputArchiveBase& arbase,
172 const mono::mono_object& obj,
173 const mono::mono_property& prop) -> bool
174 {
175 auto invoker = mono::make_property_invoker<mono::mono_object>(prop);
176 return try_save_mono_invoker(arbase, obj, invoker);
177 }
178};
179
180template<typename Archive, typename T>
182{
183 template<typename U>
184 static auto is_supported_type(const mono::mono_type& type) -> bool
185 {
186 return mono::is_compatible_type<U>(type);
187 }
188
189 template<typename Invoker>
190 static auto try_load_mono_invoker(ser20::detail::InputArchiveBase& arbase,
191 mono::mono_object& obj,
192 const Invoker& invoker) -> bool
193 {
194 auto& ar = static_cast<Archive&>(arbase);
195
196 if(is_supported_type<T>(invoker.get_type()))
197 {
198 T val{};
199 if(try_load(ar, ser20::make_nvp(invoker.get_name(), val)))
200 {
201 invoker.set_value(obj, val);
202 }
203 return true;
204 }
205 return false;
206 }
207
208 static auto try_load_mono_field(ser20::detail::InputArchiveBase& arbase,
209 mono::mono_object& obj,
210 mono::mono_field& field) -> bool
211 {
212 auto invoker = mono::make_field_invoker<T>(field);
213 return try_load_mono_invoker(arbase, obj, invoker);
214 }
215
216 static auto try_load_mono_property(ser20::detail::InputArchiveBase& arbase,
217 mono::mono_object& obj,
218 mono::mono_property& prop) -> bool
219 {
220 auto invoker = mono::make_property_invoker<T>(prop);
221 return try_load_mono_invoker(arbase, obj, invoker);
222 }
223};
224
225template<typename Archive>
226struct mono_loader<Archive, entt::entity>
227{
228 template<typename U>
229 static auto is_supported_type(const mono::mono_type& type) -> bool
230 {
231 const auto& expected_name = type.get_name();
232 bool is_supported = std::is_same_v<entt::entity, U> && expected_name == "Entity";
233 return is_supported;
234 }
235
236 template<typename Invoker>
237 static auto try_load_mono_invoker(ser20::detail::InputArchiveBase& arbase,
238 mono::mono_object& obj,
239 const Invoker& invoker) -> bool
240 {
241 auto& ar = static_cast<Archive&>(arbase);
242
243 if(is_supported_type<entt::entity>(invoker.get_type()))
244 {
246 if(try_load(ar, ser20::make_nvp(invoker.get_name(), val)))
247 {
248 invoker.set_value(obj, val.handle.entity());
249 }
250 return true;
251 }
252 return false;
253 }
254
255 static auto try_load_mono_field(ser20::detail::InputArchiveBase& arbase,
256 mono::mono_object& obj,
257 mono::mono_field& field) -> bool
258 {
259 auto invoker = mono::make_field_invoker<entt::entity>(field);
260 return try_load_mono_invoker(arbase, obj, invoker);
261 }
262
263 static auto try_load_mono_property(ser20::detail::InputArchiveBase& arbase,
264 mono::mono_object& obj,
265 mono::mono_property& prop) -> bool
266 {
267 auto invoker = mono::make_property_invoker<entt::entity>(prop);
268 return try_load_mono_invoker(arbase, obj, invoker);
269 }
270};
271
272template<typename Archive, typename T>
273struct mono_loader<Archive, asset_handle<T>>
274{
275 template<typename U>
276 static auto is_supported_type(const mono::mono_type& type) -> bool
277 {
278 const auto& expected_name = type.get_name();
279 bool is_supported = false;
280
281 if(!is_supported)
282 {
283 is_supported |= std::is_same_v<asset_handle<gfx::texture>, U> && expected_name == "Texture";
284 }
285 if(!is_supported)
286 {
287 is_supported |= std::is_same_v<asset_handle<material>, U> && expected_name == "Material";
288 }
289 if(!is_supported)
290 {
291 is_supported |= std::is_same_v<asset_handle<mesh>, U> && expected_name == "Mesh";
292 }
293 if(!is_supported)
294 {
295 is_supported |= std::is_same_v<asset_handle<animation_clip>, U> && expected_name == "AnimationClip";
296 }
297 if(!is_supported)
298 {
299 is_supported |= std::is_same_v<asset_handle<prefab>, U> && expected_name == "Prefab";
300 }
301 if(!is_supported)
302 {
303 is_supported |= std::is_same_v<asset_handle<scene_prefab>, U> && expected_name == "Scene";
304 }
305 if(!is_supported)
306 {
307 is_supported |= std::is_same_v<asset_handle<physics_material>, U> && expected_name == "PhysicsMaterial";
308 }
309 if(!is_supported)
310 {
311 is_supported |= std::is_same_v<asset_handle<audio_clip>, U> && expected_name == "AudioClip";
312 }
313 if(!is_supported)
314 {
315 is_supported |= std::is_same_v<asset_handle<font>, U> && expected_name == "Font";
316 }
317 return is_supported;
318 }
319
320 template<typename Invoker>
321 static auto try_load_mono_invoker(ser20::detail::InputArchiveBase& arbase,
322 mono::mono_object& obj,
323 const Invoker& invoker) -> bool
324 {
325 auto& ar = static_cast<Archive&>(arbase);
326
327 if(is_supported_type<asset_handle<T>>(invoker.get_type()))
328 {
329 asset_handle<T> val{};
330 if(try_load(ar, ser20::make_nvp(invoker.get_name(), val)))
331 {
332 const auto& field_type = invoker.get_type();
333 auto guid_property = field_type.get_property("uid");
334 auto mutable_uid_property = mono::make_property_invoker<hpp::uuid>(guid_property);
335
336 auto var = invoker.get_value(obj);
337 if(!var && val)
338 {
339 var = field_type.new_instance();
340 invoker.set_value(obj, var);
341 }
342
343 if(var)
344 {
345 mutable_uid_property.set_value(var, val.uid());
346 }
347 }
348 return true;
349 }
350 return false;
351 }
352
353 static auto try_load_mono_field(ser20::detail::InputArchiveBase& arbase,
354 mono::mono_object& obj,
355 mono::mono_field& field) -> bool
356 {
357 auto invoker = mono::make_field_invoker<mono::mono_object>(field);
358 return try_load_mono_invoker(arbase, obj, invoker);
359 }
360
361 static auto try_load_mono_property(ser20::detail::InputArchiveBase& arbase,
362 mono::mono_object& obj,
363 mono::mono_property& prop) -> bool
364 {
365 auto invoker = mono::make_property_invoker<mono::mono_object>(prop);
366 return try_load_mono_invoker(arbase, obj, invoker);
367 }
368};
369
371{
372 using mono_field_serializer =
373 std::function<bool(ser20::detail::OutputArchiveBase&, const mono::mono_object&, const mono::mono_field&)>;
374
375 auto get_field_serilizer = [](const std::string& type_name) -> const mono_field_serializer&
376 {
377 // clang-format off
378 static std::map<std::string, mono_field_serializer> reg = {
393
394
401
402 {"Texture", &mono_saver<Archive, asset_handle<gfx::texture>>::try_save_mono_field},
403 {"Material", &mono_saver<Archive, asset_handle<material>>::try_save_mono_field},
404 {"Mesh", &mono_saver<Archive, asset_handle<mesh>>::try_save_mono_field},
405 {"AnimationClip", &mono_saver<Archive, asset_handle<animation_clip>>::try_save_mono_field},
406 {"Prefab", &mono_saver<Archive, asset_handle<prefab>>::try_save_mono_field},
407 {"Scene", &mono_saver<Archive, asset_handle<scene_prefab>>::try_save_mono_field},
408 {"PhysicsMaterial", &mono_saver<Archive, asset_handle<physics_material>>::try_save_mono_field},
409 {"AudioClip", &mono_saver<Archive, asset_handle<audio_clip>>::try_save_mono_field},
410 {"Font", &mono_saver<Archive, asset_handle<font>>::try_save_mono_field},
411 };
412 // clang-format on
413
414 auto it = reg.find(type_name);
415 if(it != reg.end())
416 {
417 return it->second;
418 }
419 static const mono_field_serializer empty;
420 return empty;
421 };
422
423 using mono_property_serializer =
424 std::function<bool(ser20::detail::OutputArchiveBase&, const mono::mono_object&, const mono::mono_property&)>;
425
426 auto get_property_serilizer = [](const std::string& type_name) -> const mono_property_serializer&
427 {
428 // clang-format off
429 static std::map<std::string, mono_property_serializer> reg = {
444
451
452
453
454 {"Texture", &mono_saver<Archive, asset_handle<gfx::texture>>::try_save_mono_property},
455 {"Material", &mono_saver<Archive, asset_handle<material>>::try_save_mono_property},
456 {"Mesh", &mono_saver<Archive, asset_handle<mesh>>::try_save_mono_property},
457 {"AnimationClip", &mono_saver<Archive, asset_handle<animation_clip>>::try_save_mono_property},
458 {"Prefab", &mono_saver<Archive, asset_handle<prefab>>::try_save_mono_property},
459 {"Scene", &mono_saver<Archive, asset_handle<scene_prefab>>::try_save_mono_property},
460 {"PhysicsMaterial", &mono_saver<Archive, asset_handle<physics_material>>::try_save_mono_property},
461 {"AudioClip", &mono_saver<Archive, asset_handle<audio_clip>>::try_save_mono_property},
462 {"Font", &mono_saver<Archive, asset_handle<font>>::try_save_mono_property},
463
464 };
465 // clang-format on
466
467 auto it = reg.find(type_name);
468 if(it != reg.end())
469 {
470 return it->second;
471 }
472 static const mono_property_serializer empty;
473 return empty;
474 };
475
476 const auto& object = obj.scoped->object;
477 const auto& type = object.get_type();
478
479 try_save(ar, ser20::make_nvp("type", type.get_fullname()));
480
481 auto fields = type.get_fields();
482 auto properties = type.get_properties();
483 for(auto& field : fields)
484 {
485 if(field.get_visibility() == mono::visibility::vis_public)
486 {
487 const auto& field_type = field.get_type();
488
489 auto field_serilizer = get_field_serilizer(field_type.get_name());
490 if(field_serilizer)
491 {
492 field_serilizer(ar, object, field);
493 }
494 else if(field_type.is_enum())
495 {
496 auto enum_type = field_type.get_enum_base_type();
497
498 auto enum_serilizer = get_field_serilizer(enum_type.get_name());
499 if(enum_serilizer)
500 {
501 enum_serilizer(ar, object, field);
502 }
503 }
504 }
505 }
506
507 for(auto& prop : properties)
508 {
509 if(prop.get_visibility() == mono::visibility::vis_public)
510 {
511 const auto& prop_type = prop.get_type();
512
513 auto prop_serilizer = get_property_serilizer(prop_type.get_name());
514 if(prop_serilizer)
515 {
516 prop_serilizer(ar, object, prop);
517 }
518 else if(prop_type.is_enum())
519 {
520 auto enum_type = prop_type.get_enum_base_type();
521
522 auto enum_serilizer = get_property_serilizer(enum_type.get_name());
523 if(enum_serilizer)
524 {
525 enum_serilizer(ar, object, prop);
526 }
527 }
528 }
529 }
530}
533
535{
536 auto& ctx = engine::context();
537 auto& sys = ctx.get_cached<script_system>();
538 const auto& all_scriptable_components = sys.get_all_scriptable_components();
539
540 std::string type;
541 try_load(ar, ser20::make_nvp("type", type));
542
543 auto it = std::find_if(std::begin(all_scriptable_components),
544 std::end(all_scriptable_components),
545 [&](const mono::mono_type& script_type)
546 {
547 return type == script_type.get_fullname();
548 });
549
550 if(it == std::end(all_scriptable_components))
551 {
552 return;
553 }
554
556
557 const auto& script_type = *it;
558
559 auto* existing_obj = script_component_loader_ctx
560 ? script_component_loader_ctx->get_script_object(script_type.get_hash())
561 : nullptr;
562 if(existing_obj)
563 {
564 obj = *existing_obj;
565 }
566 else
567 {
568 auto object = script_type.new_instance();
570 }
571
572 using mono_field_serializer =
573 std::function<bool(ser20::detail::InputArchiveBase&, mono::mono_object&, mono::mono_field&)>;
574
575 auto get_field_serilizer = [](const std::string& type_name) -> const mono_field_serializer&
576 {
577 // clang-format off
578 static const std::map<std::string, mono_field_serializer> reg = {
593
594
601
602
603
604 {"Texture", &mono_loader<Archive, asset_handle<gfx::texture>>::try_load_mono_field},
605 {"Material", &mono_loader<Archive, asset_handle<material>>::try_load_mono_field},
606 {"Mesh", &mono_loader<Archive, asset_handle<mesh>>::try_load_mono_field},
607 {"AnimationClip", &mono_loader<Archive, asset_handle<animation_clip>>::try_load_mono_field},
608 {"Prefab", &mono_loader<Archive, asset_handle<prefab>>::try_load_mono_field},
609 {"Scene", &mono_loader<Archive, asset_handle<scene_prefab>>::try_load_mono_field},
610 {"PhysicsMaterial", &mono_loader<Archive, asset_handle<physics_material>>::try_load_mono_field},
611 {"AudioClip", &mono_loader<Archive, asset_handle<audio_clip>>::try_load_mono_field},
612 {"Font", &mono_loader<Archive, asset_handle<font>>::try_load_mono_field},
613
614 };
615 // clang-format on
616
617 auto it = reg.find(type_name);
618 if(it != reg.end())
619 {
620 return it->second;
621 }
622 static const mono_field_serializer empty;
623 return empty;
624 };
625
626 using mono_property_serializer =
627 std::function<bool(ser20::detail::InputArchiveBase&, mono::mono_object&, mono::mono_property&)>;
628
629 auto get_property_serilizer = [](const std::string& type_name) -> const mono_property_serializer&
630 {
631 // clang-format off
632 static const std::map<std::string, mono_property_serializer> reg = {
647
654
655 {"Texture", &mono_loader<Archive, asset_handle<gfx::texture>>::try_load_mono_property},
656 {"Material", &mono_loader<Archive, asset_handle<material>>::try_load_mono_property},
657 {"Mesh", &mono_loader<Archive, asset_handle<mesh>>::try_load_mono_property},
658 {"AnimationClip", &mono_loader<Archive, asset_handle<animation_clip>>::try_load_mono_property},
659 {"Prefab", &mono_loader<Archive, asset_handle<prefab>>::try_load_mono_property},
660 {"Scene", &mono_loader<Archive, asset_handle<scene_prefab>>::try_load_mono_property},
661 {"PhysicsMaterial", &mono_loader<Archive, asset_handle<physics_material>>::try_load_mono_property},
662 {"AudioClip", &mono_loader<Archive, asset_handle<audio_clip>>::try_load_mono_property},
663 {"Font", &mono_loader<Archive, asset_handle<font>>::try_load_mono_property},
664
665 };
666 // clang-format on
667
668 auto it = reg.find(type_name);
669 if(it != reg.end())
670 {
671 return it->second;
672 }
673 static const mono_property_serializer empty;
674 return empty;
675 };
676
677 auto fields = script_type.get_fields();
678 auto properties = script_type.get_properties();
679
680 for(auto& field : fields)
681 {
682 if(field.get_visibility() == mono::visibility::vis_public)
683 {
684 const auto& field_type = field.get_type();
685
686 auto field_serilizer = get_field_serilizer(field_type.get_name());
687 if(field_serilizer)
688 {
689 field_serilizer(ar, obj.scoped->object, field);
690 }
691 else if(field_type.is_enum())
692 {
693 auto enum_type = field_type.get_enum_base_type();
694
695 auto enum_serilizer = get_field_serilizer(enum_type.get_name());
696 if(enum_serilizer)
697 {
698 enum_serilizer(ar, obj.scoped->object, field);
699 }
700 }
701 }
702 }
703 for(auto& prop : properties)
704 {
705 if(prop.get_visibility() == mono::visibility::vis_public)
706 {
707 const auto& prop_type = prop.get_type();
708
709 auto prop_serilizer = get_property_serilizer(prop_type.get_name());
710 if(prop_serilizer)
711 {
712 prop_serilizer(ar, obj.scoped->object, prop);
713 }
714 else if(prop_type.is_enum())
715 {
716 auto enum_type = prop_type.get_enum_base_type();
717
718 auto enum_serilizer = get_property_serilizer(enum_type.get_name());
719 if(enum_serilizer)
720 {
721 enum_serilizer(ar, obj.scoped->object, prop);
722 }
723 }
724 }
725 }
726}
729
731{
732 const auto& comps = obj.get_script_components();
733 try_save(ar, ser20::make_nvp("script_components", comps));
734}
737
739{
740
741
742 auto& load_ctx = get_load_context();
743 if(load_ctx.is_updating_prefab())
744 {
745
746 script_component_loader_context ctx;
747 ctx.script_objects = obj.get_script_components();
748 script_component_loader_ctx = &ctx;
749
750
752 if(try_load(ar, ser20::make_nvp("script_components", comps)))
753 {
754 obj.add_missing_script_components(comps);
755 }
756
757 script_component_loader_ctx = nullptr;
758 }
759 else
760 {
762 if(try_load(ar, ser20::make_nvp("script_components", comps)))
763 {
764 obj.add_script_components(comps);
765 }
766 }
767
768}
771
772
773
774
775auto save_to_stream(std::ostream& stream, entt::const_handle e, const script_component::script_object& obj) -> bool
776{
777 bool pushed = push_save_context();
778 auto& save_ctx = get_save_context();
779 save_ctx.save_source = e;
780 save_ctx.to_prefab = false;
781
782 bool was_successful = false;
783 try
784 {
786 ar(ser20::make_nvp("script_object", obj));
787 was_successful = true;
788 }
789 catch(const ser20::Exception& e)
790 {
791 APPLOG_ERROR("Failed to save script component to stream: {}", e.what());
792 }
793
794 save_ctx.to_prefab = false;
795 save_ctx.save_source = {};
796 pop_save_context(pushed);
797 return was_successful;
798}
799auto load_from_stream(std::istream& stream, entt::handle e, script_component::script_object& obj) -> bool
800{
801 bool pushed = push_load_context(*e.registry());
802
803 bool was_successful = false;
804 try
805 {
807 ar(ser20::make_nvp("script_object", obj));
808 was_successful = true;
809 }
810 catch(const ser20::Exception& e)
811 {
812 APPLOG_ERROR("Failed to load script component from stream: {}", e.what());
813 }
814 pop_load_context(pushed);
815 return was_successful;
816}
817
818} // namespace unravel
manifold_type type
Manages assets, including loading, unloading, and storage.
auto get_asset(const std::string &key, load_flags flags=load_flags::standard) -> asset_handle< T >
Gets an asset by its key.
Class that contains core data for audio listeners. There can only be one instance of it per scene.
std::vector< script_object > script_components_t
#define APPLOG_ERROR(...)
Definition logging.h:20
std::vector< script_component::script_object > script_objects
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
auto push_save_context() -> bool
Definition entity.cpp:90
void pop_load_context(bool push_result)
Definition entity.cpp:75
auto push_load_context(entt::registry &registry) -> bool
Definition entity.cpp:64
auto get_save_context() -> save_context &
Definition entity.cpp:111
auto get_load_context() -> load_context &
Definition entity.cpp:84
auto load_from_stream(std::istream &stream, entt::handle e, script_component::script_object &obj) -> bool
void pop_save_context(bool push_result)
Definition entity.cpp:101
auto save_to_stream(std::ostream &stream, entt::const_handle e, const script_component::script_object &obj) -> bool
#define REFLECT(cls)
Definition reflection.h:133
entt::entity entity
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Represents a handle to an asset, providing access and management functions.
Manages the entity-component-system (ECS) operations for the ACE framework.
Definition ecs.h:12
static auto context() -> rtti::context &
Definition engine.cpp:115
static auto is_supported_type(const mono::mono_type &type) -> bool
static auto try_load_mono_field(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_field &field) -> bool
static auto try_load_mono_property(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_property &prop) -> bool
static auto try_load_mono_invoker(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_load_mono_invoker(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_load_mono_property(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_property &prop) -> bool
static auto is_supported_type(const mono::mono_type &type) -> bool
static auto try_load_mono_field(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_field &field) -> bool
static auto try_load_mono_invoker(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_load_mono_field(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_field &field) -> bool
static auto is_supported_type(const mono::mono_type &type) -> bool
static auto try_load_mono_property(ser20::detail::InputArchiveBase &arbase, mono::mono_object &obj, mono::mono_property &prop) -> bool
static auto try_save_mono_property(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_property &prop) -> bool
static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_save_mono_field(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_field &field) -> bool
static auto try_save_mono_field(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_field &field) -> bool
static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_save_mono_property(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_property &prop) -> bool
static auto try_save_mono_invoker(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const Invoker &invoker) -> bool
static auto try_save_mono_field(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_field &field) -> bool
static auto try_save_mono_property(ser20::detail::OutputArchiveBase &arbase, const mono::mono_object &obj, const mono::mono_property &prop) -> bool
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21
auto create_handle(entt::entity e) -> entt::handle
Creates an entity in the scene.
Definition scene.cpp:304
auto get_all_scriptable_components() const -> const std::vector< mono::mono_type > &