package_reward_build.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include "../../../../middleware/content/packages/reader/reader.h"
  3. #include "../../../../middleware/content/packages/tables/definition_index_table.h"
  4. #include "../../../../state/account/account_state.h"
  5. #include "../../../../state/build_data/rewards/definition.h"
  6. namespace sunrise::client::content::items::packages {
  7. struct SlotMaps;
  8. /** Resolves expression references and unlock slots once for a package pass. */
  9. class RewardConditions {
  10. public:
  11. [[nodiscard]] bool load(const middleware::content::packages::reader::Source& source,
  12. middleware::content::packages::reader::Scratch& scratch,
  13. std::span<const std::byte> root,
  14. const SlotMaps& maps) noexcept;
  15. [[nodiscard]] bool bind(state::build_data::rewards::Instruction& instruction) const noexcept;
  16. [[nodiscard]] bool read(std::span<const std::byte> blob,
  17. std::size_t at,
  18. std::vector<state::build_data::rewards::Instruction>& bank,
  19. state::build_data::rewards::Range& range) const noexcept;
  20. [[nodiscard]] bool read_list(std::span<const std::byte> blob,
  21. std::size_t at,
  22. std::span<state::build_data::rewards::Instruction> output,
  23. std::size_t& count) const noexcept;
  24. private:
  25. [[nodiscard]] bool append_expression(std::span<const std::byte> blob,
  26. std::size_t at,
  27. std::vector<state::build_data::rewards::Instruction>& bank,
  28. std::size_t depth) const noexcept;
  29. void load_class_flags(const middleware::content::packages::reader::Source& source,
  30. middleware::content::packages::reader::Scratch& scratch,
  31. std::span<const std::byte> root) noexcept;
  32. std::array<std::uint16_t, state::kCharacterClassCount> classFlags_{};
  33. const SlotMaps* maps_{};
  34. std::vector<std::byte> flags_;
  35. std::vector<std::byte> values_;
  36. std::vector<std::byte> expressions_;
  37. middleware::content::packages::tables::Array flagRows_{};
  38. middleware::content::packages::tables::Array valueRows_{};
  39. middleware::content::packages::tables::Array expressionRows_{};
  40. };
  41. /** Reward metadata collected alongside the existing item-definition walk. */
  42. class RewardBuild {
  43. public:
  44. RewardConditions conditions;
  45. [[nodiscard]] bool load(const middleware::content::packages::reader::Source& source,
  46. middleware::content::packages::reader::Scratch& scratch,
  47. std::span<const std::byte> root,
  48. const SlotMaps& maps) noexcept;
  49. [[nodiscard]] bool begin_items(std::size_t count) noexcept;
  50. void item(std::uint16_t index, std::uint32_t hash, std::span<const std::byte> blob) noexcept;
  51. [[nodiscard]] bool publish() noexcept;
  52. private:
  53. [[nodiscard]] bool entry(std::span<const std::byte> blob, std::size_t at) noexcept;
  54. [[nodiscard]] bool read_item(std::uint32_t hash,
  55. std::span<const std::byte> blob,
  56. state::build_data::rewards::Item& item) noexcept;
  57. bool loaded_{};
  58. std::vector<state::build_data::rewards::Pool> pools_;
  59. std::vector<state::build_data::rewards::Entry> entries_;
  60. std::vector<state::build_data::rewards::Item> items_;
  61. std::vector<state::build_data::rewards::Instruction> instructions_;
  62. std::vector<state::build_data::rewards::Modifier> modifiers_;
  63. std::vector<state::build_data::rewards::SocketOverride> sockets_;
  64. };
  65. /** Progression rewards and pool entries use the same socket-override layout. */
  66. [[nodiscard]] bool read_reward_sockets(std::span<const std::byte> blob,
  67. std::size_t at,
  68. std::span<state::build_data::rewards::SocketOverride> output,
  69. std::size_t& count) noexcept;
  70. } // namespace sunrise::client::content::items::packages