summaryrefslogtreecommitdiff
path: root/src/engine/objects/Trophy.cpp
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/Trophy.cpp
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/Trophy.cpp')
-rw-r--r--src/engine/objects/Trophy.cpp101
1 files changed, 29 insertions, 72 deletions
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