Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/OOZ/OOZ1Outro.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: OOZ1Outro Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectOOZ1Outro *OOZ1Outro;
11
12
void OOZ1Outro_Update(void)
13
{
14
RSDK_THIS(OOZ1Outro);
15
16
if (isMainGameMode() && globals->enableIntro && !CutsceneRules_CheckStageReload()) {
17
self->activated = true;
18
CutsceneSeq_StartSequence(self, OOZ1Outro_Cutscene_FadeIn, OOZ1Outro_Cutscene_PostActClearSetup, OOZ1Outro_Cutscene_FallIntoAct2,
19
OOZ1Outro_Cutscene_BeginAct, StateMachine_None);
20
21
#if MANIA_USE_PLUS
22
CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);
23
#endif
24
}
25
26
self->active = ACTIVE_NEVER;
27
}
28
29
void OOZ1Outro_LateUpdate(void) {}
30
31
void OOZ1Outro_StaticUpdate(void) {}
32
33
void OOZ1Outro_Draw(void) {}
34
35
void OOZ1Outro_Create(void *data)
36
{
37
RSDK_THIS(OOZ1Outro);
38
39
if (!SceneInfo->inEditor) {
40
self->active = ACTIVE_NORMAL;
41
self->visible = false;
42
int32 rangeX = self->updateRange.x + self->size.x;
43
int32 rangeY = self->updateRange.y + self->size.y;
44
45
CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);
46
47
// This one's slightly weird, it doesn't set updateRange the same way for some reason, so lets keep that behaviour
48
self->updateRange.x = rangeX;
49
self->updateRange.y = rangeY;
50
}
51
}
52
53
void OOZ1Outro_StageLoad(void) { OOZ1Outro->sfxDrop = RSDK.GetSfx("Stage/Drop.wav"); }
54
55
bool32 OOZ1Outro_Cutscene_FadeIn(EntityCutsceneSeq *host)
56
{
57
RSDK_THIS(OOZ1Outro);
58
59
if (host->timer) {
60
if (host->fadeWhite > 0)
61
host->fadeWhite -= 4;
62
}
63
else {
64
host->fadeWhite = 512;
65
}
66
67
if (host->timer == 1) {
68
foreach_all(Player, player)
69
{
70
player->position.x = self->position.x;
71
player->position.y = self->position.y;
72
player->position.y += (self->size.y >> 1) - 0x400000;
73
}
74
75
self->boundsR = Zone->cameraBoundsR[0];
76
self->boundsT = Zone->cameraBoundsT[0];
77
self->boundsB = Zone->cameraBoundsB[0];
78
Zone->cameraBoundsL[0] = (self->position.x >> 16) - ScreenInfo->center.x;
79
Zone->cameraBoundsR[0] = (self->position.x >> 16) + ScreenInfo->center.x;
80
Zone->cameraBoundsT[0] = (self->position.y >> 16) - ScreenInfo->center.y;
81
Zone->cameraBoundsB[0] = (self->position.y >> 16) + ScreenInfo->center.y;
82
EntityCamera *camera = RSDK_GET_ENTITY(SLOT_CAMERA1, Camera);
83
camera->boundsL = Zone->cameraBoundsL[0];
84
camera->boundsR = Zone->cameraBoundsR[0];
85
camera->boundsT = Zone->cameraBoundsT[0];
86
camera->boundsB = Zone->cameraBoundsB[0];
87
Smog->forceEnabled = true;
88
}
89
90
if (host->timer == 30) {
91
ActClear->displayedActID = 1;
92
93
foreach_active(SignPost, signpost)
94
{
95
signpost->state = SignPost_State_Falling;
96
signpost->active = ACTIVE_NORMAL;
97
}
98
99
RSDK.PlaySfx(SignPost->sfxTwinkle, false, 0xFF);
100
return true;
101
}
102
return false;
103
}
104
105
bool32 OOZ1Outro_Cutscene_PostActClearSetup(EntityCutsceneSeq *host)
106
{
107
RSDK_THIS(OOZ1Outro);
108
109
if (host->fadeWhite > 0)
110
host->fadeWhite -= 4;
111
112
CutsceneSeq_LockAllPlayerControl();
113
114
if (ActClear->finished) {
115
foreach_active(Player, player)
116
{
117
player->state = Player_State_Air;
118
player->onGround = false;
119
player->collisionPlane = 1;
120
player->interaction = false;
121
player->velocity.y = -0x20000;
122
player->stateInput = StateMachine_None;
123
RSDK.SetSpriteAnimation(player->aniFrames, ANI_HURT, &player->animator, false, 0);
124
}
125
126
Zone->cameraBoundsL[0] = self->boundsL;
127
Zone->cameraBoundsR[0] = self->boundsR;
128
Zone->cameraBoundsT[0] = self->boundsT;
129
Zone->cameraBoundsB[0] = self->boundsB;
130
131
#if MANIA_USE_PLUS
132
CutsceneSeq_SetSkipType(SKIPTYPE_RELOADSCN);
133
#endif
134
return true;
135
}
136
137
return false;
138
}
139
140
bool32 OOZ1Outro_Cutscene_FallIntoAct2(EntityCutsceneSeq *host)
141
{
142
EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);
143
EntityPlayer *player2 = RSDK_GET_ENTITY(SLOT_PLAYER2, Player);
144
145
if (host->timer == 48) {
146
player1->interaction = true;
147
if (player2->classID == Player->classID)
148
player2->interaction = true;
149
}
150
151
if (Smog->forceEnabled && player1->animator.animationID)
152
return false;
153
154
player1->direction = FLIP_NONE;
155
player1->stateInput = Player_Input_P1;
156
157
if (player2->classID == Player->classID)
158
player2->stateInput = Player_Input_P2_AI;
159
160
return true;
161
}
162
163
bool32 OOZ1Outro_Cutscene_BeginAct(EntityCutsceneSeq *host)
164
{
165
if (host->timer == 120) {
166
globals->suppressTitlecard = true;
167
168
foreach_all(TitleCard, titlecard)
169
{
170
titlecard->active = ACTIVE_NORMAL;
171
titlecard->state = TitleCard_State_SetupBGElements;
172
titlecard->stateDraw = TitleCard_Draw_SlideIn;
173
foreach_break;
174
}
175
176
Music_PlayTrack(TRACK_STAGE);
177
return true;
178
}
179
180
return false;
181
}
182
183
#if GAME_INCLUDE_EDITOR
184
void OOZ1Outro_EditorDraw(void)
185
{
186
RSDK_THIS(OOZ1Outro);
187
188
CutsceneRules_DrawCutsceneBounds(self, &self->size);
189
}
190
191
void OOZ1Outro_EditorLoad(void) {}
192
#endif
193
194
void OOZ1Outro_Serialize(void) { RSDK_EDITABLE_VAR(OOZ1Outro, VAR_VECTOR2, size); }
195
196