Path: blob/master/SonicMania/Objects/GHZ/GHZCutsceneST.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: GHZCutsceneST Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectGHZCutsceneST *GHZCutsceneST;1011void GHZCutsceneST_Update(void)12{13RSDK_THIS(GHZCutsceneST);1415if (!self->setupKnuxCutscene) {16GHZCutsceneST_SetupKnuxCutscene();17self->setupKnuxCutscene = true;18}1920if (!self->activated) {21foreach_active(Player, player)22{23if (Player_CheckCollisionTouch(player, self, &self->hitbox) && !player->sidekick) {24CutsceneSeq_StartSequence(self, GHZCutsceneST_Cutscene_FadeIn, GHZCutsceneST_Cutscene_FinishRubyWarp, GHZCutsceneST_Cutscene_ExitHBH,25GHZCutsceneST_Cutscene_SetupGHZ1, StateMachine_None);2627#if MANIA_USE_PLUS28CutsceneSeq_SetSkipTypeCallback(GHZCutsceneST_Cutscene_SkipCB);29#endif3031self->activated = true;32}33}34}35++self->timer;36}3738void GHZCutsceneST_LateUpdate(void) {}3940void GHZCutsceneST_StaticUpdate(void) {}4142void GHZCutsceneST_Draw(void) {}4344void GHZCutsceneST_Create(void *data)45{46RSDK_THIS(GHZCutsceneST);47if (!SceneInfo->inEditor) {48INIT_ENTITY(self);49CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);50self->active = ACTIVE_BOUNDS;5152GHZCutsceneST_SetupObjects();5354SceneInfo->timeEnabled = false;55}56}5758void GHZCutsceneST_StageLoad(void) {}5960void GHZCutsceneST_SetupObjects(void)61{62foreach_all(Platform, platform)63{64if (!platform->frameID) {65platform->drawGroup = Zone->objectDrawGroup[1] - 1;66GHZCutsceneST->platform = platform;67foreach_break;68}69}7071foreach_all(AIZKingClaw, claw)72{73GHZCutsceneST->claw = claw;74foreach_break;75}7677foreach_all(PhantomRuby, phantomRuby)78{79GHZCutsceneST->phantomRuby = phantomRuby;80foreach_break;81}8283foreach_all(FXRuby, fxRuby)84{85GHZCutsceneST->fxRuby = fxRuby;86fxRuby->state = StateMachine_None;87fxRuby->fadeBlack = 0x200;88fxRuby->fadeWhite = 0x200;89fxRuby->outerRadius = ScreenInfo->size.x;90fxRuby->timer = 64;91foreach_break;92}9394foreach_all(CutsceneHBH, cutsceneHBH) { GHZCutsceneST->cutsceneHBH[cutsceneHBH->characterID] = cutsceneHBH; }95}9697void GHZCutsceneST_SetupKnuxCutscene(void)98{99if (CHECK_CHARACTER_ID(ID_KNUCKLES, 1)) {100EntityPlatform *platform = GHZCutsceneST->platform;101EntityAIZKingClaw *claw = GHZCutsceneST->claw;102EntityFXRuby *fxRuby = GHZCutsceneST->fxRuby;103EntityPhantomRuby *phantomRuby = GHZCutsceneST->phantomRuby;104105GHZCutsceneST->cutsceneHBH[0]->position.y += 704 << 16;106GHZCutsceneST->cutsceneHBH[1]->position.y += 704 << 16;107GHZCutsceneST->cutsceneHBH[2]->position.y += 704 << 16;108GHZCutsceneST->cutsceneHBH[3]->position.y += 704 << 16;109GHZCutsceneST->cutsceneHBH[4]->position.y += 704 << 16;110fxRuby->position.y += 704 << 16;111phantomRuby->position.y += 704 << 16;112platform->position.y += 704 << 16;113platform->drawPos.x = platform->position.x;114platform->drawPos.y = platform->position.y;115platform->centerPos.x = platform->position.x;116platform->centerPos.y = platform->position.y;117claw->position.y += 704 << 16;118}119}120121#if MANIA_USE_PLUS122void GHZCutsceneST_Cutscene_SkipCB(void)123{124#if MANIA_USE_PLUS125if (globals->gameMode == MODE_ENCORE)126RSDK.SetScene("Encore Mode", "Green Hill Zone+ 1");127else128#endif129RSDK.SetScene("Mania Mode", "Green Hill Zone 1");130}131#endif132133bool32 GHZCutsceneST_Cutscene_FadeIn(EntityCutsceneSeq *host)134{135MANIA_GET_PLAYER(player1, player2, camera);136UNUSED(camera);137138EntityFXRuby *fxRuby = GHZCutsceneST->fxRuby;139EntityPhantomRuby *ruby = GHZCutsceneST->phantomRuby;140141if (host->timer) {142if (host->timer >= 60) {143if (fxRuby->fadeBlack <= 0) {144if (fxRuby->fadeWhite <= 0) {145PhantomRuby_PlaySfx(RUBYSFX_ATTACK4);146return true;147}148fxRuby->fadeWhite -= 16;149}150else {151fxRuby->fadeBlack -= 16;152}153}154}155else {156player1->position.y = ruby->position.y;157player1->state = Player_State_Static;158player1->stateInput = StateMachine_None;159CutsceneSeq_LockAllPlayerControl();160if (player2->classID == Player->classID) {161player2->position.y = ruby->position.y;162player2->state = Player_State_Static;163player2->stateInput = StateMachine_None;164}165}166167int32 id = 0;168for (int32 angle = 0; angle < 0x80; angle += 0x40) {169EntityPlayer *player = RSDK_GET_ENTITY(id++, Player);170if (!player || player->classID == TYPE_BLANK)171break;172RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, 0, 0);173player->position.x += (player->position.x - player->position.x) >> 3;174player->position.y += (0xA00 * RSDK.Sin256(2 * (host->timer + angle - host->storedTimer)) + ruby->position.y - player->position.y) >> 3;175player->state = Player_State_Static;176}177178return false;179}180bool32 GHZCutsceneST_Cutscene_FinishRubyWarp(EntityCutsceneSeq *host)181{182MANIA_GET_PLAYER(player1, player2, camera);183UNUSED(player2);184185EntityPhantomRuby *ruby = GHZCutsceneST->phantomRuby;186EntityFXRuby *fxRuby = GHZCutsceneST->fxRuby;187if (!host->timer)188fxRuby->state = FXRuby_State_Shrinking;189190EntityPlayer **curPlayer = &player1;191if (fxRuby->outerRadius <= 0) {192int32 id = 0;193for (int32 angle = 0; angle < 0x80; angle += 0x10) {194EntityPlayer *player = RSDK_GET_ENTITY(id++, Player);195if (!player || player->classID == TYPE_BLANK)196break;197RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, false, 0);198int32 x = (player->position.x - player->position.x) >> 3;199int32 y = (0xA00 * RSDK.Sin256(2 * (angle + host->timer - host->storedTimer)) + ruby->position.y - player->position.y) >> 3;200player->velocity.x = (x >> 8) * (x >> 8);201player->velocity.y = (y >> 8) * (y >> 8);202player->state = Player_State_Air;203player->up = true;204player->camera = NULL;205++curPlayer;206}207208host->values[0] = true;209Camera_SetupLerp(CAMERA_LERP_NORMAL, 0, camera->position.x, camera->position.y, 0);210return true;211}212else {213int32 id = 0;214for (int32 angle = 0; angle < 0x80; angle += 0x10) {215EntityPlayer *player = RSDK_GET_ENTITY(id++, Player);216if (!player || player->classID == TYPE_BLANK)217break;218RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, 0, 0);219player->position.x += (player->position.x - player->position.x) >> 3;220player->position.y += (0xA00 * RSDK.Sin256(2 * (host->timer + angle - host->storedTimer)) + ruby->position.y - player->position.y) >> 3;221player->state = Player_State_Static;222++curPlayer;223}224return false;225}226return false;227}228bool32 GHZCutsceneST_Cutscene_ExitHBH(EntityCutsceneSeq *host)229{230MANIA_GET_PLAYER(player1, player2, camera);231UNUSED(player2);232233EntityPhantomRuby *ruby = GHZCutsceneST->phantomRuby;234EntityAIZKingClaw *claw = GHZCutsceneST->claw;235EntityPlatform *platform = GHZCutsceneST->platform;236237if (host->timer >= 60) {238if (host->timer == 60) {239int32 id = 0;240for (int32 i = 0; i < 2; ++i) {241EntityPlayer *player = RSDK_GET_ENTITY(id++, Player);242if (!player || player->classID == TYPE_BLANK)243break;244player->up = false;245}246247Music_FadeOut(0.025);248}249250if (host->timer == 180) {251player1->camera = camera;252Camera_SetTargetEntity(0, player1);253return true;254}255else {256claw->velocity.y -= 0x1800;257for (int32 hbhChar = 0; hbhChar < 5; ++hbhChar) {258EntityCutsceneHBH *hbh = GHZCutsceneST->cutsceneHBH[hbhChar];259switch (hbhChar) {260case HBH_GUNNER:261hbh->velocity.x += 0x800;262hbh->velocity.y -= 0x1800;263hbh->position.x += hbh->velocity.x;264hbh->position.y += hbh->velocity.y;265break;266267case HBH_SHINOBI:268if (host->timer == 60) {269RSDK.SetSpriteAnimation(hbh->aniFrames, 3, &hbh->mainAnimator, true, 0);270RSDK.SetSpriteAnimation(-1, 0, &hbh->fxAnimator, true, 0);271}272hbh->position.x -= 0x4000;273hbh->position.y -= 0x40000;274break;275276case HBH_MYSTIC:277hbh->velocity.x += 0x2000;278hbh->velocity.y -= 0x1000;279hbh->position.x += hbh->velocity.x;280hbh->position.y += hbh->velocity.y;281break;282283case HBH_RIDER:284case HBH_KING:285hbh->position.x += claw->velocity.x;286hbh->position.y += claw->velocity.y;287break;288289default: break;290}291}292293ruby->position.x += claw->velocity.x;294ruby->position.y += claw->velocity.y;295platform->position.x += claw->velocity.x;296platform->position.y += claw->velocity.y;297platform->drawPos.x = platform->position.x;298platform->drawPos.y = platform->position.y;299platform->centerPos.x = platform->position.x;300platform->centerPos.y = platform->position.y;301claw->position.x += claw->velocity.x;302claw->position.y += claw->velocity.y;303}304}305306return false;307}308309bool32 GHZCutsceneST_Cutscene_SetupGHZ1(EntityCutsceneSeq *host)310{311RSDK_THIS(GHZCutsceneST);312313#if MANIA_USE_PLUS314if (globals->gameMode == MODE_ENCORE)315RSDK.SetScene("Encore Mode", "");316else317#endif318RSDK.SetScene("Mania Mode", "");319320globals->parallaxOffset[0] = self->timer;321EntityPlayer *player = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);322player->onGround = true;323player->state = Player_State_Ground;324Zone_StoreEntities((ScreenInfo->position.x + ScreenInfo->center.x) << 16, (ScreenInfo->size.y + ScreenInfo->position.y) << 16);325RSDK.LoadScene();326return true;327}328329#if GAME_INCLUDE_EDITOR330void GHZCutsceneST_EditorDraw(void)331{332RSDK_THIS(GHZCutsceneST);333CutsceneRules_DrawCutsceneBounds(self, &self->size);334}335336void GHZCutsceneST_EditorLoad(void) {}337#endif338339void GHZCutsceneST_Serialize(void) { RSDK_EDITABLE_VAR(GHZCutsceneST, VAR_VECTOR2, size); }340341342