activity_sdk_generation_worker.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <array>
  3. #include <cstdint>
  4. #include <memory>
  5. #include <string_view>
  6. #include "../../../middleware/content/packages/reader/reader.h"
  7. #include "../../../state/activity_sdk/generated_world/format.h"
  8. #include "../../../state/activity_sdk/generation/definition.h"
  9. #include "../../../state/build_data/scriptables/definition.h"
  10. namespace sunrise::client::content::activity::sdk_generation {
  11. /** Result of one explicit synchronous build into an isolated artifact tree. */
  12. enum class OfflineBuildStatus : std::uint8_t {
  13. ready,
  14. cancelled,
  15. busy,
  16. invalidInput,
  17. failed,
  18. };
  19. /** Bounded progress event emitted at the same points as the in-client worker state. */
  20. struct OfflineBuildProgress final {
  21. state::activity_sdk::generation::Status status{};
  22. std::uint32_t current{};
  23. std::uint32_t total{};
  24. std::uint32_t scenarioTag{};
  25. std::string_view detail{};
  26. };
  27. using OfflineProgressSink = void (*)(void* context, const OfflineBuildProgress& progress) noexcept;
  28. using OfflineCancelProbe = bool (*)(void* context) noexcept;
  29. /** Explicit inputs required by the package-backed native generation pass. */
  30. struct OfflineBuildRequest final {
  31. state::activity_sdk::generated_world::Digest sourceFingerprint{};
  32. const middleware::content::packages::reader::BlockKeys* keys{};
  33. std::wstring_view packageDirectory{};
  34. std::wstring_view cacheArtifactDirectory{};
  35. std::wstring_view outputArtifactDirectory{};
  36. };
  37. /** Identity and counts returned with one complete isolated tree. */
  38. struct OfflineBuildResult final {
  39. std::uint32_t scenarioCount{};
  40. std::uint32_t activityRootCount{};
  41. std::uint32_t activityCount{};
  42. std::uint32_t builtScenarioCount{};
  43. std::uint32_t reusedScenarioCount{};
  44. state::activity_sdk::generated_world::Digest payloadSha256{};
  45. std::uint64_t packBytes{};
  46. std::uint32_t luaFiles{};
  47. };
  48. /** Runs the exact worker pipeline with one borrowed in-process or synthetic reader source. */
  49. [[nodiscard]] OfflineBuildStatus build_offline(const OfflineBuildRequest& request,
  50. OfflineCancelProbe cancel,
  51. void* cancelContext,
  52. OfflineProgressSink progress,
  53. void* progressContext,
  54. OfflineBuildResult& output) noexcept;
  55. /** Immutable boot policy for the live generator. Its pack backs host roster mission seeds. */
  56. struct Policy final {
  57. bool enabled{};
  58. /** Writes the sdk/lua declaration tree, which no runtime loads. */
  59. bool luaDeclarations{};
  60. };
  61. /** Stores the artifact paths and applies the immutable boot policy. */
  62. void initialize(void* module, const Policy& policy) noexcept;
  63. /** Starts or reaps the optional full-estate package reader without blocking the caller. */
  64. void service() noexcept;
  65. /** Loads one tag-bound published shard even when generation is disabled. */
  66. [[nodiscard]] bool
  67. load_cached_scenario(std::uint32_t scenarioTag,
  68. std::string_view scenarioName,
  69. std::shared_ptr<state::build_data::scriptables::Snapshot>& output) noexcept;
  70. /** Cancels and joins generation before clearing its paths and job state. */
  71. void reset() noexcept;
  72. } // namespace sunrise::client::content::activity::sdk_generation