mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07:00
git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
f52a2a6406
commit
5dda5762ba
217 changed files with 47152 additions and 0 deletions
97
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
97
ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "SetLightList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
|
||||
SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLightList::ParseRawData()
|
||||
{
|
||||
ZRoomCommand::ParseRawData();
|
||||
std::string declarations;
|
||||
|
||||
numLights = cmdArg1;
|
||||
int32_t currentPtr = segmentOffset;
|
||||
for (int i = 0; i < this->numLights; i++)
|
||||
{
|
||||
LightInfo light(parent->GetRawData(), currentPtr);
|
||||
|
||||
currentPtr += light.GetRawDataSize();
|
||||
lights.push_back(light);
|
||||
}
|
||||
}
|
||||
|
||||
void SetLightList::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
if (!lights.empty())
|
||||
{
|
||||
std::string declarations;
|
||||
|
||||
for (size_t i = 0; i < lights.size(); i++)
|
||||
{
|
||||
declarations +=
|
||||
StringHelper::Sprintf("\t{ %s },", lights.at(i).GetBodySourceCode().c_str());
|
||||
|
||||
if (i < lights.size() - 1)
|
||||
declarations += "\n";
|
||||
}
|
||||
|
||||
const auto& light = lights.front();
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
segmentOffset, DeclarationAlignment::Align4, lights.size() * light.GetRawDataSize(),
|
||||
light.GetSourceTypeName(),
|
||||
StringHelper::Sprintf("%sLightInfo0x%06X", prefix.c_str(), segmentOffset),
|
||||
lights.size(), declarations);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetLightList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightInfo", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_LIGHT_LIST(%i, %s)", numLights, listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetLightList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdLightList";
|
||||
}
|
||||
|
||||
RoomCommand SetLightList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetLightList;
|
||||
}
|
||||
|
||||
LightInfo::LightInfo(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
type = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0);
|
||||
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
z = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
r = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8);
|
||||
g = BitConverter::ToUInt8BE(rawData, rawDataIndex + 9);
|
||||
b = BitConverter::ToUInt8BE(rawData, rawDataIndex + 10);
|
||||
drawGlow = BitConverter::ToUInt8BE(rawData, rawDataIndex + 11);
|
||||
radius = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
|
||||
}
|
||||
|
||||
std::string LightInfo::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf(
|
||||
"0x%02X, { %i, %i, %i, { 0x%02X, 0x%02X, 0x%02X }, 0x%02X, 0x%04X }", type, x, y, z, r, g,
|
||||
b, drawGlow, radius);
|
||||
}
|
||||
|
||||
std::string LightInfo::GetSourceTypeName() const
|
||||
{
|
||||
return "LightInfo";
|
||||
}
|
||||
|
||||
size_t LightInfo::GetRawDataSize() const
|
||||
{
|
||||
return 0x0E;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue