Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/LRZ/LRZ3Outro.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: LRZ3Outro 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
ObjectLRZ3Outro *LRZ3Outro;
12
13
void LRZ3Outro_Update(void)
14
{
15
RSDK_THIS(LRZ3Outro);
16
17
StateMachine_Run(self->state);
18
}
19
20
void LRZ3Outro_LateUpdate(void) {}
21
22
void LRZ3Outro_StaticUpdate(void) {}
23
24
void LRZ3Outro_Draw(void) {}
25
26
void LRZ3Outro_Create(void *data)
27
{
28
RSDK_THIS(LRZ3Outro);
29
30
if (!SceneInfo->inEditor) {
31
self->active = ACTIVE_NORMAL;
32
self->isPermanent = true;
33
34
self->background1 = RSDK.GetTileLayer(1);
35
self->background2 = RSDK.GetTileLayer(2);
36
37
foreach_active(ParallaxSprite, sprite) { self->littlePlanet = sprite; }
38
39
self->state = LRZ3Outro_State_BlastOff;
40
}
41
}
42
43
void LRZ3Outro_StageLoad(void)
44
{
45
LRZ3Outro->sfxBlastoff = RSDK.GetSfx("LRZ/Blastoff.wav");
46
LRZ3Outro->sfxLittlePlanet = RSDK.GetSfx("LRZ/LittlePlanet.wav");
47
}
48
49
void LRZ3Outro_HandleExplosions(void)
50
{
51
RSDK_THIS(LRZ3Outro);
52
53
int32 x = (RSDK.Rand(-ScreenInfo->center.x, ScreenInfo->center.x) + ScreenInfo->center.x + ScreenInfo->position.x);
54
int32 y = ScreenInfo->position.y + 32 + ScreenInfo->size.y;
55
EntityExplosion *explosion = CREATE_ENTITY(Explosion, INT_TO_VOID(EXPLOSION_ENEMY), x << 16, y << 16);
56
57
explosion->velocity.x = RSDK.Rand(-0x20000, 0x20000);
58
explosion->velocity.y = self->velocity.y - 0x40000;
59
explosion->drawGroup = Zone->objectDrawGroup[1];
60
explosion->drawFX = FX_SCALE;
61
explosion->inkEffect = INK_BLEND;
62
explosion->scale.x = RSDK.Rand(0x200, 0x400);
63
explosion->scale.y = explosion->scale.x;
64
}
65
66
void LRZ3Outro_State_BlastOff(void)
67
{
68
RSDK_THIS(LRZ3Outro);
69
70
++self->timer;
71
if (!(self->timer & 7))
72
Camera_ShakeScreen(0, 3, 2);
73
74
if (self->timer == 1) {
75
self->blastoffChannel = RSDK.PlaySfx(LRZ3Outro->sfxBlastoff, 56628, 0xFF);
76
self->blastoffVolume = 1.0;
77
}
78
79
if (self->timer == 60) {
80
self->timer = 0;
81
self->state = LRZ3Outro_State_RocketLaunch;
82
83
RSDK.GetTileLayer(0)->drawGroup[0] = DRAWGROUP_COUNT;
84
RSDK.GetTileLayer(1)->drawGroup[0] = 0;
85
}
86
}
87
88
void LRZ3Outro_State_RocketLaunch(void)
89
{
90
RSDK_THIS(LRZ3Outro);
91
92
++self->timer;
93
if (!(self->timer & 1))
94
LRZ3Outro_HandleExplosions();
95
96
if (self->timer == 30) {
97
Zone->playerBoundActiveB[0] = true;
98
Zone->cameraBoundsB[0] = (self->position.y >> 16) + 64;
99
}
100
101
if (self->timer <= 120) {
102
if (!(self->timer & 7))
103
Camera_ShakeScreen(0, RSDK.Rand(-6, 6), 4);
104
}
105
else {
106
if (self->velocity.y < 0x60000)
107
self->velocity.y += 0x800;
108
109
if (!(self->timer & 7))
110
Camera_ShakeScreen(0, 0, 4);
111
}
112
113
if (self->timer > 390) {
114
self->blastoffVolume -= 0.0125;
115
RSDK.SetChannelAttributes(self->blastoffChannel, self->blastoffVolume, 0.0, 1.0);
116
}
117
118
if (self->timer > 480) {
119
self->timer = 0;
120
self->state = LRZ3Outro_State_EnterLittlePlanet;
121
RSDK.StopChannel(self->blastoffChannel);
122
}
123
124
TileLayer *background1 = self->background1;
125
if (background1->scrollPos <= -0xE00000) {
126
background1->scrollSpeed >>= 1;
127
}
128
else {
129
if (background1->scrollSpeed > -0x2000)
130
background1->scrollSpeed -= 0x80;
131
}
132
133
TileLayer *background2 = self->background2;
134
if (background2->scrollPos <= -0xE00000) {
135
background2->scrollSpeed >>= 1;
136
}
137
else {
138
if (background2->scrollSpeed > -0x10000)
139
background2->scrollSpeed -= 0x80;
140
}
141
142
if (self->littlePlanet->scrollSpeed.y > -0x1000)
143
self->littlePlanet->scrollSpeed.y -= 0x80;
144
}
145
146
void LRZ3Outro_State_EnterLittlePlanet(void)
147
{
148
RSDK_THIS(LRZ3Outro);
149
150
if (self->background2->scrollSpeed < 0)
151
self->background2->scrollSpeed += 0x80;
152
153
EntityParallaxSprite *littlePlanet = self->littlePlanet;
154
if (littlePlanet->scrollSpeed.y > -0x1000) {
155
littlePlanet->scrollSpeed.y -= 0x80;
156
}
157
158
if (littlePlanet->scrollPos.y < -0x1000000) {
159
littlePlanet->scrollSpeed.y = 0;
160
self->state = StateMachine_None;
161
}
162
}
163
164
void LRZ3Outro_StageFinish_EndAct2ST(void)
165
{
166
EntityLRZ3Outro *cutscene = NULL;
167
foreach_all(LRZ3Outro, outro)
168
{
169
cutscene = outro;
170
foreach_break;
171
}
172
173
if (cutscene) {
174
CutsceneSeq_StartSequence(cutscene, LRZ3Outro_Cutscene_StopPlayers, LRZ3Outro_Cutscene_LightUpLittlePlanet, StateMachine_None);
175
176
#if MANIA_USE_PLUS
177
CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);
178
#endif
179
180
HUD_MoveOut();
181
cutscene->active = ACTIVE_NEVER;
182
}
183
}
184
185
bool32 LRZ3Outro_Cutscene_StopPlayers(EntityCutsceneSeq *host)
186
{
187
foreach_active(Player, player) {
188
player->state = Player_State_Static;
189
player->stateInput = StateMachine_None;
190
}
191
192
return true;
193
}
194
195
bool32 LRZ3Outro_Cutscene_LightUpLittlePlanet(EntityCutsceneSeq *host)
196
{
197
if (host->timer > 60) {
198
int32 frame = 23 - MIN((host->timer - 60) >> 2, 6);
199
foreach_active(Player, player) { RSDK.SetSpriteAnimation(player->aniFrames, ANI_TWISTER, &player->animator, true, frame); }
200
}
201
202
if (host->timer > 120)
203
RSDK.SetLimitedFade(0, 1, 2, 4 * host->timer - 480, 245, 250);
204
205
if (host->timer == 180)
206
RSDK.PlaySfx(LRZ3Outro->sfxLittlePlanet, false, 255);
207
208
if (host->timer > 180)
209
RSDK.SetLimitedFade(0, 1, 2, 4 * host->timer - 720, 240, 244);
210
211
if (host->timer == 320) {
212
Zone_StartFadeOut(10, 0x000000);
213
return true;
214
}
215
216
return false;
217
}
218
219
#if GAME_INCLUDE_EDITOR
220
void LRZ3Outro_EditorDraw(void) {}
221
222
void LRZ3Outro_EditorLoad(void) {}
223
#endif
224
225
void LRZ3Outro_Serialize(void) {}
226
#endif
227
228