mirror of
https://github.com/zeldaret/botw
synced 2026-09-08 03:16:55 -04:00
ksys/act: Add ActorTemplate
This commit is contained in:
@@ -12,6 +12,8 @@ target_sources(uking PRIVATE
|
||||
actActorParam.h
|
||||
actActorParamMgr.cpp
|
||||
actActorParamMgr.h
|
||||
actActorTemplate.cpp
|
||||
actActorTemplate.h
|
||||
actAiAction.cpp
|
||||
actAiAction.h
|
||||
actAiClass.cpp
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user