blob: af936ed3f01a770aca12b2582e728020c95cc7b3 (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include "MoleGroup.h"
#include "Mole.h"
extern "C" {
#include "code_80057C60.h"
#include "update_objects.h"
#include "math_util.h"
#include "math_util_2.h"
}
size_t OMoleGroup::_count = 0;
OMoleGroup::OMoleGroup(std::vector<FVector>& spawns) {
_idx = _count;
for (auto& pos : spawns) {
pos.x * xOrientation;
OMole* ptr = reinterpret_cast<OMole*>(gWorldInstance.AddObject(new OMole(pos, this)));
_moles.push_back({ptr, pos, false});
}
_count += 1;
}
void OMoleGroup::Tick() {
for (auto &mole : _moles) {
if (gObjectList[mole.Mole->_objectIndex].state == 0) {
func_80081FF4(mole.Mole->_objectIndex);
} else {
mole.Mole->func_800821AC(mole.Mole->_objectIndex, 1);
}
}
/**
* This ticks the mole dirt particles. It must be ran *after* MoleGroup is done ticking. Otherwise, the dirt particle directions will not randomize
* The best solution would be for particles to be its own class. But that takes effort
* Instead, we wait until the last MoleGroup has ticked, then we tick the particles one time.
*
* Warning: Calling this more than one time per frame, will result in doubling the speed
*/
if (_idx == _count - 1) {
for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
s32 objectIndex = gObjectParticle2[i];
if (gObjectList[objectIndex].state != 0) {
if (nullptr != _moles[0].Mole) {
_moles[0].Mole->func_80081790(objectIndex);
}
}
}
}
}
void OMoleGroup::func_80081FF4(s32 objectIndex) {
init_object(objectIndex, 0);
gObjectList[objectIndex].unk_04C = random_int(30) + 5;
s16 mole = random_int(_moles.size());
for (size_t i = 0; i < _moles.size(); i++) {
if (_moles[mole].Active == true) {
mole++;
if (mole == _moles.size()) {
mole = 0;
}
} else { // if not active
_moles[mole].Active = true;
gObjectList[objectIndex].type = mole;
break;
}
}
gObjectList[objectIndex].origin_pos[0] = _moles[mole].Pos.x * xOrientation;
gObjectList[objectIndex].origin_pos[1] = _moles[mole].Pos.y - 9.0;
gObjectList[objectIndex].origin_pos[2] = _moles[mole].Pos.z;
}
|