Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/HCZ/HCZ1Intro.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: HCZ1Intro Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectHCZ1Intro *HCZ1Intro;
11
12
void HCZ1Intro_Update(void)
13
{
14
RSDK_THIS(HCZ1Intro);
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, HCZ1Intro_Cutscene_Intro, StateMachine_None);
23
24
#if MANIA_USE_PLUS
25
CutsceneSeq_SetSkipType(SKIPTYPE_DISABLED);
26
#endif
27
}
28
}
29
}
30
31
void HCZ1Intro_LateUpdate(void) {}
32
33
void HCZ1Intro_StaticUpdate(void) {}
34
35
void HCZ1Intro_Draw(void) {}
36
37
void HCZ1Intro_Create(void *data)
38
{
39
RSDK_THIS(HCZ1Intro);
40
41
INIT_ENTITY(self);
42
CutsceneRules_SetupEntity(self, &self->size, &self->hitbox);
43
self->active = ACTIVE_NORMAL;
44
}
45
46
void HCZ1Intro_StageLoad(void)
47
{
48
if (isMainGameMode() && globals->enableIntro && !CutsceneRules_CheckStageReload() && !Zone->actID) {
49
Water->disableWaterSplash = true;
50
}
51
}
52
53
bool32 HCZ1Intro_Cutscene_Intro(EntityCutsceneSeq *host)
54
{
55
RSDK_THIS(HCZ1Intro);
56
57
EntityPlayer *player1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player);
58
EntityPlayer *player2 = RSDK_GET_ENTITY(SLOT_PLAYER2, Player);
59
EntityCamera *camera = RSDK_GET_ENTITY(SLOT_CAMERA1, Camera);
60
61
if (!host->timer) {
62
camera->position.x = self->position.x;
63
camera->position.y = 0;
64
65
player1->position.x = self->position.x - 0x200000;
66
player1->camera = NULL;
67
player1->onGround = false;
68
player1->state = Player_State_Air;
69
player1->stateInput = StateMachine_None;
70
CutsceneSeq_LockAllPlayerControl();
71
72
#if MANIA_USE_PLUS
73
RSDK.SetSpriteAnimation(player1->aniFrames, ANI_FLUME, &player1->animator, false, 0);
74
#else
75
RSDK.SetSpriteAnimation(player1->aniFrames, ANI_HURT, &player1->animator, false, 0);
76
#endif
77
78
if (player2->classID == Player->classID) {
79
player2->position.x = player1->position.x - 0x200000;
80
player2->position.y = player1->position.y;
81
player2->state = Player_State_Air;
82
player2->onGround = false;
83
player2->stateInput = StateMachine_None;
84
85
#if MANIA_USE_PLUS
86
RSDK.SetSpriteAnimation(player2->aniFrames, ANI_FLUME, &player2->animator, false, 0);
87
#else
88
RSDK.SetSpriteAnimation(player1->aniFrames, ANI_HURT, &player1->animator, false, 0);
89
#endif
90
}
91
}
92
93
if (host->timer >= 8) {
94
if (host->timer == 8) {
95
camera->target = (Entity *)player1;
96
camera->state = Camera_State_FollowXY;
97
player1->stateInput = Player_Input_P1;
98
player1->camera = camera;
99
Water->disableWaterSplash = 0;
100
}
101
}
102
else {
103
player1->position.y = 0;
104
player1->velocity.x = 0;
105
player1->velocity.y = 0;
106
107
if (player2->classID == Player->classID) {
108
player2->position.y = 0;
109
player2->velocity.x = 0;
110
player2->velocity.y = 0;
111
}
112
}
113
114
if (RSDK.GetEntityCount(TitleCard->classID, false) || RSDK_GET_ENTITY(SLOT_ACTCLEAR, TitleCard)->classID) {
115
if (!host->values[0])
116
return false;
117
}
118
else if (!host->values[0]) {
119
host->values[0] = true;
120
host->storedTimer = host->timer;
121
}
122
123
if (host->timer >= 8) {
124
if (player2->classID != Player->classID)
125
return true;
126
127
if (player2->underwater) {
128
player2->stateInput = Player_Input_P2_AI;
129
return true;
130
}
131
}
132
133
return false;
134
}
135
136
#if GAME_INCLUDE_EDITOR
137
void HCZ1Intro_EditorDraw(void)
138
{
139
RSDK_THIS(HCZ1Intro);
140
141
CutsceneRules_DrawCutsceneBounds(self, &self->size);
142
}
143
144
void HCZ1Intro_EditorLoad(void) {}
145
#endif
146
147
void HCZ1Intro_Serialize(void) { RSDK_EDITABLE_VAR(HCZ1Intro, VAR_VECTOR2, size); }
148
149