Added new events

This commit is contained in:
KiritoDv 2025-01-04 00:03:33 -06:00
parent e70b4ac99c
commit 49ffb98d9b
7 changed files with 107 additions and 49 deletions

View File

@ -28,6 +28,7 @@
#include "assets/ast_ve1_boss.h"
#include "assets/ast_zoness.h"
#include "port/interpolation/FrameInterpolation.h"
#include "port/hooks/Events.h"
Vec3f D_edisplay_801615D0;
Vec3f sViewPos;
@ -1044,6 +1045,7 @@ void ObjSpecial_SetMatrix(Object* obj, f32 xRot, f32 yRot, f32 zRot, s32 drawTyp
}
void Scenery_Draw(Scenery* this, s32 cullDirection) {
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SCENERY, this);
this->obj.pos.y += gCameraShakeY;
Object_SetMatrix(&this->obj, this->info.drawType);
this->obj.pos.y -= gCameraShakeY;
@ -1058,7 +1060,10 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) {
Object_ApplyWaterDistortion();
}
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){
gSPDisplayList(gMasterDisp++, this->info.dList);
}
RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
} else {
if (this->obj.id == OBJ_SCENERY_CO_HIGHWAY_3) {
@ -1074,7 +1079,9 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) {
Object_ApplyWaterDistortion();
}
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){
gSPDisplayList(gMasterDisp++, this->info.dList);
}
if (this->obj.id == OBJ_SCENERY_CO_HIGHWAY_3) {
RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
@ -1082,16 +1089,20 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) {
}
} else if (this->info.draw != NULL) {
Object_SetCullDirection(cullDirection);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){
this->info.draw(&this->obj);
}
}
}
void Sprite_Draw(Sprite* this, s32 arg1) {
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SPRITE, this);
if (arg1 >= 0) {
this->obj.pos.y += gCameraShakeY;
Object_SetMatrix(&this->obj, 0);
this->obj.pos.y -= gCameraShakeY;
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SPRITE, this){
if (this->info.drawType == 0) {
gSPDisplayList(gMasterDisp++, this->info.dList);
} else if (this->info.draw != NULL) {
@ -1099,10 +1110,13 @@ void Sprite_Draw(Sprite* this, s32 arg1) {
}
}
}
}
void Actor_DrawOnRails(Actor* this) {
Vec3f sp34 = { 0.0f, 0.0f, 0.0f };
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR, this);
if (this->info.draw != NULL) {
switch (this->obj.id) {
case OBJ_ACTOR_ME_MORA:
@ -1128,10 +1142,14 @@ void Actor_DrawOnRails(Actor* this) {
}
if (this->info.drawType == 0) {
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){
gSPDisplayList(gMasterDisp++, this->info.dList);
}
Object_UpdateSfxSource(this->sfxSource);
} else {
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){
this->info.draw(&this->obj);
}
Object_UpdateSfxSource(this->sfxSource);
if (((this->obj.id == OBJ_ACTOR_TEAM_BOSS) ||
((this->obj.id == OBJ_ACTOR_SX_SLIPPY) && (this->animFrame > 0))) &&
@ -1158,6 +1176,8 @@ void Actor_DrawAllRange(Actor* this) {
f32 var_fv0;
f32 var_fv1;
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR, this);
sDrewActor = false;
if (this->info.drawType == 2) {
@ -1185,7 +1205,9 @@ void Actor_DrawAllRange(Actor* this) {
Matrix_RotateY(gCalcMatrix, this->obj.rot.y * M_DTOR, MTXF_APPLY);
Matrix_RotateX(gCalcMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY);
Matrix_RotateZ(gCalcMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){
this->info.draw(&this->obj);
}
sDrewActor = true;
if ((gPlayer[0].state == PLAYERSTATE_ACTIVE) && (this->obj.id == OBJ_ACTOR_ALLRANGE) &&
(this->aiType == AI360_MISSILE)) {
@ -1223,7 +1245,9 @@ void Actor_DrawAllRange(Actor* this) {
Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY);
Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){
this->info.draw(&this->obj);
}
sDrewActor = true;
if ((gPlayer[0].state == PLAYERSTATE_ACTIVE) &&
(((this->obj.id == OBJ_ACTOR_ALLRANGE) &&
@ -1267,6 +1291,8 @@ void Boss_Draw(Boss* this, s32 arg1) {
f32 sp3C;
Vec3f origin = { 0.0f, 0.0f, 0.0f };
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_BOSS, this);
if (this->info.unk_19 != 0) {
this->obj.pos.y += this->yOffset + gCameraShakeY;
Boss_SetMatrix(&this->obj, this->info.drawType);
@ -1318,22 +1344,28 @@ void Boss_Draw(Boss* this, s32 arg1) {
if (arg1 < 0) {
Object_ApplyWaterDistortion();
}
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_BOSS, this){
this->info.draw(&this->obj);
}
}
}
}
}
D_edisplay_801615D0.y = sp3C;
if (this->obj.id == OBJ_BOSS_BO_BASE) {
this->vwork[30] = D_edisplay_801615D0;
Display_SetSecondLight(&this->obj.pos);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_BOSS, this){
this->info.draw(&this->obj);
}
}
}
void Effect_DrawOnRails(Effect* this, s32 arg1) {
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_EFFECT, this);
if ((arg1 < 0) && (this->obj.pos.y < 7.0f)) {
return;
}
@ -1348,16 +1380,19 @@ void Effect_DrawOnRails(Effect* this, s32 arg1) {
Object_SetMatrix(&this->obj, 0);
}
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_EFFECT, this){
if (this->info.draw != NULL) {
this->info.draw(&this->obj);
}
}
}
void Effect_DrawAllRange(Effect* this) {
Vec3f src = { 0.0f, 0.0f, 0.0f };
Vec3f dest;
f32 minZ;
u8 drawn = false;
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_EFFECT, this);
if (this->info.unk_14 == -1) {
Matrix_Translate(gGfxMatrix, this->obj.pos.x, this->obj.pos.y + gCameraShakeY, this->obj.pos.z + gPathProgress,
@ -1383,8 +1418,10 @@ void Effect_DrawAllRange(Effect* this) {
Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY);
Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_EFFECT, this){
this->info.draw(&this->obj);
}
}
drawn = true;
}
}
@ -1402,6 +1439,8 @@ void Item_Draw(Item* this, s32 arg1) {
Vec3f dest;
u8 drawn;
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ITEM, this);
Matrix_Translate(gGfxMatrix, this->obj.pos.x, this->obj.pos.y, this->obj.pos.z + gPathProgress, MTXF_APPLY);
Matrix_MultVec3f(gGfxMatrix, &src, &dest);
@ -1416,12 +1455,14 @@ void Item_Draw(Item* this, s32 arg1) {
Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY);
Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ITEM, this){
if (this->info.drawType == 0) {
gSPDisplayList(gMasterDisp++, this->info.dList);
} else {
this->info.draw(&this->obj);
}
}
}
drawn = true;
}
}
@ -1584,6 +1625,8 @@ void Scenery360_Draw(Scenery360* this) {
Vec3f src = { 0.0f, 0.0f, 0.0f };
Vec3f dest;
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SCENERY360, this);
f32 behindZdist = 1000.0f;
f32 frontZdist = -12000.0f;
f32 xyOffsetBounds = 2000.0f + 1000.0f;
@ -1636,12 +1679,16 @@ check:
Matrix_RotateY(gGfxMatrix, M_PI / 2, MTXF_APPLY);
Matrix_Translate(gGfxMatrix, -551.0f, 0.0f, 0.0f, MTXF_APPLY);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY360, this){
gSPDisplayList(gMasterDisp++, D_VE2_6007650);
}
} else {
Matrix_RotateY(gGfxMatrix, this->obj.rot.y * M_DTOR, MTXF_APPLY);
Matrix_SetGfxMtx(&gMasterDisp);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY360, this){
gSPDisplayList(gMasterDisp++, this->info.dList);
}
}
}
}

View File

@ -20,6 +20,7 @@
#include "assets/ast_solar.h"
#include "assets/ast_ve1_boss.h"
#include "assets/ast_zoness.h"
#include "port/hooks/Events.h"
s32 gTeamEventActorIndex[4] = { 0, 0, 0, 0 };
s32 gCallVoiceParam = 0;
@ -3880,6 +3881,8 @@ void ActorEvent_Draw(ActorEvent* this) {
s16 savedState;
s32 pad;
CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this);
if (this->timer_0C6 && (this->eventType != EVID_MA_RAILROAD_CART) && (this->eventType != EVID_SY_LASER_TURRET) &&
(this->eventType != EVID_SY_SHIP_WINDOWS)) {
if ((this->eventType != EVID_ME_METEOR_1) && (this->eventType != EVID_ME_METEOR_2) &&
@ -3925,19 +3928,24 @@ void ActorEvent_Draw(ActorEvent* this) {
case EVID_WZ_PILLAR_2:
case EVID_WZ_METEOR_1:
case EVID_WZ_METEOR_2:
case EVID_WZ_GATE:
case EVID_WZ_GATE: {
RCP_SetupDL(&gMasterDisp, SETUPDL_34);
gDPSetTextureFilter(gMasterDisp++, G_TF_POINT);
gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, (s32) this->fwork[15], (s32) this->fwork[16],
(s32) this->fwork[17], 255);
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this){
gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList);
}
gDPSetTextureFilter(gMasterDisp++, G_TF_BILERP);
break;
}
default:
default: {
CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this){
if ((this->eventType < EVID_200) && (sEventActorInfo[this->eventType].dList != NULL)) {
gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList);
}
}
switch (this->eventType) {
case EVID_TI_GREAT_FOX:
@ -4217,6 +4225,7 @@ void ActorEvent_Draw(ActorEvent* this) {
break;
}
}
}
void func_enmy2_800763A4(Actor* this) {
s32 i;

View File

@ -3654,10 +3654,7 @@ void HUD_Draw(void) {
s32 i;
s32 goldRings;
bool medalStatus;
CALL_EVENT(DrawGlobalHUDPreEvent);
if (DrawGlobalHUDPreEvent_.event.cancelled){
return;
}
CALL_CANCELLABLE_RETURN_EVENT(DrawGlobalHUDPreEvent);
gDPSetTextureFilter(gMasterDisp++, G_TF_POINT);

View File

@ -3155,8 +3155,7 @@ void Player_TankCannon(Player* player) {
break;
}
}
}
if (!PlayerActionPreShootEvent_.event.cancelled){
CALL_EVENT(PlayerActionPostShootEvent, player, &gPlayerShots[i]);
}
}
@ -3170,10 +3169,7 @@ void Player_ArwingLaser(Player* player) {
laser = LASERS_SINGLE;
}
CALL_EVENT(PlayerActionPreShootEvent, player, laser);
if (PlayerActionPreShootEvent_.event.cancelled){
return;
}
CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreShootEvent, player, laser);
switch (laser) {
case LASERS_SINGLE:
@ -3213,11 +3209,7 @@ void Player_SmartBomb(Player* player) {
if ((gBombCount[player->num] != 0) && (gBombButton[player->num] & gInputPress->button) &&
(gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) {
CALL_EVENT(PlayerActionPreBombEvent, player);
if (PlayerActionPreBombEvent_.event.cancelled)
{
return;
}
CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreBombEvent, player);
if (gVersusMode) {
gBombCount[player->num] = 0;

View File

@ -1213,10 +1213,7 @@ void Aquas_BlueMarineTorpedo(Player* player) {
for (i = 15, shot = &gPlayerShots[15]; i < ARRAY_COUNT(gPlayerShots); i++, shot++) {
if (shot->obj.status == SHOT_FREE) {
CALL_EVENT(PlayerActionPreBombEvent, player)
if (PlayerActionPreBombEvent_.event.cancelled){
return;
}
CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreBombEvent, player);
Player_SetupArwingShot(player, shot, 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, 50.0f);
AUDIO_PLAY_SFX(NA_SE_MAR_BOMB_SHOT, shot->sfxSource, 0);
D_i3_801C4190[5] = i + 1;
@ -1245,8 +1242,7 @@ void Aquas_BlueMarineLaser(Player* player) {
break;
}
}
}
if (!PlayerActionPreShootEvent_.event.cancelled){
CALL_EVENT(PlayerActionPostShootEvent, player, &gPlayerShots[i]);
}
}

View File

@ -49,6 +49,16 @@ typedef struct {
EventSystem_CallEvent(eventType##ID, &eventType##_); \
if (!eventType##_.event.cancelled)
#define CHECK_IF_NOT_CANCELLED(eventType) \
if (!eventType##_.event.cancelled)
#define CALL_CANCELLABLE_RETURN_EVENT(eventType, ...) \
eventType eventType##_ = { {false}, __VA_ARGS__ }; \
EventSystem_CallEvent(eventType##ID, &eventType##_); \
if (eventType##_.event.cancelled) { \
return; \
}
#define REGISTER_EVENT(eventType) \
eventType##ID = EventSystem_RegisterEvent();

View File

@ -6,8 +6,10 @@
typedef enum {
OBJECT_TYPE_ACTOR,
OBJECT_TYPE_ACTOR_EVENT,
OBJECT_TYPE_BOSS,
OBJECT_TYPE_SCENERY,
OBJECT_TYPE_SCENERY360,
OBJECT_TYPE_SPRITE,
OBJECT_TYPE_ITEM,
OBJECT_TYPE_EFFECT,
@ -23,7 +25,12 @@ DEFINE_EVENT(ObjectUpdateEvent,
void* object;
);
DEFINE_EVENT(ObjectDrawEvent,
DEFINE_EVENT(ObjectDrawPreSetupEvent,
ObjectEventType type;
void* object;
);
DEFINE_EVENT(ObjectDrawPostSetupEvent,
ObjectEventType type;
void* object;
);