summaryrefslogtreecommitdiff
path: root/src/engine/objects
diff options
context:
space:
mode:
authorMegaMech <inkstudios1@hotmail.com>2024-12-29 21:37:06 -0700
committerMegaMech <inkstudios1@hotmail.com>2024-12-29 21:37:06 -0700
commit08e4bf37979131e76e617beafb3f5ca6286e5ebb (patch)
tree30f3b70de5987a2d4c32e9ab20da0f39bd6f48ae /src/engine/objects
parent64b9dcbb30c5007466c14da7d78d081189810308 (diff)
Fix Crab Impl
Diffstat (limited to 'src/engine/objects')
-rw-r--r--src/engine/objects/Crab.cpp30
-rw-r--r--src/engine/objects/Crab.h33
2 files changed, 35 insertions, 28 deletions
diff --git a/src/engine/objects/Crab.cpp b/src/engine/objects/Crab.cpp
index cfb84f259..b05bc85e3 100644
--- a/src/engine/objects/Crab.cpp
+++ b/src/engine/objects/Crab.cpp
@@ -23,25 +23,28 @@ extern "C" {
#include "assets/koopa_troopa_beach_data.h"
}
-OCrab::OCrab(s32 i, Vec3f pos) {
+size_t OCrab::_count = 0;
+
+OCrab::OCrab(const FVector2D& start, const FVector2D& end) {
s32 objectId;
- //for (i = 0; i < NUM_CRABS; i++) {
- _idx = i;
- objectId = indexObjectList1[i];
+ _idx = _count;
+ _start = start;
+ _end = end;
+
+ objectId = indexObjectList1[_idx];
init_object(objectId, 0);
- gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] =
- gCrabSpawns[i].startX * xOrientation;
+ gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = start.x * xOrientation;
+ gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = start.z;
- gObjectList[objectId].unk_01C[0] = gCrabSpawns[i].patrolX * xOrientation;
+ gObjectList[objectId].unk_01C[0] = end.x * xOrientation;
+ gObjectList[objectId].unk_01C[2] = end.z;
- gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gCrabSpawns[i].startZ;
- gObjectList[objectId].unk_01C[2] = gCrabSpawns[i].patrolZ;
+ _count++;
}
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);
@@ -49,12 +52,11 @@ void OCrab::Tick(void) {
OCrab::func_80082C30(objectIndex);
OCrab::func_80082E18(objectIndex);
}
- //}
}
-void OCrab::Draw(s32 objectIndex, s32 cameraId) {
+void OCrab::Draw(s32 cameraId) {
Camera* camera;
-
+ s32 objectIndex = indexObjectList1[_idx];
if (gObjectList[objectIndex].state >= 2) {
Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
camera = &camera1[cameraId];
@@ -72,7 +74,6 @@ 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) {
@@ -86,7 +87,6 @@ void OCrab::DrawModel(s32 cameraId) {
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) {
diff --git a/src/engine/objects/Crab.h b/src/engine/objects/Crab.h
index 697a8bd7b..281b080ca 100644
--- a/src/engine/objects/Crab.h
+++ b/src/engine/objects/Crab.h
@@ -2,6 +2,8 @@
#include <libultraship.h>
#include <vector>
+#include "engine/objects/Object.h"
+#include "World.h"
extern "C" {
#include "macros.h"
@@ -14,20 +16,23 @@ extern "C" {
#include "some_data.h"
}
-
-class OCrab {
-public:
- enum Behaviour : uint16_t {
- };
-
+/**
+ * @arg start x and z spawn location
+ * @arg end x and z patrol location
+ *
+ * Crab patrols between start and end.
+ * The game automatically places the actor on the course surface.
+ * Therefore, providing a Y height is unnecessary.
+ *
+ * Crab appears to have a maximum patrolling distance and will patrol between
+ * end --> max distance rather than start --> end or start --> max distance.
+ */
+class OCrab : public OObject {
public:
- f32 Diameter = 0.0f; // Waddle in a circle around the spawn point at this diameter.
- uint16_t MirrorModeAngleOffset;
+ explicit OCrab(const FVector2D& start, const FVector2D& end);
- explicit OCrab(s32 i, Vec3f pos);
-
- void Tick();
- void Draw(s32 objectIndex, s32 cameraId);
+ virtual void Tick() override;
+ virtual void Draw(s32 cameraId) override;
void DrawModel(s32 cameraId);
void init_ktb_crab(s32 objectIndex);
@@ -36,6 +41,8 @@ public:
void func_80082E18(s32 objectIndex);
private:
-
+ FVector2D _start;
+ FVector2D _end;
+ static size_t _count;
s32 _idx;
};