metaforce/Runtime/Character/CAnimSourceReader.hpp

108 lines
4.7 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-04-11 23:35:37 +00:00
#include <memory>
2018-12-08 06:46:17 +00:00
#include <set>
#include <utility>
#include <vector>
#include "Runtime/CToken.hpp"
#include "Runtime/GCNTypes.hpp"
#include "Runtime/Character/CAnimSource.hpp"
#include "Runtime/Character/CParticleData.hpp"
#include "Runtime/Character/IAnimReader.hpp"
2016-04-11 23:35:37 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2016-04-11 23:35:37 +00:00
2018-12-08 05:30:43 +00:00
class IAnimSourceInfo {
2016-04-11 23:35:37 +00:00
public:
2018-12-08 05:30:43 +00:00
virtual ~IAnimSourceInfo() = default;
virtual bool HasPOIData() const = 0;
virtual const std::vector<CBoolPOINode>& GetBoolPOIStream() const = 0;
virtual const std::vector<CInt32POINode>& GetInt32POIStream() const = 0;
virtual const std::vector<CParticlePOINode>& GetParticlePOIStream() const = 0;
virtual const std::vector<CSoundPOINode>& GetSoundPOIStream() const = 0;
virtual CCharAnimTime GetAnimationDuration() const = 0;
2016-04-11 23:35:37 +00:00
};
2018-12-08 05:30:43 +00:00
class CAnimSourceInfo : public IAnimSourceInfo {
TSubAnimTypeToken<CAnimSource> x4_token;
2016-04-11 23:35:37 +00:00
public:
explicit CAnimSourceInfo(TSubAnimTypeToken<CAnimSource> token);
bool HasPOIData() const override;
const std::vector<CBoolPOINode>& GetBoolPOIStream() const override;
const std::vector<CInt32POINode>& GetInt32POIStream() const override;
const std::vector<CParticlePOINode>& GetParticlePOIStream() const override;
const std::vector<CSoundPOINode>& GetSoundPOIStream() const override;
CCharAnimTime GetAnimationDuration() const override;
2016-04-11 23:35:37 +00:00
};
2018-12-08 05:30:43 +00:00
class CAnimSourceReaderBase : public IAnimReader {
2016-04-16 03:24:25 +00:00
protected:
2018-12-08 05:30:43 +00:00
std::unique_ptr<IAnimSourceInfo> x4_sourceInfo;
CCharAnimTime xc_curTime;
u32 x14_passedBoolCount = 0;
u32 x18_passedIntCount = 0;
u32 x1c_passedParticleCount = 0;
u32 x20_passedSoundCount = 0;
std::vector<std::pair<std::string, bool>> x24_boolStates;
std::vector<std::pair<std::string, s32>> x34_int32States;
std::vector<std::pair<std::string, CParticleData::EParentedMode>> x44_particleStates;
std::set<std::pair<std::string, s32>> GetUniqueParticlePOIs() const;
std::set<std::pair<std::string, s32>> GetUniqueInt32POIs() const;
std::set<std::pair<std::string, s32>> GetUniqueBoolPOIs() const;
2016-04-11 23:35:37 +00:00
protected:
2018-12-08 05:30:43 +00:00
void PostConstruct(const CCharAnimTime& time);
void UpdatePOIStates();
CAnimSourceReaderBase(std::unique_ptr<IAnimSourceInfo>&& sourceInfo, const CAnimSourceReaderBase& other);
2016-04-11 23:35:37 +00:00
public:
2018-12-08 05:30:43 +00:00
CAnimSourceReaderBase(std::unique_ptr<IAnimSourceInfo>&& sourceInfo, const CCharAnimTime& time);
size_t VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity, size_t iterator, u32) const override;
size_t VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity, size_t iterator,
u32) const override;
size_t VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity, size_t iterator,
u32) const override;
size_t VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity, size_t iterator,
u32) const override;
bool VGetBoolPOIState(std::string_view name) const override;
s32 VGetInt32POIState(std::string_view name) const override;
CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override;
2018-12-08 05:30:43 +00:00
using IAnimReader::VGetOffset;
virtual zeus::CVector3f VGetOffset(const CSegId& seg, const CCharAnimTime& b) const = 0;
virtual bool VSupportsReverseView() const = 0;
virtual SAdvancementResults VReverseView(const CCharAnimTime& time) = 0;
const CCharAnimTime& GetCurTime() const { return xc_curTime; }
2016-04-11 23:35:37 +00:00
};
2018-12-08 05:30:43 +00:00
class CAnimSourceReader : public CAnimSourceReaderBase {
TSubAnimTypeToken<CAnimSource> x54_source;
CSteadyStateAnimInfo x64_steadyStateInfo;
2016-04-11 23:35:37 +00:00
public:
2018-12-08 05:30:43 +00:00
CAnimSourceReader(const TSubAnimTypeToken<CAnimSource>& source, const CCharAnimTime& time);
CAnimSourceReader(const CAnimSourceReader& other);
2016-04-11 23:35:37 +00:00
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const override;
bool VSupportsReverseView() const override { return true; }
void VSetPhase(float) override;
SAdvancementResults VReverseView(const CCharAnimTime& time) override;
std::unique_ptr<IAnimReader> VClone() const override;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const override;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const override;
SAdvancementResults VAdvanceView(const CCharAnimTime& a) override;
CCharAnimTime VGetTimeRemaining() const override;
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const override;
bool VHasOffset(const CSegId& seg) const override;
zeus::CVector3f VGetOffset(const CSegId& seg) const override;
zeus::CVector3f VGetOffset(const CSegId& seg, const CCharAnimTime& time) const override;
zeus::CQuaternion VGetRotation(const CSegId& seg) const override;
2018-12-08 05:30:43 +00:00
};
2016-04-11 23:35:37 +00:00
2021-04-10 08:42:06 +00:00
} // namespace metaforce