2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CFactoryMgr.hpp"
|
|
|
|
#include "Runtime/CToken.hpp"
|
2022-02-19 13:04:45 +00:00
|
|
|
#include "Runtime/Streams/IOStreams.hpp"
|
2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/IObj.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
2020-04-20 01:09:30 +00:00
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2019-09-22 21:52:05 +00:00
|
|
|
class CColorElement;
|
2016-02-05 01:27:03 +00:00
|
|
|
class CElectricDescription;
|
2019-09-22 21:52:05 +00:00
|
|
|
class CEmitterElement;
|
|
|
|
class CGenDescription;
|
|
|
|
class CIntElement;
|
|
|
|
class CModVectorElement;
|
|
|
|
class CRealElement;
|
|
|
|
class CSimplePool;
|
|
|
|
class CSwooshDescription;
|
2016-02-05 01:27:03 +00:00
|
|
|
class CUVElement;
|
2019-09-22 21:52:05 +00:00
|
|
|
class CVParamTransfer;
|
2016-02-05 01:27:03 +00:00
|
|
|
class CVectorElement;
|
|
|
|
|
2022-03-10 23:56:55 +00:00
|
|
|
template <typename T>
|
|
|
|
struct STokenDesc {
|
|
|
|
std::optional<TLockedToken<T>> x0_res;
|
|
|
|
STokenDesc() = default;
|
|
|
|
STokenDesc(CToken&& tok) : x0_res(std::move(tok)) {}
|
|
|
|
void Load() {
|
|
|
|
if (x0_res) {
|
|
|
|
x0_res->GetObj();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
explicit operator bool() const { return x0_res.has_value(); }
|
|
|
|
auto* GetObj() { return x0_res ? x0_res->GetObj() : nullptr; }
|
|
|
|
const auto* GetObj() const { return x0_res ? x0_res->GetObj() : nullptr; }
|
|
|
|
auto& operator*() { return *x0_res; }
|
|
|
|
const auto& operator*() const { return *x0_res; }
|
|
|
|
auto& operator->() { return *x0_res; }
|
|
|
|
const auto& operator->() const { return *x0_res; }
|
2016-02-05 01:27:03 +00:00
|
|
|
};
|
|
|
|
|
2022-03-10 23:56:55 +00:00
|
|
|
using SParticleModel = STokenDesc<CModel>;
|
|
|
|
using SChildGeneratorDesc = STokenDesc<CGenDescription>;
|
|
|
|
using SSwooshGeneratorDesc = STokenDesc<CSwooshDescription>;
|
|
|
|
using SElectricGeneratorDesc = STokenDesc<CElectricDescription>;
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CParticleDataFactory {
|
|
|
|
friend class CDecalDataFactory;
|
|
|
|
friend class CCollisionResponseData;
|
|
|
|
friend class CParticleElectricDataFactory;
|
|
|
|
friend class CParticleSwooshDataFactory;
|
|
|
|
friend class CProjectileWeaponDataFactory;
|
2016-02-10 22:54:47 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static SParticleModel GetModel(CInputStream& in, CSimplePool* resPool);
|
|
|
|
static SChildGeneratorDesc GetChildGeneratorDesc(CAssetId res, CSimplePool* resPool,
|
|
|
|
const std::vector<CAssetId>& tracker);
|
|
|
|
static SChildGeneratorDesc GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool,
|
|
|
|
const std::vector<CAssetId>& tracker);
|
|
|
|
static SSwooshGeneratorDesc GetSwooshGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
|
|
|
static SElectricGeneratorDesc GetElectricGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
|
|
|
static std::unique_ptr<CUVElement> GetTextureElement(CInputStream& in, CSimplePool* resPool);
|
|
|
|
static std::unique_ptr<CColorElement> GetColorElement(CInputStream& in);
|
|
|
|
static std::unique_ptr<CModVectorElement> GetModVectorElement(CInputStream& in);
|
|
|
|
static std::unique_ptr<CEmitterElement> GetEmitterElement(CInputStream& in);
|
|
|
|
static std::unique_ptr<CVectorElement> GetVectorElement(CInputStream& in);
|
|
|
|
static std::unique_ptr<CRealElement> GetRealElement(CInputStream& in);
|
|
|
|
static std::unique_ptr<CIntElement> GetIntElement(CInputStream& in);
|
|
|
|
|
|
|
|
static float GetReal(CInputStream& in);
|
|
|
|
static s32 GetInt(CInputStream& in);
|
|
|
|
static bool GetBool(CInputStream& in);
|
|
|
|
static FourCC GetClassID(CInputStream& in);
|
2019-10-11 19:13:02 +00:00
|
|
|
static std::unique_ptr<CGenDescription> CreateGeneratorDescription(CInputStream& in, std::vector<CAssetId>& tracker,
|
|
|
|
CAssetId resId, CSimplePool* resPool);
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool CreateGPSM(CGenDescription* fillDesc, CInputStream& in, std::vector<CAssetId>& tracker,
|
|
|
|
CSimplePool* resPool);
|
|
|
|
static void LoadGPSMTokens(CGenDescription* desc);
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2016-02-15 02:31:46 +00:00
|
|
|
public:
|
2019-10-11 19:13:02 +00:00
|
|
|
static std::unique_ptr<CGenDescription> GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
2016-02-05 01:27:03 +00:00
|
|
|
};
|
|
|
|
|
2016-09-02 19:32:57 +00:00
|
|
|
CFactoryFnReturn FParticleFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
|
|
|
CObjectReference* selfRef);
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|
2020-04-20 01:09:30 +00:00
|
|
|
|
|
|
|
// FIXME hacky workaround for MSVC; these need to be complete types
|
|
|
|
// but introduce circular dependencies if included at the start
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
2022-03-10 23:56:55 +00:00
|
|
|
#include "Runtime/Particle/CElectricDescription.hpp"
|