Fix CAnimSource reader POI handling

This commit is contained in:
Jack Andersen 2018-11-20 14:51:15 -10:00
parent 925464dd56
commit e736d8fa83
5 changed files with 31 additions and 32 deletions

View File

@ -41,33 +41,36 @@ CCharAnimTime CAnimSourceInfo::GetAnimationDuration() const
return x4_token->GetDuration();
}
std::map<std::string, CParticleData::EParentedMode>
std::set<std::pair<std::string, s32>>
CAnimSourceReaderBase::GetUniqueParticlePOIs() const
{
const std::vector<CParticlePOINode>& particleNodes = x4_sourceInfo->GetParticlePOIStream();
std::map<std::string, CParticleData::EParentedMode> ret;
std::set<std::pair<std::string, s32>> ret;
for (const CParticlePOINode& node : particleNodes)
ret[std::string(node.GetString())] = node.GetParticleData().GetParentedMode();
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
return ret;
}
std::map<std::string, s32>
std::set<std::pair<std::string, s32>>
CAnimSourceReaderBase::GetUniqueInt32POIs() const
{
const std::vector<CInt32POINode>& int32Nodes = x4_sourceInfo->GetInt32POIStream();
std::map<std::string, s32> ret;
std::set<std::pair<std::string, s32>> ret;
for (const CInt32POINode& node : int32Nodes)
ret[std::string(node.GetString())] = node.GetValue();
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
return ret;
}
std::map<std::string, bool>
std::set<std::pair<std::string, s32>>
CAnimSourceReaderBase::GetUniqueBoolPOIs() const
{
const std::vector<CBoolPOINode>& boolNodes = x4_sourceInfo->GetBoolPOIStream();
std::map<std::string, bool> ret;
std::set<std::pair<std::string, s32>> ret;
for (const CBoolPOINode& node : boolNodes)
ret[std::string(node.GetString())] = node.GetValue();
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
return ret;
}
@ -80,21 +83,20 @@ void CAnimSourceReaderBase::PostConstruct(const CCharAnimTime& time)
if (x4_sourceInfo->HasPOIData())
{
std::map<std::string, bool> boolPOIs = GetUniqueBoolPOIs();
std::map<std::string, s32> int32POIs = GetUniqueInt32POIs();
std::map<std::string, CParticleData::EParentedMode> particlePOIs = GetUniqueParticlePOIs();
std::set<std::pair<std::string, s32>> boolPOIs = GetUniqueBoolPOIs();
std::set<std::pair<std::string, s32>> int32POIs = GetUniqueInt32POIs();
std::set<std::pair<std::string, s32>> particlePOIs = GetUniqueParticlePOIs();
x24_boolStates.resize(boolPOIs.size());
x34_int32States.resize(int32POIs.size());
x44_particleStates.resize(particlePOIs.size());
x24_boolStates.reserve(boolPOIs.size());
for (const auto& poi : boolPOIs)
x24_boolStates.push_back(poi);
x34_int32States.reserve(int32POIs.size());
x24_boolStates[poi.second] = std::make_pair(poi.first, false);
for (const auto& poi : int32POIs)
x34_int32States.push_back(poi);
x44_particleStates.reserve(particlePOIs.size());
x34_int32States[poi.second] = std::make_pair(poi.first, 0);
for (const auto& poi : particlePOIs)
x44_particleStates.push_back(poi);
x44_particleStates[poi.second] = std::make_pair(poi.first, CParticleData::EParentedMode::Initial);
}
CCharAnimTime tmpTime = time;

View File

@ -46,9 +46,9 @@ protected:
std::vector<std::pair<std::string, s32>> x34_int32States;
std::vector<std::pair<std::string, CParticleData::EParentedMode>> x44_particleStates;
std::map<std::string, CParticleData::EParentedMode> GetUniqueParticlePOIs() const;
std::map<std::string, s32> GetUniqueInt32POIs() const;
std::map<std::string, bool> GetUniqueBoolPOIs() const;
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;
protected:
void PostConstruct(const CCharAnimTime& time);

View File

@ -9,13 +9,13 @@ namespace urde
{
CPOINode::CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
s32 index, bool c, float weight, s32 e, s32 f)
s32 index, bool unique, float weight, s32 e, s32 f)
: x4_(1),
x8_name(name),
x18_type(type),
x1c_time(time),
x24_index(index),
x28_(c),
x28_unique(unique),
x2c_weight(weight),
x30_charIdx(e),
x34_flags(f)
@ -27,7 +27,7 @@ CPOINode::CPOINode(CInputStream& in)
x18_type(EPOIType(in.readUint16Big())),
x1c_time(in),
x24_index(in.readInt32Big()),
x28_(in.readBool()),
x28_unique(in.readBool()),
x2c_weight(in.readFloatBig()),
x30_charIdx(in.readInt32Big()),
x34_flags(in.readInt32Big())

View File

@ -27,13 +27,13 @@ protected:
EPOIType x18_type;
CCharAnimTime x1c_time;
s32 x24_index;
bool x28_;
bool x28_unique;
float x2c_weight;
s32 x30_charIdx = -1;
s32 x34_flags;
public:
CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
s32 index, bool, float weight, s32 charIdx, s32 flags);
s32 index, bool unique, float weight, s32 charIdx, s32 flags);
CPOINode(CInputStream& in);
virtual ~CPOINode() = default;
@ -42,6 +42,7 @@ public:
void SetTime(const CCharAnimTime& time) { x1c_time = time; }
EPOIType GetPoiType() const { return x18_type; }
s32 GetIndex() const { return x24_index; }
bool GetUnique() const { return x28_unique; }
float GetWeight() const { return x2c_weight; }
s32 GetCharacterIndex() const { return x30_charIdx; }
s32 GetFlags() const { return x34_flags; }

View File

@ -31,8 +31,6 @@ void CAmbientAI::Accept(IVisitor& visitor)
void CAmbientAI::Think(float dt, CStateManager& mgr)
{
return;
if (!GetActive())
return;
@ -116,8 +114,6 @@ void CAmbientAI::Think(float dt, CStateManager& mgr)
void CAmbientAI::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
return;
switch(msg)
{
case EScriptObjectMessage::Reset: