summaryrefslogtreecommitdiff
path: root/src/port/resource/importers/ResourceUtil.h
blob: 5ff4b289bdb9cac0824fdeeba231d5897f7af7ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include "libultraship/bridge/resourcebridge.h"
#include "ship/resource/ResourceManager.h"
#include "ship/Context.h"

namespace SM64 {
template <typename T> T LoadChild(uint64_t crc) {
    auto path = ResourceGetNameByCrc(crc);
    if (path == nullptr) {
        return nullptr;
    }
    auto asset = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(path);
    return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
}
template <typename T> T LoadChild(const char* path) {
    if (path == nullptr) {
        return nullptr;
    }
    auto asset = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(path);
    return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
}
}