EventInfoData

This commit is contained in:
iTNTPiston
2021-01-29 15:49:49 -05:00
parent 189aaa2698
commit 641dd1613a
5 changed files with 120 additions and 10 deletions
+2
View File
@@ -1,6 +1,8 @@
target_sources(uking PRIVATE
evtEvent.cpp
evtEvent.h
evtInfoData.cpp
evtInfoData.h
evtManager.cpp
evtManager.h
)
+72
View File
@@ -0,0 +1,72 @@
#include "KingSystem/Event/evtInfoData.h"
#include <basis/seadNew.h>
#include <prim/seadSafeString.h>
#include <resource/seadResource.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/Resource/resLoadRequest.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
namespace ksys::evt {
SEAD_SINGLETON_DISPOSER_IMPL(InfoData)
InfoData::InfoData() = default;
void InfoData::init(sead::Heap* heap) {
doInit(heap, nullptr);
}
void InfoData::doInit(sead::Heap* heap, OverlayArena* arena) {
ksys::res::LoadRequest load_request;
load_request.mRequester = "evt::InfoData";
load_request._22 = true;
load_request.mArena = arena;
mHandle.load("Event/EventInfo.product.byml", &load_request, nullptr);
auto* resource = sead::DynamicCast<sead::DirectResource>(mHandle.getResource());
if (mRootIter)
delete mRootIter;
mRootIter = new (heap) al::ByamlIter(resource->getRawData());
}
InfoData::~InfoData() {
if (mRootIter)
delete mRootIter;
if (_80) {
delete _80;
}
}
bool InfoData::getEntry(al::ByamlIter* iter, const sead::SafeString& event_flow_name,
const sead::SafeString& entry_point) {
sead::FixedSafeString<256> formatted_key;
if (entry_point.isEmpty()) {
formatted_key.format("%s<%s>", event_flow_name.cstr(), event_flow_name.cstr());
} else {
formatted_key.format("%s<%s>", event_flow_name.cstr(), entry_point.cstr());
}
return mRootIter->tryGetIterByKey(iter, formatted_key.cstr());
}
bool InfoData::getSceneChangeEventTraverseLimit(const sead::SafeString& event_flow_name) {
if (event_flow_name != "ClearRemains") {
al::ByamlIter dict;
if (!getEntry(&dict, event_flow_name, "")) {
return false;
}
f32 value{};
if (!(dict.tryGetFloatByKey(&value, "traverse_limit") && value > 0.0)) {
return false;
}
}
return true;
}
} // namespace ksys::evt
+34
View File
@@ -0,0 +1,34 @@
#pragma once
#include <heap/seadDisposer.h>
#include <prim/seadSafeString.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/Resource/resLoadRequest.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
namespace ksys::evt {
class InfoDataUnknownType {
public:
virtual ~InfoDataUnknownType();
};
class InfoData {
SEAD_SINGLETON_DISPOSER(InfoData)
InfoData();
virtual ~InfoData();
public:
bool getEntry(al::ByamlIter* iter, const sead::SafeString& event_flow_name,
const sead::SafeString& entry_point);
bool getSceneChangeEventTraverseLimit(const sead::SafeString& event_flow_name);
void init(sead::Heap* heap);
private:
void doInit(sead::Heap* heap, OverlayArena* arena);
al::ByamlIter* mRootIter = nullptr;
ksys::res::Handle mHandle;
InfoDataUnknownType* _80 = nullptr;
};
} // namespace ksys::evt
+3 -1
View File
@@ -3,6 +3,7 @@
#include <basis/seadTypes.h>
#include <prim/seadRuntimeTypeInfo.h>
#include <prim/seadSafeString.h>
#include <resource/seadResource.h>
#include "KingSystem/Utils/Types.h"
namespace sead {
@@ -15,9 +16,10 @@ class OverlayArena;
namespace ksys::res {
class EntryFactoryBase;
class Handle;
class EntryFactoryBase;
class ILoadRequest {
SEAD_RTTI_BASE(ILoadRequest)
public: