diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2024-10-15 18:54:38 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-15 18:54:38 -0600 |
| commit | af81bad1f34ee6af52a70ff8bf7ad4e1ee624a93 (patch) | |
| tree | 222f8bec40a9166b274129611ba0c80db2b753b3 /src/engine/actors | |
| parent | a0862b6a159373f2e1554e489ecb5bb08d89654e (diff) | |
[modding] Add Actors (#113)
* fix
* Add Actors
* Refactor
* Update Game.cpp
Diffstat (limited to 'src/engine/actors')
| -rw-r--r-- | src/engine/actors/ABanana.cpp | 60 | ||||
| -rw-r--r-- | src/engine/actors/ABanana.h | 21 | ||||
| -rw-r--r-- | src/engine/actors/AWarioSign.cpp | 42 | ||||
| -rw-r--r-- | src/engine/actors/AWarioSign.h | 19 |
4 files changed, 142 insertions, 0 deletions
diff --git a/src/engine/actors/ABanana.cpp b/src/engine/actors/ABanana.cpp new file mode 100644 index 000000000..c26efca24 --- /dev/null +++ b/src/engine/actors/ABanana.cpp @@ -0,0 +1,60 @@ +#include <libultraship.h> + +#include "ABanana.h" +#include "engine/Actor.h" + +extern "C" { +#include "macros.h" +#include "actor_types.h" +void update_actor_banana(struct BananaActor*); +void render_actor_banana(Camera*, float[4][4], struct BananaActor*); +} + +ABanana::ABanana(uint16_t playerId, const float pos[3], const s16 rot[3], const float velocity[3]) { + // Initialize the BananaActor's position, rotation, and velocity + std::copy(pos, pos + 3, Pos); + //std::copy(rot, rot + 3, this->a.rot); + std::copy(velocity, velocity + 3, Velocity); + + Type = 6; // ACTOR_BANANA + Flags = -0x8000; + Unk_04 = 20; + State = HELD_BANANA; + + PlayerId = playerId; + + //this->a.unk_08 = 0.0f; + Flags |= 0x4000 | 0x1000; + BoundingBoxSize = 2.0f; + + Unk30.meshIndexYX = 5000; + Unk30.meshIndexZX = 5000; + Unk30.meshIndexZY = 5000; + Unk30.unk30 = 0; + Unk30.unk32 = 0; + Unk30.unk34 = 0; + Unk30.surfaceDistance[0] = 0; + Unk30.surfaceDistance[1] = 0; + Unk30.surfaceDistance[2] = 0; + Unk30.unk48[0] = 0; + Unk30.unk48[1] = 0; + Unk30.unk48[2] = 1.0f; + Unk30.unk54[0] = 1.0f; + Unk30.unk54[1] = 0.0f; + Unk30.unk54[2] = 0.0f; + Unk30.orientationVector[0] = 0.0f; + Unk30.orientationVector[1] = 1.0f; + Unk30.orientationVector[2] = 0.0f; +} + +void ABanana::Tick() { + update_actor_banana((BananaActor*)this); +} + +void ABanana::Draw(Camera *camera) { + render_actor_banana(camera, NULL, (BananaActor*)this); +} +void ABanana::Collision() { } +void ABanana::Destroy() { } + +//void ABanana::Held() {} diff --git a/src/engine/actors/ABanana.h b/src/engine/actors/ABanana.h new file mode 100644 index 000000000..5ef8900d6 --- /dev/null +++ b/src/engine/actors/ABanana.h @@ -0,0 +1,21 @@ +#pragma once + +#include <libultraship.h> +#include "engine/Actor.h" + +class ABanana : public AActor { +public: + + uint16_t PlayerId; + + // Constructor + ABanana(uint16_t playerId, const float pos[3], const s16 rot[3], const float velocity[3]); + + virtual ~ABanana() override = default; + + // Virtual functions to be overridden by derived classes + virtual void Tick() override; + virtual void Draw(Camera*) override; + virtual void Collision() override; + virtual void Destroy() override; +}; diff --git a/src/engine/actors/AWarioSign.cpp b/src/engine/actors/AWarioSign.cpp new file mode 100644 index 000000000..2dd8a5fc9 --- /dev/null +++ b/src/engine/actors/AWarioSign.cpp @@ -0,0 +1,42 @@ +#include "AWarioSign.h" + +#include <libultra/gbi.h> +#include <assets/wario_stadium_data.h> + +extern "C" { +#include "common_structs.h" +#include "math_util.h" +#include "main.h" +} + +AWarioSign::AWarioSign(Vec3f pos) { + Pos[0] = pos[0]; + Pos[1] = pos[1]; + Pos[2] = pos[2]; +} + + // Virtual functions to be overridden by derived classes +void AWarioSign::Tick() { + Rot[1] += 0xB6; +} + +void AWarioSign::Draw(Camera *camera) { + Mat4 sp38; + f32 unk = + is_within_render_distance(camera->pos, Pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 16000000.0f); + + if (CVarGetInteger("gNoCulling", 0) == 1) { + unk = MAX(unk, 0.0f); + } + + if (!(unk < 0.0f)) { + gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); + gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); + + mtxf_pos_rotation_xyz(sp38, Pos, Rot); + if (render_set_position(sp38, 0) != 0) { + + gSPDisplayList(gDisplayListHead++, (Gfx*)d_course_wario_stadium_dl_sign); + } + } +} diff --git a/src/engine/actors/AWarioSign.h b/src/engine/actors/AWarioSign.h new file mode 100644 index 000000000..31d9b9434 --- /dev/null +++ b/src/engine/actors/AWarioSign.h @@ -0,0 +1,19 @@ +#pragma once + +#include <libultraship.h> +#include "engine/Actor.h" + +extern "C" { +#include "common_structs.h" +} + +class AWarioSign : public AActor { +public: + + + virtual ~AWarioSign() = default; + explicit AWarioSign(Vec3f pos); + + virtual void Tick() override; + virtual void Draw(Camera*) override; +}; |
