Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

67 lignes
1.7 KiB

  1. #pragma once
  2. #include <ecs/core/utils/bitset.h>
  3. namespace ecs {
  4. namespace core {
  5. namespace utils {
  6. template<typename T_settings>
  7. template<typename T_component_tag>
  8. constexpr decltype(auto) bitset<T_settings>
  9. ::component_id(T_component_tag&& ct) noexcept
  10. {
  11. return mp::list::index_of(all_components(), std::forward<T_component_tag>(ct));
  12. }
  13. template<typename T_settings>
  14. template<typename T_system_signature>
  15. constexpr decltype(auto) bitset<T_settings>
  16. ::from_system_signature(T_system_signature&& ssig) noexcept
  17. {
  18. bitset ret;
  19. hana::for_each(hana::concat(ssig.read(), ssig.write()), [&ret](auto ct){
  20. ret.set_component(ct, true);
  21. });
  22. return ret;
  23. }
  24. template<typename T_settings>
  25. inline decltype(auto) bitset<T_settings>
  26. ::to_string() const
  27. {
  28. return _bitset.to_string();
  29. }
  30. template<typename T_settings>
  31. inline void bitset<T_settings>
  32. ::clear() noexcept
  33. {
  34. _bitset.reset();
  35. }
  36. template<typename T_settings>
  37. template<typename T_other>
  38. inline bool bitset<T_settings>
  39. ::contains(const T_other& other) const noexcept
  40. {
  41. return (_bitset & other._bitset) == other._bitset;
  42. }
  43. template<typename T_settings>
  44. template<typename T_component_tag>
  45. inline bool bitset<T_settings>
  46. ::has_component(T_component_tag ct) const
  47. {
  48. return _bitset.test(component_id(ct));
  49. }
  50. template<typename T_settings>
  51. template<typename T_component_tag>
  52. inline void bitset<T_settings>
  53. ::set_component(T_component_tag ct, bool value)
  54. {
  55. _bitset.set(component_id(ct), value);
  56. }
  57. } } }