mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-09-08 20:12:43 -04:00
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
This commit is contained in:
@@ -51,15 +51,12 @@ OMole::OMole(FVector pos, OMoleGroup* group) {
|
||||
_count++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moles are ticked from OMoleGroup
|
||||
* OMoleTick is func_800821AC
|
||||
* Dirt particle tick is func_80081790
|
||||
*/
|
||||
void OMole::Tick() {
|
||||
if (_idx == 0) {
|
||||
for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
|
||||
s32 objectIndex = gObjectParticle2[i];
|
||||
if (gObjectList[objectIndex].state != 0) {
|
||||
OMole::func_80081790(objectIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OMole::Draw(s32 cameraId) {
|
||||
@@ -184,9 +181,9 @@ void OMole::func_8008153C(s32 objectIndex) {
|
||||
gObjectList[loopObjectIndex].activeTLUT = d_course_moo_moo_farm_mole_dirt;
|
||||
gObjectList[loopObjectIndex].tlutList = mole;
|
||||
gObjectList[loopObjectIndex].sizeScaling = 0.15f;
|
||||
gObjectList[loopObjectIndex].velocity[1] = random_int(0x000AU);
|
||||
gObjectList[loopObjectIndex].velocity[1] = random_int(10);
|
||||
gObjectList[loopObjectIndex].velocity[1] = (gObjectList[loopObjectIndex].velocity[1] * 0.1) + 4.8;
|
||||
gObjectList[loopObjectIndex].unk_034 = random_int(5U);
|
||||
gObjectList[loopObjectIndex].unk_034 = random_int(5);
|
||||
gObjectList[loopObjectIndex].unk_034 = (gObjectList[loopObjectIndex].unk_034 * 0.01) + 0.8;
|
||||
gObjectList[loopObjectIndex].orientation[1] = (0x10000 / sp70) * var_s1;
|
||||
gObjectList[loopObjectIndex].origin_pos[0] = gObjectList[objectIndex].origin_pos[0];
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
bool Active;
|
||||
};
|
||||
|
||||
explicit OMoleGroup(std::vector<FVector> moles);
|
||||
explicit OMoleGroup(std::vector<FVector>& moles);
|
||||
|
||||
virtual void Tick() override;
|
||||
|
||||
@@ -24,4 +24,7 @@ public:
|
||||
|
||||
|
||||
std::vector<MoleEntry> _moles;
|
||||
private:
|
||||
static size_t _count;
|
||||
size_t _idx;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user