metaforce/Runtime/CFactoryMgr.hpp

75 lines
1.6 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2015-08-23 06:42:29 +00:00
#include <unordered_map>
#include "Runtime/IFactory.hpp"
#include "Runtime/Streams/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
2015-08-23 06:42:29 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2016-02-17 03:42:27 +00:00
struct SObjectTag;
2015-08-23 06:42:29 +00:00
class CVParamTransfer;
2016-02-16 05:50:41 +00:00
class IObj;
2015-08-23 06:42:29 +00:00
2018-12-08 05:30:43 +00:00
class CFactoryMgr {
2022-02-21 00:03:38 +00:00
std::unordered_map<FourCC, FFactoryFunc> x10_factories;
std::unordered_map<FourCC, FMemFactoryFunc> x24_memFactories;
2018-12-08 05:30:43 +00:00
2015-08-23 06:42:29 +00:00
public:
2021-04-10 08:42:06 +00:00
CFactoryFnReturn MakeObject(const SObjectTag& tag, metaforce::CInputStream& in, const CVParamTransfer& paramXfer,
2018-12-08 05:30:43 +00:00
CObjectReference* selfRef);
2021-04-10 08:42:06 +00:00
bool CanMakeMemory(const metaforce::SObjectTag& tag) const;
2018-12-08 05:30:43 +00:00
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size, bool compressed,
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
2022-02-21 00:03:38 +00:00
void AddFactory(FourCC key, FFactoryFunc func) { x10_factories.insert_or_assign(key, std::move(func)); }
void AddFactory(FourCC key, FMemFactoryFunc func) { x24_memFactories.insert_or_assign(key, std::move(func)); }
2017-10-26 05:37:46 +00:00
2018-12-08 05:30:43 +00:00
enum class ETypeTable : u8 {
CLSN,
CMDL,
CSKR,
ANIM,
CINF,
TXTR,
PLTT,
FONT,
ANCS,
EVNT,
MADF,
MLVL,
MREA,
MAPW,
MAPA,
SAVW,
SAVA,
PART,
WPSC,
SWHC,
DPSC,
ELSC,
CRSC,
AFSM,
DCLN,
AGSC,
ATBL,
CSNG,
STRG,
SCAN,
PATH,
DGRP,
HMAP,
CTWK,
FRME,
HINT,
MAPU,
DUMB,
OIDS,
Invalid = 127
};
2017-10-26 05:37:46 +00:00
2018-12-08 05:30:43 +00:00
static ETypeTable FourCCToTypeIdx(FourCC fcc);
static FourCC TypeIdxToFourCC(ETypeTable fcc);
2015-08-23 06:42:29 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce