diff options
Diffstat (limited to 'src')
33 files changed, 233 insertions, 241 deletions
diff --git a/src/Game/Actor/Query/queryIsSuccessEndLastDemoAction.cpp b/src/Game/Actor/Query/queryIsSuccessEndLastDemoAction.cpp index 6c79cdc9..6d9dda5c 100644 --- a/src/Game/Actor/Query/queryIsSuccessEndLastDemoAction.cpp +++ b/src/Game/Actor/Query/queryIsSuccessEndLastDemoAction.cpp @@ -1,7 +1,7 @@ #include "Game/Actor/Query/queryIsSuccessEndLastDemoAction.h" #include <evfl/Query.h> #include "KingSystem/ActorSystem/actActor.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" namespace uking::query { diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index c83f97de..e0b70bfd 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -13,9 +13,6 @@ target_sources(uking PRIVATE Awareness/actAwarenessInstance.h - LOD/actLodState.cpp - LOD/actLodState.h - Profiles/actRopeBase.cpp Profiles/actRopeBase.h Profiles/actWeaponBase.cpp @@ -62,10 +59,6 @@ target_sources(uking PRIVATE actAiQuery.h actAiQueries.cpp actAiQueries.h - actAiRoot.cpp - actAiRoot.h - actASSetting.cpp - actASSetting.h actBaseProc.cpp actBaseProc.h actBaseProcAccessor.cpp @@ -99,6 +92,8 @@ target_sources(uking PRIVATE actClusteredRenderer.h actDebug.cpp actDebug.h + actDebugFinder.cpp + actDebugFinder.h actGlobalParameter.cpp actGlobalParameter.h actIDamageManager.cpp @@ -110,6 +105,8 @@ target_sources(uking PRIVATE actInstParamPack.cpp actInstParamPack.h actLifeRecoveryInfo.h + actLodState.cpp + actLodState.h actPhysicsConstraints.cpp actPhysicsConstraints.h actPhysicsUserTag.cpp @@ -134,6 +131,8 @@ target_sources(uking PRIVATE aiFork6AI.h aiForkAI.cpp aiForkAI.h + aiRootAi.cpp + aiRootAi.h behaviorDummyBehavior.cpp behaviorDummyBehavior.h diff --git a/src/KingSystem/ActorSystem/actASSetting.cpp b/src/KingSystem/ActorSystem/actASSetting.cpp deleted file mode 100644 index 2b020cfe..00000000 --- a/src/KingSystem/ActorSystem/actASSetting.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "KingSystem/ActorSystem/actASSetting.h" -#include "KingSystem/Resource/resLoadRequest.h" -#include "KingSystem/Resource/resResourceASSetting.h" - -namespace ksys::act { - -SEAD_SINGLETON_DISPOSER_IMPL(ASSetting) - -ASSetting::~ASSetting() = default; - -void ASSetting::init(const sead::SafeString& config_path, sead::Heap* heap) { - res::LoadRequest req; - req.mRequester = "ASSetting"; - req._22 = true; - mHandle.load(config_path, &req); -} - -// NON_MATCHING: sead::DirectResource to res::ASSetting cast nullptr check; branching for the return -res::ASParamParser* ASSetting::getBoneParams(const sead::SafeString& key) const { - auto* res = sead::DynamicCast<res::ASSetting>(mHandle.getResource()); - if (!res) - return nullptr; - - for (auto& bones : res->getBlenderBones()) { - if (key == bones.mKeyName.ref()) - return &bones.mBoneParams; - } - return nullptr; -} - -} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actASSetting.h b/src/KingSystem/ActorSystem/actASSetting.h deleted file mode 100644 index 8c97c85a..00000000 --- a/src/KingSystem/ActorSystem/actASSetting.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include <heap/seadDisposer.h> -#include <prim/seadSafeString.h> -#include "KingSystem/Resource/resHandle.h" -#include "KingSystem/Resource/resResourceASSetting.h" -#include "KingSystem/Utils/Types.h" - -namespace ksys::act { - -// FIXME: very incomplete -class ASSetting { - SEAD_SINGLETON_DISPOSER(ASSetting) - ASSetting() = default; - virtual ~ASSetting(); - -public: - void init(const sead::SafeString& config_path, sead::Heap* heap); - res::ASParamParser* getBoneParams(const sead::SafeString& key) const; - -private: - res::Handle mHandle; -}; -KSYS_CHECK_SIZE_NX150(ASSetting, 0x78); - -} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActor.cpp b/src/KingSystem/ActorSystem/actActor.cpp index ec7f3ea1..40432678 100644 --- a/src/KingSystem/ActorSystem/actActor.cpp +++ b/src/KingSystem/ActorSystem/actActor.cpp @@ -1,8 +1,8 @@ #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" -#include "KingSystem/ActorSystem/actAiRoot.h" #include "KingSystem/ActorSystem/actBaseProcLink.h" #include "KingSystem/ActorSystem/actBaseProcMgr.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Physics/System/physInstanceSet.h" namespace ksys::act { diff --git a/src/KingSystem/ActorSystem/actActorEditorNode.cpp b/src/KingSystem/ActorSystem/actActorEditorNode.cpp index 47b6621e..ecb1bf00 100644 --- a/src/KingSystem/ActorSystem/actActorEditorNode.cpp +++ b/src/KingSystem/ActorSystem/actActorEditorNode.cpp @@ -1,5 +1,5 @@ #include "KingSystem/ActorSystem/actActorEditorNode.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/System/KingEditor.h" namespace ksys::act { diff --git a/src/KingSystem/ActorSystem/actActorLinkConstDataAccess.cpp b/src/KingSystem/ActorSystem/actActorLinkConstDataAccess.cpp index 591df49e..e7ce2c15 100644 --- a/src/KingSystem/ActorSystem/actActorLinkConstDataAccess.cpp +++ b/src/KingSystem/ActorSystem/actActorLinkConstDataAccess.cpp @@ -3,8 +3,8 @@ #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/ActorSystem/actActorUtil.h" -#include "KingSystem/ActorSystem/actAiRoot.h" #include "KingSystem/ActorSystem/actBaseProc.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Map/mapObject.h" #include "KingSystem/Resource/Actor/resResourceGParamList.h" #include "KingSystem/Resource/GeneralParamList/resGParamListObjectAttack.h" diff --git a/src/KingSystem/ActorSystem/actActorParamMgr.cpp b/src/KingSystem/ActorSystem/actActorParamMgr.cpp index fdf9c870..2ff51d04 100644 --- a/src/KingSystem/ActorSystem/actActorParamMgr.cpp +++ b/src/KingSystem/ActorSystem/actActorParamMgr.cpp @@ -1,11 +1,11 @@ #include "KingSystem/ActorSystem/actActorParamMgr.h" #include <prim/seadScopedLock.h> -#include "KingSystem/ActorSystem/actASSetting.h" #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" #include "KingSystem/Resource/Actor/resResourceAISchedule.h" #include "KingSystem/Resource/Actor/resResourceAS.h" #include "KingSystem/Resource/Actor/resResourceASList.h" +#include "KingSystem/Resource/Actor/resResourceASSettingMgr.h" #include "KingSystem/Resource/Actor/resResourceActorLink.h" #include "KingSystem/Resource/Actor/resResourceAnimInfo.h" #include "KingSystem/Resource/Actor/resResourceAttClient.h" @@ -140,13 +140,13 @@ void ActorParamMgr::init(sead::Heap* heap, sead::Heap* debug_heap) { res::registerEntryFactory(new (mTempHeap) res::EntryFactory<res::ASSetting>(0.0, 0x80000), "bassetting"); - ASSetting::createInstance(mTempHeap); - ASSetting::instance()->init("Actor/ASSetting.bassetting", mTempHeap); + res::ASSettingMgr::createInstance(mTempHeap); + res::ASSettingMgr::instance()->init("Actor/ASSetting.bassetting", mTempHeap); ActorParam::resetDummyResources(); } ActorParamMgr::~ActorParamMgr() { - ASSetting::deleteInstance(); + res::ASSettingMgr::deleteInstance(); } bool ActorParamMgr::checkPath(const sead::SafeString& path) const { diff --git a/src/KingSystem/ActorSystem/actAiAction.cpp b/src/KingSystem/ActorSystem/actAiAction.cpp index 4c57a5e6..721afb09 100644 --- a/src/KingSystem/ActorSystem/actAiAction.cpp +++ b/src/KingSystem/ActorSystem/actAiAction.cpp @@ -2,8 +2,8 @@ #include <codec/seadHashCRC32.h> #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" -#include "KingSystem/ActorSystem/actAiRoot.h" #include "KingSystem/ActorSystem/actionDummyAction.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" namespace ksys::act::ai { diff --git a/src/KingSystem/ActorSystem/actAiActionBase.cpp b/src/KingSystem/ActorSystem/actAiActionBase.cpp index 81320ef1..794ec395 100644 --- a/src/KingSystem/ActorSystem/actAiActionBase.cpp +++ b/src/KingSystem/ActorSystem/actAiActionBase.cpp @@ -3,7 +3,7 @@ #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/ActorSystem/actAiAction.h" #include "KingSystem/ActorSystem/actAiInlineParam.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" #include "KingSystem/Utils/InitTimeInfo.h" #include "KingSystem/Utils/Thread/MessageTransceiverId.h" diff --git a/src/KingSystem/ActorSystem/actAiAi.cpp b/src/KingSystem/ActorSystem/actAiAi.cpp index 26949474..7602eb47 100644 --- a/src/KingSystem/ActorSystem/actAiAi.cpp +++ b/src/KingSystem/ActorSystem/actAiAi.cpp @@ -5,8 +5,8 @@ #include "KingSystem/ActorSystem/actAiAction.h" #include "KingSystem/ActorSystem/actAiClassDef.h" #include "KingSystem/ActorSystem/actAiInlineParam.h" -#include "KingSystem/ActorSystem/actAiRoot.h" #include "KingSystem/ActorSystem/aiDummyAi.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" namespace ksys::act::ai { diff --git a/src/KingSystem/ActorSystem/actAiBehavior.cpp b/src/KingSystem/ActorSystem/actAiBehavior.cpp index 2f868984..d6e31cd4 100644 --- a/src/KingSystem/ActorSystem/actAiBehavior.cpp +++ b/src/KingSystem/ActorSystem/actAiBehavior.cpp @@ -1,7 +1,7 @@ #include "KingSystem/ActorSystem/actAiBehavior.h" #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/ActorSystem/behaviorDummyBehavior.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" diff --git a/src/KingSystem/ActorSystem/actAiQuery.cpp b/src/KingSystem/ActorSystem/actAiQuery.cpp index 97f9ac33..cbfef6c0 100644 --- a/src/KingSystem/ActorSystem/actAiQuery.cpp +++ b/src/KingSystem/ActorSystem/actAiQuery.cpp @@ -3,7 +3,7 @@ #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/ActorSystem/actAiClassDef.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/Resource/Actor/resResourceAIProgram.h" namespace ksys::act::ai { diff --git a/src/KingSystem/System/DebugFinder.cpp b/src/KingSystem/ActorSystem/actDebugFinder.cpp index 7e5a1d82..54b4e1f8 100644 --- a/src/KingSystem/System/DebugFinder.cpp +++ b/src/KingSystem/ActorSystem/actDebugFinder.cpp @@ -1,6 +1,6 @@ -#include "KingSystem/System/DebugFinder.h" +#include "KingSystem/ActorSystem/actDebugFinder.h" -namespace ksys { +namespace ksys::act { SEAD_SINGLETON_DISPOSER_IMPL(DebugFinder) @@ -8,4 +8,4 @@ DebugFinder::DebugFinder() = default; DebugFinder::~DebugFinder() = default; -} // namespace ksys +} // namespace ksys::act diff --git a/src/KingSystem/System/DebugFinder.h b/src/KingSystem/ActorSystem/actDebugFinder.h index 16eb4e4c..3ca020ca 100644 --- a/src/KingSystem/System/DebugFinder.h +++ b/src/KingSystem/ActorSystem/actDebugFinder.h @@ -3,7 +3,7 @@ #include <heap/seadDisposer.h> #include <prim/seadSafeString.h> -namespace ksys { +namespace ksys::act { class DebugFinder { SEAD_SINGLETON_DISPOSER(DebugFinder) @@ -16,4 +16,4 @@ private: u32 unused_3 = 0; }; -} // namespace ksys +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/LOD/actLodState.cpp b/src/KingSystem/ActorSystem/actLodState.cpp index 3b11296b..8625ab45 100644 --- a/src/KingSystem/ActorSystem/LOD/actLodState.cpp +++ b/src/KingSystem/ActorSystem/actLodState.cpp @@ -1,4 +1,4 @@ -#include "KingSystem/ActorSystem/LOD/actLodState.h" +#include "KingSystem/ActorSystem/actLodState.h" #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/ActorSystem/actActorUtil.h" diff --git a/src/KingSystem/ActorSystem/LOD/actLodState.h b/src/KingSystem/ActorSystem/actLodState.h index 817e1a82..817e1a82 100644 --- a/src/KingSystem/ActorSystem/LOD/actLodState.h +++ b/src/KingSystem/ActorSystem/actLodState.h diff --git a/src/KingSystem/ActorSystem/aiForkAI.cpp b/src/KingSystem/ActorSystem/aiForkAI.cpp index d8cd4249..5989bdba 100644 --- a/src/KingSystem/ActorSystem/aiForkAI.cpp +++ b/src/KingSystem/ActorSystem/aiForkAI.cpp @@ -1,5 +1,5 @@ #include "KingSystem/ActorSystem/aiForkAI.h" -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" namespace ksys::act::ai { diff --git a/src/KingSystem/ActorSystem/actAiRoot.cpp b/src/KingSystem/ActorSystem/aiRootAi.cpp index 0aa8f4ac..2706a208 100644 --- a/src/KingSystem/ActorSystem/actAiRoot.cpp +++ b/src/KingSystem/ActorSystem/aiRootAi.cpp @@ -1,4 +1,4 @@ -#include "KingSystem/ActorSystem/actAiRoot.h" +#include "KingSystem/ActorSystem/aiRootAi.h" #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actAiClassDef.h" #include "KingSystem/Utils/InitTimeInfo.h" diff --git a/src/KingSystem/ActorSystem/actAiRoot.h b/src/KingSystem/ActorSystem/aiRootAi.h index c9b61df6..c9b61df6 100644 --- a/src/KingSystem/ActorSystem/actAiRoot.h +++ b/src/KingSystem/ActorSystem/aiRootAi.h diff --git a/src/KingSystem/Map/CMakeLists.txt b/src/KingSystem/Map/CMakeLists.txt index b201b701..52a8c659 100644 --- a/src/KingSystem/Map/CMakeLists.txt +++ b/src/KingSystem/Map/CMakeLists.txt @@ -26,6 +26,4 @@ target_sources(uking PRIVATE mapPlacementTree.h mapRail.cpp mapRail.h - mapStagePreActorCache.cpp - mapStagePreActorCache.h ) diff --git a/src/KingSystem/Map/mapObject.cpp b/src/KingSystem/Map/mapObject.cpp index a22274f2..c5e838a7 100644 --- a/src/KingSystem/Map/mapObject.cpp +++ b/src/KingSystem/Map/mapObject.cpp @@ -6,7 +6,7 @@ #include "KingSystem/Graphics/gfxForestRenderer.h" #include "KingSystem/Map/mapObjectLink.h" #include "KingSystem/Map/mapPlacementMgr.h" -#include "KingSystem/Map/mapStagePreActorCache.h" +#include "KingSystem/System/StagePreActorCache.h" #include "KingSystem/Terrain/teraSystem.h" #include "KingSystem/Utils/Debug.h" diff --git a/src/KingSystem/Map/mapPlacementAreaMgr.h b/src/KingSystem/Map/mapPlacementAreaMgr.h index dee435f5..e040c417 100644 --- a/src/KingSystem/Map/mapPlacementAreaMgr.h +++ b/src/KingSystem/Map/mapPlacementAreaMgr.h @@ -6,8 +6,8 @@ #include <prim/seadSafeString.h> #include <prim/seadTypedBitFlag.h> -#include "KingSystem/Map/mapStagePreActorCache.h" #include "KingSystem/Map/mapTypes.h" +#include "KingSystem/System/StagePreActorCache.h" #include "KingSystem/Utils/Types.h" namespace ksys::gdt { diff --git a/src/KingSystem/Map/mapPlacementMapMgr.h b/src/KingSystem/Map/mapPlacementMapMgr.h index 913c419a..6fb6d848 100644 --- a/src/KingSystem/Map/mapPlacementMapMgr.h +++ b/src/KingSystem/Map/mapPlacementMapMgr.h @@ -8,11 +8,14 @@ #include "KingSystem/Resource/resHandle.h" #include "KingSystem/Utils/Types.h" +namespace ksys::act { +class FarActorMerge; +} // namespace ksys::act + namespace ksys::map { class MapProperties; class Placement18; -class FarActorMerge; class PlacementActors; class PlacementMap; @@ -49,7 +52,7 @@ private: s32 _18; s32 _1c; PlacementMapArray mMapArray; - FarActorMerge* mFarActorMerge; + act::FarActorMerge* mFarActorMerge; s32 mNeedLoadDynMap; s32 mNeedLoadDynMapPhysics; bool mIsShrineOrDivineBeast; diff --git a/src/KingSystem/Map/mapStagePreActorCache.cpp b/src/KingSystem/Map/mapStagePreActorCache.cpp deleted file mode 100644 index cc853e2a..00000000 --- a/src/KingSystem/Map/mapStagePreActorCache.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "KingSystem/Map/mapStagePreActorCache.h" - -namespace ksys::map { - -SEAD_SINGLETON_DISPOSER_IMPL(StagePreActorCache) - -} // namespace ksys::map diff --git a/src/KingSystem/Resource/Actor/resResourceASResourceExtension.cpp b/src/KingSystem/Resource/Actor/resResourceASSetting.cpp index c44948f1..915bd1c4 100644 --- a/src/KingSystem/Resource/Actor/resResourceASResourceExtension.cpp +++ b/src/KingSystem/Resource/Actor/resResourceASSetting.cpp @@ -1,9 +1,10 @@ -#include "KingSystem/Resource/Actor/resResourceASResourceExtension.h" +#include "KingSystem/Resource/Actor/resResourceASSetting.h" #include <container/seadSafeArray.h> #include <optional> #include <prim/seadSafeString.h> -#include "KingSystem/ActorSystem/actASSetting.h" -#include "KingSystem/Resource/resResourceASSetting.h" +#include "KingSystem/Resource/Actor/resResourceASResourceExtension.h" +#include "KingSystem/Resource/Actor/resResourceASSettingMgr.h" +#include "KingSystem/Resource/resLoadRequest.h" namespace ksys::res { @@ -211,13 +212,41 @@ bool ASBitIndexParser::parse(const ASParamParser::ParseArgs& args) { return true; } -template <typename T> -static ASParamParser* factoryImpl_(sead::Heap* heap) { - return new (heap) T; +bool ASSetting::BoneParams::parse(const ASParamParser::ParseArgs& args) { + const auto num_objects = args.res_list.getResParameterObjNum(); + if (num_objects == 0) + return true; + + if (!mBuffer.tryAllocBuffer(num_objects, args.heap)) + return false; + + auto it = mBuffer.begin(); + const auto end = mBuffer.end(); + + sead::FixedSafeString<32> obj_name{"BoneParam"}; + const auto obj_name_base_len = obj_name.calcLength(); + + auto res_it = args.res_list.objBegin(); + const auto res_end = args.res_list.objEnd(); + + for (; it != end && res_it != res_end; ++it, ++res_it) { + it->mBone.init("", "Bone", "ボーン名", "", &it->mObj); + it->mWeight.init(0.0, "Weight", "ウェイト値", "Min=0.f,Max=1.f", &it->mObj); + + obj_name.trim(obj_name_base_len); + obj_name.appendWithFormat("%d", res_it.getIndex()); + mList.addObj(&it->mObj, obj_name); + } + + return true; } -static ASParamParser* dummyASParserFactoryImpl_(sead::Heap*) { - return nullptr; +f32 ASSetting::BoneParams::getBoneWeight(const sead::SafeString& name) const { + for (const auto& param : mBuffer) { + if (name == *param.mBone) + return *param.mWeight; + } + return 1.0; } namespace { @@ -226,17 +255,7 @@ struct Factory { ASParamParser* (*make)(sead::Heap* heap); }; -sead::SafeArray<Factory, ASParamParser::NumTypes> sASFactories{{ - {"FrameCtrl", factoryImpl_<ASFrameCtrlParser>}, - {"TriggerEvents", factoryImpl_<ASTriggerEventsParser>}, - {"HoldEvents", factoryImpl_<ASHoldEventsParser>}, - {"StringArray", factoryImpl_<ASStringArrayParser>}, - {"Ranges", factoryImpl_<ASRangesParser>}, - {"FloatArray", factoryImpl_<ASFloatArrayParser>}, - {"IntArray", factoryImpl_<ASIntArrayParser>}, - {"BitIndex", factoryImpl_<ASBitIndexParser>}, - {"BlenderBone", dummyASParserFactoryImpl_}, -}}; +extern sead::SafeArray<Factory, ASParamParser::NumTypes> sASFactories; } // namespace ASExtensions::~ASExtensions() { @@ -304,7 +323,7 @@ ASParamParser* ASExtensions::makeParser(const ASParamParser::ParseArgs& args) co const auto obj = args.res_list.getResParameterObj(0); if (obj.getNum() > 0) { const sead::SafeString name = obj.getResParameter(0).getData<const char>(); - return act::ASSetting::instance()->getBoneParams(name); + return ASSettingMgr::instance()->getBoneParams(name); } } @@ -326,6 +345,19 @@ ASParamParser* ASExtensions::makeParser(const ASParamParser::ParseArgs& args) co return parser; } +// NON_MATCHING: sead::DirectResource to res::ASSetting cast nullptr check; branching for the return +ASParamParser* ASSettingMgr::getBoneParams(const sead::SafeString& key) const { + auto* res = sead::DynamicCast<ASSetting>(mHandle.getResource()); + if (!res) + return nullptr; + + for (auto& bones : res->getBlenderBones()) { + if (key == bones.mKeyName.ref()) + return &bones.mBoneParams; + } + return nullptr; +} + ASParamParser* ASExtensions::getParser(ASParamParser::Type type) const { for (int i = 0, n = mParsers.size(); i < n; ++i) { auto* parser = mParsers[i]; @@ -335,4 +367,106 @@ ASParamParser* ASExtensions::getParser(ASParamParser::Type type) const { return nullptr; } +ASSetting::ASSetting() { + mType = "assetting"; + mVersion = 0; +} + +ASSetting::~ASSetting() { + mBlenderBones.freeBuffer(); +} + +void ASSetting::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {} + +bool allocBlenderBones(sead::Buffer<ASSetting::BlenderBone>& buffer, int size, sead::Heap* heap, + int align = sizeof(void*)); + +bool ASSetting::parse_(u8* data, size_t size, sead::Heap* heap) { + if (!data) + return true; + + agl::utl::ResParameterArchive archive{data}; + const auto root = archive.getRootList(); + + addList(&mBlenderBoneList, "BlenderBone"); + + const auto lists = agl::utl::getResParameterList(root, "BlenderBone"); + if (!lists.ptr()) + return true; + + const auto num_blender_bones = lists.getResParameterListNum(); + if (num_blender_bones == 0) + return true; + + if (!allocBlenderBones(mBlenderBones, num_blender_bones, heap)) + return false; + + auto res_it = lists.listBegin(); + const auto res_it_end = lists.listEnd(); + sead::FixedSafeString<32> list_name{"BlenderBone"}; + const auto list_name_base_len = list_name.calcLength(); + + ASParamParser::ParseArgs args; + args.res_list = {}; + args.heap = heap; + + auto it = mBlenderBones.begin(); + const auto end = mBlenderBones.end(); + for (; it != end && res_it != res_it_end; ++it, ++res_it) { + list_name.trim(list_name_base_len); + list_name.appendWithFormat("%d", it.getIndex()); + mBlenderBoneList.addList(&it->mList, list_name); + + it->mKeyName.init("", "KeyName", "キー名", "", &it->mNameParamObj); + it->mList.addObj(&it->mNameParamObj, "NameParam"); + it->mList.addList(&it->mBoneParams.getList(), "BoneParam"); + + const auto list = *res_it; + args.list = &it->mList; + args.res_list = agl::utl::getResParameterList(list, "BoneParam"); + if (!it->mBoneParams.parse(args)) + return false; + } + + applyResParameterArchive(archive); + return true; +} + +bool allocBlenderBones(sead::Buffer<ASSetting::BlenderBone>& buffer, int size, sead::Heap* heap, + int align) { + return buffer.tryAllocBuffer(size, heap, align); +} + +SEAD_SINGLETON_DISPOSER_IMPL(ASSettingMgr) + +void ASSettingMgr::init(const sead::SafeString& config_path, sead::Heap* heap) { + LoadRequest req; + req.mRequester = "ASSetting"; + req._22 = true; + mHandle.load(config_path, &req); +} + +template <typename T> +static ASParamParser* factoryImpl_(sead::Heap* heap) { + return new (heap) T; +} + +static ASParamParser* dummyASParserFactoryImpl_(sead::Heap*) { + return nullptr; +} + +namespace { +sead::SafeArray<Factory, ASParamParser::NumTypes> sASFactories{{ + {"FrameCtrl", factoryImpl_<ASFrameCtrlParser>}, + {"TriggerEvents", factoryImpl_<ASTriggerEventsParser>}, + {"HoldEvents", factoryImpl_<ASHoldEventsParser>}, + {"StringArray", factoryImpl_<ASStringArrayParser>}, + {"Ranges", factoryImpl_<ASRangesParser>}, + {"FloatArray", factoryImpl_<ASFloatArrayParser>}, + {"IntArray", factoryImpl_<ASIntArrayParser>}, + {"BitIndex", factoryImpl_<ASBitIndexParser>}, + {"BlenderBone", dummyASParserFactoryImpl_}, +}}; +} // namespace + } // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceASSetting.h b/src/KingSystem/Resource/Actor/resResourceASSetting.h index c9462199..84575fc4 100644 --- a/src/KingSystem/Resource/resResourceASSetting.h +++ b/src/KingSystem/Resource/Actor/resResourceASSetting.h @@ -29,7 +29,7 @@ public: SEAD_RTTI_OVERRIDE(BoneParams, ASParamParser) public: BoneParams() : ASParamParser(Type::BlenderBone) {} - ~BoneParams() override; + ~BoneParams() override { mBuffer.freeBuffer(); } bool parse(const ParseArgs& args) override; f32 getBoneWeight(const sead::SafeString& name) const; diff --git a/src/KingSystem/Resource/Actor/resResourceASSettingMgr.h b/src/KingSystem/Resource/Actor/resResourceASSettingMgr.h new file mode 100644 index 00000000..e4d16984 --- /dev/null +++ b/src/KingSystem/Resource/Actor/resResourceASSettingMgr.h @@ -0,0 +1,26 @@ +#pragma once + +#include <heap/seadDisposer.h> +#include <prim/seadSafeString.h> +#include "KingSystem/Resource/Actor/resResourceASSetting.h" +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +// FIXME: very incomplete +class ASSettingMgr { + SEAD_SINGLETON_DISPOSER(ASSettingMgr) + ASSettingMgr() = default; + virtual ~ASSettingMgr() = default; + +public: + void init(const sead::SafeString& config_path, sead::Heap* heap); + ASParamParser* getBoneParams(const sead::SafeString& key) const; + +private: + Handle mHandle; +}; +KSYS_CHECK_SIZE_NX150(ASSettingMgr, 0x78); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/CMakeLists.txt b/src/KingSystem/Resource/CMakeLists.txt index 1a9e5b28..825fe47a 100644 --- a/src/KingSystem/Resource/CMakeLists.txt +++ b/src/KingSystem/Resource/CMakeLists.txt @@ -128,8 +128,6 @@ target_sources(uking PRIVATE resResource.cpp resResource.h - resResourceASSetting.cpp - resResourceASSetting.h resResourceArchive.cpp resResourceArchive.h resResourceGameData.cpp @@ -153,8 +151,10 @@ target_sources(uking PRIVATE Actor/resResourceASList.h Actor/resResourceASResource.cpp Actor/resResourceASResource.h - Actor/resResourceASResourceExtension.cpp Actor/resResourceASResourceExtension.h + Actor/resResourceASSetting.cpp + Actor/resResourceASSetting.h + Actor/resResourceASSettingMgr.h Actor/resResourceAttCheck.cpp Actor/resResourceAttCheck.h Actor/resResourceAttClient.cpp diff --git a/src/KingSystem/Resource/resResourceASSetting.cpp b/src/KingSystem/Resource/resResourceASSetting.cpp deleted file mode 100644 index be0a3865..00000000 --- a/src/KingSystem/Resource/resResourceASSetting.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "KingSystem/Resource/resResourceASSetting.h" - -namespace ksys::res { - -ASSetting::ASSetting() { - mType = "assetting"; - mVersion = 0; -} - -ASSetting::~ASSetting() { - mBlenderBones.freeBuffer(); -} - -void ASSetting::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {} - -bool allocBlenderBones(sead::Buffer<ASSetting::BlenderBone>& buffer, int size, sead::Heap* heap, - int align = sizeof(void*)) { - return buffer.tryAllocBuffer(size, heap, align); -} - -bool ASSetting::parse_(u8* data, size_t size, sead::Heap* heap) { - if (!data) - return true; - - agl::utl::ResParameterArchive archive{data}; - const auto root = archive.getRootList(); - - addList(&mBlenderBoneList, "BlenderBone"); - - const auto lists = agl::utl::getResParameterList(root, "BlenderBone"); - if (!lists.ptr()) - return true; - - const auto num_blender_bones = lists.getResParameterListNum(); - if (num_blender_bones == 0) - return true; - - if (!allocBlenderBones(mBlenderBones, num_blender_bones, heap)) - return false; - - auto res_it = lists.listBegin(); - const auto res_it_end = lists.listEnd(); - sead::FixedSafeString<32> list_name{"BlenderBone"}; - const auto list_name_base_len = list_name.calcLength(); - - ASParamParser::ParseArgs args; - args.res_list = {}; - args.heap = heap; - - auto it = mBlenderBones.begin(); - const auto end = mBlenderBones.end(); - for (; it != end && res_it != res_it_end; ++it, ++res_it) { - list_name.trim(list_name_base_len); - list_name.appendWithFormat("%d", it.getIndex()); - mBlenderBoneList.addList(&it->mList, list_name); - - it->mKeyName.init("", "KeyName", "キー名", "", &it->mNameParamObj); - it->mList.addObj(&it->mNameParamObj, "NameParam"); - it->mList.addList(&it->mBoneParams.getList(), "BoneParam"); - - const auto list = *res_it; - args.list = &it->mList; - args.res_list = agl::utl::getResParameterList(list, "BoneParam"); - if (!it->mBoneParams.parse(args)) - return false; - } - - applyResParameterArchive(archive); - return true; -} - -ASSetting::BoneParams::~BoneParams() { - mBuffer.freeBuffer(); -} - -bool ASSetting::BoneParams::parse(const ASParamParser::ParseArgs& args) { - const auto num_objects = args.res_list.getResParameterObjNum(); - if (num_objects == 0) - return true; - - if (!mBuffer.tryAllocBuffer(num_objects, args.heap)) - return false; - - auto it = mBuffer.begin(); - const auto end = mBuffer.end(); - - sead::FixedSafeString<32> obj_name{"BoneParam"}; - const auto obj_name_base_len = obj_name.calcLength(); - - auto res_it = args.res_list.objBegin(); - const auto res_end = args.res_list.objEnd(); - - for (; it != end && res_it != res_end; ++it, ++res_it) { - it->mBone.init("", "Bone", "ボーン名", "", &it->mObj); - it->mWeight.init(0.0, "Weight", "ウェイト値", "Min=0.f,Max=1.f", &it->mObj); - - obj_name.trim(obj_name_base_len); - obj_name.appendWithFormat("%d", res_it.getIndex()); - mList.addObj(&it->mObj, obj_name); - } - - return true; -} - -f32 ASSetting::BoneParams::getBoneWeight(const sead::SafeString& name) const { - for (const auto& param : mBuffer) { - if (name == *param.mBone) - return *param.mWeight; - } - return 1.0; -} - -} // namespace ksys::res diff --git a/src/KingSystem/System/CMakeLists.txt b/src/KingSystem/System/CMakeLists.txt index 333d110d..81b08666 100644 --- a/src/KingSystem/System/CMakeLists.txt +++ b/src/KingSystem/System/CMakeLists.txt @@ -15,8 +15,6 @@ target_sources(uking PRIVATE CoreInfo.h CurrentResNameMgr.cpp CurrentResNameMgr.h - DebugFinder.cpp - DebugFinder.h DebugMessage.h GameConfig.h HavokWorkerMgr.cpp @@ -48,6 +46,8 @@ target_sources(uking PRIVATE Revision.h StageInfo.cpp StageInfo.h + StagePreActorCache.cpp + StagePreActorCache.h StarterPackMgr.cpp StarterPackMgr.h StringBoard.h diff --git a/src/KingSystem/System/StagePreActorCache.cpp b/src/KingSystem/System/StagePreActorCache.cpp new file mode 100644 index 00000000..0b4a6484 --- /dev/null +++ b/src/KingSystem/System/StagePreActorCache.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/System/StagePreActorCache.h" + +namespace ksys { + +SEAD_SINGLETON_DISPOSER_IMPL(StagePreActorCache) + +} // namespace ksys diff --git a/src/KingSystem/Map/mapStagePreActorCache.h b/src/KingSystem/System/StagePreActorCache.h index 666779e8..2b9927ff 100644 --- a/src/KingSystem/Map/mapStagePreActorCache.h +++ b/src/KingSystem/System/StagePreActorCache.h @@ -8,8 +8,10 @@ class ForestRenderer; } namespace ksys::map { - class LazyTraverseList; +} + +namespace ksys { // TODO class StagePreActorCache { @@ -17,13 +19,13 @@ class StagePreActorCache { StagePreActorCache(); public: - LazyTraverseList* getObjects() const { return mObjects; } + map::LazyTraverseList* getObjects() const { return mObjects; } auto* getForestRenderer() { return mForestRenderer; } private: char _0[0x20]; - LazyTraverseList* mObjects; + map::LazyTraverseList* mObjects; gfx::ForestRenderer* mForestRenderer; }; -} // namespace ksys::map +} // namespace ksys |
