From c2d27bf9446da2c38233688c5cb60158f831eecd Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Mon, 6 Jan 2025 01:57:03 -0600 Subject: [PATCH] Moved katt to hooks --- src/engine/fox_display.c | 4 +- src/port/hooks/impl/EventSystem.h | 2 +- src/port/hooks/list/EngineEvent.h | 5 +- src/port/mods/PortEnhancements.c | 95 +++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 4 deletions(-) diff --git a/src/engine/fox_display.c b/src/engine/fox_display.c index 51efb9cd..d9c837e2 100644 --- a/src/engine/fox_display.c +++ b/src/engine/fox_display.c @@ -758,7 +758,9 @@ void Display_Arwing(Player* player, s32 reflectY) { } D_display_800CA22C = true; gReflectY = reflectY; - Display_ArwingWings(&player->arwing); + CALL_CANCELLABLE_EVENT(PlayerDrawArwing, &player) { + Display_ArwingWings(&player->arwing); + } } } } diff --git a/src/port/hooks/impl/EventSystem.h b/src/port/hooks/impl/EventSystem.h index bd6a2569..2d586ae6 100644 --- a/src/port/hooks/impl/EventSystem.h +++ b/src/port/hooks/impl/EventSystem.h @@ -35,7 +35,7 @@ typedef struct { #define DEFINE_EVENT(eventName, ...) \ typedef struct { \ IEvent event; \ - __VA_ARGS__ \ + __VA_ARGS__; \ } eventName; \ \ DECLARE_EVENT(eventName) diff --git a/src/port/hooks/list/EngineEvent.h b/src/port/hooks/list/EngineEvent.h index 50db9c83..5a5c3618 100644 --- a/src/port/hooks/list/EngineEvent.h +++ b/src/port/hooks/list/EngineEvent.h @@ -9,8 +9,9 @@ DEFINE_EVENT(DisplayPostUpdateEvent); DEFINE_EVENT(GamePreUpdateEvent); DEFINE_EVENT(GamePostUpdateEvent); -DEFINE_EVENT(PlayerPreUpdateEvent, Player* player;); -DEFINE_EVENT(PlayerPostUpdateEvent, Player* player;); +DEFINE_EVENT(PlayerPreUpdateEvent, Player* player); +DEFINE_EVENT(PlayerPostUpdateEvent, Player* player); +DEFINE_EVENT(PlayerDrawArwingEvent, Player* player); DEFINE_EVENT(DrawRadarHUDEvent); DEFINE_EVENT(DrawBoostGaugeHUDEvent); diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index deacfcd9..e28f6e32 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -309,6 +309,99 @@ void OnLivesCounterDraw(IEvent* ev){ HUD_LivesCount2_Draw(258.0f, SCREEN_HEIGHT - 20, gLifeCount[gPlayerNum]); } +void Display_ArwingWings_Katt(ArwingInfo* arwing) { + Vec3f frameTable[30]; + s32 drawFace; + Matrix_Push(&gGfxMatrix); + arwing->laserGunsXpos = 0.0f; + if (arwing->laserGunsYpos < -7.0f) { + arwing->laserGunsXpos = (-arwing->laserGunsYpos - 7.0f) * 2.5f; + } + if (gGameState == GSTATE_PLAY) { + // Animation_DrawSkeleton(1, D_arwing_3016610, gPlayer[0].jointTable, Display_ArwingWingsOverrideLimbDraw, NULL, + // arwing, &gIdentityMatrix); + gSPDisplayList(gMasterDisp++, aKattShipDL); + } else { + if (gGameState == GSTATE_MENU) { + Animation_GetFrameData(&D_arwing_3015AF4, 0, frameTable); + } else { + Animation_GetFrameData(&D_arwing_3015C28, 0, frameTable); + } + //Animation_DrawSkeleton(1, D_arwing_3016610, frameTable, Display_ArwingWingsOverrideLimbDraw, NULL, arwing, + // &gIdentityMatrix); + gSPDisplayList(gMasterDisp++, aKattShipDL); + } + D_display_800CA22C = false; + drawFace = arwing->drawFace; + if (D_display_800CA220 != 0) { + drawFace = true; + } + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild(arwing, 0); + if (drawFace != 0) { + Matrix_Push(&gGfxMatrix); + // @port: Tag the transform. + FrameInterpolation_RecordOpenChild("ArwingCharFace", arwing->drawFace); + Matrix_Translate(gGfxMatrix, 0.0f, 6.4f, -16.5f, MTXF_APPLY); + Matrix_RotateY(gGfxMatrix, arwing->teamFaceYrot * M_DTOR, MTXF_APPLY); + Matrix_RotateX(gGfxMatrix, arwing->teamFaceXrot * M_DTOR, MTXF_APPLY); + Matrix_Scale(gGfxMatrix, 1.0f / 70.925f, 1.0f / 70.925f, 1.0f / 70.925f, MTXF_APPLY); + if (gGameState == GSTATE_ENDING) { + Matrix_Scale(gGfxMatrix, 0.95f, 0.95f, 0.95f, MTXF_APPLY); + } + Matrix_SetGfxMtx(&gMasterDisp); + if (gExpertMode) { + gSPDisplayList(gMasterDisp++, sExpertFaceDL[drawFace - 1]); + } else { + gSPDisplayList(gMasterDisp++, sFaceDL[drawFace - 1]); + } + Matrix_Pop(&gGfxMatrix); + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); + } + Matrix_Translate(gGfxMatrix, 0.0f, 17.2f, -25.8f, MTXF_APPLY); + Matrix_RotateX(gGfxMatrix, arwing->cockpitGlassXrot * M_DTOR, MTXF_APPLY); + Matrix_SetGfxMtx(&gMasterDisp); + RCP_SetupDL_64_2(); + if ((gGameState == GSTATE_PLAY) && (gPlayer[0].state == PLAYERSTATE_LEVEL_INTRO) && + (gCurrentLevel == LEVEL_CORNERIA)) { + gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, 120); + gSPClearGeometryMode(gMasterDisp++, G_CULL_BACK); + gSPDisplayList(gMasterDisp++, D_arwing_30194E0); + RCP_SetupDL_46(); + gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, 100); + gSPDisplayList(gMasterDisp++, D_arwing_30183D0); + } else { + RCP_SetupDL_46(); + gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, 140); + gSPClearGeometryMode(gMasterDisp++, G_CULL_BACK); + gSPDisplayList(gMasterDisp++, D_arwing_30194E0); + } + gSPSetGeometryMode(gMasterDisp++, G_CULL_BACK); + Matrix_Pop(&gGfxMatrix); + // @port Pop the transform id. + FrameInterpolation_RecordCloseChild(); +} + +void OnRenderArwing(PlayerDrawArwingEvent* event){ + // 0 = Fox + int skin = CVarGetInteger("gPlayerSkin", 0); + + if(skin == 0){ + return; + } + + event->event.cancelled = true; + + switch (skin) { + case 1: // Katt + Display_ArwingWings_Katt(&event->player.arwing); + break; + case 2: // Bill + break; + } +} + void PortEnhancements_Init() { PortEnhancements_Register(); @@ -319,6 +412,7 @@ void PortEnhancements_Init() { REGISTER_LISTENER(DrawBoostGaugeHUDEvent, OnBoostGaugeDraw, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(DrawLivesCounterHUDEvent, OnLivesCounterDraw, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(DrawBombCounterHUDEvent, OnBombCounterDraw, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(PlayerDrawArwingEvent, OnRenderArwing, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(ObjectUpdateEvent, OnItemGoldRingUpdate, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(ObjectDrawPostSetupEvent, OnItemGoldRingDraw, EVENT_PRIORITY_NORMAL); @@ -339,6 +433,7 @@ void PortEnhancements_Register() { REGISTER_EVENT(PlayerPreUpdateEvent); REGISTER_EVENT(PlayerPostUpdateEvent); + REGISTER_EVENT(PlayerDrawArwing); REGISTER_EVENT(DrawRadarHUDEvent); REGISTER_EVENT(DrawBoostGaugeHUDEvent);