summaryrefslogtreecommitdiff
path: root/ZAPD/ZWaterbox.cpp
diff options
context:
space:
mode:
authorlouist103 <35883445+louist103@users.noreply.github.com>2023-05-04 20:05:45 -0400
committerGitHub <noreply@github.com>2023-05-04 20:05:45 -0400
commit0dbba745dfed52be5cab97257dbf56a2223dd874 (patch)
treeec50457b1f5973d5679556e369f0f5b5e6d66d8f /ZAPD/ZWaterbox.cpp
parentcc01a0629af59dc45f775c0c42210d4e215da4de (diff)
Waterbox nodes (#289)
* Waterbox nodes * emplace * VS Filters.
Diffstat (limited to 'ZAPD/ZWaterbox.cpp')
-rw-r--r--ZAPD/ZWaterbox.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/ZAPD/ZWaterbox.cpp b/ZAPD/ZWaterbox.cpp
new file mode 100644
index 0000000..9a289db
--- /dev/null
+++ b/ZAPD/ZWaterbox.cpp
@@ -0,0 +1,74 @@
+#include "ZWaterbox.h"
+
+#include "Globals.h"
+#include "Utils/BitConverter.h"
+#include "Utils/StringHelper.h"
+
+REGISTER_ZFILENODE(Waterbox, ZWaterbox);
+
+ZWaterbox::ZWaterbox(ZFile* nParent) : ZResource(nParent)
+{
+}
+
+ZWaterbox::~ZWaterbox()
+{
+}
+
+void ZWaterbox::ParseRawData()
+{
+ const auto& rawData = parent->GetRawData();
+
+ xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
+ ySurface = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
+ zMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
+ xLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
+ zLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
+
+ if (Globals::Instance->game == ZGame::OOT_SW97)
+ properties = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
+ else
+ properties = BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
+}
+
+void ZWaterbox::DeclareReferences(const std::string& prefix)
+{
+ std::string declaration;
+ std::string auxName = name;
+
+ if (name == "")
+ auxName = GetDefaultName(prefix);
+
+ parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
+ GetSourceTypeName(), name.c_str(), GetBodySourceCode());
+}
+
+std::string ZWaterbox::GetBodySourceCode() const
+{
+ return StringHelper::Sprintf("%i, %i, %i, %i, %i, 0x%08X", xMin, ySurface, zMin, xLength,
+ zLength, properties);
+}
+
+std::string ZWaterbox::GetDefaultName(const std::string& prefix) const
+{
+ return StringHelper::Sprintf("%sWaterBoxes_%06X", prefix.c_str(), rawDataIndex);
+}
+
+ZResourceType ZWaterbox::GetResourceType() const
+{
+ return ZResourceType::Waterbox;
+}
+
+size_t ZWaterbox::GetRawDataSize() const
+{
+ return 16;
+}
+
+std::string ZWaterbox::GetSourceTypeName() const
+{
+ return "WaterBox";
+}
+
+bool ZWaterbox::DoesSupportArray() const
+{
+ return true;
+}