Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Credits/TryAgainE.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: TryAgainE Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
#if MANIA_USE_PLUS
11
ObjectTryAgainE *TryAgainE;
12
13
void TryAgainE_Update(void)
14
{
15
RSDK_THIS(TryAgainE);
16
17
StateMachine_Run(self->state);
18
}
19
20
void TryAgainE_LateUpdate(void) {}
21
22
void TryAgainE_StaticUpdate(void)
23
{
24
foreach_active(TryAgainE, tryAgainE) { RSDK.AddDrawListRef(2, RSDK.GetEntitySlot(tryAgainE)); }
25
}
26
27
void TryAgainE_Draw(void)
28
{
29
RSDK_THIS(TryAgainE);
30
31
if (SceneInfo->currentDrawGroup == self->drawGroup) {
32
Vector2 drawPos;
33
34
RSDK.SetActivePalette(3, 0, ScreenInfo->size.y);
35
self->mainAnimator.frameID = 0;
36
RSDK.DrawSprite(&self->mainAnimator, NULL, false);
37
38
self->mainAnimator.frameID = 1;
39
RSDK.DrawSprite(&self->mainAnimator, NULL, false);
40
RSDK.SetActivePalette(0, 0, ScreenInfo->size.y);
41
42
drawPos.x = self->position.x;
43
drawPos.y = self->position.y + 0x2E0000;
44
45
if (GET_CHARACTER_ID(2) != ID_NONE)
46
drawPos.x = self->position.x - 0x140000;
47
48
if (self->player1Animator.animationID == 2)
49
drawPos.y = self->position.y + 0x2E0000 + 0x40000;
50
51
RSDK.DrawSprite(&self->player1Animator, &drawPos, false);
52
53
int32 drawY = drawPos.y;
54
if (self->player1Animator.animationID == 2) {
55
drawY = drawPos.y - 0x40000;
56
drawPos.y -= 0x40000;
57
}
58
59
if (GET_CHARACTER_ID(2) != ID_NONE) {
60
drawPos.x += 0x280000;
61
self->direction = FLIP_X;
62
63
if (self->player2Animator.animationID == 2)
64
drawPos.y = drawY + 0x40000;
65
66
RSDK.DrawSprite(&self->player2Animator, &drawPos, false);
67
self->direction = FLIP_NONE;
68
}
69
}
70
else {
71
self->direction = FLIP_X;
72
RSDK.DrawSprite(&self->handUpAnimator, NULL, false);
73
74
self->direction = FLIP_NONE;
75
RSDK.DrawSprite(&self->handDownAnimator, NULL, false);
76
}
77
}
78
79
void TryAgainE_Create(void *data)
80
{
81
RSDK_THIS(TryAgainE);
82
83
if (!SceneInfo->inEditor) {
84
self->visible = true;
85
self->drawGroup = 1;
86
self->active = ACTIVE_BOUNDS;
87
self->updateRange.x = 0x800000;
88
self->updateRange.y = 0x800000;
89
self->drawFX = FX_FLIP;
90
91
self->state = TryAgainE_State_Stinger;
92
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 0, &self->mainAnimator, true, 0);
93
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handUpAnimator, true, 4);
94
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handDownAnimator, true, 3);
95
96
RSDK.SetSpriteAnimation(TryAgainE->playerFrames, 2 * HUD_CharacterIndexFromID(GET_CHARACTER_ID(1)), &self->player1Animator, true, 3);
97
98
if (GET_CHARACTER_ID(2) != ID_NONE)
99
RSDK.SetSpriteAnimation(TryAgainE->playerFrames, 2 * HUD_CharacterIndexFromID(GET_CHARACTER_ID(2)), &self->player2Animator, true, 3);
100
}
101
}
102
103
void TryAgainE_StageLoad(void)
104
{
105
TryAgainE->aniFrames = RSDK.LoadSpriteAnimation("Credits/TryAgainE.bin", SCOPE_STAGE);
106
TryAgainE->playerFrames = RSDK.LoadSpriteAnimation("Players/Continue.bin", SCOPE_STAGE);
107
108
TryAgainE->active = ACTIVE_ALWAYS;
109
RSDK.CopyPalette(0, 0, 1, 0, 128);
110
}
111
112
void TryAgainE_SetupEmeralds(void)
113
{
114
int32 timer = 0;
115
116
int32 id = 0;
117
foreach_all(TAEmerald, emerald)
118
{
119
emerald->state = TAEmerald_State_MoveCircle;
120
emerald->timer = timer;
121
122
if (SaveGame_GetSaveRAM() && !SaveGame_GetEmerald(id))
123
timer += 8;
124
id++;
125
}
126
}
127
128
void TryAgainE_State_Stinger(void)
129
{
130
RSDK_THIS(TryAgainE);
131
132
RSDK.ProcessAnimation(&self->handUpAnimator);
133
RSDK.ProcessAnimation(&self->handDownAnimator);
134
RSDK.ProcessAnimation(&self->player1Animator);
135
136
if (GET_CHARACTER_ID(2) != ID_NONE)
137
RSDK.ProcessAnimation(&self->player2Animator);
138
139
if ((self->timer & 0x7F) == 1) {
140
if ((self->timer & 0x80) && self->handUpAnimator.animationID == 2)
141
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handUpAnimator, true, 0);
142
143
if ((int8)(self->timer & 0xFF) >= 0 && self->handDownAnimator.animationID == 2)
144
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 1, &self->handDownAnimator, true, 0);
145
146
TryAgainE_SetupEmeralds();
147
}
148
else if ((self->timer & 0x7F) == 59) {
149
if ((self->timer & 0x80) == 0 && self->handUpAnimator.animationID == 1)
150
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handUpAnimator, true, 0);
151
152
if ((int8)(self->timer & 0xFF) < 0 && self->handDownAnimator.animationID == 1)
153
RSDK.SetSpriteAnimation(TryAgainE->aniFrames, 2, &self->handDownAnimator, true, 0);
154
}
155
156
if (++self->timer == 1) {
157
foreach_all(TAEmerald, emerald)
158
{
159
emerald->originPos.x = self->position.x;
160
emerald->originPos.y = self->position.y + 0x100000;
161
162
emerald->position.x = emerald->originPos.x + 0x480000;
163
emerald->position.y = emerald->originPos.y;
164
165
emerald->angle = 0;
166
emerald->drawFX = FX_ROTATE;
167
emerald->state = StateMachine_None;
168
}
169
}
170
171
if (ControllerInfo->keyA.press || ControllerInfo->keyStart.press)
172
self->timer = 600;
173
174
if (self->timer == 600) {
175
PhantomRuby_PlaySfx(RUBYSFX_ATTACK4);
176
177
EntityFXFade *fxFade = CREATE_ENTITY(FXFade, INT_TO_VOID(0xFFFFFF), self->position.x, self->position.y);
178
fxFade->speedIn = 24;
179
fxFade->speedOut = 24;
180
fxFade->fadeOutBlack = true;
181
}
182
183
if (self->timer >= 740) {
184
if (API.CheckDLC(DLC_PLUS))
185
RSDK.SetScene("Presentation", "Encore Summary");
186
else
187
RSDK.SetScene("Presentation", "Menu");
188
189
RSDK.LoadScene();
190
}
191
}
192
193
#if GAME_INCLUDE_EDITOR
194
void TryAgainE_EditorDraw(void) {}
195
196
void TryAgainE_EditorLoad(void) {}
197
#endif
198
199
void TryAgainE_Serialize(void) {}
200
#endif
201
202