mirror of
https://github.com/zeldaret/botw
synced 2026-06-11 05:08:09 -04:00
ksys/act: Implement more ActorParamMgr functions
This commit is contained in:
@@ -49,8 +49,8 @@ void ActorParam::deleteResHandles() {
|
||||
handles.freeBuffer();
|
||||
}
|
||||
|
||||
bool ActorParam::isDummyParam(res::ActorLink::Users::User user) const {
|
||||
return mRes.mActorLink->getUsers().getUserName(user) == "Dummy";
|
||||
bool ActorParam::isDummyParam(res::ActorLink::User user) const {
|
||||
return sead::SafeString(mRes.mActorLink->getUserName(user)) == "Dummy";
|
||||
}
|
||||
|
||||
void ActorParam::allocResHandles(sead::Heap* heap, u32 buffer_idx, s32 count) {
|
||||
@@ -154,4 +154,6 @@ void ActorParam::setProfileAndPriority(const char* profile, const char* priority
|
||||
}
|
||||
}
|
||||
|
||||
void ActorParam::onLoadFinished(ActorParamMgr*) {}
|
||||
|
||||
} // namespace ksys::act
|
||||
|
||||
@@ -40,6 +40,8 @@ class UMii;
|
||||
|
||||
namespace act {
|
||||
|
||||
class ActorParamMgr;
|
||||
|
||||
// FIXME: incomplete
|
||||
class ActorParam : public sead::hostio::Node {
|
||||
public:
|
||||
@@ -69,8 +71,15 @@ public:
|
||||
LifeCondition = 22,
|
||||
UMii = 23,
|
||||
AnimationInfo = 24,
|
||||
AS = 25,
|
||||
AttClient = 26,
|
||||
RagdollConfig = 27,
|
||||
};
|
||||
|
||||
static constexpr bool isValidType(ResourceType type) {
|
||||
return type <= ResourceType::AnimationInfo;
|
||||
}
|
||||
|
||||
union Resources {
|
||||
struct {
|
||||
res::ActorLink* mActorLink;
|
||||
@@ -112,7 +121,7 @@ public:
|
||||
Priority getPriority() const { return mPriority; }
|
||||
const Resources& getRes() const { return mRes; }
|
||||
|
||||
bool isDummyParam(res::ActorLink::Users::User user) const;
|
||||
bool isDummyParam(res::ActorLink::User user) const;
|
||||
|
||||
static void resetDummyResources();
|
||||
|
||||
@@ -141,7 +150,15 @@ private:
|
||||
bool setPriority(const sead::SafeString& priority);
|
||||
void setProfileAndPriority(const char* profile, const char* priority);
|
||||
|
||||
u16 _8 = 0;
|
||||
void setResourceIfValidType(ResourceType type, ParamIO* param_io) {
|
||||
if (isValidType(type))
|
||||
setResource(type, param_io);
|
||||
}
|
||||
|
||||
void onLoadFinished(ActorParamMgr* mgr);
|
||||
|
||||
u8 _8 = 0;
|
||||
u8 _9 = 0;
|
||||
u8 _a = 0;
|
||||
sead::FixedSafeString<64> mActorName;
|
||||
sead::SafeString mProfile;
|
||||
|
||||
@@ -3,7 +3,36 @@
|
||||
#include "KingSystem/ActorSystem/actASSetting.h"
|
||||
#include "KingSystem/ActorSystem/actActorParam.h"
|
||||
#include "KingSystem/Resource/resLoadRequest.h"
|
||||
#include "KingSystem/Resource/resResourceAIProgram.h"
|
||||
#include "KingSystem/Resource/resResourceAISchedule.h"
|
||||
#include "KingSystem/Resource/resResourceAS.h"
|
||||
#include "KingSystem/Resource/resResourceASList.h"
|
||||
#include "KingSystem/Resource/resResourceActorLink.h"
|
||||
#include "KingSystem/Resource/resResourceAnimInfo.h"
|
||||
#include "KingSystem/Resource/resResourceArchive.h"
|
||||
#include "KingSystem/Resource/resResourceAttClient.h"
|
||||
#include "KingSystem/Resource/resResourceAttClientList.h"
|
||||
#include "KingSystem/Resource/resResourceAwareness.h"
|
||||
#include "KingSystem/Resource/resResourceBoneControl.h"
|
||||
#include "KingSystem/Resource/resResourceChemical.h"
|
||||
#include "KingSystem/Resource/resResourceDamageParam.h"
|
||||
#include "KingSystem/Resource/resResourceDrop.h"
|
||||
#include "KingSystem/Resource/resResourceGParamList.h"
|
||||
#include "KingSystem/Resource/resResourceLifeCondition.h"
|
||||
#include "KingSystem/Resource/resResourceLod.h"
|
||||
#include "KingSystem/Resource/resResourceMgrTask.h"
|
||||
#include "KingSystem/Resource/resResourceModelList.h"
|
||||
#include "KingSystem/Resource/resResourcePhysics.h"
|
||||
#include "KingSystem/Resource/resResourceRagdollBlendWeight.h"
|
||||
#include "KingSystem/Resource/resResourceRagdollConfig.h"
|
||||
#include "KingSystem/Resource/resResourceRagdollConfigList.h"
|
||||
#include "KingSystem/Resource/resResourceRecipe.h"
|
||||
#include "KingSystem/Resource/resResourceShop.h"
|
||||
#include "KingSystem/Resource/resResourceUMii.h"
|
||||
#include "KingSystem/Resource/resSystem.h"
|
||||
#include "KingSystem/Resource/resTempResourceLoader.h"
|
||||
#include "KingSystem/Utils/Debug.h"
|
||||
#include "KingSystem/Utils/ParamIO.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
@@ -15,6 +44,31 @@ ActorParamMgr::~ActorParamMgr() {
|
||||
ASSetting::deleteInstance();
|
||||
}
|
||||
|
||||
bool ActorParamMgr::checkPath(const sead::SafeString& path) const {
|
||||
return res::returnFalse3(path);
|
||||
}
|
||||
|
||||
ActorParam* ActorParamMgr::allocParam(const char* actor_name, bool* allocated_new) {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
ActorParam* free_param = nullptr;
|
||||
auto* param = getParam(actor_name, &free_param);
|
||||
|
||||
if (!param) {
|
||||
param = free_param;
|
||||
if (free_param)
|
||||
free_param->mRes = {};
|
||||
else
|
||||
param = &mParams[NumParams - 1];
|
||||
|
||||
param->mActorName = actor_name;
|
||||
*allocated_new = true;
|
||||
}
|
||||
|
||||
param->incrementRef();
|
||||
return param;
|
||||
}
|
||||
|
||||
// NON_MATCHING: addressing mode
|
||||
ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_free_param) const {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
@@ -32,30 +86,10 @@ ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_fre
|
||||
|
||||
ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* handle, void* x,
|
||||
u32 load_req_c) {
|
||||
ActorParam* param;
|
||||
bool existing = false;
|
||||
bool allocated_new = false;
|
||||
ActorParam* param = allocParam(actor_name, &allocated_new);
|
||||
|
||||
{
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
ActorParam* free_param = nullptr;
|
||||
param = getParam(actor_name, &free_param);
|
||||
|
||||
if (param) {
|
||||
existing = true;
|
||||
} else {
|
||||
param = free_param;
|
||||
if (free_param)
|
||||
free_param->mRes = {};
|
||||
else
|
||||
param = &mParams[NumParams - 1];
|
||||
|
||||
param->mActorName = actor_name;
|
||||
}
|
||||
param->incrementRef();
|
||||
}
|
||||
|
||||
if (!existing) {
|
||||
if (allocated_new) {
|
||||
loadFiles(param, mTmpActorParamMgrHeap, handle, x, load_req_c);
|
||||
param->setEventSignal();
|
||||
} else {
|
||||
@@ -65,8 +99,43 @@ ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* handle
|
||||
return param;
|
||||
}
|
||||
|
||||
bool ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& actor_name,
|
||||
u32 load_req_c) {
|
||||
void ActorParamMgr::loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle,
|
||||
void* x, u32 load_req_c) {
|
||||
param->deleteResHandles();
|
||||
param->allocResHandles(heap, 0, 29);
|
||||
param->mActiveBufferIdx = 0;
|
||||
|
||||
using Type = ActorParam::ResourceType;
|
||||
using User = res::ActorLink::User;
|
||||
|
||||
const auto* link =
|
||||
loadFile<res::ActorLink>(param, Type::ActorLink, "Actor/ActorLink", "xml",
|
||||
param->getActorName().cstr(), pack_handle, x, load_req_c);
|
||||
|
||||
if (link)
|
||||
param->setProfileAndPriority(link->getUserName(User::Profile), link->getPriority().cstr());
|
||||
|
||||
const auto* actor_link = param->getRes().mActorLink;
|
||||
if (!actor_link)
|
||||
return;
|
||||
|
||||
param->mActiveBufferIdx = 0;
|
||||
|
||||
loadFile<res::ModelList>(param, Type::ModelList, "Actor/ModelList", "modellist",
|
||||
actor_link->getUserName(User::Model), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::UMii>(param, Type::UMii, "Actor/UMii", "umii",
|
||||
actor_link->getUserName(User::UMii), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::ASList>(param, Type::ASList, "Actor/ASList", "aslist",
|
||||
actor_link->getUserName(res::ActorLink::User::AS), pack_handle, x,
|
||||
load_req_c);
|
||||
|
||||
loadFilesStep2(param, heap, pack_handle, x, load_req_c);
|
||||
}
|
||||
|
||||
bool ActorParamMgr::requestLoadActorPack(res::Handle* handle, const sead::SafeString& actor_name,
|
||||
u32 load_req_c) {
|
||||
sead::FixedSafeString<128> path;
|
||||
res::LoadRequest req;
|
||||
|
||||
@@ -81,6 +150,279 @@ bool ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& a
|
||||
return handle->requestLoad(path, &req);
|
||||
}
|
||||
|
||||
void ActorParamMgr::loadFilesStep2(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle,
|
||||
void* x, u32 load_req_c) {
|
||||
const auto* link = param->getRes().mActorLink;
|
||||
param->mActiveBufferIdx = 0;
|
||||
|
||||
using Type = ActorParam::ResourceType;
|
||||
using User = res::ActorLink::User;
|
||||
|
||||
loadFile<res::AttClientList>(param, Type::AttClientList, "Actor/AttClientList", "atcllist",
|
||||
link->getUserName(User::Attention), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::RagdollConfigList>(param, Type::RagdollConfigList, "Actor/RagdollConfigList",
|
||||
"rgconfiglist", link->getUserName(User::RgConfigList),
|
||||
pack_handle, x, load_req_c);
|
||||
|
||||
{
|
||||
s32 num_extra_handles = 0;
|
||||
auto* aslist = param->getRes().mASList;
|
||||
auto* atcllist = param->getRes().mAttClientList;
|
||||
auto* rgconfiglist = param->getRes().mRagdollConfigList;
|
||||
if (aslist)
|
||||
num_extra_handles += aslist->getBuffers().as_defines.size();
|
||||
if (atcllist)
|
||||
num_extra_handles += atcllist->getClients().size();
|
||||
if (rgconfiglist)
|
||||
num_extra_handles += rgconfiglist->getImpulseParams().size();
|
||||
|
||||
param->allocResHandles(heap, 1, num_extra_handles);
|
||||
}
|
||||
|
||||
// Start loading the extra ActorParam files.
|
||||
param->mActiveBufferIdx = 1;
|
||||
|
||||
if (auto* aslist = param->getRes().mASList) {
|
||||
for (s32 i = 0; i < aslist->getBuffers().as_defines.size(); ++i) {
|
||||
auto* as = loadFile<res::AS>(param, Type::AS, "Actor/AS", "as",
|
||||
aslist->getBuffers().as_defines[i].file_name.ref().cstr(),
|
||||
pack_handle, x, load_req_c);
|
||||
if (as) {
|
||||
as->setIndex(u32(Type::AS));
|
||||
aslist->addAS_(i, as);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto* list = param->getRes().mAttClientList) {
|
||||
for (s32 i = 0; i < list->getClients().size(); ++i) {
|
||||
auto* client = loadFile<res::AttClient>(
|
||||
param, Type::AttClient, "Actor/AttClient", "atcl",
|
||||
list->getClients()[i].file_name.ref().cstr(), pack_handle, x, load_req_c);
|
||||
if (client) {
|
||||
client->setIndex(u32(Type::AttClient));
|
||||
list->addClient_(i, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto* list = param->getRes().mRagdollConfigList) {
|
||||
for (s32 i = 0; i < list->getImpulseParams().size(); ++i) {
|
||||
auto* config = loadFile<res::RagdollConfig>(
|
||||
param, Type::RagdollConfig, "Actor/RagdollConfig", "rgconfig",
|
||||
list->getImpulseParams()[i].file_name.ref().cstr(), pack_handle, x, load_req_c);
|
||||
if (config) {
|
||||
config->setIndex(u32(Type::RagdollConfig));
|
||||
list->addImpulseParamConfig_(i, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We have now finished loading the extra ActorParam files.
|
||||
// Go back to using the main resource handle buffer.
|
||||
param->mActiveBufferIdx = 0;
|
||||
|
||||
loadFile<res::AIProgram>(param, Type::AIProgram, "Actor/AIProgram", "aiprog",
|
||||
link->getUsers().getAIProgram(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::GParamList>(param, Type::GParamList, "Actor/GeneralParamList", "gparamlist",
|
||||
link->getUsers().getGParam(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Physics>(param, Type::Physics, "Actor/Physics", "physics",
|
||||
link->getUsers().getPhysics(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Chemical>(param, Type::Chemical, "Actor/Chemical", "chemical",
|
||||
link->getUsers().getChemical(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::DamageParam>(param, Type::DamageParam, "Actor/DamageParam", "dmgparam",
|
||||
link->getUsers().getDamageParam(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::RagdollBlendWeight>(param, Type::RagdollBlendWeight, "Actor/RagdollBlendWeight",
|
||||
"rgbw", link->getUsers().getRgBlendWeight(), pack_handle, x,
|
||||
load_req_c);
|
||||
|
||||
loadFile<res::Awareness>(param, Type::Awareness, "Actor/Awareness", "awareness",
|
||||
link->getUsers().getAwareness(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Drop>(param, Type::DropTable, "Actor/DropTable", "drop",
|
||||
link->getUsers().getDropTable(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Shop>(param, Type::ShopData, "Actor/ShopData", "shop",
|
||||
link->getUsers().getShopData(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Recipe>(param, Type::Recipe, "Actor/Recipe", "recipe",
|
||||
link->getUsers().getRecipe(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::Lod>(param, Type::Lod, "Actor/LOD", "lod", link->getUsers().getLOD(), pack_handle,
|
||||
x, load_req_c);
|
||||
|
||||
loadFile<res::AISchedule>(param, Type::AISchedule, "Actor/AISchedule", "aischedule",
|
||||
link->getUsers().getAISchedule(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::BoneControl>(param, Type::BoneControl, "Actor/BoneControl", "bonectrl",
|
||||
link->getUsers().getBoneControl(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::LifeCondition>(param, Type::LifeCondition, "Actor/LifeCondition", "lifecondition",
|
||||
link->getUsers().getLifeCondition(), pack_handle, x, load_req_c);
|
||||
|
||||
loadFile<res::AnimInfo>(param, Type::AnimationInfo, "Actor/AnimationInfo", "animinfo",
|
||||
link->getUsers().getAnimationInfo(), pack_handle, x, load_req_c);
|
||||
|
||||
param->_9 = 0;
|
||||
param->onLoadFinished(this);
|
||||
}
|
||||
|
||||
void ActorParamMgr::unloadParam(ActorParam* param) {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
param->decrementRef();
|
||||
}
|
||||
|
||||
bool ActorParamMgr::prepareLoadFromActorPack(sead::BufferedSafeString* path, res::LoadRequest* req,
|
||||
void*, const sead::SafeString& dir_name,
|
||||
const sead::SafeString& extension,
|
||||
const sead::SafeString& file_name,
|
||||
res::Handle* pack_handle, u32 load_req_c,
|
||||
const sead::SafeString& requester) {
|
||||
path->format("%s/%s.b%s", dir_name.cstr(), file_name.cstr(), extension.cstr());
|
||||
|
||||
bool in_pack = false;
|
||||
if (pack_handle && pack_handle->isSuccess()) {
|
||||
auto* pack = static_cast<sead::ArchiveRes*>(pack_handle->getResourceUnchecked());
|
||||
in_pack = pack->getFile(*path) != nullptr;
|
||||
}
|
||||
|
||||
const bool cond1 = res::returnFalse3(*path);
|
||||
const bool is_host_path = res::isHostPath(*path);
|
||||
if (!in_pack && !cond1 && !is_host_path && path->include("bxml")) {
|
||||
sead::FormatFixedSafeString<256> message("↓↓↓\nファイルパス : %s\n↑↑↑\n", path->cstr());
|
||||
util::PrintDebug(message);
|
||||
}
|
||||
|
||||
const bool ret = res::returnFalse3(*path);
|
||||
if (!ret && pack_handle && pack_handle->isSuccess()) {
|
||||
req->mPackHandle = pack_handle;
|
||||
req->_24 = false;
|
||||
}
|
||||
|
||||
req->_c = load_req_c;
|
||||
req->mRequester = requester;
|
||||
req->_8 = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
res::Archive* ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& actor_name,
|
||||
u32 load_req_c) {
|
||||
sead::FixedSafeString<128> path;
|
||||
res::TempResourceLoader::LoadArg arg;
|
||||
arg.retry_on_failure = true;
|
||||
arg.use_handle = true;
|
||||
|
||||
if (mFlags.isOn(Flag::_5))
|
||||
return nullptr;
|
||||
|
||||
path.format("Actor/Pack/%s.bactorpack", actor_name.cstr());
|
||||
arg.load_req.mRequester = actor_name;
|
||||
arg.load_req._c = load_req_c;
|
||||
arg.load_req._8 = true;
|
||||
arg.load_req._28 = false;
|
||||
arg.load_req.mPath = path;
|
||||
|
||||
res::TempResourceLoader loader;
|
||||
{
|
||||
res::TempResourceLoader::InitArg init_arg{};
|
||||
res::ResourceMgrTask::instance()->initTempResourceLoader(&loader, init_arg);
|
||||
}
|
||||
loader.load(arg);
|
||||
|
||||
res::SimpleLoadRequest req;
|
||||
req.mRequester = "tap::ActorParamMgr";
|
||||
req.mPath = path;
|
||||
req._c = 2;
|
||||
return sead::DynamicCast<res::Archive>(handle->load(path, &req));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* ActorParamMgr::loadFile(ActorParam* param, ActorParam::ResourceType type, const char* dir_name_c,
|
||||
const char* extension_c, const char* name_c, res::Handle* pack_handle,
|
||||
void* x, u32 load_req_c) {
|
||||
const sead::SafeString name = name_c;
|
||||
const sead::SafeString extension = extension_c;
|
||||
sead::FixedSafeString<128> path;
|
||||
|
||||
T* res = nullptr;
|
||||
|
||||
if (name != "Dummy" && !name.isEmpty()) {
|
||||
auto* temp_handle = param->allocHandle();
|
||||
const sead::SafeString* actor_name;
|
||||
path.format("%s/%s.b%s", dir_name_c, name_c, extension_c);
|
||||
{
|
||||
res::SimpleLoadRequest req;
|
||||
req._8 = true;
|
||||
actor_name = ¶m->getActorName();
|
||||
req.mRequester = *actor_name;
|
||||
req.mPath = path;
|
||||
req._c = 2;
|
||||
res = sead::DynamicCast<T>(temp_handle->load(path, &req));
|
||||
}
|
||||
|
||||
// If loading the resource from the RomFS has failed, try to load it from the actor pack.
|
||||
if (!res) {
|
||||
if (!pack_handle->isSuccess())
|
||||
loadActorPack(pack_handle, *actor_name, load_req_c);
|
||||
|
||||
res::LoadRequest req;
|
||||
prepareLoadFromActorPack(&path, &req, x, dir_name_c, extension_c, name_c, pack_handle,
|
||||
load_req_c, *actor_name);
|
||||
res = sead::DynamicCast<T>(temp_handle->load(path, &req));
|
||||
|
||||
if (!res) {
|
||||
static_cast<void>(temp_handle->isSuccess());
|
||||
// Try again without the pack.
|
||||
if (req.mPackHandle) {
|
||||
req.mPackHandle = nullptr;
|
||||
req._24 = false;
|
||||
res = sead::DynamicCast<T>(temp_handle->load(path, &req));
|
||||
if (!res)
|
||||
static_cast<void>(temp_handle->isSuccess());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!res)
|
||||
param->freeLastHandle();
|
||||
else if (type == ActorParam::ResourceType::EventFlow)
|
||||
temp_handle->requestUnload2();
|
||||
|
||||
} else {
|
||||
path.format("%s/%s.b%s", dir_name_c, name_c, extension_c);
|
||||
res = sead::DynamicCast<T>(mResHandles[s32(type)].getResource());
|
||||
}
|
||||
|
||||
if (res) {
|
||||
if (type == ActorParam::ResourceType::EventFlow)
|
||||
return res;
|
||||
|
||||
static_cast<ParamIO*>(res)->getPath().copy(path);
|
||||
param->setResourceIfValidType(type, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (extension != "fevfl")
|
||||
param->_a = 1;
|
||||
|
||||
// Fall back to using the dummy resource.
|
||||
res = sead::DynamicCast<T>(mResHandles[s32(type)].getResource());
|
||||
sead::FixedSafeString<128> dummy_path;
|
||||
dummy_path.format("%s/Dummy.b%s", dir_name_c, extension_c);
|
||||
if (res) {
|
||||
static_cast<ParamIO*>(res)->getPath().copy(dummy_path);
|
||||
param->setResourceIfValidType(type, res);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
res::GParamList* ActorParamMgr::getDummyGParamList() const {
|
||||
return static_cast<res::GParamList*>(
|
||||
mResHandles[u32(ActorParam::ResourceType::GParamList)].getResourceUnchecked());
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <prim/seadSafeString.h>
|
||||
#include <prim/seadTypedBitFlag.h>
|
||||
#include <thread/seadCriticalSection.h>
|
||||
#include "KingSystem/ActorSystem/actActorParam.h"
|
||||
#include "KingSystem/Resource/resHandle.h"
|
||||
#include "KingSystem/System/DebugMessage.h"
|
||||
#include "KingSystem/System/KingEditor.h"
|
||||
@@ -14,13 +15,13 @@
|
||||
namespace ksys {
|
||||
|
||||
namespace res {
|
||||
class Archive;
|
||||
class GParamList;
|
||||
class LoadRequest;
|
||||
} // namespace res
|
||||
|
||||
namespace act {
|
||||
|
||||
class ActorParam;
|
||||
|
||||
// FIXME: incomplete
|
||||
class ActorParamMgr final : public sead::hostio::Node, public KingEditorComponent {
|
||||
SEAD_SINGLETON_DISPOSER(ActorParamMgr)
|
||||
@@ -35,10 +36,14 @@ public:
|
||||
sead::Heap* getDebugHeap() const { return mDebugHeap; }
|
||||
sead::Heap* getTmpActorParamMgrHeap() const { return mTmpActorParamMgrHeap; }
|
||||
|
||||
bool checkPath(const sead::SafeString& path) const;
|
||||
|
||||
void init(sead::Heap* heap, sead::Heap* debug_heap);
|
||||
|
||||
ActorParam* allocParam(const char* actor_name, bool* allocated_new);
|
||||
ActorParam* getParam(const char* actor_name, ActorParam** out_free_param) const;
|
||||
ActorParam* loadParam(const char* actor_name, res::Handle* handle, void* x, u32 load_req_c);
|
||||
void unloadParam(ActorParam* param);
|
||||
|
||||
res::GParamList* getDummyGParamList() const;
|
||||
|
||||
@@ -50,9 +55,25 @@ private:
|
||||
_5 = _1 | _4,
|
||||
};
|
||||
|
||||
void loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* handle, void* x,
|
||||
void loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, void* x,
|
||||
u32 load_req_c);
|
||||
bool loadActorPack(res::Handle* handle, const sead::SafeString& actor_name, u32 load_req_c);
|
||||
bool requestLoadActorPack(res::Handle* handle, const sead::SafeString& actor_name,
|
||||
u32 load_req_c);
|
||||
bool prepareLoadFromActorPack(sead::BufferedSafeString* path, res::LoadRequest* req, void* x,
|
||||
const sead::SafeString& dir_name,
|
||||
const sead::SafeString& extension,
|
||||
const sead::SafeString& file_name, res::Handle* pack_handle,
|
||||
u32 load_req_c, const sead::SafeString& requester);
|
||||
res::Archive* loadActorPack(res::Handle* handle, const sead::SafeString& actor_name,
|
||||
u32 load_req_c);
|
||||
|
||||
template <typename T>
|
||||
T* loadFile(ActorParam* param, ActorParam::ResourceType type, const char* dir_name_c,
|
||||
const char* extension_c, const char* name_c, res::Handle* pack_handle, void* x,
|
||||
u32 load_req_c);
|
||||
|
||||
void loadFilesStep2(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, void* x,
|
||||
u32 load_req_c);
|
||||
|
||||
static constexpr s32 NumParams = 0x400;
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
class AS;
|
||||
|
||||
class ASList : public ParamIO, public Resource {
|
||||
SEAD_RTTI_OVERRIDE(ASList, Resource)
|
||||
public:
|
||||
@@ -17,7 +19,7 @@ public:
|
||||
agl::utl::Parameter<sead::SafeString> name;
|
||||
agl::utl::Parameter<sead::SafeString> file_name;
|
||||
agl::utl::ParameterObj obj;
|
||||
void* _88;
|
||||
AS* as;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ASDefine, 0x88);
|
||||
|
||||
@@ -65,6 +67,8 @@ public:
|
||||
const Buffers& getBuffers() const { return mBuffers; }
|
||||
const Common& getCommon() const { return mCommon.ref(); }
|
||||
|
||||
void addAS_(s32 index, AS* as);
|
||||
|
||||
protected:
|
||||
bool finishParsing_() override;
|
||||
bool m7_() override;
|
||||
|
||||
@@ -13,41 +13,68 @@ namespace ksys::res {
|
||||
class ActorLink : public ParamIO, public Resource {
|
||||
SEAD_RTTI_OVERRIDE(ActorLink, Resource)
|
||||
public:
|
||||
struct Users {
|
||||
enum class User {
|
||||
Profile = 0,
|
||||
ActorCapture = 1,
|
||||
AS = 2,
|
||||
Model = 3,
|
||||
Anim = 4,
|
||||
AIProgram = 5,
|
||||
GParam = 6,
|
||||
DamageParam = 7,
|
||||
RgConfigList = 8,
|
||||
RgBlendWeight = 9,
|
||||
Awareness = 10,
|
||||
Physics = 11,
|
||||
Chemical = 12,
|
||||
Attention = 13,
|
||||
ELink = 14,
|
||||
SLink = 15,
|
||||
XLink = 16,
|
||||
DropTable = 17,
|
||||
ShopData = 18,
|
||||
Recipe = 19,
|
||||
LOD = 20,
|
||||
BoneControl = 21,
|
||||
AISchedule = 22,
|
||||
LifeCondition = 23,
|
||||
UMii = 24,
|
||||
AnimationInfo = 25,
|
||||
};
|
||||
enum class User {
|
||||
Profile = 0,
|
||||
ActorCapture = 1,
|
||||
AS = 2,
|
||||
Model = 3,
|
||||
Anim = 4,
|
||||
AIProgram = 5,
|
||||
GParam = 6,
|
||||
DamageParam = 7,
|
||||
RgConfigList = 8,
|
||||
RgBlendWeight = 9,
|
||||
Awareness = 10,
|
||||
Physics = 11,
|
||||
Chemical = 12,
|
||||
Attention = 13,
|
||||
ELink = 14,
|
||||
SLink = 15,
|
||||
XLink = 16,
|
||||
DropTable = 17,
|
||||
ShopData = 18,
|
||||
Recipe = 19,
|
||||
LOD = 20,
|
||||
BoneControl = 21,
|
||||
AISchedule = 22,
|
||||
LifeCondition = 23,
|
||||
UMii = 24,
|
||||
AnimationInfo = 25,
|
||||
};
|
||||
|
||||
struct Users {
|
||||
const agl::utl::Parameter<sead::SafeString>& getUser(User user) const {
|
||||
return *(&profile + u32(user));
|
||||
}
|
||||
|
||||
sead::SafeString getUserName(User user) const { return getUser(user).ref().cstr(); }
|
||||
const char* getUserName(User user) const { return getUser(user).ref().cstr(); }
|
||||
|
||||
const char* getProfile() const { return profile.ref().cstr(); }
|
||||
const char* getActorCapture() const { return actor_capture.ref().cstr(); }
|
||||
const char* getAS() const { return as.ref().cstr(); }
|
||||
const char* getModel() const { return model.ref().cstr(); }
|
||||
const char* getAnim() const { return anim.ref().cstr(); }
|
||||
const char* getAIProgram() const { return ai_program.ref().cstr(); }
|
||||
const char* getGParam() const { return gparam.ref().cstr(); }
|
||||
const char* getDamageParam() const { return damage_param.ref().cstr(); }
|
||||
const char* getRgConfigList() const { return rg_config_list.ref().cstr(); }
|
||||
const char* getRgBlendWeight() const { return rg_blend_weight.ref().cstr(); }
|
||||
const char* getAwareness() const { return awareness.ref().cstr(); }
|
||||
const char* getPhysics() const { return physics.ref().cstr(); }
|
||||
const char* getChemical() const { return chemical.ref().cstr(); }
|
||||
const char* getAttention() const { return attention.ref().cstr(); }
|
||||
const char* getELink() const { return elink.ref().cstr(); }
|
||||
const char* getSLink() const { return slink.ref().cstr(); }
|
||||
const char* getXLink() const { return xlink.ref().cstr(); }
|
||||
const char* getDropTable() const { return drop_table.ref().cstr(); }
|
||||
const char* getShopData() const { return shop_data.ref().cstr(); }
|
||||
const char* getRecipe() const { return recipe.ref().cstr(); }
|
||||
const char* getLOD() const { return lod.ref().cstr(); }
|
||||
const char* getBoneControl() const { return bone_control.ref().cstr(); }
|
||||
const char* getAISchedule() const { return ai_schedule.ref().cstr(); }
|
||||
const char* getLifeCondition() const { return life_condition.ref().cstr(); }
|
||||
const char* getUMii() const { return umii.ref().cstr(); }
|
||||
const char* getAnimationInfo() const { return animation_info.ref().cstr(); }
|
||||
|
||||
agl::utl::Parameter<sead::SafeString> profile;
|
||||
agl::utl::Parameter<sead::SafeString> actor_capture;
|
||||
@@ -84,6 +111,7 @@ public:
|
||||
bool needsParse() const override { return true; }
|
||||
|
||||
const Users& getUsers() const { return mUsers; }
|
||||
const char* getUserName(User user) const { return getUsers().getUserName(user); }
|
||||
const sead::SafeString& getActorNameJpn() const { return mActorNameJpn.ref(); }
|
||||
const sead::SafeString& getPriority() const { return mPriority.ref(); }
|
||||
f32 getActorScale() const { return mActorScale.ref(); }
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
class AttClient;
|
||||
|
||||
class AttClientList : public ParamIO, public Resource {
|
||||
SEAD_RTTI_OVERRIDE(AttClientList, Resource)
|
||||
public:
|
||||
@@ -26,7 +28,7 @@ public:
|
||||
agl::utl::Parameter<sead::SafeString> file_name;
|
||||
agl::utl::Parameter<bool> is_valid;
|
||||
agl::utl::ParameterObj obj;
|
||||
void* _a0;
|
||||
AttClient* client;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Client, 0xa8);
|
||||
|
||||
@@ -36,6 +38,8 @@ public:
|
||||
bool isForceEdit() const { return mForceEdit.ref(); }
|
||||
const sead::Buffer<Client>& getClients() const { return mClients; }
|
||||
|
||||
void addClient_(s32 index, AttClient* client) { mClients[index].client = client; }
|
||||
|
||||
private:
|
||||
agl::utl::ParameterList mAttClientsList;
|
||||
agl::utl::ParameterObj mAttPosObj;
|
||||
|
||||
@@ -373,7 +373,7 @@ bool ResourceMgrTask::canUseSdCard() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ResourceMgrTask::returnFalse() const {
|
||||
bool ResourceMgrTask::isHostPath(const sead::SafeString&) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -634,6 +634,12 @@ bool ResourceMgrTask::isCompactionStopped() const {
|
||||
return mCompactionCounter == 0;
|
||||
}
|
||||
|
||||
bool ResourceMgrTask::initTempResourceLoader(TempResourceLoader* loader,
|
||||
TempResourceLoader::InitArg& arg) {
|
||||
arg.work = mTexHandleMgr->getArchiveWork();
|
||||
return loader->init(arg);
|
||||
}
|
||||
|
||||
bool ResourceMgrTask::returnTrue1() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "KingSystem/Resource/resControlTask.h"
|
||||
#include "KingSystem/Resource/resCounter.h"
|
||||
#include "KingSystem/Resource/resInfoContainer.h"
|
||||
#include "KingSystem/Resource/resTempResourceLoader.h"
|
||||
#include "KingSystem/Resource/resUnit.h"
|
||||
#include "KingSystem/Resource/resUnitPool.h"
|
||||
#include "KingSystem/System/OverlayArena.h"
|
||||
@@ -162,7 +163,7 @@ public:
|
||||
sead::DirectResource* load(const DirectLoadArg& arg);
|
||||
|
||||
bool canUseSdCard() const;
|
||||
bool returnFalse() const;
|
||||
bool isHostPath(const sead::SafeString& path) const;
|
||||
|
||||
bool dropSFromExtensionIfNeeded(const sead::SafeString& path,
|
||||
sead::BufferedSafeString& new_path, s32 dot_idx,
|
||||
@@ -213,6 +214,8 @@ public:
|
||||
void setCompactionStopped(bool stopped);
|
||||
bool isCompactionStopped() const;
|
||||
|
||||
bool initTempResourceLoader(TempResourceLoader* loader, TempResourceLoader::InitArg& arg);
|
||||
|
||||
bool returnTrue1();
|
||||
|
||||
void clearCacheWithFileExtension(const sead::SafeString& extension);
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
class RagdollConfig;
|
||||
|
||||
class RagdollConfigList : public ParamIO, public Resource {
|
||||
SEAD_RTTI_OVERRIDE(RagdollConfigList, Resource)
|
||||
public:
|
||||
struct ImpulseParam {
|
||||
agl::utl::Parameter<sead::SafeString> file_name;
|
||||
agl::utl::ParameterObj obj;
|
||||
void* _58;
|
||||
RagdollConfig* config;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ImpulseParam, 0x60);
|
||||
|
||||
@@ -39,7 +41,11 @@ public:
|
||||
const sead::Buffer<ImpulseParam>& getImpulseParams() const { return mImpulseParams; }
|
||||
f32 getUpperLimitHeight() const { return mUpperLimitHeight.ref(); }
|
||||
f32 getLowerLimitHeight() const { return mLowerLimitHeight.ref(); }
|
||||
const sead::Buffer<BodyParam>& getMBodyParams() const { return mBodyParams; }
|
||||
const sead::Buffer<BodyParam>& getBodyParams() const { return mBodyParams; }
|
||||
|
||||
void addImpulseParamConfig_(s32 index, RagdollConfig* config) {
|
||||
mImpulseParams[index].config = config;
|
||||
}
|
||||
|
||||
private:
|
||||
agl::utl::ParameterList mImpulseParamList;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "KingSystem/Resource/resSystem.h"
|
||||
#include "KingSystem/Resource/resResourceMgrTask.h"
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
@@ -6,6 +7,10 @@ bool stubbedLogFunction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isHostPath(const sead::SafeString& path) {
|
||||
return ResourceMgrTask::instance()->isHostPath(path);
|
||||
}
|
||||
|
||||
bool returnFalse() {
|
||||
return false;
|
||||
}
|
||||
@@ -14,6 +19,10 @@ bool returnFalse2(const sead::SafeString&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool returnFalse3(const sead::SafeString&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 getDefaultAlignment() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class EntryFactoryBase;
|
||||
void registerEntryFactory(EntryFactoryBase* factory, const sead::SafeString& name);
|
||||
void unregisterEntryFactory(EntryFactoryBase* factory);
|
||||
|
||||
bool isHostPath(const sead::SafeString& path);
|
||||
|
||||
// In release builds, the only thing this function does is return 1.
|
||||
// TODO: figure out what this is used for. Stubbed log function?
|
||||
bool stubbedLogFunction();
|
||||
@@ -21,6 +23,8 @@ bool returnFalse();
|
||||
// TODO: figure out what this is used for. Stubbed log function?
|
||||
bool returnFalse2(const sead::SafeString&);
|
||||
|
||||
bool returnFalse3(const sead::SafeString& path);
|
||||
|
||||
s32 getDefaultAlignment();
|
||||
|
||||
} // namespace ksys::res
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
class ArchiveWork;
|
||||
|
||||
// TODO: very incomplete
|
||||
class TextureHandleMgr {
|
||||
public:
|
||||
virtual ~TextureHandleMgr();
|
||||
|
||||
ArchiveWork* getArchiveWork() const;
|
||||
void clearAllCache();
|
||||
};
|
||||
|
||||
|
||||
@@ -16,12 +16,13 @@ public:
|
||||
bool applyResourceUpdate(const char* data, const char* data1);
|
||||
|
||||
u32 getIdx() const { return mIdx; }
|
||||
const sead::SafeString& getId() const { return mId; }
|
||||
sead::BufferedSafeString& getPath() { return mPath; }
|
||||
const sead::BufferedSafeString& getPath() const { return mPath; }
|
||||
void setIndex(u32 idx) { mIdx = idx; }
|
||||
|
||||
protected:
|
||||
u32 mIdx = 0x1c;
|
||||
sead::FixedSafeString<128> mId;
|
||||
sead::FixedSafeString<128> mPath;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ParamIO, 0x278);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user