mirror of https://github.com/zeldaret/botw.git
ksys: Implement Timer
This commit is contained in:
parent
053c200741
commit
51755635aa
|
|
@ -91872,9 +91872,9 @@
|
|||
0x00000071011c0b1c,j__ZdlPv_1213,4,
|
||||
0x00000071011c0b20,BaseProcMgr::Struct2::getForBaseProcDualHeap,8,
|
||||
0x00000071011c0b28,BaseProcMgr::Struct2::setHeap,8,
|
||||
0x00000071011c0b30,TimerSimple::update,128,
|
||||
0x00000071011c0bb0,Timer::update,136,
|
||||
0x00000071011c0c38,Timer::ended,48,
|
||||
0x00000071011c0b30,TimerSimple::update,128,_ZN4ksys5Timer6updateEPff
|
||||
0x00000071011c0bb0,Timer::update,136,_ZN4ksys5Timer6updateEv
|
||||
0x00000071011c0c38,Timer::ended,48,_ZNK4ksys5Timer8hasEndedEf
|
||||
0x00000071011c0c68,sub_71011C0C68,100,_ZN4ksys3VFR18SingletonDisposer_D2Ev
|
||||
0x00000071011c0ccc,sub_71011C0CCC,108,_ZN4ksys3VFR18SingletonDisposer_D0Ev
|
||||
0x00000071011c0d38,VFR::createInstance,332,_ZN4ksys3VFR14createInstanceEPN4sead4HeapE
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -1 +1,22 @@
|
|||
#include "KingSystem/System/Timer.h"
|
||||
#include "KingSystem/System/VFR.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
void Timer::update(f32* t, f32 rate) {
|
||||
*t += VFR::instance()->getDeltaTime() * rate;
|
||||
}
|
||||
|
||||
void Timer::update() {
|
||||
previous_value = value;
|
||||
update(&value, rate);
|
||||
}
|
||||
|
||||
bool Timer::hasEnded(f32 end_time) const {
|
||||
if (value == end_time)
|
||||
return true;
|
||||
|
||||
return (previous_value - end_time) * (value - end_time) < 0.0;
|
||||
}
|
||||
|
||||
} // namespace ksys
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ namespace ksys {
|
|||
|
||||
struct Timer {
|
||||
Timer() = default;
|
||||
Timer(f32 value, f32 previous_value, f32 speed = -1.0)
|
||||
: value(value), previous_value(previous_value), speed(speed) {}
|
||||
Timer(f32 value, f32 previous_value, f32 rate = -1.0)
|
||||
: value(value), previous_value(previous_value), rate(rate) {}
|
||||
|
||||
void reset(f32 value_, f32 speed_ = -1.0) {
|
||||
void reset(f32 value_, f32 rate_ = -1.0) {
|
||||
value = previous_value = value_;
|
||||
speed = speed_;
|
||||
rate = rate_;
|
||||
}
|
||||
|
||||
void update();
|
||||
static void update(f32& t);
|
||||
static void update(f32* t, f32 rate);
|
||||
bool hasEnded(f32 end_time) const;
|
||||
|
||||
f32 value{};
|
||||
f32 previous_value{};
|
||||
f32 speed{};
|
||||
f32 rate{};
|
||||
};
|
||||
|
||||
} // namespace ksys
|
||||
|
|
|
|||
Loading…
Reference in New Issue