Path: blob/master/SonicMania/Objects/FBZ/FBZ1Outro.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: FBZ1Outro Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectFBZ1Outro *FBZ1Outro;1011void FBZ1Outro_Update(void)12{13RSDK_THIS(FBZ1Outro);1415if (!self->activated) {16FBZ1Outro_StartCutscene();17self->activated = true;18}19}2021void FBZ1Outro_LateUpdate(void) {}2223void FBZ1Outro_StaticUpdate(void) {}2425void FBZ1Outro_Draw(void) {}2627void FBZ1Outro_Create(void *data)28{29RSDK_THIS(FBZ1Outro);3031INIT_ENTITY(self);32CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);33self->active = ACTIVE_NEVER;34}3536void FBZ1Outro_StageLoad(void)37{38foreach_all(BigSqueeze, boss)39{40switch (boss->type) {41default: break;4243case BIGSQUEEZE_CRUSHER_L: FBZ1Outro->bossBorderL = boss; break;44case BIGSQUEEZE_CRUSHER_R: FBZ1Outro->bossBorderR = boss; break;45case BIGSQUEEZE_MANAGER: FBZ1Outro->bossManager = boss; break;46}47}4849foreach_all(CollapsingPlatform, platform)50{51if (platform->eventOnly) {52FBZ1Outro->collapsingPlatform = platform;53foreach_break;54}55}5657foreach_all(Crane, crane)58{59if (crane->position.x == 0x33400000 && crane->position.y == 0x9100000)60FBZ1Outro->craneP1 = crane;6162if (crane->position.x == 0x33640000 && crane->position.y == 0x9100000)63FBZ1Outro->craneP2 = crane;64}6566FBZ1Outro->sfxDrop = RSDK.GetSfx("Stage/Drop.wav");67}6869void FBZ1Outro_StartCutscene(void)70{71RSDK_THIS(FBZ1Outro);7273CutsceneSeq_StartSequence(self, FBZ1Outro_Cutscene_CrushTrash, FBZ1Outro_Cutscene_TrashDrop, FBZ1Outro_Cutscene_CraneRide,74FBZ1Outro_Cutscene_PrepareFBZ2, StateMachine_None);7576#if MANIA_USE_PLUS77CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);78#endif79}8081void FBZ1Outro_HandleTrash(void)82{83foreach_active(FBZTrash, trash) { trash->velocity.y = 0; }84foreach_active(FBZSinkTrash, sinkTrash) { sinkTrash->velocity.y = 0; }8586foreach_active(SignPost, signPost)87{88signPost->velocity.x = 0;89signPost->velocity.y = 0;90signPost->position.y = BigSqueeze->boundsB - 0x180000;9192int32 boundsL = BigSqueeze->crusherX[BIGSQUEEZE_CRUSHER_L] + 0x180000;93int32 boundsR = BigSqueeze->crusherX[BIGSQUEEZE_CRUSHER_R] - 0x180000;9495signPost->position.x = CLAMP(signPost->position.x, boundsL, boundsR);96}97}9899void FBZ1Outro_DispenseTrash(void)100{101foreach_active(FBZTrash, trash)102{103trash->state = StateMachine_None;104trash->position.y += trash->velocity.y;105trash->velocity.y += 0x3800;106}107108foreach_active(FBZSinkTrash, sinkTrash)109{110sinkTrash->position.y += sinkTrash->velocity.y;111sinkTrash->velocity.y += 0x3800;112sinkTrash->type = FBZSINKTRASH_DECOR;113}114115foreach_active(SignPost, signPost)116{117signPost->position.y += signPost->velocity.y;118signPost->velocity.y += 0x3800;119signPost->type = SIGNPOST_COMP;120}121}122123bool32 FBZ1Outro_Cutscene_CrushTrash(EntityCutsceneSeq *host)124{125RSDK_THIS(FBZ1Outro);126127MANIA_GET_PLAYER(player1, player2, camera);128UNUSED(camera);129130EntityBigSqueeze *bossBorderL = FBZ1Outro->bossBorderL;131EntityBigSqueeze *bossBorderR = FBZ1Outro->bossBorderR;132EntityBigSqueeze *bossManager = FBZ1Outro->bossManager;133134EntityCollapsingPlatform *platform = FBZ1Outro->collapsingPlatform;135136if (!host->timer) {137player1->stateInput = StateMachine_None;138RSDK.SetSpriteAnimation(player1->aniFrames, ANI_BALANCE_1, &player1->animator, false, 0);139140player1->state = Player_State_Static;141CutsceneSeq_LockPlayerControl(player1);142143if (player2->classID == Player->classID) {144RSDK.SetSpriteAnimation(player2->aniFrames, ANI_BALANCE_1, &player2->animator, false, 0);145146player2->state = Player_State_Static;147CutsceneSeq_LockPlayerControl(player2);148}149}150151player1->nextGroundState = StateMachine_None;152player1->nextAirState = StateMachine_None;153if (player2->classID == Player->classID) {154player2->nextGroundState = StateMachine_None;155player2->nextAirState = StateMachine_None;156}157158if (BigSqueeze->crusherX[BIGSQUEEZE_CRUSHER_R] - BigSqueeze->crusherX[BIGSQUEEZE_CRUSHER_L] <= 0xB00000) {159BigSqueeze->isCrushing = false;160RSDK.SetSpriteAnimation(player1->aniFrames, ANI_HURT, &player1->animator, false, 0);161player1->state = Player_State_Air;162player1->onGround = false;163if (player2->classID == Player->classID) {164RSDK.SetSpriteAnimation(player2->aniFrames, ANI_HURT, &player2->animator, false, 0);165player2->state = Player_State_Air;166player2->onGround = false;167}168else {169destroyEntity(FBZ1Outro->craneP2);170self->grabbedPlayers |= 2;171}172173bossBorderL->setupTimer = 0;174bossBorderL->state = BigSqueeze_StateCrusher_BeginCrushing;175bossBorderR->setupTimer = 0;176bossBorderR->state = BigSqueeze_StateCrusher_BeginCrushing;177bossManager->state = BigSqueeze_StateManager_HandleOutro;178Zone->cameraBoundsB[0] = 2660;179Zone->cameraBoundsB[1] = 2660;180Zone->cameraBoundsR[0] = 14080;181Zone->cameraBoundsR[1] = 14080;182platform->stoodPos.x = 1;183RSDK.PlaySfx(FBZ1Outro->sfxDrop, false, 255);184185return true;186}187else {188BigSqueeze->isCrushing = true;189FBZ1Outro_HandleTrash();190if (host->values[0])191host->values[0] = true;192193bossBorderL->setupTimer = 0;194bossBorderL->state = BigSqueeze_StateCrusher_Crushing;195bossBorderR->setupTimer = 0;196bossBorderR->state = BigSqueeze_StateCrusher_Crushing;197}198199return false;200}201bool32 FBZ1Outro_Cutscene_TrashDrop(EntityCutsceneSeq *host)202{203RSDK_THIS(FBZ1Outro);204205MANIA_GET_PLAYER(player1, player2, camera);206UNUSED(camera);207208EntityBigSqueeze *bossBorderL = FBZ1Outro->bossBorderL;209EntityBigSqueeze *bossBorderR = FBZ1Outro->bossBorderR;210bossBorderL->setupTimer = 0;211bossBorderL->state = BigSqueeze_StateCrusher_BeginCrushing;212bossBorderR->setupTimer = 0;213bossBorderR->state = BigSqueeze_StateCrusher_BeginCrushing;214215EntityCrane *craneP1 = FBZ1Outro->craneP1;216craneP1->position.x = player1->position.x;217if (craneP1->state == Crane_State_RiseUp) {218craneP1->startPos.x = player1->position.x;219craneP1->startPos.y = craneP1->position.y;220self->grabbedPlayers |= 1;221}222223if (player2->classID == Player->classID) {224EntityCrane *craneP2 = FBZ1Outro->craneP2;225craneP2->position.x = player2->position.x;226if (craneP2->state == Crane_State_RiseUp) {227craneP2->startPos.x = craneP2->position.x;228craneP2->startPos.y = craneP2->position.y;229self->grabbedPlayers |= 2;230}231}232233if (self->grabbedPlayers == (1 | 2))234return true;235236FBZ1Outro_DispenseTrash();237238return false;239}240bool32 FBZ1Outro_Cutscene_CraneRide(EntityCutsceneSeq *host)241{242MANIA_GET_PLAYER(player1, player2, camera);243UNUSED(camera);244245FBZ1Outro_DispenseTrash();246247return player1->onGround && (player2->classID != Player->classID || player2->onGround);248}249bool32 FBZ1Outro_Cutscene_PrepareFBZ2(EntityCutsceneSeq *host)250{251MANIA_GET_PLAYER(player1, player2, camera);252253if (!host->timer) {254Zone->cameraBoundsL[0] = 13568;255Zone->cameraBoundsL[1] = 13568;256Zone->cameraBoundsB[0] = 2660;257Zone->cameraBoundsB[0] = 2660;258Zone->playerBoundActiveL[0] = true;259}260261RSDK.SetSpriteAnimation(player1->aniFrames, ANI_IDLE, &player1->animator, false, 0);262if (player2->classID == Player->classID)263RSDK.SetSpriteAnimation(player2->aniFrames, ANI_IDLE, &player2->animator, false, 0);264265if (camera->offset.x || ScreenInfo->position.x < Zone->cameraBoundsL[0] || host->timer < 30) {266if (ScreenInfo->position.x < Zone->cameraBoundsL[0])267ScreenInfo->position.x++;268if (camera->offset.x > 0)269camera->offset.x -= 0x10000;270}271else {272Zone_StoreEntities(13780 << 16, 2660 << 16);273RSDK.LoadScene();274275int32 id = 0;276TileLayer *layer = RSDK.GetTileLayer(1);277for (int32 i = 0; i < layer->scrollInfoCount; ++i) {278globals->parallaxOffset[id++] = layer->scrollInfo[i].scrollPos + layer->scrollInfo[i].parallaxFactor * ScreenInfo->position.x;279}280281foreach_all(ParallaxSprite, parallaxSprite)282{283globals->parallaxOffset[id++] = parallaxSprite->scrollPos.x + parallaxSprite->parallaxFactor.x * ScreenInfo->position.x;284}285286return true;287}288return false;289}290291#if GAME_INCLUDE_EDITOR292void FBZ1Outro_EditorDraw(void)293{294RSDK_THIS(FBZ1Outro);295CutsceneRules_DrawCutsceneBounds(self, &self->size);296}297298void FBZ1Outro_EditorLoad(void) {}299#endif300301void FBZ1Outro_Serialize(void) { RSDK_EDITABLE_VAR(FBZ1Outro, VAR_VECTOR2, size); }302303304