diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-01-13 21:15:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-13 21:15:16 -0700 |
| commit | 04d56d6ba0705776149358608a27db8ab23e9449 (patch) | |
| tree | ee699599021dde72fb4a2b8eb34792be53ec5ecd /src/engine/objects/Bat.cpp | |
| parent | 389f0f495131928cd620afee41095aff6683c8e9 (diff) | |
Fixes as per Sonic (#154)
* Fix imGUI game reset button
* Fix course select cursor sound oob
* Fix cloud rendering
* Fix centering of tt race data cannot be saved by ghost
* Impl chain chomp & bats
* Fix retry crash
* DebugMode On Skips intro logo menu
* rename
Diffstat (limited to 'src/engine/objects/Bat.cpp')
| -rw-r--r-- | src/engine/objects/Bat.cpp | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp new file mode 100644 index 000000000..f32ef2d41 --- /dev/null +++ b/src/engine/objects/Bat.cpp @@ -0,0 +1,256 @@ +#include "Bat.h" +#include "World.h" +#include "CoreMath.h" + +extern "C" { +#include "render_objects.h" +#include "update_objects.h" +#include "assets/banshee_boardwalk_data.h" +#include "assets/common_data.h" +#include "math_util.h" +#include "math_util_2.h" +#include "code_80086E70.h" +#include "code_80057C60.h" +#include "code_800029B0.h" +} + +const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gTextureBat4 }; + +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, + (u16) 0x00000040); + gObjectList[objectId].orientation[0] = rot.pitch; + gObjectList[objectId].orientation[1] = rot.roll; + gObjectList[objectId].orientation[2] = rot.yaw; // 0x8000 + + _count++; +} + +void OBat::Tick() { + s32 var_s2; + s32 temp_s0; + Object* object; + + if (D_8018CFC8 != 0) { + D_8018CFC8 -= 1; + } + 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); + 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) { + continue; + } + + object = &gObjectList[temp_s0]; + if (object->state == 0) { + continue; + } + + OBat::func_8007D8D4(temp_s0, 1); + OBat::func_8007DAF8(temp_s0, 1); + OBat::func_8007D794(temp_s0); + if (object->state == 0) { + delete_object_wrapper(&gObjectParticle2[var_s2]); + } + D_8018CFD8 += 1; + } + if (D_8018CFD8 != 0) { + D_8018CFC8 = 0x012C; + } + } + 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) { + continue; + } + + object = &gObjectList[temp_s0]; + if (object->state == 0) { + continue; + } + + OBat::func_8007D8D4(temp_s0, 2); + OBat::func_8007DAF8(temp_s0, 2); + OBat::func_8007D794(temp_s0); + if (object->state == 0) { + delete_object_wrapper(&gObjectParticle3[var_s2]); + } + D_8018D010 += 1; + } + if (D_8018D010 != 0) { + D_8018D000 = 0x012C; + } + } +} + +void OBat::Draw(s32 cameraId) { + s32 var_s2; + s32 objectIndex; + Camera* temp_s7; + + objectIndex = indexObjectList1[0]; + temp_s7 = &camera1[cameraId]; + OBat::func_80046F60((u8*)gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, 0x00000020, 0x00000040, + 5); + D_80183E80[0] = gObjectList[objectIndex].orientation[0]; + D_80183E80[2] = gObjectList[objectIndex].orientation[2]; + if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) { + for (var_s2 = 0; var_s2 < 40; var_s2++) { + objectIndex = gObjectParticle2[var_s2]; + if (objectIndex == -1) { + continue; + } + + if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + D_80183E80[1] = + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, + (Vtx*)D_0D0062B0); + } + } + } + if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) { + for (var_s2 = 0; var_s2 < 30; var_s2++) { + objectIndex = gObjectParticle3[var_s2]; + if (objectIndex == -1) { + continue; + } + + if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + D_80183E80[1] = + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, + (Vtx*)D_0D0062B0); + } + } + } + gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF); +} + +void OBat::func_80046F60(u8* tlut, u8* arg1, s32 arg2, s32 arg3, s32 arg4) { + gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007D78); + gDPLoadTLUT_pal256(gDisplayListHead++, tlut); + rsp_load_texture_mask(arg1, arg2, arg3, arg4); +} + +void OBat::func_8007D8AC(s32 arg0) { + object_next_state(arg0); + func_80086E70(arg0); +} + +s32 OBat::func_8007D804(s32 objectIndex) { + s32 loopIndex; + s32 someCount; + + someCount = 0; + for (loopIndex = 0; loopIndex < gPlayerCountSelection1; loopIndex++) { + if (is_object_visible_on_camera(objectIndex, &camera1[loopIndex], 0x4000U) != 0) { + someCount += 1; + } + } + return someCount; +} + +void OBat::func_8007D8D4(s32 objectIndex, s32 arg1) { + switch (gObjectList[objectIndex].state) { + case 1: + OBat::func_8007D8AC(objectIndex); + break; + case 2: + if (OBat::func_8007D804(objectIndex) == 0) { + func_80072428(objectIndex); + } + if (arg1 == 1) { + if (gIsMirrorMode != 0) { + if (gObjectList[objectIndex].pos[0] >= 2540.0) { + func_80072428(objectIndex); + } + } else if (gObjectList[objectIndex].pos[0] <= -2540.0) { + func_80072428(objectIndex); + } + } else if (gIsMirrorMode != 0) { + if (gObjectList[objectIndex].pos[0] >= 2150.0) { + func_80072428(objectIndex); + } + } else { + if (gObjectList[objectIndex].pos[0] <= -2150.0) { + func_80072428(objectIndex); + } + } + break; + case 0: + break; + } +} + +void OBat::func_8007DA74(s32 objectIndex) { + UNUSED s32 pad; + if ((gObjectList[objectIndex].unk_0AE != 0) && (gObjectList[objectIndex].unk_0AE == 1)) { + if (func_80087060(objectIndex, 0x0000001E) != 0) { + gObjectList[objectIndex].unk_0C6 = 0U; + } + } + gObjectList[objectIndex].direction_angle[0] = + func_800417B4(gObjectList[objectIndex].direction_angle[0], gObjectList[objectIndex].unk_0C6); + func_80087844(objectIndex); + object_calculate_new_pos_offset(objectIndex); +} + +void OBat::func_8007DA4C(s32 objectIndex) { + func_8008781C(objectIndex); + object_calculate_new_pos_offset(objectIndex); +} + +void OBat::func_8007DAF8(s32 objectIndex, s32 arg1) { + switch (arg1) { + case 1: + OBat::func_8007DA74(objectIndex); + return; + case 2: + OBat::func_8007DA4C(objectIndex); + return; + } +} + +void OBat::func_80089A04(s32 objectIndex, f32 arg1, f32 arg2) { + Player* player; + s32 var_s1; + + player = gPlayerOne; + if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { + for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | STAR_EFFECT)) && + (has_collided_with_player(objectIndex, player) != 0)) { + func_8008933C(player, objectIndex, arg1, arg2 * 1.1); + if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { + func_80072180(); + } + } + } + } +} + +void OBat::func_8007D794(s32 objectIndex) { + if (gCCSelection == CC_50) { + OBat::func_80089A04(objectIndex, 0.5f, 0.2f); + } else if (gCCSelection == CC_100) { + OBat::func_80089A04(objectIndex, 0.4f, 0.15f); + } else { + OBat::func_80089A04(objectIndex, 0.25f, 0.1f); + } +} |
