2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-06 19:21:52 +00:00

Add AssetLoader basis

This commit is contained in:
Jan
2021-03-13 14:27:20 +01:00
parent 83080db991
commit a7860c7c76
34 changed files with 736 additions and 149 deletions

View File

@ -5,6 +5,27 @@
using namespace IW4;
ZoneCreator::ZoneCreator()
{
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
{
AddAssetTypeName(assetType, GameAssetPoolIW4::AssetTypeNameByType(assetType));
}
}
void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
{
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
}
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
{
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zone, zone->m_priority);
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
zone->m_pools->InitPoolDynamic(assetType);
}
bool ZoneCreator::SupportsGame(const std::string& gameName) const
{
return gameName == g_GameIW4.GetShortName();

View File

@ -1,11 +1,22 @@
#pragma once
#include <unordered_map>
#include <string>
#include "Zone/ZoneTypes.h"
#include "ZoneCreation/IZoneCreator.h"
namespace IW4
{
class ZoneCreator final : public IZoneCreator
{
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
void AddAssetTypeName(asset_type_t assetType, std::string name);
void CreateZoneAssetPools(Zone* zone) const;
public:
ZoneCreator();
_NODISCARD bool SupportsGame(const std::string& gameName) const override;
_NODISCARD std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
};