refactor(tools): replace name_space parser with ResourceLocation

This commit is contained in:
2026-08-08 14:56:52 +08:00
parent 1baa2d6672
commit bc4bbe1ff2
4 changed files with 55 additions and 39 deletions

View File

@@ -2,7 +2,7 @@
#include "Cubed/tools/cubed_assert.hpp"
#include "Cubed/tools/log.hpp"
#include "Cubed/tools/name_space.hpp"
#include "Cubed/tools/resource_location.hpp"
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
@@ -57,15 +57,18 @@ HitboxManager::Handle HitboxManager::get_hitbox(const std::string& name) {
}
HitboxManager::Handle HitboxManager::load(std::string_view name) {
auto space = parse_namespace(name);
ASSERT(space.size() >= 2);
auto space = ResourceLocation::parse(name);
if (!space) {
Logger::error("Can't load hitbox {}", name);
ASSERT(false);
}
fs::path p;
if (space[0] == "cubed") {
if (space->ns == "cubed") {
p = std::format("{}model/creature/{}/collision.json", ASSETS_PATH,
space[1]);
space->path);
} else {
p = std::format("{}/model/creature/{}/collision.json", space[0],
space[1]);
p = std::format("{}/model/creature/{}/collision.json", space->ns,
space->path);
}
try {