Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/SSZ/MSOrb.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: MSOrb Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectMSOrb *MSOrb;
11
12
void MSOrb_Update(void)
13
{
14
RSDK_THIS(MSOrb);
15
16
StateMachine_Run(self->state);
17
}
18
19
void MSOrb_LateUpdate(void) {}
20
21
void MSOrb_StaticUpdate(void) {}
22
23
void MSOrb_Draw(void)
24
{
25
RSDK_THIS(MSOrb);
26
27
StateMachine_Run(self->stateDraw);
28
}
29
30
void MSOrb_Create(void *data)
31
{
32
RSDK_THIS(MSOrb);
33
34
if (!SceneInfo->inEditor) {
35
self->active = ACTIVE_NORMAL;
36
self->inkEffect = INK_ALPHA;
37
self->visible = true;
38
self->updateRange.x = 0x400000;
39
self->updateRange.y = 0x400000;
40
self->alpha = 0xC0;
41
self->drawGroup = Zone->objectDrawGroup[0];
42
43
RSDK.SetSpriteAnimation(MSOrb->aniFrames, 15, &self->animator, true, 0);
44
self->state = MSOrb_State_Orb;
45
self->stateDraw = MSOrb_Draw_Orb;
46
}
47
}
48
49
void MSOrb_StageLoad(void)
50
{
51
if (RSDK.CheckSceneFolder("SSZ2"))
52
MSOrb->aniFrames = RSDK.LoadSpriteAnimation("SSZ2/MetalSonic.bin", SCOPE_STAGE);
53
54
MSOrb->hitboxOrb.left = -6;
55
MSOrb->hitboxOrb.top = -6;
56
MSOrb->hitboxOrb.right = 6;
57
MSOrb->hitboxOrb.bottom = 6;
58
}
59
60
void MSOrb_CheckPlayerCollisions(void)
61
{
62
RSDK_THIS(MSOrb);
63
64
foreach_active(Player, player)
65
{
66
if (Player_CheckCollisionTouch(player, self, &MSOrb->hitboxOrb))
67
Player_Hurt(player, self);
68
}
69
}
70
71
void MSOrb_State_Orb(void)
72
{
73
RSDK_THIS(MSOrb);
74
75
RSDK.ProcessAnimation(&self->animator);
76
77
self->position.x += self->velocity.x;
78
self->position.y += self->velocity.y;
79
80
MSOrb_CheckPlayerCollisions();
81
}
82
83
void MSOrb_Draw_Orb(void)
84
{
85
RSDK_THIS(MSOrb);
86
87
RSDK.DrawSprite(&self->animator, NULL, false);
88
}
89
90
#if GAME_INCLUDE_EDITOR
91
void MSOrb_EditorDraw(void)
92
{
93
RSDK_THIS(MSOrb);
94
95
self->inkEffect = INK_ALPHA;
96
self->visible = true;
97
self->updateRange.x = 0x400000;
98
self->updateRange.y = 0x400000;
99
self->alpha = 0xC0;
100
self->drawGroup = Zone->objectDrawGroup[0];
101
RSDK.SetSpriteAnimation(MSOrb->aniFrames, 15, &self->animator, true, 0);
102
103
MSOrb_Draw_Orb();
104
}
105
106
void MSOrb_EditorLoad(void) { MSOrb->aniFrames = RSDK.LoadSpriteAnimation("SSZ2/MetalSonic.bin", SCOPE_STAGE); }
107
#endif
108
109
void MSOrb_Serialize(void) {}
110
111