#pragma once #include "core/inflate.h" #include #include #include #include #include #include #include namespace playground { enum class CadiKind { OggVorbis, Xml }; enum class CadiChannel { Sfx, Music, Environment }; struct CadiEventInfo { std::vector clips; CadiChannel channel = CadiChannel::Sfx; bool loop = false; }; struct CadiRecord { uint32_t token = 0; // opaque bank index value uint32_t offset = 0; uint32_t size = 0; CadiKind kind = CadiKind::OggVorbis; }; // Read-only parser for a caller-supplied CADI audio bank. class CadiBank { public: bool load(Bytes bytes, std::string* error = nullptr); const std::vector& records() const { return records_; } std::span data(size_t index) const; std::optional clipForEvent(std::string_view event) const; std::vector clipsForEvent(std::string_view event) const; std::optional eventInfo(std::string_view event) const; size_t mappedEventCount() const { return eventClips_.size(); } private: Bytes bytes_; std::vector records_; std::unordered_map eventClips_; }; } // namespace playground