metaforce/Runtime/Character/CAdditiveAnimPlayback.hpp

60 lines
1.9 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2016-04-15 20:24:25 -07:00
#include <memory>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Streams/CInputStream.hpp"
2016-04-15 20:24:25 -07:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-04-15 20:24:25 -07:00
class CAdditiveAnimationInfo;
class CAnimTreeNode;
2016-04-15 20:24:25 -07:00
class CCharLayoutInfo;
class CSegIdList;
2016-04-15 20:24:25 -07:00
class CSegStatementSet;
2018-12-07 21:30:43 -08:00
class CAdditiveAnimationInfo {
float x0_fadeInDur = 0.f;
float x4_fadeOutDur = 0.f;
2016-04-15 20:24:25 -07:00
public:
2018-12-07 21:30:43 -08:00
void read(CInputStream& in) {
x0_fadeInDur = in.ReadFloat();
x4_fadeOutDur = in.ReadFloat();
2018-12-07 21:30:43 -08:00
}
CAdditiveAnimationInfo() = default;
explicit CAdditiveAnimationInfo(CInputStream& in) { read(in); }
2018-12-07 21:30:43 -08:00
float GetFadeInDuration() const { return x0_fadeInDur; }
float GetFadeOutDuration() const { return x4_fadeOutDur; }
2016-04-15 20:24:25 -07:00
};
2018-12-07 21:30:43 -08:00
enum class EAdditivePlaybackPhase { None, FadingIn, FadingOut, FadedIn, FadedOut };
2017-02-28 22:02:54 -08:00
2018-12-07 21:30:43 -08:00
class CAdditiveAnimPlayback {
CAdditiveAnimationInfo x0_info;
std::shared_ptr<CAnimTreeNode> x8_anim;
float xc_targetWeight;
float x10_curWeight = 0.f;
bool x14_active;
float x18_weightTimer = 0.f;
EAdditivePlaybackPhase x1c_phase = EAdditivePlaybackPhase::FadingIn;
bool x20_needsFadeOut = false;
2016-04-15 20:24:25 -07:00
2018-12-07 21:30:43 -08:00
public:
CAdditiveAnimPlayback(const std::weak_ptr<CAnimTreeNode>& anim, float weight, bool active,
const CAdditiveAnimationInfo& info, bool fadeOut);
void AddToSegStatementSet(const CSegIdList& list, const CCharLayoutInfo&, CSegStatementSet&) const;
void Update(float dt);
void FadeOut();
void SetWeight(float w);
float GetTargetWeight() const { return xc_targetWeight; }
bool IsActive() const { return x14_active; }
void SetActive(bool active) { x14_active = active; }
const std::shared_ptr<CAnimTreeNode>& GetAnim() const { return x8_anim; }
std::shared_ptr<CAnimTreeNode>& GetAnim() { return x8_anim; }
EAdditivePlaybackPhase GetPhase() const { return x1c_phase; }
void SetNeedsFadeOut(bool b) { x20_needsFadeOut = b; }
bool NeedsFadeOut() const { return x20_needsFadeOut; }
2016-04-15 20:24:25 -07:00
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce