|
1 | 1 | #pragma once
|
2 | 2 |
|
3 | 3 | #include <type_traits>
|
| 4 | +#include <span> |
| 5 | +#if __has_include(<ranges>) |
| 6 | +# include <ranges> |
| 7 | +#endif |
4 | 8 | #include "ecsact/runtime/core.h"
|
5 | 9 |
|
6 | 10 | namespace ecsact::core {
|
7 | 11 |
|
| 12 | +class execution_options_view { |
| 13 | + ecsact_execution_options& _c_exec_opts; |
| 14 | + |
| 15 | +public: |
| 16 | + inline execution_options_view(ecsact_execution_options& options) |
| 17 | + : _c_exec_opts(options) { |
| 18 | + } |
| 19 | + |
| 20 | + inline auto add_components() -> std::span<ecsact_component> { |
| 21 | + return std::span( |
| 22 | + _c_exec_opts.add_components, |
| 23 | + static_cast<size_t>(_c_exec_opts.add_components_length) |
| 24 | + ); |
| 25 | + } |
| 26 | + |
| 27 | + inline auto add_components_entities() -> std::span<ecsact_entity_id> { |
| 28 | + return std::span( |
| 29 | + _c_exec_opts.add_components_entities, |
| 30 | + static_cast<size_t>(_c_exec_opts.add_components_length) |
| 31 | + ); |
| 32 | + } |
| 33 | + |
| 34 | + inline auto update_components() -> std::span<ecsact_component> { |
| 35 | + return std::span( |
| 36 | + _c_exec_opts.update_components, |
| 37 | + static_cast<size_t>(_c_exec_opts.update_components_length) |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + inline auto update_components_entities() -> std::span<ecsact_entity_id> { |
| 42 | + return std::span( |
| 43 | + _c_exec_opts.update_components_entities, |
| 44 | + static_cast<size_t>(_c_exec_opts.update_components_length) |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + inline auto remove_components() -> std::span<ecsact_component_id> { |
| 49 | + return std::span( |
| 50 | + _c_exec_opts.remove_components, |
| 51 | + static_cast<size_t>(_c_exec_opts.remove_components_length) |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + inline auto remove_components_entities() -> std::span<ecsact_entity_id> { |
| 56 | + return std::span( |
| 57 | + _c_exec_opts.remove_components_entities, |
| 58 | + static_cast<size_t>(_c_exec_opts.remove_components_length) |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + inline auto actions() -> std::span<ecsact_action> { |
| 63 | + return std::span( |
| 64 | + _c_exec_opts.actions, |
| 65 | + static_cast<size_t>(_c_exec_opts.actions_length) |
| 66 | + ); |
| 67 | + } |
| 68 | + |
| 69 | +#ifdef __cpp_lib_ranges_zip |
| 70 | + inline auto add_components_zip() { |
| 71 | + return std::views::zip(add_components_entities(), add_components()); |
| 72 | + } |
| 73 | + |
| 74 | + inline auto update_components_zip() { |
| 75 | + return std::views::zip(update_components_entities(), update_components()); |
| 76 | + } |
| 77 | + |
| 78 | + inline auto remove_components_zip() { |
| 79 | + return std::views::zip(remove_components_entities(), remove_components()); |
| 80 | + } |
| 81 | +#endif |
| 82 | +}; |
| 83 | + |
8 | 84 | class registry {
|
9 | 85 | ecsact_registry_id _id;
|
10 | 86 | bool _owned = false;
|
|
0 commit comments