1#ifndef YAZE_ZELDA3_DUNGEON_CUSTOM_OBJECT_H_
2#define YAZE_ZELDA3_DUNGEON_CUSTOM_OBJECT_H_
10#include <unordered_map>
13#include "absl/status/status.h"
14#include "absl/status/statusor.h"
54 std::vector<TileMapEntry>
tiles;
68 for (
size_t i = 1; i <
tiles.size(); ++i) {
92 const std::vector<uint8_t>& data);
100 const std::string& custom_objects_folder,
const std::string& filename);
105 const std::string& custom_objects_folder,
const std::string& filename);
111 const std::string& custom_objects_folder,
const std::string& filename,
113 const std::vector<uint8_t>& expected_source_bytes,
114 const std::filesystem::path& expected_resolved_path);
149 void Initialize(
const std::string& custom_objects_folder);
153 const std::unordered_map<
int, std::vector<std::string>>& map);
168 absl::StatusOr<std::shared_ptr<CustomObject>>
LoadObject(
169 const std::string& filename);
212 std::unordered_map<std::string,
213 absl::StatusOr<std::shared_ptr<CustomObject>>>
Manages loading and caching of custom object binary files.
RuntimeContext & ActiveContext()
int GetSubtypeCount(int object_id) const
void RestoreState(const State &state)
std::unordered_map< uint64_t, RuntimeContext > runtime_contexts_
absl::StatusOr< CustomObjectSlotBinding > ResolveSlotBinding(int object_id, int subtype) const
uint64_t asset_generation() const
bool HasCustomFileMap() const
const std::string & GetBasePath() const
RuntimeContext standalone_context_
static const std::array< int, 3 > & RuntimeObjectIds()
static const std::vector< std::string > kSubtype54Filenames
void RemoveRuntimeContext(uint64_t context_id)
static const std::vector< std::string > & DefaultSubtypeFilenamesForObject(int object_id)
void SetObjectFileMap(const std::unordered_map< int, std::vector< std::string > > &map)
static int RuntimeSubtypeCountForObject(int object_id)
std::optional< uint64_t > active_runtime_context_id_
static CustomObjectManager & Get()
uint64_t next_asset_generation_
absl::StatusOr< std::shared_ptr< CustomObject > > LoadObject(const std::string &filename)
absl::StatusOr< std::shared_ptr< CustomObject > > GetObjectInternal(int object_id, int subtype)
static const std::vector< std::string > kSubtype2Filenames
void Initialize(const std::string &custom_objects_folder)
const std::vector< std::string > * ResolveFileList(int object_id) const
void ClearObjectFileMap()
std::optional< uint64_t > active_runtime_context_id() const
uint64_t NextAssetGeneration()
std::string ResolveFilename(int object_id, int subtype) const
static const std::vector< std::string > kSubtype1Filenames
void ActivateRuntimeContext(uint64_t context_id, const State &state)
void ActivateStandaloneContext()
std::vector< std::string > GetEffectiveFileList(int object_id) const
State SnapshotState() const
absl::StatusOr< CustomObject > DecodeCustomObjectBinary(const std::vector< uint8_t > &data)
absl::StatusOr< std::vector< uint8_t > > EncodeCustomObjectBinary(const CustomObject &object)
CustomObjectMappingOrigin
@ kConfiguredSlotUnmapped
uint16_t CustomObjectRuntimeTileWord(int object_id, uint16_t source_word)
absl::StatusOr< fs::path > ResolveCustomObjectAssetPath(const std::string &custom_objects_folder, const std::string &filename)
absl::StatusOr< std::vector< uint8_t > > PublishCustomObjectBinary(const std::string &custom_objects_folder, const std::string &filename, const CustomObject &object, const std::vector< uint8_t > &expected_source_bytes, const fs::path &expected_resolved_path)
absl::StatusOr< CustomObjectAsset > LoadCustomObjectAsset(const std::string &custom_objects_folder, const std::string &filename)
std::filesystem::path resolved_path
std::vector< uint8_t > source_bytes
std::unordered_map< std::string, absl::StatusOr< std::shared_ptr< CustomObject > > > cache
uint64_t asset_generation
bool operator==(const State &) const =default
std::unordered_map< int, std::vector< std::string > > custom_file_map
CustomObjectMappingOrigin origin
bool operator==(const TileMapEntry &) const =default
Represents a decoded custom object (from binary format)
BoundingBox GetBoundingBox() const
std::vector< TileMapEntry > tiles