Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/SPZ/SPZ1Intro.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: SPZ1Intro Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectSPZ1Intro *SPZ1Intro;
11
12
void SPZ1Intro_Update(void)
13
{
14
RSDK_THIS(SPZ1Intro);
15
16
if (!self->activated) {
17
if (!isMainGameMode() || !globals->enableIntro || CutsceneRules_CheckStageReload()) {
18
self->active = ACTIVE_NEVER;
19
}
20
else {
21
self->activated = true;
22
CutsceneSeq_StartSequence(self, SPZ1Intro_Cutscene_SetupAct, SPZ1Intro_Cutscene_ExitPipe, SPZ1Intro_Cutscene_BeginAct1, StateMachine_None);
23
24
#if MANIA_USE_PLUS
25
CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);
26
#endif
27
}
28
}
29
}
30
31
void SPZ1Intro_LateUpdate(void) {}
32
33
void SPZ1Intro_StaticUpdate(void) {}
34
35
void SPZ1Intro_Draw(void) {}
36
37
void SPZ1Intro_Create(void *data)
38
{
39
RSDK_THIS(SPZ1Intro);
40
41
INIT_ENTITY(self);
42
CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);
43
self->active = ACTIVE_NORMAL;
44
}
45
46
void SPZ1Intro_StageLoad(void)
47
{
48
SPZ1Intro->sfxGasPop = RSDK.GetSfx("OOZ/GasPop.wav");
49
SPZ1Intro->sfxPon = RSDK.GetSfx("Stage/Pon.wav");
50
51
SPZ1Intro->aniFrames = RSDK.LoadSpriteAnimation("SPZ1/ManholeCover.bin", SCOPE_STAGE);
52
}
53
54
bool32 SPZ1Intro_Cutscene_SetupAct(EntityCutsceneSeq *host)
55
{
56
RSDK_THIS(SPZ1Intro);
57
MANIA_GET_PLAYER(player1, player2, camera);
58
59
Entity *curEnt = host->activeEntity;
60
if (!host->timer) {
61
player1->position.x = self->position.x;
62
camera->position.x = self->position.x;
63
player1->position.y += 0x250000;
64
player1->camera = StateMachine_None;
65
player1->tileCollisions = TILECOLLISION_NONE;
66
player1->onGround = false;
67
player1->state = Player_State_Static;
68
player1->stateInput = StateMachine_None;
69
CutsceneSeq_LockAllPlayerControl();
70
RSDK.SetSpriteAnimation(player1->aniFrames, ANI_JUMP, &player1->animator, false, 0);
71
72
if (player2->classID == Player->classID) {
73
player2->position.x = player1->position.x;
74
player2->position.y = player1->position.y;
75
player2->tileCollisions = TILECOLLISION_NONE;
76
player2->onGround = false;
77
player2->velocity.y = -1;
78
player2->state = Player_State_Static;
79
player2->stateInput = StateMachine_None;
80
RSDK.SetSpriteAnimation(player2->aniFrames, ANI_JUMP, &player2->animator, false, 0);
81
}
82
83
EntityDebris *lid = CREATE_ENTITY(Debris, NULL, curEnt->position.x, curEnt->position.y + 0x390000);
84
lid->drawGroup = Zone->playerDrawGroup[1];
85
lid->state = StateMachine_None;
86
lid->drawFX = FX_SCALE | FX_ROTATE;
87
lid->scale.x = 0x200;
88
lid->scale.y = 0x200;
89
lid->updateRange.x = 0x800000;
90
lid->updateRange.y = 0x800000;
91
RSDK.SetSpriteAnimation(SPZ1Intro->aniFrames, 0, &lid->animator, true, 0);
92
SPZ1Intro->sewerLid = lid;
93
}
94
95
if (!RSDK.GetEntityCount(TitleCard->classID, false) && !RSDK_GET_ENTITY(SLOT_PAUSEMENU, PauseMenu)->classID && !host->values[0]) {
96
host->values[0] = true;
97
host->storedTimer = host->timer;
98
}
99
100
if (host->values[0]) {
101
if (host->timer == 45)
102
RSDK.PlaySfx(Player->sfxRoll, false, 0xFF);
103
104
if (host->timer == 90)
105
return true;
106
}
107
108
SceneInfo->timeEnabled = false;
109
SceneInfo->milliseconds = 0;
110
camera->state = StateMachine_None;
111
112
return false;
113
}
114
115
bool32 SPZ1Intro_Cutscene_ExitPipe(EntityCutsceneSeq *host)
116
{
117
MANIA_GET_PLAYER(player1, player2, camera);
118
UNUSED(camera);
119
120
if (!host->timer) {
121
player1->velocity.x = 0;
122
player1->velocity.y = -0x80000;
123
player1->state = Player_State_Air;
124
player1->nextAirState = StateMachine_None;
125
player1->nextGroundState = StateMachine_None;
126
RSDK.PlaySfx(SPZ1Intro->sfxGasPop, false, 0xFF);
127
RSDK.PlaySfx(SPZ1Intro->sfxPon, false, 0xFF);
128
RSDK.StopSfx(Player->sfxRoll);
129
Camera_ShakeScreen(0, 0, 2);
130
EntityDebris *lid = SPZ1Intro->sewerLid;
131
lid->state = Debris_State_Fall;
132
lid->velocity.y = -0x60000;
133
lid->velocity.x = -0x18000;
134
lid->gravityStrength = 0x3800;
135
lid->scaleSpeed.x = 8;
136
lid->scaleSpeed.y = 8;
137
lid->rotSpeed = -1;
138
RSDK.SetSpriteAnimation(SPZ1Intro->aniFrames, 1, &lid->animator, true, 0);
139
}
140
141
if (player1->velocity.y > 0)
142
player1->tileCollisions = TILECOLLISION_DOWN;
143
144
if (player2->classID == Player->classID) {
145
if (host->timer == 10) {
146
player2->velocity.x = 0;
147
player2->velocity.y = -0x80000;
148
player2->state = Player_State_Air;
149
player2->nextAirState = StateMachine_None;
150
player2->nextGroundState = StateMachine_None;
151
}
152
153
if (player2->velocity.y > 0)
154
player2->tileCollisions = TILECOLLISION_DOWN;
155
156
if (player1->onGround && player2->onGround)
157
return true;
158
}
159
else if (player1->onGround) {
160
return true;
161
}
162
163
return false;
164
}
165
166
bool32 SPZ1Intro_Cutscene_BeginAct1(EntityCutsceneSeq *host)
167
{
168
MANIA_GET_PLAYER(player1, player2, camera);
169
170
if (!host->timer) {
171
camera->target = (Entity *)player1;
172
camera->state = Camera_State_FollowXY;
173
player1->stateInput = Player_Input_P1;
174
player1->state = Player_State_Ground;
175
player1->camera = camera;
176
177
if (player2->classID == Player->classID)
178
player2->stateInput = Player_Input_P2_AI;
179
180
SceneInfo->timeEnabled = true;
181
return true;
182
}
183
184
return false;
185
}
186
187
#if GAME_INCLUDE_EDITOR
188
void SPZ1Intro_EditorDraw(void)
189
{
190
RSDK_THIS(SPZ1Intro);
191
192
if (showGizmos())
193
CutsceneRules_DrawCutsceneBounds(self, &self->size);
194
}
195
196
void SPZ1Intro_EditorLoad(void) {}
197
#endif
198
199
void SPZ1Intro_Serialize(void) { RSDK_EDITABLE_VAR(SPZ1Intro, VAR_VECTOR2, size); }
200
201