Path: blob/master/SonicMania/Objects/LRZ/LRZ3Outro.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: LRZ3Outro Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89#if MANIA_USE_PLUS10ObjectLRZ3Outro *LRZ3Outro;1112void LRZ3Outro_Update(void)13{14RSDK_THIS(LRZ3Outro);1516StateMachine_Run(self->state);17}1819void LRZ3Outro_LateUpdate(void) {}2021void LRZ3Outro_StaticUpdate(void) {}2223void LRZ3Outro_Draw(void) {}2425void LRZ3Outro_Create(void *data)26{27RSDK_THIS(LRZ3Outro);2829if (!SceneInfo->inEditor) {30self->active = ACTIVE_NORMAL;31self->isPermanent = true;3233self->background1 = RSDK.GetTileLayer(1);34self->background2 = RSDK.GetTileLayer(2);3536foreach_active(ParallaxSprite, sprite) { self->littlePlanet = sprite; }3738self->state = LRZ3Outro_State_BlastOff;39}40}4142void LRZ3Outro_StageLoad(void)43{44LRZ3Outro->sfxBlastoff = RSDK.GetSfx("LRZ/Blastoff.wav");45LRZ3Outro->sfxLittlePlanet = RSDK.GetSfx("LRZ/LittlePlanet.wav");46}4748void LRZ3Outro_HandleExplosions(void)49{50RSDK_THIS(LRZ3Outro);5152int32 x = (RSDK.Rand(-ScreenInfo->center.x, ScreenInfo->center.x) + ScreenInfo->center.x + ScreenInfo->position.x);53int32 y = ScreenInfo->position.y + 32 + ScreenInfo->size.y;54EntityExplosion *explosion = CREATE_ENTITY(Explosion, INT_TO_VOID(EXPLOSION_ENEMY), x << 16, y << 16);5556explosion->velocity.x = RSDK.Rand(-0x20000, 0x20000);57explosion->velocity.y = self->velocity.y - 0x40000;58explosion->drawGroup = Zone->objectDrawGroup[1];59explosion->drawFX = FX_SCALE;60explosion->inkEffect = INK_BLEND;61explosion->scale.x = RSDK.Rand(0x200, 0x400);62explosion->scale.y = explosion->scale.x;63}6465void LRZ3Outro_State_BlastOff(void)66{67RSDK_THIS(LRZ3Outro);6869++self->timer;70if (!(self->timer & 7))71Camera_ShakeScreen(0, 3, 2);7273if (self->timer == 1) {74self->blastoffChannel = RSDK.PlaySfx(LRZ3Outro->sfxBlastoff, 56628, 0xFF);75self->blastoffVolume = 1.0;76}7778if (self->timer == 60) {79self->timer = 0;80self->state = LRZ3Outro_State_RocketLaunch;8182RSDK.GetTileLayer(0)->drawGroup[0] = DRAWGROUP_COUNT;83RSDK.GetTileLayer(1)->drawGroup[0] = 0;84}85}8687void LRZ3Outro_State_RocketLaunch(void)88{89RSDK_THIS(LRZ3Outro);9091++self->timer;92if (!(self->timer & 1))93LRZ3Outro_HandleExplosions();9495if (self->timer == 30) {96Zone->playerBoundActiveB[0] = true;97Zone->cameraBoundsB[0] = (self->position.y >> 16) + 64;98}99100if (self->timer <= 120) {101if (!(self->timer & 7))102Camera_ShakeScreen(0, RSDK.Rand(-6, 6), 4);103}104else {105if (self->velocity.y < 0x60000)106self->velocity.y += 0x800;107108if (!(self->timer & 7))109Camera_ShakeScreen(0, 0, 4);110}111112if (self->timer > 390) {113self->blastoffVolume -= 0.0125;114RSDK.SetChannelAttributes(self->blastoffChannel, self->blastoffVolume, 0.0, 1.0);115}116117if (self->timer > 480) {118self->timer = 0;119self->state = LRZ3Outro_State_EnterLittlePlanet;120RSDK.StopChannel(self->blastoffChannel);121}122123TileLayer *background1 = self->background1;124if (background1->scrollPos <= -0xE00000) {125background1->scrollSpeed >>= 1;126}127else {128if (background1->scrollSpeed > -0x2000)129background1->scrollSpeed -= 0x80;130}131132TileLayer *background2 = self->background2;133if (background2->scrollPos <= -0xE00000) {134background2->scrollSpeed >>= 1;135}136else {137if (background2->scrollSpeed > -0x10000)138background2->scrollSpeed -= 0x80;139}140141if (self->littlePlanet->scrollSpeed.y > -0x1000)142self->littlePlanet->scrollSpeed.y -= 0x80;143}144145void LRZ3Outro_State_EnterLittlePlanet(void)146{147RSDK_THIS(LRZ3Outro);148149if (self->background2->scrollSpeed < 0)150self->background2->scrollSpeed += 0x80;151152EntityParallaxSprite *littlePlanet = self->littlePlanet;153if (littlePlanet->scrollSpeed.y > -0x1000) {154littlePlanet->scrollSpeed.y -= 0x80;155}156157if (littlePlanet->scrollPos.y < -0x1000000) {158littlePlanet->scrollSpeed.y = 0;159self->state = StateMachine_None;160}161}162163void LRZ3Outro_StageFinish_EndAct2ST(void)164{165EntityLRZ3Outro *cutscene = NULL;166foreach_all(LRZ3Outro, outro)167{168cutscene = outro;169foreach_break;170}171172if (cutscene) {173CutsceneSeq_StartSequence(cutscene, LRZ3Outro_Cutscene_StopPlayers, LRZ3Outro_Cutscene_LightUpLittlePlanet, StateMachine_None);174175#if MANIA_USE_PLUS176CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);177#endif178179HUD_MoveOut();180cutscene->active = ACTIVE_NEVER;181}182}183184bool32 LRZ3Outro_Cutscene_StopPlayers(EntityCutsceneSeq *host)185{186foreach_active(Player, player) {187player->state = Player_State_Static;188player->stateInput = StateMachine_None;189}190191return true;192}193194bool32 LRZ3Outro_Cutscene_LightUpLittlePlanet(EntityCutsceneSeq *host)195{196if (host->timer > 60) {197int32 frame = 23 - MIN((host->timer - 60) >> 2, 6);198foreach_active(Player, player) { RSDK.SetSpriteAnimation(player->aniFrames, ANI_TWISTER, &player->animator, true, frame); }199}200201if (host->timer > 120)202RSDK.SetLimitedFade(0, 1, 2, 4 * host->timer - 480, 245, 250);203204if (host->timer == 180)205RSDK.PlaySfx(LRZ3Outro->sfxLittlePlanet, false, 255);206207if (host->timer > 180)208RSDK.SetLimitedFade(0, 1, 2, 4 * host->timer - 720, 240, 244);209210if (host->timer == 320) {211Zone_StartFadeOut(10, 0x000000);212return true;213}214215return false;216}217218#if GAME_INCLUDE_EDITOR219void LRZ3Outro_EditorDraw(void) {}220221void LRZ3Outro_EditorLoad(void) {}222#endif223224void LRZ3Outro_Serialize(void) {}225#endif226227228