Path: blob/master/SonicMania/Objects/Credits/TryAgainE.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: TryAgainE Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89#if MANIA_USE_PLUS10ObjectTryAgainE *TryAgainE;1112void TryAgainE_Update(void)13{14RSDK_THIS(TryAgainE);1516StateMachine_Run(self->state);17}1819void TryAgainE_LateUpdate(void) {}2021void TryAgainE_StaticUpdate(void)22{23foreach_active(TryAgainE, tryAgainE) { RSDK.AddDrawListRef(2, RSDK.GetEntitySlot(tryAgainE)); }24}2526void TryAgainE_Draw(void)27{28RSDK_THIS(TryAgainE);2930if (SceneInfo->currentDrawGroup == self->drawGroup) {31Vector2 drawPos;3233RSDK.SetActivePalette(3, 0, ScreenInfo->size.y);34self->mainAnimator.frameID = 0;35RSDK.DrawSprite(&self->mainAnimator, NULL, false);3637self->mainAnimator.frameID = 1;38RSDK.DrawSprite(&self->mainAnimator, NULL, false);39RSDK.SetActivePalette(0, 0, ScreenInfo->size.y);4041drawPos.x = self->position.x;42drawPos.y = self->position.y + 0x2E0000;4344if (GET_CHARACTER_ID(2) != ID_NONE)45drawPos.x = self->position.x - 0x140000;4647if (self->player1Animator.animationID == 2)48drawPos.y = self->position.y + 0x2E0000 + 0x40000;4950RSDK.DrawSprite(&self->player1Animator, &drawPos, false);5152int32 drawY = drawPos.y;53if (self->player1Animator.animationID == 2) {54drawY = drawPos.y - 0x40000;55drawPos.y -= 0x40000;56}5758if (GET_CHARACTER_ID(2) != ID_NONE) {59drawPos.x += 0x280000;60self->direction = FLIP_X;6162if (self->player2Animator.animationID == 2)63drawPos.y = drawY + 0x40000;6465RSDK.DrawSprite(&self->player2Animator, &drawPos, false);66self->direction = FLIP_NONE;67}68}69else {70self->direction = FLIP_X;71RSDK.DrawSprite(&self->handUpAnimator, NULL, false);7273self->direction = FLIP_NONE;74RSDK.DrawSprite(&self->handDownAnimator, NULL, false);75}76}7778void TryAgainE_Create(void *data)79{80RSDK_THIS(TryAgainE);8182if (!SceneInfo->inEditor) {83self->visible = true;84self->drawGroup = 1;85self->active = ACTIVE_BOUNDS;86self->updateRange.x = 0x800000;87self->updateRange.y = 0x800000;88self->drawFX = FX_FLIP;8990self->state = TryAgainE_State_Stinger;91RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 0, &self->mainAnimator, true, 0);92RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handUpAnimator, true, 4);93RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handDownAnimator, true, 3);9495RSDK.SetSpriteAnimation(TryAgainE->playerFrames, 2 * HUD_CharacterIndexFromID(GET_CHARACTER_ID(1)), &self->player1Animator, true, 3);9697if (GET_CHARACTER_ID(2) != ID_NONE)98RSDK.SetSpriteAnimation(TryAgainE->playerFrames, 2 * HUD_CharacterIndexFromID(GET_CHARACTER_ID(2)), &self->player2Animator, true, 3);99}100}101102void TryAgainE_StageLoad(void)103{104TryAgainE->aniFrames = RSDK.LoadSpriteAnimation("Credits/TryAgainE.bin", SCOPE_STAGE);105TryAgainE->playerFrames = RSDK.LoadSpriteAnimation("Players/Continue.bin", SCOPE_STAGE);106107TryAgainE->active = ACTIVE_ALWAYS;108RSDK.CopyPalette(0, 0, 1, 0, 128);109}110111void TryAgainE_SetupEmeralds(void)112{113int32 timer = 0;114115int32 id = 0;116foreach_all(TAEmerald, emerald)117{118emerald->state = TAEmerald_State_MoveCircle;119emerald->timer = timer;120121if (SaveGame_GetSaveRAM() && !SaveGame_GetEmerald(id))122timer += 8;123id++;124}125}126127void TryAgainE_State_Stinger(void)128{129RSDK_THIS(TryAgainE);130131RSDK.ProcessAnimation(&self->handUpAnimator);132RSDK.ProcessAnimation(&self->handDownAnimator);133RSDK.ProcessAnimation(&self->player1Animator);134135if (GET_CHARACTER_ID(2) != ID_NONE)136RSDK.ProcessAnimation(&self->player2Animator);137138if ((self->timer & 0x7F) == 1) {139if ((self->timer & 0x80) && self->handUpAnimator.animationID == 2)140RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handUpAnimator, true, 0);141142if ((int8)(self->timer & 0xFF) >= 0 && self->handDownAnimator.animationID == 2)143RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handDownAnimator, true, 0);144145TryAgainE_SetupEmeralds();146}147else if ((self->timer & 0x7F) == 59) {148if ((self->timer & 0x80) == 0 && self->handUpAnimator.animationID == 1)149RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handUpAnimator, true, 0);150151if ((int8)(self->timer & 0xFF) < 0 && self->handDownAnimator.animationID == 1)152RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handDownAnimator, true, 0);153}154155if (++self->timer == 1) {156foreach_all(TAEmerald, emerald)157{158emerald->originPos.x = self->position.x;159emerald->originPos.y = self->position.y + 0x100000;160161emerald->position.x = emerald->originPos.x + 0x480000;162emerald->position.y = emerald->originPos.y;163164emerald->angle = 0;165emerald->drawFX = FX_ROTATE;166emerald->state = StateMachine_None;167}168}169170if (ControllerInfo->keyA.press || ControllerInfo->keyStart.press)171self->timer = 600;172173if (self->timer == 600) {174PhantomRuby_PlaySfx(RUBYSFX_ATTACK4);175176EntityFXFade *fxFade = CREATE_ENTITY(FXFade, INT_TO_VOID(0xFFFFFF), self->position.x, self->position.y);177fxFade->speedIn = 24;178fxFade->speedOut = 24;179fxFade->fadeOutBlack = true;180}181182if (self->timer >= 740) {183if (API.CheckDLC(DLC_PLUS))184RSDK.SetScene("Presentation", "Encore Summary");185else186RSDK.SetScene("Presentation", "Menu");187188RSDK.LoadScene();189}190}191192#if GAME_INCLUDE_EDITOR193void TryAgainE_EditorDraw(void) {}194195void TryAgainE_EditorLoad(void) {}196#endif197198void TryAgainE_Serialize(void) {}199#endif200201202