[ZoneBuilder] Add ComWorld interface

This commit is contained in:
momo5502 2016-12-21 17:26:16 +01:00
parent 3e69704aed
commit 48557d02d1
4 changed files with 59 additions and 0 deletions

View File

@ -391,6 +391,7 @@ namespace Components
AssetHandler::RegisterInterface(new Assets::IXModel());
AssetHandler::RegisterInterface(new Assets::IMapEnts());
AssetHandler::RegisterInterface(new Assets::IRawFile());
AssetHandler::RegisterInterface(new Assets::IComWorld());
AssetHandler::RegisterInterface(new Assets::IGfxImage());
AssetHandler::RegisterInterface(new Assets::IGfxWorld());
AssetHandler::RegisterInterface(new Assets::ISndCurve());

View File

@ -73,6 +73,7 @@ namespace Components
#include "AssetInterfaces\IXModel.hpp"
#include "AssetInterfaces\IMapEnts.hpp"
#include "AssetInterfaces\IRawFile.hpp"
#include "AssetInterfaces\IComWorld.hpp"
#include "AssetInterfaces\IGfxImage.hpp"
#include "AssetInterfaces\IGfxWorld.hpp"
#include "AssetInterfaces\IMaterial.hpp"

View File

@ -0,0 +1,47 @@
#include <STDInclude.hpp>
namespace Assets
{
void IComWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
AssertSize(Game::ComWorld, 16);
Utils::Stream* buffer = builder->getBuffer();
Game::ComWorld* asset = header.comWorld;
Game::ComWorld* dest = buffer->dest<Game::ComWorld>();
buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
if (asset->name)
{
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
Utils::Stream::ClearPointer(&dest->name);
}
if (asset->lights)
{
AssertSize(Game::ComPrimaryLight, 68);
buffer->align(Utils::Stream::ALIGN_4);
Game::ComPrimaryLight* destLights = buffer->dest<Game::ComPrimaryLight>();
buffer->saveArray(asset->lights, asset->lightCount);
for (int i = 0; i < asset->lightCount; ++i)
{
Game::ComPrimaryLight* destLight = &destLights[i];
Game::ComPrimaryLight* light = &asset->lights[i];
if (light->name)
{
buffer->saveString(light->name);
Utils::Stream::ClearPointer(&destLight->name);
}
}
Utils::Stream::ClearPointer(&dest->lights);
}
buffer->popBlock();
}
}

View File

@ -0,0 +1,10 @@
namespace Assets
{
class IComWorld : public Components::AssetHandler::IAsset
{
public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_COM_MAP; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
};
}