entity_position_profiles.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <array>
  3. #include <cstddef>
  4. #include <cstdint>
  5. #include <span>
  6. #include <string>
  7. #include <string_view>
  8. #include <vector>
  9. namespace sunrise::state::gameplay::entity_position_profiles {
  10. using Fingerprint = std::array<std::byte, 32>;
  11. struct Row final {
  12. std::string activity;
  13. std::uint16_t cell{};
  14. std::array<std::uint8_t, 3> axisBits{};
  15. std::uint8_t bubble{255};
  16. bool operator==(const Row&) const = default;
  17. };
  18. using Rows = std::vector<Row>;
  19. /** Bounds heap-owned catalogue and shared-cache scratch storage. */
  20. inline constexpr std::size_t kMaximumRows = 65536;
  21. /** Package names reserve one final null byte on disk. */
  22. inline constexpr std::size_t kNameCapacity = 128;
  23. /** Rejects duplicates and widths outside the native 31-bit bound. */
  24. [[nodiscard]] bool validate(std::span<const Row> rows) noexcept;
  25. /** Publishes only one complete, validated extraction. */
  26. [[nodiscard]] bool publish(Rows rows, const Fingerprint& fingerprint) noexcept;
  27. /** Checks whether the installed content already owns the published rows. */
  28. [[nodiscard]] bool ready(const Fingerprint& fingerprint) noexcept;
  29. /** Clears package-derived values before a new build is loaded. */
  30. void reset() noexcept;
  31. /** Restored rows remain unavailable until their package fingerprint is confirmed. */
  32. [[nodiscard]] bool restore(std::span<const Row> rows, const Fingerprint& fingerprint) noexcept;
  33. /** Confirms a restored shared-cache domain against the installed packages. */
  34. [[nodiscard]] bool confirm(const Fingerprint& fingerprint) noexcept;
  35. /** Reports whether validated package data is available for shared-cache publication. */
  36. [[nodiscard]] bool available() noexcept;
  37. /** Copies active rows and their fingerprint into shared-cache scratch. */
  38. [[nodiscard]] bool
  39. snapshot(std::span<Row> output, std::size_t& count, Fingerprint& fingerprint) noexcept;
  40. /** Returns the exact map-to-scenario bubble join for one native cell. */
  41. [[nodiscard]] bool
  42. lookup_bubble(std::string_view activity, std::uint16_t cell, std::uint8_t& bubble) noexcept;
  43. /** Looks up only package-validated widths for this exact activity and cell. */
  44. [[nodiscard]] bool lookup(std::string_view activity,
  45. std::uint16_t cell,
  46. std::array<std::uint8_t, 3>& axisBits) noexcept;
  47. } // namespace sunrise::state::gameplay::entity_position_profiles