nw::ResourceManager

struct ResourceManager : public nw::kernel::Service

Public Types

using SearchVector = Vector<LocatorPayload>

Public Functions

ResourceManager(MemoryResource *memory, const ResourceManager *parent = nullptr)
virtual ~ResourceManager() = default
virtual void initialize(kernel::ServiceInitTime time) override

Initializes resources management system.

bool add_base_container(const std::filesystem::path &path, const String &name, ResourceType::type restype = ResourceType::invalid)

Add a base container

Note

This anything that is BELOW the module in priority

bool add_custom_container(Container *container, bool take_ownership = true, ResourceType::type restype = ResourceType::invalid)

Add already created container

Note

These containers are above all others in priority

bool add_override_container(const std::filesystem::path &path, const String &name, ResourceType::type restype = ResourceType::invalid)

Add override container

Note

This anything that is ABOVE the module in priority

void build_registry()

Builds resource main registry.

bool contains(Resource uri) const noexcept

Determines if a resource is in the resource manager.

ResourceData demand(Resource uri) const

Demand some resource.

ResourceData demand_in_order(Resref resref, std::initializer_list<ResourceType::type> restypes) const

Demand some resource by resource priority.

bool load_module(std::filesystem::path path)

Loads container resources for a module.

void load_module_haks(const Vector<String> &haks)

Loads module haks.

virtual nlohmann::json stats() const override

Logs service metrics.

Container *module_container() const

Gets module container.

void unload_module()

Unloads module.

ResourceData demand_server_vault(StringView cdkey, StringView resref)

Demands a player character file.

Image *palette_texture(PltLayer layer)

Gets cached palette texture.

Image *texture(Resref resref) const

Loads a texture from the resource manager

Note

This is a wrapper around demand_in_order with types dds, and tga passed. plt is not included here or are other image types, png, etc.

inline const String &name() const
size_t size() const
inline bool valid() const noexcept
void visit(std::function<void(Resource)> visitor) const

Executes callback on all assets in the resource registry.

MemoryResource *allocator() const noexcept

Gets the memory allocator for the servce.

Public Static Attributes

static const std::type_index type_index = {typeid(ResourceManager)}