summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem/actInfoData.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-11-22 12:27:07 +0100
committerLéo Lam <leo@leolam.fr>2020-11-22 15:36:18 +0100
commit622104fbd219117455c7a6776aea1658e36cd888 (patch)
treeebeaf572bed218de3c05717bb29cac6a1570081d /src/KingSystem/ActorSystem/actInfoData.cpp
parente99f0f8949978ed0c1ee2a3ad1255666a3639262 (diff)
ksys/act: Add more InfoData functions
Diffstat (limited to 'src/KingSystem/ActorSystem/actInfoData.cpp')
-rw-r--r--src/KingSystem/ActorSystem/actInfoData.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/KingSystem/ActorSystem/actInfoData.cpp b/src/KingSystem/ActorSystem/actInfoData.cpp
index af03b8a3..9d6427cb 100644
--- a/src/KingSystem/ActorSystem/actInfoData.cpp
+++ b/src/KingSystem/ActorSystem/actInfoData.cpp
@@ -2,6 +2,9 @@
#include <KingSystem/Resource/resModelResourceDivide.h>
#include <codec/seadHashCRC32.h>
#include <math/seadMathNumbers.h>
+#include "KingSystem/ActorSystem/actActorCreator.h"
+#include "KingSystem/ActorSystem/actDebug.h"
+#include "KingSystem/Event/evtEvent.h"
#include "KingSystem/Event/evtManager.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
#include "KingSystem/Utils/Byaml/ByamlArrayIter.h"
@@ -144,6 +147,35 @@ bool InfoData::getActorIter(al::ByamlIter* iter, const char* actor, bool x) cons
return false;
}
+bool InfoData::logFailure(const sead::SafeString& actor_name) const {
+#ifdef MATCHING_HACK_NX_CLANG
+ // This is required to prevent LLVM from detecting that 'this' is unused
+ // and optimizing out the passing of 'this' in callers.
+ __builtin_assume(mActorsBytes);
+#endif
+
+ auto* event = evt::Manager::instance()->getActiveEvent();
+ if (event && event->hasFlag(evt::Event::Flag::_80000000000))
+ return false;
+
+ if (!ActorCreator::instance()->get5a())
+ return false;
+
+ if (ActorDebug::instance() && ActorDebug::instance()->hasFlag(ActorDebug::Flag::_10000000))
+ return false;
+
+ if (actor_name.startsWith("MergedGrudge"))
+ return false;
+
+ if (actor_name.startsWith("Armor_50"))
+ return false;
+
+ if (actor_name == "Weapon_Sword_DemoCheck")
+ return false;
+
+ return true;
+}
+
void InfoData::getRecipeInfo(const char* actor, InfoData::RecipeInfo& info) const {
al::ByamlIter iter;
if (getActorIter(&iter, actor)) {
@@ -614,4 +646,84 @@ bool InfoData::hasDropEntry(const char* actor, const char* key) const {
return iter.isExistKey(key);
}
+s32 InfoData::getInstSize(const char* actor) const {
+ return getInt(actor, "instSize", 0, false);
+}
+
+u32 InfoData::getBugMask(const char* actor) const {
+ return getInt(actor, "bugMask");
+}
+
+u32 InfoData::getModelFlags(const char* actor) const {
+ u32 flags = 0x4000;
+ if (!actor)
+ return flags;
+
+ bool is_map_const = false;
+
+ {
+ const char* profile;
+ if (getActorProfile(&profile, actor)) {
+ const sead::SafeString profile_ = profile;
+ if (profile_ == "MapConstPassive" || profile_ == "MapConstActive")
+ is_map_const = true;
+ }
+ }
+
+ {
+ al::ByamlIter iter;
+ if (getActorIter(&iter, actor)) {
+ if (!hasTag(iter, tags::Tree))
+ flags |= 0x1000;
+ } else {
+ flags |= 0x1000;
+ }
+ }
+
+ s32 type = -1;
+ {
+ al::ByamlIter iter;
+ if (getActorIter(&iter, actor)) {
+ if (hasTag(iter, tags::Unk_0x4F4E1426))
+ type = 0;
+ else if (hasTag(iter, tags::PasteGrudgeSlime))
+ type = 1;
+ }
+ }
+
+ if (is_map_const)
+ flags &= ~0x1000;
+
+ if (type == 0 || (type != 1 && !is_map_const))
+ flags |= 0x2000;
+
+ if (is_map_const && type == 1)
+ flags |= 0x1000;
+
+ return flags;
+}
+
+bool InfoData::getVariationMatAnim(const char* actor, const char** anim, f32* frame) const {
+ al::ByamlIter iter;
+ if (!getActorIter(&iter, actor))
+ return false;
+
+ *anim = getStringByKey(iter, "variationMatAnim", sead::SafeString::cEmptyString);
+ *frame = getIntByKey(iter, "variationMatAnimFrame");
+ return (*anim)[0] != 0;
+}
+
+bool InfoData::getName(al::ByamlIter* iter, const char** name, s32 idx) const {
+ if (idx < 0 || idx >= mNumActors)
+ return false;
+
+ *iter = {mActorsBytes, mActorsBytes + mActorOffsets[idx]};
+ al::ByamlHashIter hash_iter{iter->getRootNode()};
+ al::ByamlData data;
+ if (!hash_iter.getDataByKey(&data, mNameIdx))
+ return false;
+
+ return iter->tryConvertString(name, &data);
+}
+
} // namespace ksys::act