Shipwright/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp
Pepe20129 92467b87b5
Add scene command XML parsers (#4054)
* Add scene command parsers

* Move logging & add logging cvar

* Use new CVAR_DEVELOPER_TOOLS macro

* Update soh/soh/resource/logging/SceneCommandLoggers.h

---------

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
2024-04-28 20:58:12 -04:00

38 lines
1.5 KiB
C++

#include "soh/resource/importer/scenecommand/SetWindSettingsFactory.h"
#include "soh/resource/type/scenecommand/SetWindSettings.h"
#include "soh/resource/logging/SceneCommandLoggers.h"
#include "spdlog/spdlog.h"
namespace SOH {
std::shared_ptr<LUS::IResource>
SetWindSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
auto setWind = std::make_shared<SetWindSettings>(initData);
ReadCommandId(setWind, reader);
setWind->settings.windWest = reader->ReadInt8();
setWind->settings.windVertical = reader->ReadInt8();
setWind->settings.windSouth = reader->ReadInt8();
setWind->settings.windSpeed = reader->ReadUByte();
if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) {
LogWindSettingsAsXML(setWind);
}
return setWind;
}
std::shared_ptr<LUS::IResource> SetWindSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setWind = std::make_shared<SetWindSettings>(initData);
setWind->cmdId = SceneCommandID::SetWind;
setWind->settings.windWest = reader->IntAttribute("WindWest");
setWind->settings.windVertical = reader->IntAttribute("WindVertical");
setWind->settings.windSouth = reader->IntAttribute("WindSouth");
setWind->settings.windSpeed = reader->IntAttribute("WindSpeed");
return setWind;
}
} // namespace SOH