mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-09-06 19:31:06 -04:00
Reimplementing objects
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
#include <libultraship.h>
|
||||
#include <libultra/gbi.h>
|
||||
#include "Crab.h"
|
||||
#include <vector>
|
||||
|
||||
#include "port/Game.h"
|
||||
|
||||
extern "C" {
|
||||
#include "macros.h"
|
||||
#include "main.h"
|
||||
#include "defines.h"
|
||||
#include "camera.h"
|
||||
#include "update_objects.h"
|
||||
#include "render_objects.h"
|
||||
#include "actors.h"
|
||||
#include "code_80057C60.h"
|
||||
#include "code_80086E70.h"
|
||||
#include "math_util.h"
|
||||
#include "math_util_2.h"
|
||||
#include "code_80005FD0.h"
|
||||
#include "some_data.h"
|
||||
#include "ceremony_and_credits.h"
|
||||
#include "assets/koopa_troopa_beach_data.h"
|
||||
}
|
||||
|
||||
OCrab::OCrab(s32 i, Vec3f pos) {
|
||||
s32 objectId;
|
||||
//for (i = 0; i < NUM_CRABS; i++) {
|
||||
_idx = i;
|
||||
objectId = indexObjectList1[i];
|
||||
init_object(objectId, 0);
|
||||
gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] =
|
||||
gCrabSpawns[i].startX * xOrientation;
|
||||
|
||||
gObjectList[objectId].unk_01C[0] = gCrabSpawns[i].patrolX * xOrientation;
|
||||
|
||||
gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gCrabSpawns[i].startZ;
|
||||
gObjectList[objectId].unk_01C[2] = gCrabSpawns[i].patrolZ;
|
||||
}
|
||||
|
||||
void OCrab::Tick(void) {
|
||||
s32 objectIndex;
|
||||
|
||||
//for (var_s1 = 0; var_s1 < NUM_CRABS; var_s1++) {
|
||||
objectIndex = indexObjectList1[_idx];
|
||||
if (gObjectList[objectIndex].state != 0) {
|
||||
OCrab::func_80082B34(objectIndex);
|
||||
func_8008A6DC(objectIndex, 500.0f);
|
||||
OCrab::func_80082C30(objectIndex);
|
||||
OCrab::func_80082E18(objectIndex);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void OCrab::Draw(s32 objectIndex, s32 cameraId) {
|
||||
Camera* camera;
|
||||
|
||||
if (gObjectList[objectIndex].state >= 2) {
|
||||
Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
|
||||
camera = &camera1[cameraId];
|
||||
func_8004A6EC(objectIndex, 0.5f);
|
||||
gObjectList[objectIndex].orientation[1] =
|
||||
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
|
||||
draw_2d_texture_at(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation,
|
||||
gObjectList[objectIndex].sizeScaling, (u8*) gObjectList[objectIndex].activeTLUT,
|
||||
(uint8_t*)gObjectList[objectIndex].activeTexture, vtx, 64, 64,
|
||||
64, 32);
|
||||
}
|
||||
}
|
||||
|
||||
void OCrab::DrawModel(s32 cameraId) {
|
||||
s32 someIndex;
|
||||
s32 test;
|
||||
|
||||
//for (someIndex = 0; someIndex < NUM_CRABS; someIndex++) {
|
||||
test = indexObjectList1[_idx];
|
||||
func_8008A364(test, cameraId, 0x2AABU, 800);
|
||||
if (is_obj_flag_status_active(test, VISIBLE) != 0) {
|
||||
Camera *camera;
|
||||
s32 objectIndex;
|
||||
|
||||
if (gObjectList[objectIndex].state >= 2) {
|
||||
camera = &camera1[cameraId];
|
||||
func_8004A6EC(objectIndex, 0.5f);
|
||||
gObjectList[objectIndex].orientation[1] = func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
|
||||
draw_2d_texture_at(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation, gObjectList[objectIndex].sizeScaling, (u8*) gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, (Vtx*)common_vtx_hedgehog, 0x00000040, 0x00000040, 0x00000040, 0x00000020);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void OCrab::init_ktb_crab(s32 objectIndex) {
|
||||
Object* object;
|
||||
|
||||
init_texture_object(objectIndex, (uint8_t*) d_course_koopa_troopa_beach_crab_tlut,
|
||||
(const char**) d_course_koopa_troopa_beach_crab_frames, 64, (u16) 64);
|
||||
object = &gObjectList[objectIndex];
|
||||
object->sizeScaling = 0.15f;
|
||||
object->textureListIndex = 0;
|
||||
object_next_state(objectIndex);
|
||||
object->boundingBoxSize = 1;
|
||||
set_object_flag(objectIndex, 0x04000420);
|
||||
func_80086EAC(objectIndex, 0, 1);
|
||||
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
|
||||
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
|
||||
object->unk_034 = 1.5f;
|
||||
set_object_flag(objectIndex, 0x00000200);
|
||||
}
|
||||
|
||||
void OCrab::func_80082B34(s32 objectIndex) {
|
||||
switch (gObjectList[objectIndex].state) { /* irregular */
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
OCrab::init_ktb_crab(objectIndex);
|
||||
break;
|
||||
case 2:
|
||||
func_80072E54(objectIndex, 0, 3, 1, 2, -1);
|
||||
break;
|
||||
case 3:
|
||||
func_80072E54(objectIndex, 4, 6, 1, 2, -1);
|
||||
break;
|
||||
}
|
||||
if (gObjectList[objectIndex].state >= 2) {
|
||||
func_80073514(objectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void OCrab::func_80082C30(s32 objectIndex) {
|
||||
switch (gObjectList[objectIndex].unk_0AE) {
|
||||
case 1:
|
||||
if (func_80087A0C(objectIndex, gObjectList[objectIndex].origin_pos[0], gObjectList[objectIndex].unk_01C[0],
|
||||
gObjectList[objectIndex].origin_pos[2], gObjectList[objectIndex].unk_01C[2]) != 0) {
|
||||
func_800726CC(objectIndex, 3);
|
||||
func_80086FD4(objectIndex);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (func_80087104(objectIndex, 0x003CU) != 0) {
|
||||
gObjectList[objectIndex].unk_034 = 0.8f;
|
||||
func_800726CC(objectIndex, 2);
|
||||
func_80086FD4(objectIndex);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (func_80087954(objectIndex, 0x0000003C) != 0) {
|
||||
func_80086FD4(objectIndex);
|
||||
func_800726CC(objectIndex, 3);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (func_80087104(objectIndex, 0x003CU) != 0) {
|
||||
func_800726CC(objectIndex, 2);
|
||||
func_80086FD4(objectIndex);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (func_8008789C(objectIndex, 0x0000003C) != 0) {
|
||||
func_800726CC(objectIndex, 3);
|
||||
func_8008701C(objectIndex, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
object_calculate_new_pos_offset(objectIndex);
|
||||
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
|
||||
func_80088538(objectIndex);
|
||||
gObjectList[objectIndex].pos[1] = (f32) (gObjectList[objectIndex].surfaceHeight + 2.5);
|
||||
}
|
||||
}
|
||||
|
||||
void OCrab::func_80082E18(s32 objectIndex) {
|
||||
if (gObjectList[objectIndex].state >= 2) {
|
||||
func_80089F24(objectIndex);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user