2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-02-19 13:04:45 +00:00
|
|
|
#include "Runtime/Streams/IOStreams.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/Character/CPASAnimState.hpp"
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2016-04-27 19:59:38 +00:00
|
|
|
class CRandom16;
|
|
|
|
class CPASAnimParmData;
|
2018-12-08 05:30:43 +00:00
|
|
|
class CPASDatabase {
|
|
|
|
std::vector<CPASAnimState> x0_states;
|
|
|
|
s32 x10_defaultState;
|
|
|
|
void AddAnimState(CPASAnimState&& state);
|
|
|
|
void SetDefaultState(s32 state) { x10_defaultState = state; }
|
|
|
|
|
2016-04-10 04:49:02 +00:00
|
|
|
public:
|
2020-02-28 09:35:50 +00:00
|
|
|
explicit CPASDatabase(CInputStream& in);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-03-25 05:43:25 +00:00
|
|
|
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData& data, s32 ignoreAnim) const;
|
|
|
|
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData& data, CRandom16& rand, s32 ignoreAnim) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 GetDefaultState() const { return x10_defaultState; }
|
2020-04-06 17:21:04 +00:00
|
|
|
size_t GetNumAnimStates() const { return x0_states.size(); }
|
2020-04-22 09:08:02 +00:00
|
|
|
const CPASAnimState* GetAnimState(pas::EAnimationState id) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const CPASAnimState& state : x0_states)
|
|
|
|
if (id == state.GetStateId())
|
|
|
|
return &state;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-04-06 17:21:04 +00:00
|
|
|
const CPASAnimState* GetAnimStateByIndex(size_t index) const {
|
|
|
|
if (index >= x0_states.size()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return nullptr;
|
2020-04-06 17:21:04 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-06 17:21:04 +00:00
|
|
|
return &x0_states[index];
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
bool HasState(pas::EAnimationState id) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
const auto& st = std::find_if(x0_states.begin(), x0_states.end(),
|
|
|
|
[&id](const CPASAnimState& other) -> bool { return other.GetStateId() == id; });
|
|
|
|
return st != x0_states.end();
|
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|