-
Notifications
You must be signed in to change notification settings - Fork 9
/
GunReload.h
59 lines (40 loc) · 1016 Bytes
/
GunReload.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <chrono>
#include "utils.h"
namespace F4VRBody {
enum ReloadState {
idle,
reloadingStart,
newMagReady,
magInserted
};
class GunReload {
public:
GunReload() {
startAnimCap = false;
state = idle;
reloadButtonPressed = false;
}
inline void startAnimationCapture() {
startAnimCap = !startAnimCap; // hook gets called twice once at the start of reload and once after animation is done
startCapTime = std::chrono::high_resolution_clock::now();
}
void DoAnimationCapture();
void Update();
bool StartReloading();
bool SetAmmoMesh();
private:
std::chrono::high_resolution_clock::time_point startCapTime;
bool startAnimCap;
ReloadState state;
bool reloadButtonPressed;
TESAmmo* currentAmmo{ nullptr };
NiNode* magMesh{ nullptr };
TESObjectREFR* currentRefr{ nullptr };
};
extern GunReload* g_gunReloadSystem;
extern float g_animDeltaTime;
inline void InitGunReloadSystem() {
g_gunReloadSystem = new GunReload();
}
}