metaforce/Runtime/Character/CCharAnimTime.hpp

46 lines
1.6 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2015-08-17 22:54:43 -07:00
#include "Runtime/IOStreams.hpp"
2016-04-10 20:59:54 -07:00
2017-12-29 17:09:45 -08:00
#undef min
#undef max
2021-04-10 01:42:06 -07:00
namespace metaforce {
2015-08-17 22:54:43 -07:00
2018-12-07 21:30:43 -08:00
class CCharAnimTime {
2016-09-13 22:45:46 -07:00
public:
2018-12-07 21:30:43 -08:00
enum class EType { NonZero, ZeroIncreasing, ZeroSteady, ZeroDecreasing, Infinity };
2016-09-13 22:45:46 -07:00
private:
2018-12-07 21:30:43 -08:00
float x0_time = 0.f;
EType x4_type = EType::ZeroSteady;
2017-07-09 21:55:51 -07:00
2018-12-07 21:30:43 -08:00
public:
constexpr CCharAnimTime() = default;
constexpr CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {}
constexpr CCharAnimTime(EType type, float t) : x0_time(t), x4_type(type) {}
explicit CCharAnimTime(CInputStream& in) : x0_time(in.ReadFloat()), x4_type(EType(in.ReadLong())) {}
2018-12-07 21:30:43 -08:00
static constexpr CCharAnimTime Infinity() { return {EType::Infinity, 1.0f}; }
2018-12-07 21:30:43 -08:00
float GetSeconds() const { return x0_time; }
bool EqualsZero() const;
bool EpsilonZero() const;
bool GreaterThanZero() const;
bool operator==(const CCharAnimTime& other) const;
bool operator!=(const CCharAnimTime& other) const;
bool operator>=(const CCharAnimTime& other) const;
bool operator<=(const CCharAnimTime& other) const;
bool operator>(const CCharAnimTime& other) const;
bool operator<(const CCharAnimTime& other) const;
CCharAnimTime& operator*=(const CCharAnimTime& other);
CCharAnimTime& operator+=(const CCharAnimTime& other);
CCharAnimTime operator+(const CCharAnimTime& other) const;
CCharAnimTime& operator-=(const CCharAnimTime& other);
CCharAnimTime operator-(const CCharAnimTime& other) const;
CCharAnimTime operator*(const CCharAnimTime& other) const;
CCharAnimTime operator*(const float& other) const;
float operator/(const CCharAnimTime& other) const;
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce