mirror of
https://github.com/zeldaret/botw
synced 2026-09-01 01:22:07 -04:00
ksys/chm: Add SystemConfig
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "KingSystem/Chemical/chmSystemConfig.h"
|
||||
|
||||
namespace ksys::chm {
|
||||
|
||||
SEAD_SINGLETON_DISPOSER_IMPL(SystemConfig)
|
||||
|
||||
SystemConfig::~SystemConfig() {
|
||||
mMaterials.freeBuffer();
|
||||
mWorlds.freeBuffer();
|
||||
}
|
||||
|
||||
void SystemConfig::init(sead::Heap* heap) {
|
||||
mMaterials.allocBufferAssert(128, heap);
|
||||
mElements.allocBufferAssert(128, heap);
|
||||
mWorlds.allocBufferAssert(8, heap);
|
||||
|
||||
addList(&mWorldList, "world");
|
||||
addList(&mMaterialList, "material");
|
||||
addList(&mElementList, "element");
|
||||
|
||||
for (auto it = mWorlds.begin(), end = mWorlds.end(); it != end; ++it)
|
||||
mWorldList.addObj(&*it, sead::FormatFixedSafeString<1024>("%d", it.getIndex()));
|
||||
for (auto it = mMaterials.begin(), end = mMaterials.end(); it != end; ++it)
|
||||
mMaterialList.addObj(&*it, sead::FormatFixedSafeString<1024>("%d", it.getIndex()));
|
||||
for (auto it = mElements.begin(), end = mElements.end(); it != end; ++it)
|
||||
mElementList.addObj(&*it, sead::FormatFixedSafeString<1024>("%d", it.getIndex()));
|
||||
}
|
||||
|
||||
const SystemConfig::World& SystemConfig::getWorld(const sead::SafeString& name) const {
|
||||
for (auto it = mWorlds.begin(), end = mWorlds.end(); it != end; ++it) {
|
||||
if (name == it->id.ref())
|
||||
return *it;
|
||||
}
|
||||
return mDummyWorld;
|
||||
}
|
||||
|
||||
const SystemConfig::Material& SystemConfig::getMaterial(const sead::SafeString& name) const {
|
||||
for (auto it = mMaterials.begin(), end = mMaterials.end(); it != end; ++it) {
|
||||
if (name == it->id.ref())
|
||||
return *it;
|
||||
}
|
||||
return mDummyMaterial;
|
||||
}
|
||||
|
||||
const SystemConfig::Element& SystemConfig::getElement(const sead::SafeString& name) const {
|
||||
for (auto it = mElements.begin(), end = mElements.end(); it != end; ++it) {
|
||||
if (name == it->name.ref())
|
||||
return *it;
|
||||
}
|
||||
return mDummyElement;
|
||||
}
|
||||
|
||||
} // namespace ksys::chm
|
||||
Reference in New Issue
Block a user