Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Menu/ThanksSetup.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: ThanksSetup Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectThanksSetup *ThanksSetup;
11
12
void ThanksSetup_Update(void)
13
{
14
RSDK_THIS(ThanksSetup);
15
16
StateMachine_Run(self->state);
17
18
ScreenInfo->position.x = 0x100 - ScreenInfo->center.x;
19
}
20
21
void ThanksSetup_LateUpdate(void) {}
22
23
void ThanksSetup_StaticUpdate(void) {}
24
25
void ThanksSetup_Draw(void)
26
{
27
RSDK_THIS(ThanksSetup);
28
29
StateMachine_Run(self->stateDraw);
30
}
31
32
void ThanksSetup_Create(void *data)
33
{
34
RSDK_THIS(ThanksSetup);
35
36
if (!SceneInfo->inEditor) {
37
self->active = ACTIVE_ALWAYS;
38
self->visible = true;
39
self->drawGroup = 12;
40
self->drawFX = FX_FLIP;
41
self->state = ThanksSetup_State_ThanksForPlaying;
42
self->stateDraw = ThanksSetup_Draw_Fade;
43
44
self->timer = 0x300;
45
self->radius = 0x10000;
46
self->scale.x = 0x200;
47
self->scale.y = 0x200;
48
49
self->thanksLogo = RSDK_GET_ENTITY(RESERVE_ENTITY_COUNT + 16, UIPicture);
50
self->thanksLogo->scale.x = 0x200;
51
self->thanksLogo->scale.y = 0x200;
52
}
53
}
54
55
void ThanksSetup_StageLoad(void)
56
{
57
ThanksSetup->sfxSega = RSDK.GetSfx("Stage/Sega.wav");
58
59
RSDK.ResetEntitySlot(0, ThanksSetup->classID, 0);
60
61
UIPicture->aniFrames = RSDK.LoadSpriteAnimation("Thanks/Decorations.bin", SCOPE_STAGE);
62
63
for (int32 c = 0; c < CHANNEL_COUNT; ++c) RSDK.StopChannel(c);
64
}
65
66
void ThanksSetup_HandleIconsPos(void)
67
{
68
RSDK_THIS(ThanksSetup);
69
70
self->angle = (self->angle - 3) & 0x1FF;
71
72
int32 angle = self->angle;
73
foreach_active(UIPicture, picture)
74
{
75
if (!picture->animator.animationID) {
76
picture->position.x = 0x1000000 + self->radius * RSDK.Sin512(angle);
77
picture->position.y = 0x780000 + self->radius * RSDK.Cos512(angle);
78
angle += 32;
79
}
80
}
81
}
82
83
void ThanksSetup_State_ThanksForPlaying(void)
84
{
85
RSDK_THIS(ThanksSetup);
86
87
if (self->timer <= 0) {
88
self->timer = 0;
89
self->radius += (0x3000 - self->radius) >> 4;
90
self->state = ThanksSetup_State_FlipOverIcon;
91
self->stateDraw = 0;
92
}
93
else {
94
self->radius += (0x3000 - self->radius) >> 4;
95
self->timer -= 16;
96
}
97
98
ThanksSetup_HandleIconsPos();
99
}
100
101
void ThanksSetup_State_FlipOverIcon(void)
102
{
103
RSDK_THIS(ThanksSetup);
104
105
if (++self->timer > 120) {
106
self->rotation += 4;
107
EntityUIPicture *picture = self->thanksLogo;
108
109
picture->drawFX = FX_SCALE;
110
picture->scale.x = RSDK.Cos512(self->rotation);
111
112
if (self->rotation == 128) {
113
RSDK.SetSpriteAnimation(UIPicture->aniFrames, 2, &picture->animator, true, 0);
114
self->timer = 0;
115
self->state = ThanksSetup_State_Mania2017;
116
}
117
}
118
self->radius += (0x3000 - self->radius) >> 4;
119
120
ThanksSetup_HandleIconsPos();
121
}
122
123
void ThanksSetup_State_Mania2017(void)
124
{
125
RSDK_THIS(ThanksSetup);
126
127
if (self->rotation <= 0) {
128
if (++self->timer > 120) {
129
self->timer = 0;
130
self->state = ThanksSetup_State_FadeOut;
131
self->stateDraw = ThanksSetup_Draw_Fade;
132
}
133
}
134
else {
135
EntityUIPicture *picture = self->thanksLogo;
136
137
self->rotation -= 4;
138
picture->scale.x = RSDK.Cos512(self->rotation);
139
140
if (!self->rotation)
141
picture->drawFX = FX_NONE;
142
}
143
144
ThanksSetup_HandleIconsPos();
145
}
146
147
void ThanksSetup_State_FadeOut(void)
148
{
149
RSDK_THIS(ThanksSetup);
150
151
if (self->timer >= 1024) {
152
SceneInfo->listPos = 0;
153
RSDK.LoadScene();
154
}
155
else {
156
self->timer += 16;
157
}
158
159
self->radius += (self->radius - 0x2000) >> 4;
160
161
ThanksSetup_HandleIconsPos();
162
}
163
164
void ThanksSetup_Draw_Fade(void)
165
{
166
RSDK_THIS(ThanksSetup);
167
168
RSDK.FillScreen(0x000000, self->timer, self->timer - 128, self->timer - 256);
169
}
170
171
#if GAME_INCLUDE_EDITOR
172
void ThanksSetup_EditorDraw(void) {}
173
174
void ThanksSetup_EditorLoad(void) { UIPicture->aniFrames = RSDK.LoadSpriteAnimation("Thanks/Decorations.bin", SCOPE_STAGE); }
175
#endif
176
177
void ThanksSetup_Serialize(void) {}
178
179