Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/PGZ/PSZ2Intro.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: PSZ2Intro Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectPSZ2Intro *PSZ2Intro;
11
12
void PSZ2Intro_Update(void)
13
{
14
RSDK_THIS(PSZ2Intro);
15
16
self->activated = true;
17
18
CutsceneSeq_StartSequence(self, PSZ2Intro_Cutscene_HandleAct1Finish, PSZ2Intro_Cutscene_ShowActClear, PSZ2Intro_Cutscene_RunToAct2,
19
PSZ2Intro_Cutscene_JogIntoPlace, StateMachine_None);
20
21
#if MANIA_USE_PLUS
22
CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);
23
#endif
24
25
self->active = ACTIVE_NEVER;
26
}
27
28
void PSZ2Intro_LateUpdate(void) {}
29
30
void PSZ2Intro_StaticUpdate(void) {}
31
32
void PSZ2Intro_Draw(void) {}
33
34
void PSZ2Intro_Create(void *data)
35
{
36
RSDK_THIS(PSZ2Intro);
37
38
INIT_ENTITY(self);
39
CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);
40
self->active = ACTIVE_BOUNDS;
41
}
42
43
void PSZ2Intro_StageLoad(void)
44
{
45
PSZ2Intro->sfxExplosion3 = RSDK.GetSfx("Stage/Explosion3.wav");
46
47
foreach_all(FXFade, fxFade)
48
{
49
PSZ2Intro->fxFade = fxFade;
50
foreach_break;
51
}
52
53
if (!isMainGameMode() || !globals->atlEnabled || CutsceneRules_CheckStageReload()) {
54
foreach_all(PSZ2Intro, intro) { destroyEntity(intro); }
55
}
56
}
57
58
bool32 PSZ2Intro_Cutscene_HandleAct1Finish(EntityCutsceneSeq *host)
59
{
60
MANIA_GET_PLAYER(player1, player2, camera);
61
UNUSED(camera);
62
63
EntityFXFade *fxFade = PSZ2Intro->fxFade;
64
EntitySignPost *post = PSZ2Intro->signPost;
65
66
if (!host->timer) {
67
Zone->cameraBoundsR[0] = 1024;
68
Zone->cameraBoundsR[1] = 1024;
69
Zone->playerBoundActiveR[0] = true;
70
Zone->playerBoundActiveR[1] = true;
71
player1->pushing = false;
72
if (player2->classID == Player->classID)
73
player2->pushing = false;
74
}
75
76
if (host->values[0]) {
77
if (host->timer - host->storedTimer == 30) {
78
ActClear->displayedActID = 1;
79
post->state = SignPost_State_Falling;
80
post->active = ACTIVE_NORMAL;
81
RSDK.PlaySfx(SignPost->sfxTwinkle, false, 0xFF);
82
83
return true;
84
}
85
}
86
else if (!fxFade->timer) {
87
host->values[0] = true;
88
host->storedTimer = host->timer;
89
90
foreach_all(SignPost, signPost)
91
{
92
PSZ2Intro->signPost = signPost;
93
foreach_break;
94
}
95
}
96
97
return false;
98
}
99
100
bool32 PSZ2Intro_Cutscene_ShowActClear(EntityCutsceneSeq *host)
101
{
102
if (ActClear->finished) {
103
#if MANIA_USE_PLUS
104
CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);
105
#endif
106
107
return true;
108
}
109
110
return false;
111
}
112
113
bool32 PSZ2Intro_Cutscene_RunToAct2(EntityCutsceneSeq *host)
114
{
115
MANIA_GET_PLAYER(player1, player2, camera);
116
UNUSED(camera);
117
118
if (!host->timer) {
119
Vector2 size;
120
RSDK.GetLayerSize(Zone->fgLayer[0], &size, true);
121
Zone->cameraBoundsR[0] = size.x;
122
Zone->cameraBoundsR[1] = size.x;
123
124
RSDK.SetSpriteAnimation(player1->aniFrames, ANI_IDLE, &player1->animator, true, 0);
125
player1->state = Player_State_Ground;
126
player1->up = false;
127
player1->stateInput = StateMachine_None;
128
129
CutsceneSeq_LockAllPlayerControl();
130
player1->jumpPress = false;
131
player1->jumpHold = false;
132
player1->left = false;
133
player1->down = false;
134
135
if (player2->classID == Player->classID) {
136
// Bug Details:
137
// Player 2's animation should be set here, but it sets it to Player 1's animator instead.
138
// In doing so, if you were to beat Press Garden Act 1 and watch the transition cutscene,
139
// Player 1 will temporarily use the idle sprite of Player 2 for a single frame
140
// before turning back into the character Player 1 is supposed to be.
141
// Pretty odd, huh?
142
// Change &player1->animator to &player2->animator to fix it.
143
RSDK.SetSpriteAnimation(player2->aniFrames, ANI_IDLE, &player1->animator, true, 0);
144
player2->state = Player_State_Ground;
145
player2->up = false;
146
player2->stateInput = Player_Input_P2_AI;
147
}
148
}
149
150
if (player1->jumpPress)
151
player1->jumpPress = false;
152
153
if (abs(player1->pushing) >= 3) {
154
player1->jumpPress = true;
155
player1->jumpHold = true;
156
}
157
158
if (player1->position.x >= 0x3800000) {
159
player1->right = false;
160
Zone->cameraBoundsL[0] = 1024;
161
Zone->cameraBoundsL[1] = 1024;
162
return true;
163
}
164
else {
165
player1->right = true;
166
}
167
168
return false;
169
}
170
171
bool32 PSZ2Intro_Cutscene_JogIntoPlace(EntityCutsceneSeq *host)
172
{
173
MANIA_GET_PLAYER(player1, player2, camera);
174
UNUSED(camera);
175
176
if (ScreenInfo->position.x < Zone->cameraBoundsL[0]) {
177
// Bug Details:
178
// groundVel is set here, but the game doesn't make sure you're facing that direction
179
// meaning you can be moving right but facing left, a simple player->direction = FLIP_NONE would fix this
180
// though it'd be best to place it up where player->right = true; is set
181
if (player1->groundVel < 0x20000)
182
player1->groundVel = 0x20000;
183
184
if (player2->classID == Player->classID) {
185
if (player2->groundVel < 0x20000)
186
player2->groundVel = 0x20000;
187
}
188
}
189
else {
190
player1->stateInput = Player_Input_P1;
191
player1->state = Player_State_Ground;
192
193
foreach_all(TitleCard, titleCard)
194
{
195
titleCard->active = ACTIVE_NORMAL;
196
titleCard->state = TitleCard_State_SetupBGElements;
197
titleCard->stateDraw = TitleCard_Draw_SlideIn;
198
foreach_break;
199
}
200
201
Music_PlayTrack(TRACK_STAGE);
202
return true;
203
}
204
205
return false;
206
}
207
208
#if GAME_INCLUDE_EDITOR
209
void PSZ2Intro_EditorDraw(void)
210
{
211
RSDK_THIS(PSZ2Outro);
212
CutsceneRules_DrawCutsceneBounds(self, &self->size);
213
}
214
215
void PSZ2Intro_EditorLoad(void) {}
216
#endif
217
218
void PSZ2Intro_Serialize(void) { RSDK_EDITABLE_VAR(PSZ2Intro, VAR_VECTOR2, size); }
219
220