summaryrefslogtreecommitdiff
path: root/src/engine/objects/MoleGroup.cpp
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-11-22 18:13:33 -0700
committerGitHub <noreply@github.com>2025-11-22 18:13:33 -0700
commit5f60e30b59497d54b23097f8dbe5009faa43504d (patch)
tree3ddd0e64f452843e67774b040a207de84dca852d /src/engine/objects/MoleGroup.cpp
parentfffd3f7fe92c6eb45b68c0ca522066bf9c54abb2 (diff)
Fix Moles and some UI Interpolation bugs (#565)
* Update render_objects.c * Update FrameInterpolation.h * Update render_objects.c * Fix mac compile probably * Fix Mole Dirt Particles * Fix Mole Duplication Bug, probably * Fix drawing using wrong camera bug
Diffstat (limited to 'src/engine/objects/MoleGroup.cpp')
-rw-r--r--src/engine/objects/MoleGroup.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/engine/objects/MoleGroup.cpp b/src/engine/objects/MoleGroup.cpp
index 6e98edbbb..af936ed3f 100644
--- a/src/engine/objects/MoleGroup.cpp
+++ b/src/engine/objects/MoleGroup.cpp
@@ -8,12 +8,17 @@ extern "C" {
#include "math_util_2.h"
}
-OMoleGroup::OMoleGroup(std::vector<FVector> spawns) {
+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() {
@@ -24,14 +29,32 @@ void OMoleGroup::Tick() {
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() - 1);
- for (size_t i = 0; i < _moles.size() - 1; i++) {
+ 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()) {