Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/AIZ/AIZEncoreTutorial.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: AIZEncoreTutorial 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
ObjectAIZEncoreTutorial *AIZEncoreTutorial;
12
13
void AIZEncoreTutorial_Update(void)
14
{
15
RSDK_THIS(AIZEncoreTutorial);
16
RSDK.ProcessAnimation(&self->bubbleAnimator);
17
StateMachine_Run(self->state);
18
}
19
20
void AIZEncoreTutorial_LateUpdate(void) {}
21
22
void AIZEncoreTutorial_StaticUpdate(void) {}
23
24
void AIZEncoreTutorial_Draw(void)
25
{
26
RSDK_THIS(AIZEncoreTutorial);
27
Vector2 drawPos;
28
29
self->inkEffect = INK_NONE;
30
RSDK.DrawSprite(&self->bubbleAnimator, NULL, false);
31
32
self->inkEffect = INK_ALPHA;
33
drawPos.x = (RSDK.Cos256(self->angle) << 12) + self->position.x;
34
drawPos.y = ((RSDK.Sin256(self->angle) + 512) << 11) + self->position.y;
35
RSDK.DrawSprite(&self->playerAnimator, &drawPos, false);
36
37
drawPos.x = (RSDK.Cos256(self->angle + 128) << 12) + self->position.x;
38
drawPos.y = ((RSDK.Sin256(self->angle + 128) + 512) << 11) + self->position.y;
39
RSDK.DrawSprite(&self->buddyAnimator, &drawPos, false);
40
41
drawPos.x = self->position.x;
42
drawPos.y = self->position.y - 0x100000;
43
RSDK.DrawSprite(&self->buttonPressAnimator, &drawPos, false);
44
45
switch (self->buttonPressAnimator.frameID) {
46
default: break;
47
48
case 0:
49
case 2: drawPos.y -= 0x30000; break;
50
}
51
52
RSDK.DrawSprite(&self->buttonAnimator, &drawPos, false);
53
}
54
55
void AIZEncoreTutorial_Create(void *data)
56
{
57
RSDK_THIS(AIZEncoreTutorial);
58
if (!SceneInfo->inEditor) {
59
self->visible = true;
60
self->drawGroup = Zone->objectDrawGroup[1];
61
self->active = ACTIVE_BOUNDS;
62
self->updateRange.x = 0x800000;
63
self->updateRange.y = 0x800000;
64
self->state = AIZEncoreTutorial_State_ShowTutBubble;
65
66
RSDK.SetSpriteAnimation(AIZEncoreTutorial->cutsceneFrames, 7, &self->bubbleAnimator, true, 0);
67
RSDK.SetSpriteAnimation(AIZEncoreTutorial->cutsceneFrames, 4, &self->playerAnimator, true, 0);
68
RSDK.SetSpriteAnimation(AIZEncoreTutorial->cutsceneFrames, VOID_TO_INT(data), &self->buddyAnimator, true, 0);
69
RSDK.SetSpriteAnimation(AIZEncoreTutorial->cutsceneFrames, 8, &self->buttonPressAnimator, true, 0);
70
}
71
}
72
73
void AIZEncoreTutorial_StageLoad(void)
74
{
75
AIZEncoreTutorial->cutsceneFrames = RSDK.LoadSpriteAnimation("AIZ/Cutscene.bin", SCOPE_STAGE);
76
AIZEncoreTutorial->dustFrames = RSDK.LoadSpriteAnimation("Global/Dust.bin", SCOPE_STAGE);
77
}
78
79
void AIZEncoreTutorial_State_ShowTutBubble(void)
80
{
81
RSDK_THIS(AIZEncoreTutorial);
82
if (self->bubbleAnimator.frameID == 6) {
83
HUD_GetButtonFrame(&self->buttonAnimator, KEY_Y);
84
self->state = AIZEncoreTutorial_State_EnterTutorial;
85
}
86
}
87
88
void AIZEncoreTutorial_State_EnterTutorial(void)
89
{
90
RSDK_THIS(AIZEncoreTutorial);
91
if (self->alpha >= 0x100) {
92
self->state = AIZEncoreTutorial_State_ShowSwapTutorial;
93
}
94
else {
95
self->alpha += 8;
96
}
97
}
98
99
void AIZEncoreTutorial_State_ShowSwapTutorial(void)
100
{
101
RSDK_THIS(AIZEncoreTutorial);
102
RSDK.ProcessAnimation(&self->buttonPressAnimator);
103
HUD_GetButtonFrame(&self->buttonAnimator, KEY_Y);
104
105
if (self->timer >= 60) {
106
self->angle += 4;
107
if (self->angle == 0x80 || self->angle == 0x100) {
108
self->timer = 0;
109
if (++self->swapCount == 3)
110
self->state = AIZEncoreTutorial_State_ExitTutorial;
111
}
112
self->angle &= 0xFF;
113
}
114
else {
115
self->timer++;
116
}
117
}
118
119
void AIZEncoreTutorial_State_ExitTutorial(void)
120
{
121
RSDK_THIS(AIZEncoreTutorial);
122
if (self->alpha <= 0) {
123
for (int32 i = 0; i < 8; ++i) {
124
EntityDebris *debris =
125
CREATE_ENTITY(Debris, NULL, self->position.x + RSDK.Rand(-0x180000, 0x180000), self->position.y + RSDK.Rand(-0x100000, 0x100000));
126
debris->state = Debris_State_Move;
127
debris->velocity.x = RSDK.Rand(-0x20000, 0x20000);
128
debris->velocity.y = RSDK.Rand(-0x20000, 0x20000);
129
debris->drawFX = FX_FLIP | FX_SCALE;
130
debris->direction = i & 3;
131
debris->scale.x = RSDK.Rand(0x200, 0x400);
132
debris->scale.y = debris->scale.x;
133
debris->drawGroup = Zone->objectDrawGroup[1];
134
RSDK.SetSpriteAnimation(AIZEncoreTutorial->dustFrames, 0, &debris->animator, true, RSDK.Rand(0, 4));
135
}
136
destroyEntity(self);
137
}
138
else {
139
self->alpha -= 8;
140
}
141
}
142
143
void AIZEncoreTutorial_State_ReturnToCutscene(void)
144
{
145
EntityCutsceneSeq *cutsceneSeq = RSDK_GET_ENTITY(SLOT_CUTSCENESEQ, CutsceneSeq);
146
EntityFXRuby *fxRuby = CREATE_ENTITY(FXRuby, NULL, 0, 0);
147
fxRuby->drawGroup = Zone->playerDrawGroup[1] + 1;
148
EncoreIntro->fxRuby = fxRuby;
149
PhantomRuby_PlaySfx(RUBYSFX_ATTACK4);
150
Music_FadeOut(0.012);
151
152
cutsceneSeq->skipType = SKIPTYPE_DISABLED;
153
for (int32 i = 0; i < 64; ++i) {
154
if (cutsceneSeq->cutsceneStates[i] == EncoreIntro_Cutscene_SkipAndFadeOut)
155
CutsceneSeq_NewState(i, cutsceneSeq);
156
}
157
}
158
159
#if GAME_INCLUDE_EDITOR
160
void AIZEncoreTutorial_EditorDraw(void) {}
161
162
void AIZEncoreTutorial_EditorLoad(void) {}
163
#endif
164
165
void AIZEncoreTutorial_Serialize(void) {}
166
#endif
167
168