summaryrefslogtreecommitdiff
path: root/src/engine/objects
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-02-07 14:36:55 -0700
committerGitHub <noreply@github.com>2025-02-07 14:36:55 -0700
commitfc1e1a97825c129f114a5c59ab1820d1a1b9187f (patch)
tree3d18b98adf1a3c62fcbd203f55a89e047782808a /src/engine/objects
parent6f8cbc0279004a39635c922b824e8561f5355bc5 (diff)
Reimpl star emitter (#180)
* Reimpl star emitter * Remove OObject Lists * wip mole reimpl * nearly fix moles * Cleanup * Update reimpl seagull * Rework finishline to auto spawn and not to run in credits * Fix train crossing direction in extra mode * Clarification * micro optimization * update mole --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/engine/objects')
-rw-r--r--src/engine/objects/Bat.cpp50
-rw-r--r--src/engine/objects/Bat.h1
-rw-r--r--src/engine/objects/Crab.cpp28
-rw-r--r--src/engine/objects/Crab.h1
-rw-r--r--src/engine/objects/Flagpole.cpp8
-rw-r--r--src/engine/objects/Flagpole.h1
-rw-r--r--src/engine/objects/HotAirBalloon.cpp8
-rw-r--r--src/engine/objects/HotAirBalloon.h1
-rw-r--r--src/engine/objects/Mole.cpp270
-rw-r--r--src/engine/objects/Mole.h23
-rw-r--r--src/engine/objects/MoleGroup.cpp50
-rw-r--r--src/engine/objects/MoleGroup.h27
-rw-r--r--src/engine/objects/Object.cpp1
-rw-r--r--src/engine/objects/Object.h1
-rw-r--r--src/engine/objects/Penguin.cpp91
-rw-r--r--src/engine/objects/Penguin.h20
-rw-r--r--src/engine/objects/Podium.cpp57
-rw-r--r--src/engine/objects/Podium.h5
-rw-r--r--src/engine/objects/Seagull.cpp36
-rw-r--r--src/engine/objects/Seagull.h5
-rw-r--r--src/engine/objects/Snowman.cpp54
-rw-r--r--src/engine/objects/Snowman.h4
-rw-r--r--src/engine/objects/Thwomp.cpp69
-rw-r--r--src/engine/objects/Thwomp.h1
-rw-r--r--src/engine/objects/TrashBin.cpp17
-rw-r--r--src/engine/objects/TrashBin.h1
-rw-r--r--src/engine/objects/Trophy.cpp101
-rw-r--r--src/engine/objects/Trophy.h6
28 files changed, 476 insertions, 461 deletions
diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp
index f32ef2d41..b90f7c857 100644
--- a/src/engine/objects/Bat.cpp
+++ b/src/engine/objects/Bat.cpp
@@ -19,19 +19,21 @@ const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gT
size_t OBat::_count = 0;
OBat::OBat(const FVector& pos, const FRotation& rot) {
- s32 objectId = indexObjectList1[0];
- init_texture_object(objectId, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U,
+
+ find_unused_obj_index(&_objectIndex);
+
+ init_texture_object(_objectIndex, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U,
(u16) 0x00000040);
- gObjectList[objectId].orientation[0] = rot.pitch;
- gObjectList[objectId].orientation[1] = rot.roll;
- gObjectList[objectId].orientation[2] = rot.yaw; // 0x8000
+ gObjectList[_objectIndex].orientation[0] = rot.pitch;
+ gObjectList[_objectIndex].orientation[1] = rot.roll;
+ gObjectList[_objectIndex].orientation[2] = rot.yaw; // 0x8000
_count++;
}
void OBat::Tick() {
s32 var_s2;
- s32 temp_s0;
+ s32 objectIndex;
Object* object;
if (D_8018CFC8 != 0) {
@@ -40,28 +42,28 @@ void OBat::Tick() {
if (D_8018D000 != 0) {
D_8018D000 -= 1;
}
- temp_s0 = indexObjectList1[0];
- func_80072E54(temp_s0, 0, 3, 1, 0, -1);
- func_80073514(temp_s0);
- object = &gObjectList[temp_s0];
- func_80073CB0(temp_s0, &object->primAlpha, -0x00001000, 0x00001000, 0x00000400, 0, -1);
+ objectIndex = _objectIndex;
+ func_80072E54(objectIndex, 0, 3, 1, 0, -1);
+ func_80073514(objectIndex);
+ object = &gObjectList[objectIndex];
+ func_80073CB0(objectIndex, &object->primAlpha, -0x00001000, 0x00001000, 0x00000400, 0, -1);
object->orientation[2] = object->primAlpha + 0x8000;
if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) {
D_8018CFD8 = 0;
for (var_s2 = 0; var_s2 < 40; var_s2++) {
- temp_s0 = gObjectParticle2[var_s2];
- if (temp_s0 == -1) {
+ objectIndex = gObjectParticle2[var_s2];
+ if (objectIndex == -1) {
continue;
}
- object = &gObjectList[temp_s0];
+ object = &gObjectList[objectIndex];
if (object->state == 0) {
continue;
}
- OBat::func_8007D8D4(temp_s0, 1);
- OBat::func_8007DAF8(temp_s0, 1);
- OBat::func_8007D794(temp_s0);
+ OBat::func_8007D8D4(objectIndex, 1);
+ OBat::func_8007DAF8(objectIndex, 1);
+ OBat::func_8007D794(objectIndex);
if (object->state == 0) {
delete_object_wrapper(&gObjectParticle2[var_s2]);
}
@@ -74,19 +76,19 @@ void OBat::Tick() {
if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) {
D_8018D010 = 0;
for (var_s2 = 0; var_s2 < 30; var_s2++) {
- temp_s0 = gObjectParticle3[var_s2];
- if (temp_s0 == -1) {
+ objectIndex = gObjectParticle3[var_s2];
+ if (objectIndex == -1) {
continue;
}
- object = &gObjectList[temp_s0];
+ object = &gObjectList[objectIndex];
if (object->state == 0) {
continue;
}
- OBat::func_8007D8D4(temp_s0, 2);
- OBat::func_8007DAF8(temp_s0, 2);
- OBat::func_8007D794(temp_s0);
+ OBat::func_8007D8D4(objectIndex, 2);
+ OBat::func_8007DAF8(objectIndex, 2);
+ OBat::func_8007D794(objectIndex);
if (object->state == 0) {
delete_object_wrapper(&gObjectParticle3[var_s2]);
}
@@ -103,7 +105,7 @@ void OBat::Draw(s32 cameraId) {
s32 objectIndex;
Camera* temp_s7;
- objectIndex = indexObjectList1[0];
+ objectIndex = _objectIndex;
temp_s7 = &camera1[cameraId];
OBat::func_80046F60((u8*)gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, 0x00000020, 0x00000040,
5);
diff --git a/src/engine/objects/Bat.h b/src/engine/objects/Bat.h
index 39a9e65d8..f9e0df074 100644
--- a/src/engine/objects/Bat.h
+++ b/src/engine/objects/Bat.h
@@ -56,4 +56,5 @@ private:
FVector _pos;
static size_t _count;
size_t _idx;
+ s32 _objectIndex;
};
diff --git a/src/engine/objects/Crab.cpp b/src/engine/objects/Crab.cpp
index 3a71e075d..c722a9037 100644
--- a/src/engine/objects/Crab.cpp
+++ b/src/engine/objects/Crab.cpp
@@ -28,26 +28,24 @@ extern "C" {
size_t OCrab::_count = 0;
OCrab::OCrab(const FVector2D& start, const FVector2D& end) {
- s32 objectId;
_idx = _count;
_start = start;
_end = end;
- objectId = indexObjectList1[_idx];
- init_object(objectId, 0);
- gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = start.x * xOrientation;
- gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = start.z;
+ find_unused_obj_index(&_objectIndex);
- gObjectList[objectId].unk_01C[0] = end.x * xOrientation;
- gObjectList[objectId].unk_01C[2] = end.z;
+ init_object(_objectIndex, 0);
+ gObjectList[_objectIndex].pos[0] = gObjectList[_objectIndex].origin_pos[0] = start.x * xOrientation;
+ gObjectList[_objectIndex].pos[2] = gObjectList[_objectIndex].origin_pos[2] = start.z;
+
+ gObjectList[_objectIndex].unk_01C[0] = end.x * xOrientation;
+ gObjectList[_objectIndex].unk_01C[2] = end.z;
_count++;
}
void OCrab::Tick(void) {
- s32 objectIndex;
-
- objectIndex = indexObjectList1[_idx];
+ s32 objectIndex = _objectIndex;
if (gObjectList[objectIndex].state != 0) {
OCrab::func_80082B34(objectIndex);
func_8008A6DC(objectIndex, 500.0f);
@@ -58,7 +56,7 @@ void OCrab::Tick(void) {
void OCrab::Draw(s32 cameraId) {
Camera* camera;
- s32 objectIndex = indexObjectList1[_idx];
+ s32 objectIndex = _objectIndex;
if (gObjectList[objectIndex].state >= 2) {
Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
camera = &camera1[cameraId];
@@ -74,11 +72,9 @@ void OCrab::Draw(s32 cameraId) {
void OCrab::DrawModel(s32 cameraId) {
s32 someIndex;
- s32 test;
-
- test = indexObjectList1[_idx];
- func_8008A364(test, cameraId, 0x2AABU, 800);
- if (is_obj_flag_status_active(test, VISIBLE) != 0) {
+ s32 objectIndex = _objectIndex;
+ func_8008A364(objectIndex, cameraId, 0x2AABU, 800);
+ if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
Camera *camera;
s32 objectIndex;
diff --git a/src/engine/objects/Crab.h b/src/engine/objects/Crab.h
index 4cadd3b87..2d1ef5e93 100644
--- a/src/engine/objects/Crab.h
+++ b/src/engine/objects/Crab.h
@@ -46,4 +46,5 @@ private:
FVector2D _end;
static size_t _count;
s32 _idx;
+ s32 _objectIndex;
};
diff --git a/src/engine/objects/Flagpole.cpp b/src/engine/objects/Flagpole.cpp
index 682f74915..7b5e5af20 100644
--- a/src/engine/objects/Flagpole.cpp
+++ b/src/engine/objects/Flagpole.cpp
@@ -20,13 +20,15 @@ OFlagpole::OFlagpole(const FVector& pos, s16 direction) {
_pos = pos;
_direction = direction;
- init_object(indexObjectList1[_idx], 0);
+ find_unused_obj_index(&_objectIndex);
+
+ init_object(_objectIndex, 0);
_count++;
}
void OFlagpole::Tick() { // func_80083080
- s32 objectIndex = indexObjectList1[_idx];
+ s32 objectIndex = _objectIndex;
if (gObjectList[objectIndex].state != 0) {
OFlagpole::func_80083018(objectIndex);
@@ -35,7 +37,7 @@ void OFlagpole::Tick() { // func_80083080
}
void OFlagpole::Draw(s32 cameraId) { // func_80055228
- s32 objectIndex = indexObjectList1[_idx];
+ s32 objectIndex = _objectIndex;
func_8008A364(objectIndex, cameraId, 0x4000U, 0x000005DC);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
diff --git a/src/engine/objects/Flagpole.h b/src/engine/objects/Flagpole.h
index 5824fcf18..034db865e 100644
--- a/src/engine/objects/Flagpole.h
+++ b/src/engine/objects/Flagpole.h
@@ -42,4 +42,5 @@ private:
s16 _direction;
static size_t _count;
size_t _idx;
+ s32 _objectIndex;
};
diff --git a/src/engine/objects/HotAirBalloon.cpp b/src/engine/objects/HotAirBalloon.cpp
index 234eef6d9..917fd7354 100644
--- a/src/engine/objects/HotAirBalloon.cpp
+++ b/src/engine/objects/HotAirBalloon.cpp
@@ -27,11 +27,13 @@ OHotAirBalloon::OHotAirBalloon(const FVector& pos) {
_visible = &mod;
}
- init_object(indexObjectList1[0], 0);
+ find_unused_obj_index(&_objectIndex);
+
+ init_object(_objectIndex, 0);
}
void OHotAirBalloon::Tick() {
- s32 objectIndex = indexObjectList1[0];
+ s32 objectIndex = _objectIndex;
if (*_visible) {
if (gObjectList[objectIndex].state != 0) {
@@ -49,7 +51,7 @@ void OHotAirBalloon::Tick() {
void OHotAirBalloon::Draw(s32 cameraId) {
s32 objectIndex;
- objectIndex = indexObjectList1[0];
+ objectIndex = _objectIndex;
if (*_visible) {
if (gGamestate != CREDITS_SEQUENCE) {
func_8008A1D0(objectIndex, cameraId, 0x000005DC, 0x00000BB8);
diff --git a/src/engine/objects/HotAirBalloon.h b/src/engine/objects/HotAirBalloon.h
index 301e111c4..5dad406db 100644
--- a/src/engine/objects/HotAirBalloon.h
+++ b/src/engine/objects/HotAirBalloon.h
@@ -31,4 +31,5 @@ public:
private:
FVector _pos;
bool *_visible;
+ s32 _objectIndex;
};
diff --git a/src/engine/objects/Mole.cpp b/src/engine/objects/Mole.cpp
index 7cc21e118..fdf5e7b08 100644
--- a/src/engine/objects/Mole.cpp
+++ b/src/engine/objects/Mole.cpp
@@ -22,64 +22,59 @@ extern "C" {
#include "external.h"
}
-OMole::OMole(Vec3f pos) {
+size_t OMole::_count = 0;
- find_unused_obj_index(&indexObjectList1[0]);
-}
+OMole::OMole(FVector pos, OMoleGroup* group) {
+ _idx = _count;
+ _group = group;
-void OMole::Tick() {
- s32 var_s1;
- s32 objectIndex;
+ find_unused_obj_index(&_objectIndex);
- for (var_s1 = 0; var_s1 < D_8018D1C8; var_s1++) {
- objectIndex = indexObjectList1[var_s1];
- if (gObjectList[objectIndex].state == 0) {
- if (are_players_in_course_section(8, 9) != 0) {
- func_80081FF4(objectIndex, 1);
- }
- } else {
- OMole::func_800821AC(objectIndex, 1);
- }
- }
+ gObjectList[_objectIndex].pos[0] = pos.x * xOrientation;
+ gObjectList[_objectIndex].pos[1] = pos.y;
+ gObjectList[_objectIndex].pos[2] = pos.z;
- for (var_s1 = 0; var_s1 < D_8018D1D0; var_s1++) {
- objectIndex = indexObjectList2[var_s1];
- if (gObjectList[objectIndex].state == 0) {
- if (are_players_in_course_section(0x0010, 0x0013) != 0) {
- OMole::func_80081FF4(objectIndex, 2);
- }
- } else {
- OMole::func_800821AC(objectIndex, 2);
- }
- }
+ gObjectList[_objectIndex].origin_pos[0] = pos.x * xOrientation;
+ gObjectList[_objectIndex].origin_pos[1] = pos.y - 9.0;
+ gObjectList[_objectIndex].origin_pos[2] = pos.z;
- for (var_s1 = 0; var_s1 < D_8018D1D8; var_s1++) {
- objectIndex = indexObjectList3[var_s1];
- if (gObjectList[objectIndex].state == 0) {
- if (are_players_in_course_section(0x0011, 0x0014) != 0) {
- func_80081FF4(objectIndex, 3);
- }
- } else {
- OMole::func_800821AC(objectIndex, 3);
- }
- }
+ // This is probably the mole particles
+ find_unused_obj_index(&_moleIndex);
+ init_object(_moleIndex, 0);
+ gObjectList[_moleIndex].pos[0] = pos.x * xOrientation;
+ gObjectList[_moleIndex].pos[2] = pos.z;
+ func_800887C0(_moleIndex);
+ gObjectList[_moleIndex].sizeScaling = 0.7f;
- for (var_s1 = 0; var_s1 < gObjectParticle2_SIZE; var_s1++) {
- objectIndex = gObjectParticle2[var_s1];
- if (gObjectList[objectIndex].state != 0) {
- OMole::func_80081790(objectIndex);
+ _count++;
+}
+
+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) {
+ size_t i;
+ OMole::func_80054D00(_objectIndex, cameraId);
+
+ OMole::func_80054EB8();
+ if (_idx == 0) {
+ OMole::func_80054F04(cameraId);
+ }
}
void OMole::func_80081790(s32 objectIndex) {
switch (gObjectList[objectIndex].state) {
case 0:
- break; /* irregular */
+ break;
case 1:
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.3f, gObjectList[objectIndex].unk_034,
gObjectList[objectIndex].orientation[1], 0x00000032) != 0) {
@@ -94,10 +89,6 @@ void OMole::func_80081790(s32 objectIndex) {
}
}
-
-
-
-
void OMole::func_80081AFC(s32 objectIndex, s32 arg1) {
s8* sp2C;
Object* object;
@@ -119,7 +110,7 @@ void OMole::func_80081AFC(s32 objectIndex, s32 arg1) {
case 0x3:
if (object->unk_0AE == 0) {
func_80086EAC(objectIndex, 2, 4);
- func_8008153C(objectIndex);
+ OMole::func_8008153C(objectIndex);
object_next_state(objectIndex);
func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x07));
}
@@ -139,18 +130,21 @@ void OMole::func_80081AFC(s32 objectIndex, s32 arg1) {
if (object->unk_0AE == 0) {
clear_object_flag(objectIndex, 0x00000200);
func_80072428(objectIndex);
- switch (arg1) { /* switch 1; irregular */
- case 1: /* switch 1 */
- sp2C = D_8018D198;
- break;
- case 2: /* switch 1 */
- sp2C = D_8018D1A8;
- break;
- case 3: /* switch 1 */
- sp2C = D_8018D1B8;
- break;
- }
- sp2C[object->type] = 0;
+
+ _group->_moles[object->type].Active = false;
+
+ // switch (arg1) {
+ // case 1:
+ // sp2C = D_8018D198;
+ // break;
+ // case 2:
+ // sp2C = D_8018D1A8;
+ // break;
+ // case 3:
+ // sp2C = D_8018D1B8;
+ // break;
+ // }
+ //sp2C[object->type] = 0;
}
break;
case 0:
@@ -162,17 +156,55 @@ void OMole::func_80081AFC(s32 objectIndex, s32 arg1) {
}
}
+void OMole::func_8008153C(s32 objectIndex) {
+ UNUSED s32 stackPadding[3];
+ s32 sp70;
+ s32 var_s1;
+ s32 var_s7;
+ s32 loopObjectIndex;
+
+ if (gPlayerCountSelection1 == 1) {
+ sp70 = 8;
+ } else {
+ sp70 = 4;
+ }
+
+ for (var_s7 = 0; var_s7 < sp70; var_s7++) {
+ for (var_s1 = 0; var_s1 < gObjectParticle2_SIZE; var_s1++) {
+ loopObjectIndex = gObjectParticle2[var_s1];
+
+ if (gObjectList[loopObjectIndex].state != 0) {
+ continue;
+ }
+
+ u8* mole = (u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_dirt);
+ init_object(loopObjectIndex, 0);
+ 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] = (gObjectList[loopObjectIndex].velocity[1] * 0.1) + 4.8;
+ gObjectList[loopObjectIndex].unk_034 = random_int(5U);
+ 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];
+ gObjectList[loopObjectIndex].origin_pos[1] = gObjectList[objectIndex].origin_pos[1] - 13.0;
+ gObjectList[loopObjectIndex].origin_pos[2] = gObjectList[objectIndex].origin_pos[2];
+ break;
+ }
+ }
+}
+
void OMole::func_80081D34(s32 objectIndex) {
Player* player;
- Camera* var_s4;
- s32 var_s2;
+ Camera* camera;
s32 var_s5;
Object* object;
var_s5 = 0;
player = gPlayerOne;
- var_s4 = camera1;
- for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, player++, var_s4++) {
+ camera = camera1;
+ for (size_t i = 0; i < D_8018D158; i++, player++, camera++) {
if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(player->effects & 0x80000000) &&
(has_collided_with_player(objectIndex, player) != 0)) {
if ((player->type & 0x8000) && !(player->type & 0x100)) {
@@ -182,11 +214,11 @@ void OMole::func_80081D34(s32 objectIndex) {
func_80072180();
}
if (player->effects & 0x200) {
- func_800C9060(var_s2, 0x1900A046U);
+ func_800C9060(i, 0x1900A046U);
} else {
player->soundEffects |= 2;
}
- object->direction_angle[1] = var_s4->rot[1];
+ object->direction_angle[1] = camera->rot[1];
object->velocity[1] = (player->unk_094 / 2) + 3.0;
object->unk_034 = player->unk_094 + 1.0;
if (object->velocity[1] >= 5.0) {
@@ -209,66 +241,23 @@ void OMole::func_80081D34(s32 objectIndex) {
}
}
+static const char* frames[] = {
+ gTextureMole1,
+ gTextureMole2,
+ gTextureMole3,
+ gTextureMole4,
+ gTextureMole5,
+ gTextureMole6,
+ gTextureMole7,
+ d_course_moo_moo_farm_mole_dirt,
+};
-void OMole::func_80081FF4(s32 objectIndex, s32 arg1) {
- UNUSED s32 stackPadding0;
- UNUSED s32 stackPadding1;
- s32 moleCount;
- s16 var_v1;
- s16 offset;
- s32 var_a0;
- s8* var_a2;
-
- init_object(objectIndex, 0);
- gObjectList[objectIndex].unk_04C = random_int(0x001EU) + 5;
- switch (arg1) { /* irregular */
- case 1:
- var_a2 = D_8018D198;
- moleCount = NUM_GROUP1_MOLES;
- offset = 0;
- break;
- case 2:
- var_a2 = D_8018D1A8;
- moleCount = NUM_GROUP2_MOLES;
- offset = 24;
- // offset = NUM_GROUP1_MOLES;
- break;
- case 3:
- var_a2 = D_8018D1B8;
- moleCount = NUM_GROUP3_MOLES;
- offset = 57;
- // offset = NUM_GROUP1_MOLES + NUM_GROUP2_MOLES;
- break;
- }
- var_v1 = random_int(moleCount);
- for (var_a0 = 0; var_a0 < moleCount; var_a0++) {
- if (var_a2[var_v1] != 0) {
- var_v1++;
- if (var_v1 == moleCount) {
- var_v1 = 0;
- }
- } else {
- var_a2[var_v1] = 1;
- gObjectList[objectIndex].type = var_v1;
- break;
- }
- }
- /*
- Ideally `gMoleSpawns` wouldn't be a union at all and its just be a list of Vec3s
- Even more ideally each mole group would have its own array for its spawns
- gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asVec3sList[offset + var_v1][0] * xOrientation;
- gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asVec3sList[offset + var_v1][1] - 9.0;
- gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asVec3sList[offset + var_v1][2];
- */
- gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 0] * xOrientation;
- gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 1] - 9.0;
- gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 2];
-}
void OMole::func_80081848(s32 objectIndex) {
- u8* mole = (u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_frames);
- u8* tlut = (u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_tlut);
- init_texture_object(objectIndex, (u8*)d_course_moo_moo_farm_mole_tlut, (const char**) mole, 0x20U, (u16) 0x00000040);
+ init_texture_object(objectIndex, (u8*)d_course_moo_moo_farm_mole_tlut, (const char**) frames, 0x20U, (u16) 0x00000040);
+ //gObjectList[objectIndex].activeTexture = (const char*)d_course_moo_moo_farm_mole_frames;
+ //gObjectList[objectIndex].activeTLUT = (const char*)d_course_moo_moo_farm_mole_tlut;
+
gObjectList[objectIndex].sizeScaling = 0.15f;
gObjectList[objectIndex].textureListIndex = 0;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
@@ -358,9 +347,9 @@ void OMole::func_80054E10(s32 objectIndex) {
void OMole::func_80054EB8() {
s32 someIndex;
- for (someIndex = 0; someIndex < NUM_TOTAL_MOLES; someIndex++) {
- func_80054E10(gObjectParticle1[someIndex]);
- }
+ //for (someIndex = 0; someIndex < NUM_TOTAL_MOLES; someIndex++) {
+ func_80054E10(_moleIndex);
+ //}
}
void OMole::func_80054D00(s32 objectIndex, s32 cameraId) {
@@ -382,41 +371,24 @@ void OMole::func_80054D00(s32 objectIndex, s32 cameraId) {
}
void OMole::func_80054F04(s32 cameraId) {
- s32 var_s2;
- s32 objectIndex;
- Camera* sp44;
- Object* object;
+ Camera* camera = &camera1[cameraId];
- sp44 = &camera1[cameraId];
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0079C8);
load_texture_block_rgba16_mirror((u8*) LOAD_ASSET_RAW(d_course_moo_moo_farm_mole_dirt), 0x00000010, 0x00000010);
- for (var_s2 = 0; var_s2 < gObjectParticle2_SIZE; var_s2++) {
- objectIndex = gObjectParticle2[var_s2];
- object = &gObjectList[objectIndex];
+
+if (_idx == 0) {
+ for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
+ s32 objectIndex = gObjectParticle2[i];
+ Object* object = &gObjectList[objectIndex];
if (object->state > 0) {
func_8008A364(objectIndex, cameraId, 0x2AABU, 0x000000C8);
if ((is_obj_flag_status_active(objectIndex, VISIBLE) != 0) && (gMatrixHudCount <= MTX_HUD_POOL_SIZE_MAX)) {
- object->orientation[1] = func_800418AC(object->pos[0], object->pos[2], sp44->pos);
+ object->orientation[1] = func_800418AC(object->pos[0], object->pos[2], camera->pos);
rsp_set_matrix_gObjectList(objectIndex);
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D006980);
}
}
}
+}
gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF);
}
-
-void OMole::render_object_moles(s32 cameraId) {
- s32 i;
-
- for (i = 0; i < NUM_GROUP1_MOLES; i++) {
- OMole::func_80054D00(indexObjectList1[i], cameraId);
- }
- for (i = 0; i < NUM_GROUP2_MOLES; i++) {
- OMole::func_80054D00(indexObjectList2[i], cameraId);
- }
- for (i = 0; i < NUM_GROUP3_MOLES; i++) {
- OMole::func_80054D00(indexObjectList3[i], cameraId);
- }
- OMole::func_80054EB8();
- OMole::func_80054F04(cameraId);
-} \ No newline at end of file
diff --git a/src/engine/objects/Mole.h b/src/engine/objects/Mole.h
index 7ff95c58c..7707b5383 100644
--- a/src/engine/objects/Mole.h
+++ b/src/engine/objects/Mole.h
@@ -3,6 +3,8 @@
#include <libultraship.h>
#include <vector>
#include "Object.h"
+#include "CoreMath.h"
+#include "MoleGroup.h"
extern "C" {
#include "macros.h"
@@ -15,14 +17,11 @@ extern "C" {
#include "some_data.h"
}
+class OMoleGroup;
class OMole : public OObject {
public:
- enum Behaviour : uint16_t {
- };
-
-public:
- explicit OMole(Vec3f pos);
+ explicit OMole(FVector pos, OMoleGroup* group);
virtual void Tick() override;
virtual void Draw(s32 cameraId) override;
@@ -33,20 +32,18 @@ public:
void render_object_moles(s32 cameraId);
void func_80054D00(s32 objectIndex, s32 cameraId);
void func_800821AC(s32 objectIndex, s32 arg1);
- void func_80081FF4(s32 objectIndex, s32 arg1);
void func_80081D34(s32 objectIndex);
void func_80081AFC(s32 objectIndex, s32 arg1);
void func_80081A88(s32 objectIndex);
void func_80081924(s32 objectIndex);
void func_80081848(s32 objectIndex);
void func_80081790(s32 objectIndex);
+ void func_8008153C(s32 objectIndex);
+ s32 _objectIndex;
+ s32 _moleIndex;
private:
- s32 _idx;
- s32 _state;
- s32 _timer;
- s32 _status;
- bool _toggle;
-
- SplineData *spline;
+ static size_t _count;
+ size_t _idx;
+ OMoleGroup* _group;
};
diff --git a/src/engine/objects/MoleGroup.cpp b/src/engine/objects/MoleGroup.cpp
new file mode 100644
index 000000000..6e98edbbb
--- /dev/null
+++ b/src/engine/objects/MoleGroup.cpp
@@ -0,0 +1,50 @@
+#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"
+}
+
+OMoleGroup::OMoleGroup(std::vector<FVector> spawns) {
+ for (auto& pos : spawns) {
+ pos.x * xOrientation;
+ OMole* ptr = reinterpret_cast<OMole*>(gWorldInstance.AddObject(new OMole(pos, this)));
+ _moles.push_back({ptr, pos, false});
+ }
+}
+
+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);
+ }
+ }
+}
+
+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++) {
+ 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;
+}
diff --git a/src/engine/objects/MoleGroup.h b/src/engine/objects/MoleGroup.h
new file mode 100644
index 000000000..dfb920985
--- /dev/null
+++ b/src/engine/objects/MoleGroup.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <libultraship.h>
+#include <vector>
+#include "World.h"
+#include "CoreMath.h"
+#include "Mole.h"
+
+class OMole;
+
+class OMoleGroup : public OObject {
+public:
+ struct MoleEntry {
+ OMole* Mole;
+ FVector Pos;
+ bool Active;
+ };
+
+ explicit OMoleGroup(std::vector<FVector> moles);
+
+ virtual void Tick() override;
+
+ void func_80081FF4(s32 objectIndex);
+
+
+ std::vector<MoleEntry> _moles;
+};
diff --git a/src/engine/objects/Object.cpp b/src/engine/objects/Object.cpp
index eb23b853e..d532dd566 100644
--- a/src/engine/objects/Object.cpp
+++ b/src/engine/objects/Object.cpp
@@ -20,3 +20,4 @@ void OObject::Expire() { }
void OObject::Destroy() {
PendingDestroy = true;
}
+void OObject::Reset() { }
diff --git a/src/engine/objects/Object.h b/src/engine/objects/Object.h
index c02deda23..b78b27240 100644
--- a/src/engine/objects/Object.h
+++ b/src/engine/objects/Object.h
@@ -22,4 +22,5 @@ public:
virtual void Draw(s32 cameraId);
virtual void Expire();
virtual void Destroy(); // Mark object for deletion at the start of the next frame
+ virtual void Reset();
};
diff --git a/src/engine/objects/Penguin.cpp b/src/engine/objects/Penguin.cpp
index c690e1ef2..1eeb00ff4 100644
--- a/src/engine/objects/Penguin.cpp
+++ b/src/engine/objects/Penguin.cpp
@@ -33,22 +33,16 @@ extern "C" {
extern s8 gPlayerCount;
}
-size_t OPenguin::_count = 0;
OPenguin::OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behaviour) {
- _idx = _count;
_type = type;
_bhv = behaviour;
- if (_idx >= 32) {
- printf("MAX penguin REACHED (32), skipping\n");
- return;
- }
+ find_unused_obj_index(&_objectIndex);
- s32 objectIndex = indexObjectList1[_idx];
- init_object(objectIndex, 0);
+ init_object(_objectIndex, 0);
- Object *object = &gObjectList[objectIndex];
+ Object *object = &gObjectList[_objectIndex];
object->origin_pos[0] = pos[0] * xOrientation;
object->origin_pos[1] = pos[1];
object->origin_pos[2] = pos[2];
@@ -75,14 +69,11 @@ OPenguin::OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behavio
object->boundingBoxSize = 0x000C;
break;
}
-
- _count++;
}
void OPenguin::Tick(void) {
- s32 objectIndex;
+ s32 objectIndex = _objectIndex;
- objectIndex = indexObjectList1[_idx];
if (gObjectList[objectIndex].state != 0) {
if (_type == PenguinType::EMPEROR) {
OPenguin::EmperorPenguin(objectIndex);
@@ -90,7 +81,7 @@ void OPenguin::Tick(void) {
OPenguin::OtherPenguin(objectIndex);
}
- OPenguin::Behaviours(objectIndex, _idx);
+ OPenguin::Behaviours(objectIndex);
}
if (func_80072320(objectIndex, 1) != 0) {
func_80089820(objectIndex, 1.75f, 1.5f, 0x1900A046U);
@@ -107,7 +98,7 @@ void OPenguin::Tick(void) {
}
void OPenguin::Draw(s32 cameraId) {
- s32 objectIndex;
+ s32 objectIndex = _objectIndex;
s32 temp_s1;
s32 drawDistance;
u16 var_s1;
@@ -121,26 +112,26 @@ void OPenguin::Draw(s32 cameraId) {
var_s3 = 0x00015F90;
}
- objectIndex = indexObjectList1[_idx];
+
if (gObjectList[objectIndex].state >= 2) {
- if (gPlayerCountSelection1 == 1) {
+
+ // This code decreased draw dist if there's more players.
+ // The var_s1 = 0x4000 for everything is just a guess.
+ // It seems to check the angle of the camera.
+ // These changes were so instance indices are not required.
+
+ //if (gPlayerCountSelection1 == 1) {
var_s1 = 0x4000;
- if (_idx == 0) {
- drawDistance = 0x000005DC;
- } else if (func_80072320(objectIndex, 8) != 0) {
- drawDistance = 0x00000320;
- } else {
- drawDistance = 0x000003E8;
- }
- } else {
- if (func_80072320(objectIndex, 8) != 0) {
- drawDistance = 0x000001F4;
- var_s1 = 0x4000;
- } else {
- drawDistance = 0x00000258;
- var_s1 = 0x5555;
- }
- }
+ drawDistance = 1500;
+ //} else {
+ // if (func_80072320(objectIndex, 8) != 0) {
+ // drawDistance = 500;
+ // var_s1 = 0x4000;
+ // } else {
+ // drawDistance = 600;
+ // var_s1 = 0x5555;
+ // }
+ //}
temp_s1 = func_8008A364(objectIndex, cameraId, var_s1, drawDistance);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
func_800557B4(objectIndex, (u32) temp_s1, var_s3);
@@ -148,7 +139,7 @@ void OPenguin::Draw(s32 cameraId) {
}
}
-void OPenguin::Behaviours(s32 objectIndex, s32 arg1) { // func_800850B0
+void OPenguin::Behaviours(s32 objectIndex) { // func_800850B0
Object* object;
object = &gObjectList[objectIndex];
@@ -157,7 +148,7 @@ void OPenguin::Behaviours(s32 objectIndex, s32 arg1) { // func_800850B0
OPenguin::func_80085080(objectIndex);
break;
case 2:
- OPenguin::func_8008502C(objectIndex, arg1);
+ OPenguin::func_8008502C(objectIndex);
break;
case 3:
OPenguin::func_80084D2C(objectIndex, 0);
@@ -226,17 +217,17 @@ void OPenguin::func_80084D2C(s32 objectIndex, s32 arg1) {
}
break;
case 3:
- switch (arg1) { /* switch 1; irregular */
- case 0: /* switch 1 */
+ switch (arg1) {
+ case 0:
sp24 = 1.0f;
break;
- case 1: /* switch 1 */
+ case 1:
sp24 = 1.5f;
break;
- case 2: /* switch 1 */
+ case 2:
sp24 = 2.0f;
break;
- case 3: /* switch 1 */
+ case 3:
sp24 = 2.5f;
break;
}
@@ -285,7 +276,7 @@ void OPenguin::func_80085080(s32 objectIndex) {
func_800873F4(objectIndex);
}
-void OPenguin::func_8008502C(s32 objectIndex, s32 arg1) {
+void OPenguin::func_8008502C(s32 objectIndex) {
func_80088038(objectIndex, gObjectList[objectIndex].unk_01C[1], gObjectList[objectIndex].unk_0C6);
object_calculate_new_pos_offset(objectIndex);
func_800873F4(objectIndex);
@@ -371,6 +362,8 @@ void OPenguin::OtherPenguin(s32 objectIndex) {
}
}
+bool OPenguin::_toggle = false;
+
void OPenguin::InitOtherPenguin(s32 objectIndex) {
Object* object;
@@ -380,7 +373,7 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
object->vertex = (Vtx*) d_course_sherbet_land_unk_data11;
//object->boundingBoxSize = 4;
object->unk_09C = 2;
- object->unk_04C = random_int(0x012CU);
+ object->unk_04C = random_int(300);
set_object_flag(objectIndex, 0x04000220);
// This code has been significantly refactored from the original func_800845C8
@@ -388,7 +381,15 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
switch(_bhv) {
case Behaviour::CIRCLE:
object->unk_01C[1] = Diameter;
- object->unk_0C4 = (_idx << 0xF) & 0xFFFF;
+
+ if (_toggle) {
+ object->unk_0C4 = 0x8000;
+ } else {
+ object->unk_0C4 = 0;
+ }
+
+ _toggle = !_toggle;
+
//object->unk_0DD = 2;
func_800722A4(objectIndex, 8);
break;
@@ -411,3 +412,7 @@ void OPenguin::InitOtherPenguin(s32 objectIndex) {
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
object_next_state(objectIndex);
}
+
+void OPenguin::Reset() {
+ _toggle = false;
+}
diff --git a/src/engine/objects/Penguin.h b/src/engine/objects/Penguin.h
index 63c2207c1..72ba16285 100644
--- a/src/engine/objects/Penguin.h
+++ b/src/engine/objects/Penguin.h
@@ -40,32 +40,22 @@ public:
explicit OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behaviour);
- ~OPenguin() {
- _count--;
- }
-
- static size_t GetCount() {
- return _count;
- }
-
-
virtual void Tick() override;
virtual void Draw(s32 cameraId) override;
+ virtual void Reset() override;
private:
- void Behaviours(s32 objectIndex, s32 arg1);
+ void Behaviours(s32 objectIndex);
void EmperorPenguin(s32 objectIndex);
void func_80085080(s32 objectIndex);
- void func_8008502C(s32 objectIndex, s32 arg1);
+ void func_8008502C(s32 objectIndex);
void func_80084D2C(s32 objectIndex, s32 arg1);
void InitEmperorPenguin(s32 objectIndex);
void OtherPenguin(s32 objectIndex);
void InitOtherPenguin(s32 objectIndex);
- static size_t _count;
- s32 _idx;
+ static bool _toggle;
+ s32 _objectIndex;
PenguinType _type;
Behaviour _bhv;
-
-
};
diff --git a/src/engine/objects/Podium.cpp b/src/engine/objects/Podium.cpp
index 1922c98a5..d8f1e2ff2 100644
--- a/src/engine/objects/Podium.cpp
+++ b/src/engine/objects/Podium.cpp
@@ -29,45 +29,66 @@ OPodium::OPodium(const FVector& pos) {
_pos = pos;
- for (size_t i = 0; i < NUM_PODIUMS; i++) {
- s32 objectIndex = indexObjectList1[i];
- //init_object(objectIndex, 0);
- //set_obj_origin_pos(objectIndex, pos.x - 1.5, pos.y, pos.z);
- }
+ find_unused_obj_index(&_podium1Index);
+ find_unused_obj_index(&_podium2Index);
+ find_unused_obj_index(&_podium3Index);
+
+ //init_object(objectIndex, 0);
+ //set_obj_origin_pos(objectIndex, pos.x - 1.5, pos.y, pos.z);
}
void OPodium::Tick() { // func_80086604
- s32 objectIndex;
if ((D_8016347C != 0) && (D_802874D8.unk1D < 3)) {
if (D_801658C6 == 0) {
for (size_t i = 0; i < 3; i++) {
- objectIndex = indexObjectList1[i];
- init_object(objectIndex, 0);
+ init_object(_podium1Index, 0);
+ init_object(_podium2Index, 0);
+ init_object(_podium3Index, 0);
}
D_801658C6 = 1;
}
}
- for (size_t i = 0; i != NUM_PODIUMS; i++) {
- objectIndex = indexObjectList1[i];
- if (gObjectList[objectIndex].state != 0) {
- OPodium::func_80086528(objectIndex, i);
- OPodium::func_80086424(objectIndex);
- }
+
+ if (gObjectList[_podium1Index].state != 0) {
+ OPodium::func_80086528(_podium1Index, 0);
+ OPodium::func_80086424(_podium1Index);
+ }
+
+ if (gObjectList[_podium2Index].state != 0) {
+ OPodium::func_80086528(_podium2Index, 1);
+ OPodium::func_80086424(_podium2Index);
+ }
+
+ if (gObjectList[_podium3Index].state != 0) {
+ OPodium::func_80086528(_podium3Index, 2);
+ OPodium::func_80086424(_podium3Index);
}
}
void OPodium::Draw(s32 cameraId) { // func_80055F48
- for (size_t i = 0; i < NUM_PODIUMS; i++) {
- Object* object;
+ Object* object = &gObjectList[_podium1Index];
+ if (object->state >= 2) {
+ //func_80043220(object->pos, object->direction_angle, object->sizeScaling, object->model);
+ rsp_set_matrix_transformation(object->pos, object->direction_angle, object->sizeScaling);
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077A0);
+ gSPDisplayList(gDisplayListHead++, object->model);
+ }
- object = &gObjectList[indexObjectList1[i]];
+ object = &gObjectList[_podium2Index];
+ if (object->state >= 2) {
+ //func_80043220(object->pos, object->direction_angle, object->sizeScaling, object->model);
+ rsp_set_matrix_transformation(object->pos, object->direction_angle, object->sizeScaling);
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077A0);
+ gSPDisplayList(gDisplayListHead++, object->model);
+ }
+
+ object = &gObjectList[_podium3Index];
if (object->state >= 2) {
//func_80043220(object->pos, object->direction_angle, object->sizeScaling, object->model);
rsp_set_matrix_transformation(object->pos, object->direction_angle, object->sizeScaling);
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077A0);
gSPDisplayList(gDisplayListHead++, object->model);
}
- }
}
void OPodium::func_8008629C(s32 objectIndex, s32 arg1) {
diff --git a/src/engine/objects/Podium.h b/src/engine/objects/Podium.h
index ea79d7232..fafdfe63d 100644
--- a/src/engine/objects/Podium.h
+++ b/src/engine/objects/Podium.h
@@ -33,7 +33,8 @@ public:
void func_80086528(s32 objectIndex, s32 arg1);
private:
-
- s32 _idx;
+ s32 _podium1Index;
+ s32 _podium2Index;
+ s32 _podium3Index;
FVector _pos;
};
diff --git a/src/engine/objects/Seagull.cpp b/src/engine/objects/Seagull.cpp
index cced70348..11043238f 100644
--- a/src/engine/objects/Seagull.cpp
+++ b/src/engine/objects/Seagull.cpp
@@ -31,12 +31,11 @@ SplineData* D_800E633C[] = { &D_800E6034, &D_800E60F0, &D_800E61B4, &D_800E6280
size_t OSeagull::_count = 0;
-OSeagull::OSeagull(Vec3f pos) {
- size_t objectIndex;
+OSeagull::OSeagull(FVector pos) {
_idx = _count;
- _pos[0] = pos[0];
- _pos[1] = pos[1];
- _pos[2] = pos[2];
+ _pos.x = pos.x;
+ _pos.y = pos.y;
+ _pos.z = pos.z;
s16 randZ;
s16 randX;
@@ -45,18 +44,16 @@ OSeagull::OSeagull(Vec3f pos) {
randY = random_int(20);
randZ = random_int(200) + -100.0;
- //for (i = 0; i < NUM_SEAGULLS; i++) {
+ find_unused_obj_index(&_objectIndex);
+ init_object(_objectIndex, 0);
- objectIndex = indexObjectList2[_idx];
- init_object(objectIndex, 0);
-
- set_obj_origin_pos(objectIndex, pos[0], pos[1], pos[2]);
+ set_obj_origin_pos(_objectIndex, pos.x, pos.y, pos.z);
if (_idx < (NUM_SEAGULLS / 2)) {
- gObjectList[objectIndex].unk_0D5 = 0;
+ gObjectList[_objectIndex].unk_0D5 = 0;
} else {
- gObjectList[objectIndex].unk_0D5 = 1;
+ gObjectList[_objectIndex].unk_0D5 = 1;
}
_count++;
@@ -64,7 +61,7 @@ OSeagull::OSeagull(Vec3f pos) {
void OSeagull::Tick() {
Object* object;
- s32 objectIndex = indexObjectList2[_idx];
+ s32 objectIndex = _objectIndex;
object = &gObjectList[objectIndex];
if (object->state == 0) {
@@ -83,10 +80,11 @@ void OSeagull::Tick() {
if (gGamestate != CREDITS_SEQUENCE) {
func_800C98B8(object->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43));
} else {
- objectIndex = indexObjectList2[1];
- if (gCutsceneShotTimer <= 150) {
- object = &gObjectList[objectIndex];
- func_800C98B8(object->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43));
+ if (_idx == 1) {
+ if (gCutsceneShotTimer <= 150) {
+ object = &gObjectList[_objectIndex];
+ func_800C98B8(object->pos, D_80183E40, SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x43));
+ }
}
}
}
@@ -108,7 +106,7 @@ void OSeagull::Tick() {
}
void OSeagull::Draw(s32 cameraId) { // render_object_seagulls
- s32 objectIndex = indexObjectList2[_idx];
+ s32 objectIndex = _objectIndex;
if (func_8008A364(objectIndex, cameraId, 0x5555U, 0x000005DC) < 0x9C401 && CVarGetInteger("gNoCulling", 0) == 0) {
D_80165908 = 1;
@@ -172,7 +170,7 @@ void OSeagull::func_8008241C(s32 objectIndex, s32 arg1) {
randY = random_int(0x0014);
randZ = random_int(0x00C8) + -100.0;
- set_obj_origin_pos(objectIndex, (randX + _pos[0]) * xOrientation, randY + _pos[1], randZ + _pos[2]);
+ set_obj_origin_pos(objectIndex, (randX + _pos.x) * xOrientation, randY + _pos.y, randZ + _pos.z);
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
gObjectList[objectIndex].unk_034 = 1.0f;
func_80086EF0(objectIndex);
diff --git a/src/engine/objects/Seagull.h b/src/engine/objects/Seagull.h
index c6898dcc2..a0e5cd233 100644
--- a/src/engine/objects/Seagull.h
+++ b/src/engine/objects/Seagull.h
@@ -19,7 +19,7 @@ extern "C" {
//! @todo unk_0D5 needs to be a struct variable probably. What does it do? Behaviour?
class OSeagull : public OObject {
public:
- explicit OSeagull(Vec3f pos);
+ explicit OSeagull(FVector pos);
~OSeagull() {
_count--;
@@ -38,7 +38,8 @@ public:
void func_8008241C(s32 objectIndex, s32 arg1);
void func_80082714(s32 objectIndex, s32 arg1);
private:
- Vec3f _pos;
+ s32 _objectIndex;
+ FVector _pos;
static size_t _count;
s32 _idx;
bool _toggle;
diff --git a/src/engine/objects/Snowman.cpp b/src/engine/objects/Snowman.cpp
index c05f464ef..2052a8adb 100644
--- a/src/engine/objects/Snowman.cpp
+++ b/src/engine/objects/Snowman.cpp
@@ -20,31 +20,30 @@ OSnowman::OSnowman(const FVector& pos) {
_idx = _count;
_pos = pos;
- s32 objectId = indexObjectList2[_idx];
- init_object(objectId, 0);
- gObjectList[objectId].origin_pos[0] = pos.x * xOrientation;
- gObjectList[objectId].origin_pos[1] = pos.y + 5.0 + 3.0;
- gObjectList[objectId].origin_pos[2] = pos.z;
- gObjectList[objectId].pos[0] = pos.x * xOrientation;
- gObjectList[objectId].pos[1] = pos.y + 5.0 + 3.0;
- gObjectList[objectId].pos[2] = pos.z;
-
- objectId = indexObjectList1[_idx];
- init_object(objectId, 0);
- gObjectList[objectId].origin_pos[0] = pos.x * xOrientation;
- gObjectList[objectId].origin_pos[1] = pos.y + 3.0;
- gObjectList[objectId].origin_pos[2] = pos.z;
- gObjectList[objectId].unk_0D5 = 0; // Section Id no longer used.
-
- gObjectList[objectId].pos[0] = pos.x * xOrientation;
- gObjectList[objectId].pos[1] = pos.y + 3.0;
- gObjectList[objectId].pos[2] = pos.z;
+ find_unused_obj_index(&_headIndex);
+ init_object(_headIndex, 0);
+ gObjectList[_headIndex].origin_pos[0] = pos.x * xOrientation;
+ gObjectList[_headIndex].origin_pos[1] = pos.y + 5.0 + 3.0;
+ gObjectList[_headIndex].origin_pos[2] = pos.z;
+ gObjectList[_headIndex].pos[0] = pos.x * xOrientation;
+ gObjectList[_headIndex].pos[1] = pos.y + 5.0 + 3.0;
+ gObjectList[_headIndex].pos[2] = pos.z;
+
+ find_unused_obj_index(&_bodyIndex);
+ init_object(_bodyIndex, 0);
+ gObjectList[_bodyIndex].origin_pos[0] = pos.x * xOrientation;
+ gObjectList[_bodyIndex].origin_pos[1] = pos.y + 3.0;
+ gObjectList[_bodyIndex].origin_pos[2] = pos.z;
+ gObjectList[_bodyIndex].unk_0D5 = 0; // Section Id no longer used.
+
+ gObjectList[_bodyIndex].pos[0] = pos.x * xOrientation;
+ gObjectList[_bodyIndex].pos[1] = pos.y + 3.0;
+ gObjectList[_bodyIndex].pos[2] = pos.z;
_count++;
}
void OSnowman::Tick() {
- s32 var_s0;
s32 var_s3;
s32 var_s4;
s32 objectIndex;
@@ -52,8 +51,8 @@ void OSnowman::Tick() {
//! @todo quick hack to add the snow particles on hit. Need to separate into its own class
if (_idx == 0) {
- for (var_s0 = 0; var_s0 < gObjectParticle2_SIZE; var_s0++) {
- objectIndex = gObjectParticle2[var_s0];
+ for (size_t i = 0; i < gObjectParticle2_SIZE; i++) {
+ objectIndex = gObjectParticle2[i];
if (objectIndex == DELETED_OBJECT_ID) {
continue;
@@ -66,14 +65,13 @@ void OSnowman::Tick() {
if (gObjectList[objectIndex].state != 0) {
continue;
}
- delete_object_wrapper(&gObjectParticle2[var_s0]);
- if (var_s0) {} // ??
+ delete_object_wrapper(&gObjectParticle2[i]);
}
}
//for (var_s0 = 0; var_s0 < NUM_SNOWMEN; var_s0++) {
- var_s4 = indexObjectList1[_idx];
- var_s3 = indexObjectList2[_idx];
+ var_s4 = _bodyIndex;
+ var_s3 = _headIndex;
OSnowman::func_80083A94(var_s3); // snowman head
OSnowman::func_80083C04(var_s4); // snowman body
if (is_obj_index_flag_status_inactive(var_s4, 0x00001000) != 0) {
@@ -113,7 +111,7 @@ void OSnowman::func_800836F0(Vec3f pos) {
void OSnowman::DrawHead(s32 cameraId) {
s32 objectIndex;
Camera* camera = &camera1[cameraId];
- objectIndex = indexObjectList1[_idx];
+ objectIndex = _bodyIndex;
if (gObjectList[objectIndex].state >= 2) {
func_8008A364(objectIndex, cameraId, 0x2AABU, 0x00000258);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
@@ -127,7 +125,7 @@ void OSnowman::DrawHead(s32 cameraId) {
(u8*)gObjectList[objectIndex].activeTexture, gObjectList[objectIndex].vertex,
0x00000040, 0x00000040, 0x00000040, 0x00000020);
}
- objectIndex = indexObjectList2[_idx];
+ objectIndex = _headIndex;
D_80183E80[0] = (s16) gObjectList[objectIndex].orientation[0];
D_80183E80[2] = (u16) gObjectList[objectIndex].orientation[2];
draw_2d_texture_at(gObjectList[objectIndex].pos, (u16*) D_80183E80,
diff --git a/src/engine/objects/Snowman.h b/src/engine/objects/Snowman.h
index e3e2a0138..ffa927769 100644
--- a/src/engine/objects/Snowman.h
+++ b/src/engine/objects/Snowman.h
@@ -46,9 +46,11 @@ public:
void func_80083538(s32 objectIndex, Vec3f arg1, s32 arg2, s32 arg3);
void func_8008379C(s32 objectIndex);
-
private:
FVector _pos;
static size_t _count;
size_t _idx;
+ s32 _objectIndex;
+ s32 _headIndex;
+ s32 _bodyIndex;
};
diff --git a/src/engine/objects/Thwomp.cpp b/src/engine/objects/Thwomp.cpp
index afa12b03b..6a04f07bb 100644
--- a/src/engine/objects/Thwomp.cpp
+++ b/src/engine/objects/Thwomp.cpp
@@ -52,11 +52,9 @@ OThwomp::OThwomp(s16 x, s16 z, s16 direction, f32 scale, s16 behaviour, s16 prim
_boundingBoxSize = boundingBoxSize;
State = (States)behaviour;
- if (_idx >= 32) {
- printf("MAX THWOMPS REACHED (32), skipping\n");
- return;
- }
- s32 objectId = indexObjectList1[_idx];
+ find_unused_obj_index(&_objectIndex);
+
+ s32 objectId = _objectIndex;
init_object(objectId, 0);
gObjectList[objectId].origin_pos[0] = x * xOrientation;
gObjectList[objectId].origin_pos[2] = z;
@@ -79,9 +77,8 @@ void OThwomp::Tick60fps() { // func_80081210
s32 var_s2_3;
s32 var_s4;
- objectIndex = indexObjectList1[_idx];
- func_800722CC(objectIndex, 0x00000010);
- OThwomp::SetVisibility(objectIndex);
+ func_800722CC(_objectIndex, 0x00000010);
+ OThwomp::SetVisibility(_objectIndex);
OThwomp::func_8007F8D8();
@@ -92,26 +89,25 @@ void OThwomp::Tick60fps() { // func_80081210
D_80165834[1] += 0x200;
}
- objectIndex = indexObjectList1[_idx];
- if (gObjectList[objectIndex].state != 0) {
+ if (gObjectList[_objectIndex].state != 0) {
switch (State) {
case STATIONARY:
- OThwomp::StationaryBehaviour(objectIndex);
+ OThwomp::StationaryBehaviour(_objectIndex);
break;
case MOVE_AND_ROTATE:
- OThwomp::MoveAndRotateBehaviour(objectIndex);
+ OThwomp::MoveAndRotateBehaviour(_objectIndex);
break;
case MOVE_FAR:
- OThwomp::MoveFarBehaviour(objectIndex);
+ OThwomp::MoveFarBehaviour(_objectIndex);
break;
case STATIONARY_FAST:
- OThwomp::StationaryFastBehaviour(objectIndex);
+ OThwomp::StationaryFastBehaviour(_objectIndex);
break;
case JAILED:
- OThwomp::JailedBehaviour(objectIndex);
+ OThwomp::JailedBehaviour(_objectIndex);
break;
case SLIDE:
- OThwomp::SlidingBehaviour(objectIndex);
+ OThwomp::SlidingBehaviour(_objectIndex);
break;
}
}
@@ -121,27 +117,25 @@ void OThwomp::Tick60fps() { // func_80081210
player->tyres[FRONT_LEFT].unk_14 &= ~3;
player->unk_046 &= ~0x0006;
- objectIndex = indexObjectList1[_idx];
if (!(player->effects & BOO_EFFECT)) {
- OThwomp::func_80080B28(objectIndex, var_s4);
+ OThwomp::func_80080B28(_objectIndex, var_s4);
}
- if (is_obj_flag_status_active(objectIndex, 0x00020000) != 0) {
- OThwomp::SetPlayerCrushedEffect(objectIndex, player);
+ if (is_obj_flag_status_active(_objectIndex, 0x00020000) != 0) {
+ OThwomp::SetPlayerCrushedEffect(_objectIndex, player);
}
- if (is_obj_flag_status_active(objectIndex, 0x00010000) != 0) {
- OThwomp::func_80080A4C(objectIndex, var_s4);
+ if (is_obj_flag_status_active(_objectIndex, 0x00010000) != 0) {
+ OThwomp::func_80080A4C(_objectIndex, var_s4);
}
}
OThwomp::func_8007542C(3);
- objectIndex = indexObjectList1[_idx];
- if (func_80072320(objectIndex, 0x00000020) == 0) {
+ if (func_80072320(_objectIndex, 0x00000020) == 0) {
return;
}
- func_800722CC(objectIndex, 0x00000020);
- OThwomp::AddParticles(objectIndex);
+ func_800722CC(_objectIndex, 0x00000020);
+ OThwomp::AddParticles(_objectIndex);
for (var_s4 = 0; var_s4 < gObjectParticle2_SIZE; var_s4++) {
objectIndex = gObjectParticle2[var_s4];
@@ -160,7 +154,7 @@ void OThwomp::Tick60fps() { // func_80081210
}
void OThwomp::func_800810F4(s32 objectIndex) {
- switch (gObjectList[objectIndex].state) { /* irregular */
+ switch (gObjectList[objectIndex].state) {
case 0:
break;
case 1:
@@ -336,7 +330,6 @@ void OThwomp::SetVisibility(s32 objectIndex) { // func_8008A4CC
void OThwomp::func_8007F8D8() {
Player* player;
- s32 objectIndex;
s32 var_s0;
s32 someIndex;
s32 var_s4;
@@ -345,11 +338,10 @@ void OThwomp::func_8007F8D8() {
player = gPlayerOne;
var_s4 = 1;
- objectIndex = indexObjectList1[_idx];
- object = &gObjectList[objectIndex];
+ object = &gObjectList[_objectIndex];
if (object->unk_0D5 == 3) {
var_s0 = 0;
- if ((object->state >= 2) && (func_80072354(objectIndex, 8) != 0)) {
+ if ((object->state >= 2) && (func_80072354(_objectIndex, 8) != 0)) {
var_s0 = 1;
}
var_s4 *= var_s0;
@@ -368,7 +360,6 @@ void OThwomp::func_8007F8D8() {
s32 OThwomp::func_8007F75C(s32 playerId) {
s32 someIndex;
- s32 objectIndex;
s32 temp_s7;
s32 var_s6;
s32 waypoint;
@@ -377,17 +368,15 @@ s32 OThwomp::func_8007F75C(s32 playerId) {
var_s6 = 0;
if ((waypoint >= 0xAA) && (waypoint < 0xB5)) {
temp_s7 = random_int(0x0032U) + 0x32;
- objectIndex = indexObjectList1[_idx];
- if (gObjectList[objectIndex].unk_0D5 == 3) {
+ if (gObjectList[_objectIndex].unk_0D5 == 3) {
var_s6 = 1;
- OThwomp::func_8007F660(objectIndex, playerId, temp_s7);
+ OThwomp::func_8007F660(_objectIndex, playerId, temp_s7);
}
} else if ((waypoint >= 0xD7) && (waypoint < 0xE2)) {
- objectIndex = indexObjectList1[_idx];
- if (gObjectList[objectIndex].unk_0D5 == 3) {
+ if (gObjectList[_objectIndex].unk_0D5 == 3) {
var_s6 = 1;
- OThwomp::func_8007F6C4(objectIndex, playerId);
+ OThwomp::func_8007F6C4(_objectIndex, playerId);
}
}
return var_s6;
@@ -668,7 +657,7 @@ Lights1 D_800E4680 = gdSPDefLights1(85, 85, 85, 255, 255, 255, 0, 0, 120);
Lights1 D_800E4698 = gdSPDefLights1(85, 85, 85, 255, 255, 255, 0, 0, 120);
void OThwomp::Draw(s32 cameraId) {
- s32 objectIndex = 0;
+ s32 objectIndex = _objectIndex;
s32 i;
UNUSED s32 stackPadding0;
s16 minusone, plusone;
@@ -677,14 +666,12 @@ void OThwomp::Draw(s32 cameraId) {
camera = &camera1[cameraId];
if (cameraId == PLAYER_ONE) {
- objectIndex = indexObjectList1[_idx];
clear_object_flag(objectIndex, 0x00070000);
func_800722CC(objectIndex, 0x00000110);
}
OThwomp::TranslateThwompLights();
- objectIndex = indexObjectList1[_idx];
minusone = gObjectList[objectIndex].unk_0DF - 1;
plusone = gObjectList[objectIndex].unk_0DF + 1;
diff --git a/src/engine/objects/Thwomp.h b/src/engine/objects/Thwomp.h
index 22c674bb5..75aeaf1a0 100644
--- a/src/engine/objects/Thwomp.h
+++ b/src/engine/objects/Thwomp.h
@@ -113,6 +113,7 @@ public:
private:
static size_t _count;
s32 _idx;
+ s32 _objectIndex;
s16 _faceDirection;
//! @todo Write this better. This effects the squish size and the bounding box size.
// We should probably return to the programmer the pointer to the actor so they can do thwomp->squishSize = value.
diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp
index 43d43b1fc..6aa556470 100644
--- a/src/engine/objects/TrashBin.cpp
+++ b/src/engine/objects/TrashBin.cpp
@@ -26,7 +26,9 @@ OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, O
_scale = scale;
_bhv = bhv;
- init_object(indexObjectList1[1], 0);
+ find_unused_obj_index(&_objectIndex);
+
+ init_object(_objectIndex, 0);
if (GetCourse() != GetBansheeBoardwalk()) {
_drawBin = true;
@@ -34,26 +36,23 @@ OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, O
}
void OTrashBin::Tick() {
- s32 objectIndex = indexObjectList1[1];
- OTrashBin::func_8007E00C(objectIndex);
+ OTrashBin::func_8007E00C(_objectIndex);
switch(_bhv) {
case STATIC:
break;
case MUNCHING:
- func_8007DDC0(objectIndex);
+ func_8007DDC0(_objectIndex);
break;
}
}
void OTrashBin::Draw(s32 cameraId) {
- s32 objectIndex;
Object* object;
- objectIndex = indexObjectList1[1];
- func_8008A364(objectIndex, cameraId, 0x5555U, 0x00000320);
- if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
- object = &gObjectList[objectIndex];
+ func_8008A364(_objectIndex, cameraId, 0x5555U, 0x00000320);
+ if (is_obj_flag_status_active(_objectIndex, VISIBLE) != 0) {
+ object = &gObjectList[_objectIndex];
if (object->state >= 2) {
func_80043220(object->pos, object->orientation, object->sizeScaling, object->model);
}
diff --git a/src/engine/objects/TrashBin.h b/src/engine/objects/TrashBin.h
index 2ef500f92..2ebe13e87 100644
--- a/src/engine/objects/TrashBin.h
+++ b/src/engine/objects/TrashBin.h
@@ -41,5 +41,6 @@ private:
FRotation _rot;
float _scale;
size_t _idx;
+ s32 _objectIndex;
bool _drawBin = false;
};
diff --git a/src/engine/objects/Trophy.cpp b/src/engine/objects/Trophy.cpp
index 4de758aab..54bd70d3e 100644
--- a/src/engine/objects/Trophy.cpp
+++ b/src/engine/objects/Trophy.cpp
@@ -1,6 +1,8 @@
#include "Trophy.h"
#include "assets/common_data.h"
#include "assets/data_segment2.h"
+#include "port/Game.h"
+
extern "C" {
#include "main.h"
#include "defines.h"
@@ -8,6 +10,7 @@ extern "C" {
#include "code_80057C60.h"
#include "assets/ceremony_data.h"
#include "podium_ceremony_actors.h"
+#include "engine/particles/StarEmitter.h"
#include "math_util.h"
#include "math_util_2.h"
#include "data/some_data.h"
@@ -18,12 +21,18 @@ extern "C" {
}
OTrophy::OTrophy(const FVector& pos, TrophyType trophy, Behaviour bhv) {
- s32 objectIndex = indexObjectList1[3];
_trophy = trophy;
_spawnPos = pos;
_spawnPos.y += 16.0f; // Adjust the height so the trophy sits on the surface when positioned to 0,0,0
_bhv = bhv;
+ find_unused_obj_index(&_objectIndex);
+
+ // If you're trying to place multiple trophies in the podium ceremony
+ // This will make the camera look at the last trophy spawned.
+ // Thus this will need to be changed if that's not desired.
+ gTrophyIndex = _objectIndex;
+
if (bhv == OTrophy::Behaviour::PODIUM_CEREMONY) {
_toggleVisibility = &D_801658CE;
} else {
@@ -34,55 +43,57 @@ OTrophy::OTrophy(const FVector& pos, TrophyType trophy, Behaviour bhv) {
// This allows spawning for mods
if (*_toggleVisibility == true) {
- init_object(objectIndex, 0);
+ init_object(_objectIndex, 0);
}
switch (trophy) {
case TrophyType::GOLD:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl10;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl10;
break;
case TrophyType::SILVER:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl12;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl12;
break;
case TrophyType::BRONZE:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl14;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl14;
break;
case TrophyType::GOLD_150:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl11;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl11;
break;
case TrophyType::SILVER_150:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl13;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl13;
break;
case TrophyType::BRONZE_150:
- gObjectList[objectIndex].model = (Gfx*)gold_trophy_dl15;
+ gObjectList[_objectIndex].model = (Gfx*)gold_trophy_dl15;
break;
}
// Set defaults for modded behaviours
if (_bhv != OTrophy::Behaviour::PODIUM_CEREMONY) {
- gObjectList[objectIndex].sizeScaling = 0.025f;
- gObjectList[objectIndex].unk_084[1] = 0x0200;
- object_next_state(objectIndex);
- func_80086E70(objectIndex);
+ gObjectList[_objectIndex].sizeScaling = 0.025f;
+ gObjectList[_objectIndex].unk_084[1] = 0x0200;
+ object_next_state(_objectIndex);
+ func_80086E70(_objectIndex);
}
switch(_bhv) {
case OTrophy::Behaviour::GO_FISH:
- gObjectList[objectIndex].sizeScaling = 0.010f;
+ gObjectList[_objectIndex].sizeScaling = 0.010f;
break;
}
- Object *object = &gObjectList[objectIndex];
+ Object *object = &gObjectList[_objectIndex];
object->origin_pos[0] = _spawnPos.x;
object->origin_pos[1] = _spawnPos.y;
object->origin_pos[2] = _spawnPos.z;
object->pos[0] = _spawnPos.x;
object->pos[1] = _spawnPos.y;
object->pos[2] = _spawnPos.z;
+
+ _emitter = reinterpret_cast<StarEmitter*>(gWorldInstance.AddEmitter(new StarEmitter()));
}
void OTrophy::Tick() { // func_80086D80
- s32 objectIndex = indexObjectList1[3];
+ s32 objectIndex = _objectIndex;
s32 var_s0;
// Fallback for podium ceremony where the trophy is not spawned until it is needed
@@ -197,7 +208,7 @@ void OTrophy::Tick() { // func_80086D80
}
void OTrophy::Draw(s32 cameraId) {
- s32 listIndex = indexObjectList1[3];
+ s32 listIndex = _objectIndex;
Mat4 someMatrix1;
Mat4 someMatrix2;
Object* object;
@@ -333,62 +344,8 @@ void OTrophy::func_80086C6C(s32 objectIndex) {
} else {
sp24[1] = gObjectList[objectIndex].pos[1] - 2.0;
}
- func_800773D8(sp24, (s32) D_801658F4);
-}
-void OTrophy::func_800773D8(f32* arg0, s32 arg1) {
- s32 objectIndex = add_unused_obj_index(gObjectParticle3, &gNextFreeObjectParticle3, gObjectParticle3_SIZE);
- if (objectIndex != NULL_OBJECT_ID) {
- func_80077138(objectIndex, arg0, arg1);
+ if (_emitter != nullptr) {
+ _emitter->Emit(sp24, D_801658F4);
}
}
-
-void OTrophy::func_80077138(s32 objectIndex, Vec3f arg1, s32 arg2) {
- s8 temp_v0_3;
- Vec3s sp30;
-
- init_object(objectIndex, arg2);
- gObjectList[objectIndex].unk_0D5 = 0x0C;
- gObjectList[objectIndex].sizeScaling = 0.05f;
- set_obj_origin_pos(objectIndex, arg1[0], arg1[1], arg1[2]);
- set_obj_orientation(objectIndex, 0U, 0U, 0U);
- set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
- switch (arg2) {
- case 0:
- gObjectList[objectIndex].velocity[1] = -1.0f;
- gObjectList[objectIndex].unk_034 = (f32) ((random_int(0x004BU) * 0.01) + 0.25);
- gObjectList[objectIndex].direction_angle[1] = random_int(0x0040U) << 0xA;
- func_8008751C(objectIndex);
- gObjectList[objectIndex].unk_084[5] = 0x001E;
- break;
- case 1:
- gObjectList[objectIndex].velocity[1] = 1.5f;
- gObjectList[objectIndex].unk_034 = (f32) ((random_int(0x0064U) * 0.01) + 0.5);
- gObjectList[objectIndex].direction_angle[1] = random_int(0x0040U) << 0xA;
- func_8008751C(objectIndex);
- gObjectList[objectIndex].unk_084[5] = 0x0032;
- break;
- }
- temp_v0_3 = random_int(0x000CU);
- if (temp_v0_3 < 9) {
- func_8005C674(temp_v0_3, &sp30[2], &sp30[1], sp30);
- gObjectList[objectIndex].unk_048 = 0;
- gObjectList[objectIndex].unk_084[0] = sp30[2];
- gObjectList[objectIndex].unk_084[1] = sp30[1];
- gObjectList[objectIndex].unk_084[2] = sp30[0];
- } else {
- temp_v0_3 = random_int(3U);
- func_8005C6B4(temp_v0_3, &sp30[2], &sp30[1], sp30);
- gObjectList[objectIndex].unk_084[0] = sp30[2];
- gObjectList[objectIndex].unk_084[1] = sp30[1];
- gObjectList[objectIndex].unk_084[2] = sp30[0];
- gObjectList[objectIndex].unk_084[4] = temp_v0_3;
- gObjectList[objectIndex].unk_048 = 1;
- }
- gObjectList[objectIndex].primAlpha = 0x00FF;
- gObjectList[objectIndex].unk_084[3] = random_int(0x0800U) + 0x400;
- if ((gObjectList[objectIndex].direction_angle[1] < 0x3000) ||
- (gObjectList[objectIndex].direction_angle[1] >= 0xB001)) {
- gObjectList[objectIndex].unk_084[3] = -gObjectList[objectIndex].unk_084[3];
- }
-} \ No newline at end of file
diff --git a/src/engine/objects/Trophy.h b/src/engine/objects/Trophy.h
index a227ef5b9..c2bb937ab 100644
--- a/src/engine/objects/Trophy.h
+++ b/src/engine/objects/Trophy.h
@@ -4,6 +4,7 @@
#include <vector>
#include "Object.h"
#include "World.h"
+#include "engine/particles/StarEmitter.h"
extern "C" {
#include "macros.h"
@@ -43,12 +44,11 @@ public:
void func_80086940(s32 objectIndex);
void func_80086C14(s32 objectIndex);
void func_80086C6C(s32 objectIndex);
- void func_800773D8(f32* arg0, s32 arg1);
- void func_80077138(s32 objectIndex, Vec3f arg1, s32 arg2);
private:
+ StarEmitter* _emitter;
- s32 _idx;
+ s32 _objectIndex;
TrophyType _trophy;
FVector _spawnPos;
Behaviour _bhv;