Path: blob/master/SonicMania/Objects/PGZ/PSZ2Intro.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: PSZ2Intro Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectPSZ2Intro *PSZ2Intro;1011void PSZ2Intro_Update(void)12{13RSDK_THIS(PSZ2Intro);1415self->activated = true;1617CutsceneSeq_StartSequence(self, PSZ2Intro_Cutscene_HandleAct1Finish, PSZ2Intro_Cutscene_ShowActClear, PSZ2Intro_Cutscene_RunToAct2,18PSZ2Intro_Cutscene_JogIntoPlace, StateMachine_None);1920#if MANIA_USE_PLUS21CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);22#endif2324self->active = ACTIVE_NEVER;25}2627void PSZ2Intro_LateUpdate(void) {}2829void PSZ2Intro_StaticUpdate(void) {}3031void PSZ2Intro_Draw(void) {}3233void PSZ2Intro_Create(void *data)34{35RSDK_THIS(PSZ2Intro);3637INIT_ENTITY(self);38CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);39self->active = ACTIVE_BOUNDS;40}4142void PSZ2Intro_StageLoad(void)43{44PSZ2Intro->sfxExplosion3 = RSDK.GetSfx("Stage/Explosion3.wav");4546foreach_all(FXFade, fxFade)47{48PSZ2Intro->fxFade = fxFade;49foreach_break;50}5152if (!isMainGameMode() || !globals->atlEnabled || CutsceneRules_CheckStageReload()) {53foreach_all(PSZ2Intro, intro) { destroyEntity(intro); }54}55}5657bool32 PSZ2Intro_Cutscene_HandleAct1Finish(EntityCutsceneSeq *host)58{59MANIA_GET_PLAYER(player1, player2, camera);60UNUSED(camera);6162EntityFXFade *fxFade = PSZ2Intro->fxFade;63EntitySignPost *post = PSZ2Intro->signPost;6465if (!host->timer) {66Zone->cameraBoundsR[0] = 1024;67Zone->cameraBoundsR[1] = 1024;68Zone->playerBoundActiveR[0] = true;69Zone->playerBoundActiveR[1] = true;70player1->pushing = false;71if (player2->classID == Player->classID)72player2->pushing = false;73}7475if (host->values[0]) {76if (host->timer - host->storedTimer == 30) {77ActClear->displayedActID = 1;78post->state = SignPost_State_Falling;79post->active = ACTIVE_NORMAL;80RSDK.PlaySfx(SignPost->sfxTwinkle, false, 0xFF);8182return true;83}84}85else if (!fxFade->timer) {86host->values[0] = true;87host->storedTimer = host->timer;8889foreach_all(SignPost, signPost)90{91PSZ2Intro->signPost = signPost;92foreach_break;93}94}9596return false;97}9899bool32 PSZ2Intro_Cutscene_ShowActClear(EntityCutsceneSeq *host)100{101if (ActClear->finished) {102#if MANIA_USE_PLUS103CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);104#endif105106return true;107}108109return false;110}111112bool32 PSZ2Intro_Cutscene_RunToAct2(EntityCutsceneSeq *host)113{114MANIA_GET_PLAYER(player1, player2, camera);115UNUSED(camera);116117if (!host->timer) {118Vector2 size;119RSDK.GetLayerSize(Zone->fgLayer[0], &size, true);120Zone->cameraBoundsR[0] = size.x;121Zone->cameraBoundsR[1] = size.x;122123RSDK.SetSpriteAnimation(player1->aniFrames, ANI_IDLE, &player1->animator, true, 0);124player1->state = Player_State_Ground;125player1->up = false;126player1->stateInput = StateMachine_None;127128CutsceneSeq_LockAllPlayerControl();129player1->jumpPress = false;130player1->jumpHold = false;131player1->left = false;132player1->down = false;133134if (player2->classID == Player->classID) {135// Bug Details:136// Player 2's animation should be set here, but it sets it to Player 1's animator instead.137// In doing so, if you were to beat Press Garden Act 1 and watch the transition cutscene,138// Player 1 will temporarily use the idle sprite of Player 2 for a single frame139// before turning back into the character Player 1 is supposed to be.140// Pretty odd, huh?141// Change &player1->animator to &player2->animator to fix it.142RSDK.SetSpriteAnimation(player2->aniFrames, ANI_IDLE, &player1->animator, true, 0);143player2->state = Player_State_Ground;144player2->up = false;145player2->stateInput = Player_Input_P2_AI;146}147}148149if (player1->jumpPress)150player1->jumpPress = false;151152if (abs(player1->pushing) >= 3) {153player1->jumpPress = true;154player1->jumpHold = true;155}156157if (player1->position.x >= 0x3800000) {158player1->right = false;159Zone->cameraBoundsL[0] = 1024;160Zone->cameraBoundsL[1] = 1024;161return true;162}163else {164player1->right = true;165}166167return false;168}169170bool32 PSZ2Intro_Cutscene_JogIntoPlace(EntityCutsceneSeq *host)171{172MANIA_GET_PLAYER(player1, player2, camera);173UNUSED(camera);174175if (ScreenInfo->position.x < Zone->cameraBoundsL[0]) {176// Bug Details:177// groundVel is set here, but the game doesn't make sure you're facing that direction178// meaning you can be moving right but facing left, a simple player->direction = FLIP_NONE would fix this179// though it'd be best to place it up where player->right = true; is set180if (player1->groundVel < 0x20000)181player1->groundVel = 0x20000;182183if (player2->classID == Player->classID) {184if (player2->groundVel < 0x20000)185player2->groundVel = 0x20000;186}187}188else {189player1->stateInput = Player_Input_P1;190player1->state = Player_State_Ground;191192foreach_all(TitleCard, titleCard)193{194titleCard->active = ACTIVE_NORMAL;195titleCard->state = TitleCard_State_SetupBGElements;196titleCard->stateDraw = TitleCard_Draw_SlideIn;197foreach_break;198}199200Music_PlayTrack(TRACK_STAGE);201return true;202}203204return false;205}206207#if GAME_INCLUDE_EDITOR208void PSZ2Intro_EditorDraw(void)209{210RSDK_THIS(PSZ2Outro);211CutsceneRules_DrawCutsceneBounds(self, &self->size);212}213214void PSZ2Intro_EditorLoad(void) {}215#endif216217void PSZ2Intro_Serialize(void) { RSDK_EDITABLE_VAR(PSZ2Intro, VAR_VECTOR2, size); }218219220