Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/FBZ/Mine.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: Mine Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectMine *Mine;
11
12
void Mine_Update(void)
13
{
14
RSDK_THIS(Mine);
15
16
if (self->timer <= 0) {
17
foreach_active(Player, player)
18
{
19
if (Player_CheckCollisionTouch(player, self, &Mine->hitboxMine)) {
20
self->active = ACTIVE_NORMAL;
21
self->timer = 30;
22
}
23
}
24
25
#if MANIA_USE_PLUS
26
Mine_CheckMightyHit();
27
#endif
28
}
29
else {
30
self->animator.frameID ^= 1;
31
if (--self->timer) {
32
#if MANIA_USE_PLUS
33
Mine_CheckMightyHit();
34
#endif
35
}
36
else {
37
foreach_active(FBZMissile, missile)
38
{
39
if (missile->type == FBZMISSILE_HULL
40
&& RSDK.CheckObjectCollisionTouchBox(missile, &FBZMissile->hitboxHull, self, &FBZMissile->hitboxMissileV)) {
41
if (--missile->timer <= 0) {
42
destroyEntity(missile);
43
RSDK.PlaySfx(Player->sfxRelease, false, 255);
44
}
45
46
int32 x = self->position.x;
47
int32 y = self->position.y + 0x30000;
48
CREATE_ENTITY(Explosion, INT_TO_VOID(EXPLOSION_BOSSPUFF), x, y)->drawGroup = Zone->objectDrawGroup[1];
49
RSDK.PlaySfx(FBZMissile->sfxExplosion, false, 255);
50
destroyEntity(self);
51
foreach_return;
52
}
53
}
54
55
foreach_active(Player, player)
56
{
57
if (Player_CheckCollisionTouch(player, self, &Mine->hitboxMine)) {
58
#if MANIA_USE_PLUS
59
if (Player_CheckMightyUnspin(player, 0x400, true, &player->uncurlTimer))
60
player->onGround = false;
61
else
62
#endif
63
Player_Hurt(player, self);
64
}
65
}
66
67
CREATE_ENTITY(Explosion, INT_TO_VOID(EXPLOSION_ENEMY), self->position.x, self->position.y - 0x30000)->drawGroup =
68
Zone->objectDrawGroup[1];
69
RSDK.PlaySfx(Mine->sfxExplosion, false, 255);
70
#if MANIA_USE_PLUS
71
Mine_CheckMightyHit();
72
#endif
73
destroyEntity(self);
74
}
75
}
76
}
77
78
void Mine_LateUpdate(void) {}
79
80
void Mine_StaticUpdate(void) {}
81
82
void Mine_Draw(void)
83
{
84
RSDK_THIS(Mine);
85
86
RSDK.DrawSprite(&self->animator, NULL, false);
87
}
88
89
void Mine_Create(void *data)
90
{
91
RSDK_THIS(Mine);
92
93
if (!SceneInfo->inEditor) {
94
self->active = ACTIVE_BOUNDS;
95
self->visible = true;
96
self->drawGroup = Zone->objectDrawGroup[0];
97
self->updateRange.x = 0x400000;
98
self->updateRange.y = 0x400000;
99
100
RSDK.SetSpriteAnimation(Mine->aniFrames, 0, &self->animator, true, 0);
101
}
102
}
103
104
void Mine_StageLoad(void)
105
{
106
Mine->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Mine.bin", SCOPE_STAGE);
107
108
Mine->hitboxMine.top = -6;
109
Mine->hitboxMine.left = -12;
110
Mine->hitboxMine.right = 12;
111
Mine->hitboxMine.bottom = 0;
112
113
Mine->sfxExplosion = RSDK.GetSfx("Stage/Explosion2.wav");
114
}
115
116
#if MANIA_USE_PLUS
117
void Mine_CheckMightyHit(void)
118
{
119
RSDK_THIS(Mine);
120
121
foreach_active(Player, player)
122
{
123
if (Player_CheckBadnikTouch(player, self, &Mine->hitboxMine) && (player->characterID == ID_MIGHTY && player->jumpAbilityState > 1)) {
124
self->timer = 1;
125
}
126
}
127
}
128
#endif
129
130
#if GAME_INCLUDE_EDITOR
131
void Mine_EditorDraw(void)
132
{
133
RSDK_THIS(Mine);
134
self->drawGroup = Zone->objectDrawGroup[0];
135
RSDK.SetSpriteAnimation(Mine->aniFrames, 0, &self->animator, true, 0);
136
137
Mine_Draw();
138
}
139
140
void Mine_EditorLoad(void) { Mine->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Mine.bin", SCOPE_STAGE); }
141
#endif
142
143
void Mine_Serialize(void) {}
144
145