Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/UFO/UFO_Message.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: UFO_Message Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectUFO_Message *UFO_Message;
11
12
void UFO_Message_Update(void)
13
{
14
RSDK_THIS(UFO_Message);
15
16
StateMachine_Run(self->state);
17
}
18
19
void UFO_Message_LateUpdate(void) {}
20
21
void UFO_Message_StaticUpdate(void) {}
22
23
void UFO_Message_Draw(void)
24
{
25
RSDK_THIS(UFO_Message);
26
27
Vector2 drawPos;
28
drawPos.x = (ScreenInfo->center.x - self->timer) << 16;
29
drawPos.y = 0x580000;
30
RSDK.DrawSprite(&self->leftAnimator, &drawPos, true);
31
32
drawPos.x = (self->timer + ScreenInfo->center.x) << 16;
33
RSDK.DrawSprite(&self->rightAnimator, &drawPos, true);
34
}
35
36
void UFO_Message_Create(void *data)
37
{
38
RSDK_THIS(UFO_Message);
39
40
if (!SceneInfo->inEditor) {
41
self->active = ACTIVE_NORMAL;
42
self->visible = true;
43
self->drawGroup = 12;
44
self->state = UFO_Message_State_Appear;
45
46
int32 type = VOID_TO_INT(data);
47
RSDK.SetSpriteAnimation(UFO_Message->aniFrames, 4, &self->leftAnimator, true, 2 * type);
48
RSDK.SetSpriteAnimation(UFO_Message->aniFrames, 4, &self->rightAnimator, true, 2 * type + 1);
49
self->timer = 320;
50
51
foreach_active(UFO_Message, message)
52
{
53
if (message != self)
54
message->state = UFO_Message_State_Exit;
55
}
56
}
57
}
58
59
void UFO_Message_StageLoad(void) { UFO_Message->aniFrames = RSDK.LoadSpriteAnimation("SpecialUFO/HUD.bin", SCOPE_STAGE); }
60
61
void UFO_Message_State_Appear(void)
62
{
63
RSDK_THIS(UFO_Message);
64
65
self->timer -= 16;
66
67
if (self->timer <= 0)
68
self->state = UFO_Message_State_ShowMsg;
69
}
70
void UFO_Message_State_ShowMsg(void)
71
{
72
RSDK_THIS(UFO_Message);
73
74
if (++self->displayTime >= 180) {
75
self->displayTime = 0;
76
77
self->state = UFO_Message_State_Exit;
78
}
79
}
80
void UFO_Message_State_Exit(void)
81
{
82
RSDK_THIS(UFO_Message);
83
84
self->timer += 16;
85
if (self->timer > 320)
86
destroyEntity(self);
87
}
88
89
#if GAME_INCLUDE_EDITOR
90
void UFO_Message_EditorDraw(void) {}
91
92
void UFO_Message_EditorLoad(void) {}
93
#endif
94
95
void UFO_Message_Serialize(void) {}
96
97