Path: blob/master/SonicMania/Objects/SPZ/SPZ1Intro.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: SPZ1Intro Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectSPZ1Intro *SPZ1Intro;1011void SPZ1Intro_Update(void)12{13RSDK_THIS(SPZ1Intro);1415if (!self->activated) {16if (!isMainGameMode() || !globals->enableIntro || CutsceneRules_CheckStageReload()) {17self->active = ACTIVE_NEVER;18}19else {20self->activated = true;21CutsceneSeq_StartSequence(self, SPZ1Intro_Cutscene_SetupAct, SPZ1Intro_Cutscene_ExitPipe, SPZ1Intro_Cutscene_BeginAct1, StateMachine_None);2223#if MANIA_USE_PLUS24CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);25#endif26}27}28}2930void SPZ1Intro_LateUpdate(void) {}3132void SPZ1Intro_StaticUpdate(void) {}3334void SPZ1Intro_Draw(void) {}3536void SPZ1Intro_Create(void *data)37{38RSDK_THIS(SPZ1Intro);3940INIT_ENTITY(self);41CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);42self->active = ACTIVE_NORMAL;43}4445void SPZ1Intro_StageLoad(void)46{47SPZ1Intro->sfxGasPop = RSDK.GetSfx("OOZ/GasPop.wav");48SPZ1Intro->sfxPon = RSDK.GetSfx("Stage/Pon.wav");4950SPZ1Intro->aniFrames = RSDK.LoadSpriteAnimation("SPZ1/ManholeCover.bin", SCOPE_STAGE);51}5253bool32 SPZ1Intro_Cutscene_SetupAct(EntityCutsceneSeq *host)54{55RSDK_THIS(SPZ1Intro);56MANIA_GET_PLAYER(player1, player2, camera);5758Entity *curEnt = host->activeEntity;59if (!host->timer) {60player1->position.x = self->position.x;61camera->position.x = self->position.x;62player1->position.y += 0x250000;63player1->camera = StateMachine_None;64player1->tileCollisions = TILECOLLISION_NONE;65player1->onGround = false;66player1->state = Player_State_Static;67player1->stateInput = StateMachine_None;68CutsceneSeq_LockAllPlayerControl();69RSDK.SetSpriteAnimation(player1->aniFrames, ANI_JUMP, &player1->animator, false, 0);7071if (player2->classID == Player->classID) {72player2->position.x = player1->position.x;73player2->position.y = player1->position.y;74player2->tileCollisions = TILECOLLISION_NONE;75player2->onGround = false;76player2->velocity.y = -1;77player2->state = Player_State_Static;78player2->stateInput = StateMachine_None;79RSDK.SetSpriteAnimation(player2->aniFrames, ANI_JUMP, &player2->animator, false, 0);80}8182EntityDebris *lid = CREATE_ENTITY(Debris, NULL, curEnt->position.x, curEnt->position.y + 0x390000);83lid->drawGroup = Zone->playerDrawGroup[1];84lid->state = StateMachine_None;85lid->drawFX = FX_SCALE | FX_ROTATE;86lid->scale.x = 0x200;87lid->scale.y = 0x200;88lid->updateRange.x = 0x800000;89lid->updateRange.y = 0x800000;90RSDK.SetSpriteAnimation(SPZ1Intro->aniFrames, 0, &lid->animator, true, 0);91SPZ1Intro->sewerLid = lid;92}9394if (!RSDK.GetEntityCount(TitleCard->classID, false) && !RSDK_GET_ENTITY(SLOT_PAUSEMENU, PauseMenu)->classID && !host->values[0]) {95host->values[0] = true;96host->storedTimer = host->timer;97}9899if (host->values[0]) {100if (host->timer == 45)101RSDK.PlaySfx(Player->sfxRoll, false, 0xFF);102103if (host->timer == 90)104return true;105}106107SceneInfo->timeEnabled = false;108SceneInfo->milliseconds = 0;109camera->state = StateMachine_None;110111return false;112}113114bool32 SPZ1Intro_Cutscene_ExitPipe(EntityCutsceneSeq *host)115{116MANIA_GET_PLAYER(player1, player2, camera);117UNUSED(camera);118119if (!host->timer) {120player1->velocity.x = 0;121player1->velocity.y = -0x80000;122player1->state = Player_State_Air;123player1->nextAirState = StateMachine_None;124player1->nextGroundState = StateMachine_None;125RSDK.PlaySfx(SPZ1Intro->sfxGasPop, false, 0xFF);126RSDK.PlaySfx(SPZ1Intro->sfxPon, false, 0xFF);127RSDK.StopSfx(Player->sfxRoll);128Camera_ShakeScreen(0, 0, 2);129EntityDebris *lid = SPZ1Intro->sewerLid;130lid->state = Debris_State_Fall;131lid->velocity.y = -0x60000;132lid->velocity.x = -0x18000;133lid->gravityStrength = 0x3800;134lid->scaleSpeed.x = 8;135lid->scaleSpeed.y = 8;136lid->rotSpeed = -1;137RSDK.SetSpriteAnimation(SPZ1Intro->aniFrames, 1, &lid->animator, true, 0);138}139140if (player1->velocity.y > 0)141player1->tileCollisions = TILECOLLISION_DOWN;142143if (player2->classID == Player->classID) {144if (host->timer == 10) {145player2->velocity.x = 0;146player2->velocity.y = -0x80000;147player2->state = Player_State_Air;148player2->nextAirState = StateMachine_None;149player2->nextGroundState = StateMachine_None;150}151152if (player2->velocity.y > 0)153player2->tileCollisions = TILECOLLISION_DOWN;154155if (player1->onGround && player2->onGround)156return true;157}158else if (player1->onGround) {159return true;160}161162return false;163}164165bool32 SPZ1Intro_Cutscene_BeginAct1(EntityCutsceneSeq *host)166{167MANIA_GET_PLAYER(player1, player2, camera);168169if (!host->timer) {170camera->target = (Entity *)player1;171camera->state = Camera_State_FollowXY;172player1->stateInput = Player_Input_P1;173player1->state = Player_State_Ground;174player1->camera = camera;175176if (player2->classID == Player->classID)177player2->stateInput = Player_Input_P2_AI;178179SceneInfo->timeEnabled = true;180return true;181}182183return false;184}185186#if GAME_INCLUDE_EDITOR187void SPZ1Intro_EditorDraw(void)188{189RSDK_THIS(SPZ1Intro);190191if (showGizmos())192CutsceneRules_DrawCutsceneBounds(self, &self->size);193}194195void SPZ1Intro_EditorLoad(void) {}196#endif197198void SPZ1Intro_Serialize(void) { RSDK_EDITABLE_VAR(SPZ1Intro, VAR_VECTOR2, size); }199200201