Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/TMZ/TMZAlert.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: TMZAlert Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectTMZAlert *TMZAlert;
11
12
void TMZAlert_Update(void)
13
{
14
RSDK_THIS(TMZAlert);
15
16
StateMachine_Run(self->state);
17
}
18
19
void TMZAlert_LateUpdate(void) {}
20
21
void TMZAlert_StaticUpdate(void) {}
22
23
void TMZAlert_Draw(void)
24
{
25
RSDK_THIS(TMZAlert);
26
27
self->drawFX = FX_NONE;
28
self->inkEffect = INK_NONE;
29
self->screenAnimator.frameID = 0;
30
RSDK.DrawSprite(&self->screenAnimator, NULL, false);
31
32
if (self->scale.y != 0x200)
33
self->drawFX = FX_SCALE;
34
35
self->inkEffect = INK_ALPHA;
36
self->screenAnimator.frameID = 1;
37
RSDK.DrawSprite(&self->screenAnimator, NULL, false);
38
39
RSDK.DrawSprite(&self->messageAnimator, NULL, false);
40
}
41
42
void TMZAlert_Create(void *data)
43
{
44
RSDK_THIS(TMZAlert);
45
46
if (!SceneInfo->inEditor) {
47
self->inkEffect = INK_ALPHA;
48
self->visible = true;
49
self->drawFX = FX_SCALE;
50
self->drawGroup = Zone->objectDrawGroup[0];
51
self->active = ACTIVE_BOUNDS;
52
self->updateRange.x = 0x800000;
53
self->updateRange.y = 0x800000;
54
self->scale.x = 0x200;
55
self->alpha = 0x10 * (RSDK.Rand(-32, -8) - 16);
56
57
RSDK.SetSpriteAnimation(TMZAlert->aniFrames, 0, &self->screenAnimator, true, 0);
58
}
59
}
60
61
void TMZAlert_StageLoad(void) { TMZAlert->aniFrames = RSDK.LoadSpriteAnimation("Phantom/AlertScreen.bin", SCOPE_STAGE); }
62
63
void TMZAlert_State_Activating(void)
64
{
65
RSDK_THIS(TMZAlert);
66
67
if (self->alpha >= 0x100) {
68
self->drawFX = FX_NONE;
69
self->state = TMZAlert_State_Alerting;
70
}
71
else {
72
self->alpha += 0x20;
73
if (self->alpha > 0x100)
74
self->alpha = 0x100;
75
76
self->scale.y = 2 * self->alpha;
77
}
78
}
79
void TMZAlert_State_Alerting(void)
80
{
81
RSDK_THIS(TMZAlert);
82
83
self->alpha = 0xE0 + (RSDK.Cos256(8 * ++self->timer) >> 2);
84
85
if (!(self->timer & 0xF))
86
RSDK.SetSpriteAnimation(TMZAlert->aniFrames, 1, &self->messageAnimator, true, RSDK.Rand(0, 2));
87
88
if (self->timer == 320) {
89
self->timer = 0;
90
self->state = TMZAlert_State_ShuttingDown;
91
}
92
}
93
94
void TMZAlert_State_ShuttingDown(void)
95
{
96
RSDK_THIS(TMZAlert);
97
98
if (self->alpha <= 0x10)
99
self->state = StateMachine_None;
100
else
101
self->alpha -= 8;
102
}
103
104
#if GAME_INCLUDE_EDITOR
105
void TMZAlert_EditorDraw(void)
106
{
107
RSDK_THIS(TMZAlert);
108
109
RSDK.SetSpriteAnimation(TMZAlert->aniFrames, 0, &self->screenAnimator, true, 0);
110
111
TMZAlert_Draw();
112
}
113
114
void TMZAlert_EditorLoad(void) { TMZAlert->aniFrames = RSDK.LoadSpriteAnimation("Phantom/AlertScreen.bin", SCOPE_STAGE); }
115
#endif
116
117
void TMZAlert_Serialize(void) {}
118
119