ksys/act: Add ActorTemplate

This commit is contained in:
Léo Lam 2020-11-08 15:33:57 +01:00
parent a9ec880f2e
commit f128251414
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
5 changed files with 146 additions and 13 deletions

View File

@ -85591,18 +85591,18 @@
0x0000007101089dd0,sub_7101089DD0,36,_ZN4ksys3res12ActorCapture9LightInfoD2Ev
0x0000007101089df4,j__ZdlPv_1143,4,_ZN4ksys3res12ActorCapture9LightInfoD0Ev
0x0000007101089f6c,sub_7101089F6C,100,_GLOBAL__sub_I_resResourceActorCapture.cpp?
0x0000007101089fd0,sub_7101089FD0,100,
0x000000710108a034,sub_710108A034,108,
0x000000710108a0a0,ActorTemplate::createInstance,148,
0x000000710108a134,sub_710108A134,60,
0x000000710108a170,sub_710108A170,60,
0x000000710108a1ac,ActorTemplate::init,76,
0x000000710108a1f8,ActorTemplate::getActorClassFromProfile,252,
0x000000710108a2f4,sub_710108A2F4,184,
0x000000710108a3ac,sub_710108A3AC,292,
0x000000710108a4d0,sub_710108A4D0,240,
0x000000710108a5c0,ActorTemplate::getNumEntries,8,
0x000000710108a5c8,ActorTemplate::getKeyNameByIdx,76,
0x0000007101089fd0,sub_7101089FD0,100,_ZN4ksys3act13ActorTemplate18SingletonDisposer_D2Ev
0x000000710108a034,sub_710108A034,108,_ZN4ksys3act13ActorTemplate18SingletonDisposer_D0Ev
0x000000710108a0a0,ActorTemplate::createInstance,148,_ZN4ksys3act13ActorTemplate14createInstanceEPN4sead4HeapE
0x000000710108a134,sub_710108A134,60,_ZN4ksys3act13ActorTemplateD1Ev
0x000000710108a170,sub_710108A170,60,_ZN4ksys3act13ActorTemplateD0Ev
0x000000710108a1ac,ActorTemplate::init,76,_ZN4ksys3act13ActorTemplate4initEPKhPN4sead4HeapE
0x000000710108a1f8,ActorTemplate::getActorClassFromProfile,252,_ZNK4ksys3act13ActorTemplate13getActorClassEPPKcS3_
0x000000710108a2f4,sub_710108A2F4,184,_ZNK4ksys3act13ActorTemplate24getNumAttPriorityEntriesEPKc
0x000000710108a3ac,sub_710108A3AC,292,_ZNK4ksys3act13ActorTemplate14getAttPriorityEPPKcS3_i
0x000000710108a4d0,sub_710108A4D0,240,_ZNK4ksys3act13ActorTemplate17getAttDefPriorityEPPKcS3_
0x000000710108a5c0,ActorTemplate::getNumEntries,8,_ZNK4ksys3act13ActorTemplate14getNumProfilesEv
0x000000710108a5c8,ActorTemplate::getKeyNameByIdx,76,_ZNK4ksys3act13ActorTemplate14getProfileNameEi
0x000000710108a614,nullsub_4457,4,
0x000000710108a618,sub_710108A618,8,
0x000000710108a620,sub_710108A620,8,

Can't render this file because it is too large.

View File

@ -12,6 +12,8 @@ target_sources(uking PRIVATE
actActorParam.h
actActorParamMgr.cpp
actActorParamMgr.h
actActorTemplate.cpp
actActorTemplate.h
actAiAction.cpp
actAiAction.h
actAiClass.cpp

View File

@ -0,0 +1,90 @@
#include "KingSystem/ActorSystem/actActorTemplate.h"
#include "KingSystem/ActorSystem/actActorParamMgr.h"
#include "KingSystem/Utils/Byaml.h"
#include "KingSystem/Utils/SafeDelete.h"
namespace ksys::act {
SEAD_SINGLETON_DISPOSER_IMPL(ActorTemplate)
ActorTemplate::~ActorTemplate() {
util::safeDelete(mIter);
}
void ActorTemplate::init(const u8* data, sead::Heap* heap) {
mIter = new (heap) al::ByamlIter(data);
}
bool ActorTemplate::getActorClass(const char** actor_class, const char* profile) const {
*actor_class = "Dummy";
al::ByamlIter iter;
if (mIter->tryGetIterByKey(&iter, profile)) {
if (iter.tryGetStringByKey(actor_class, "class"))
return true;
ActorParamMgr::instance()->getDebugMessage().log("[%s] classの定義がありません", profile);
} else {
ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile);
}
return false;
}
s32 ActorTemplate::getNumAttPriorityEntries(const char* profile) const {
al::ByamlIter iter;
if (mIter->tryGetIterByKey(&iter, profile)) {
al::ByamlIter attpriority;
if (iter.tryGetIterByKey(&attpriority, "attpriority"))
return attpriority.getSize();
} else {
ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile);
}
return 0;
}
bool ActorTemplate::getAttPriority(const char** priority, const char* profile, s32 idx) const {
*priority = "Obj";
al::ByamlIter iter;
if (mIter->tryGetIterByKey(&iter, profile)) {
al::ByamlIter attpriority;
if (!iter.tryGetIterByKey(&attpriority, "attpriority"))
return false;
if (attpriority.tryGetStringByIndex(priority, idx))
return true;
ActorParamMgr::instance()->getDebugMessage().log(
"[%s]指定できるアテンションの優先度のインデックスが範囲外です(%d)", profile, idx);
return false;
}
ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile);
return false;
}
bool ActorTemplate::getAttDefPriority(const char** priority, const char* profile) const {
al::ByamlIter iter;
if (mIter->tryGetIterByKey(&iter, profile)) {
if (iter.tryGetStringByKey(priority, "attdefpriority"))
return true;
ActorParamMgr::instance()->getDebugMessage().log(
"[%s] ActorTemplate.xmlでAttDefaultPriorityが未定義です", profile);
return false;
}
ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile);
return false;
}
s32 ActorTemplate::getNumProfiles() const {
return mIter->getSize();
}
const char* ActorTemplate::getProfileName(s32 idx) const {
const char* name = nullptr;
al::ByamlIter iter;
mIter->tryGetIterAndKeyNameByIndex(&iter, &name, idx);
return name;
}
} // namespace ksys::act

View File

@ -0,0 +1,31 @@
#pragma once
#include <heap/seadDisposer.h>
#include "KingSystem/Utils/Types.h"
namespace al {
class ByamlIter;
}
namespace ksys::act {
class ActorTemplate {
SEAD_SINGLETON_DISPOSER(ActorTemplate)
virtual ~ActorTemplate();
public:
void init(const u8* data, sead::Heap* heap);
bool getActorClass(const char** actor_class, const char* profile) const;
s32 getNumAttPriorityEntries(const char* profile) const;
bool getAttPriority(const char** priority, const char* profile, s32 idx) const;
bool getAttDefPriority(const char** priority, const char* profile) const;
s32 getNumProfiles() const;
const char* getProfileName(s32 idx) const;
private:
al::ByamlIter* mIter = nullptr;
};
KSYS_CHECK_SIZE_NX150(ActorTemplate, 0x30);
} // namespace ksys::act

View File

@ -8,12 +8,22 @@
namespace ksys {
struct DebugMessage {
struct Buffer {
~Buffer() {
if (buffer && _8)
buffer[0x44] = 1;
}
char* buffer;
bool _8;
};
DebugMessage() = default;
explicit DebugMessage(const sead::SafeString& msg) : message(msg) {}
virtual ~DebugMessage() { ; }
void log(const char* format, ...);
Buffer log(const char* format, ...);
u64 _8 = 0;
sead::FixedSafeString<64> message;