summaryrefslogtreecommitdiff
path: root/ZAPD/ZWaterbox.cpp
blob: 39aae5a1f35b3603d5e74b5d1b61f9c6d9aee702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "ZWaterbox.h"

#include "Globals.h"
#include "Utils/BitConverter.h"
#include <ship/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;
}