Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/FBZ/Propeller.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: Propeller Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectPropeller *Propeller;
11
12
void Propeller_Update(void)
13
{
14
RSDK_THIS(Propeller);
15
16
RSDK.ProcessAnimation(&self->animator);
17
Hitbox *hitboxHurt = RSDK.GetHitbox(&self->animator, 0);
18
19
self->hitboxFan.top = (RSDK.Sin256(2 * Zone->timer) >> 4) - 64;
20
self->hitboxFan.bottom = -8;
21
22
self->hitboxTrigger.top = -96;
23
self->hitboxTrigger.bottom = -8;
24
25
foreach_active(Player, player)
26
{
27
int32 playerID = RSDK.GetEntitySlot(player);
28
bool32 propellerActive = false;
29
30
int32 anim = player->animator.animationID;
31
if (anim != ANI_SHAFT_SWING && anim != ANI_HURT && self->fanEnabled
32
&& RSDK.CheckObjectCollisionTouchBox(self, &self->hitboxFan, player, &self->hitboxPlayer)) {
33
propellerActive = true;
34
RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, false, 0);
35
player->state = Player_State_Air;
36
player->onGround = false;
37
player->velocity.y = 0;
38
player->position.y += (self->position.y + (self->hitboxFan.top << 16) - player->position.y) >> 4;
39
}
40
41
if (RSDK.CheckObjectCollisionTouchBox(self, &self->hitboxTrigger, player, &self->hitboxPlayer)) {
42
if (!((1 << playerID) & self->activePlayers) && propellerActive) {
43
RSDK.PlaySfx(Propeller->sfxFan, false, 0xFF);
44
self->activePlayers |= (1 << playerID);
45
}
46
}
47
else {
48
self->activePlayers &= ~(1 << playerID);
49
}
50
51
if (Player_CheckCollisionTouch(player, self, hitboxHurt))
52
Player_Hurt(player, self);
53
}
54
}
55
56
void Propeller_LateUpdate(void) {}
57
58
void Propeller_StaticUpdate(void) {}
59
60
void Propeller_Draw(void)
61
{
62
RSDK_THIS(Propeller);
63
64
RSDK.DrawSprite(&self->animator, NULL, false);
65
}
66
67
void Propeller_Create(void *data)
68
{
69
RSDK_THIS(Propeller);
70
71
if (!SceneInfo->inEditor) {
72
self->active = ACTIVE_BOUNDS;
73
self->visible = true;
74
self->drawGroup = Zone->objectDrawGroup[1];
75
self->updateRange.x = 0x800000;
76
self->updateRange.y = 0x800000;
77
78
self->hitboxPlayer.left = -1;
79
self->hitboxPlayer.top = -1;
80
self->hitboxPlayer.right = 1;
81
self->hitboxPlayer.bottom = 1;
82
83
self->hitboxTrigger.left = -104;
84
self->hitboxTrigger.right = 104;
85
86
self->hitboxFan.left = -104;
87
self->hitboxFan.right = 104;
88
89
RSDK.SetSpriteAnimation(Propeller->aniFrames, 0, &self->animator, true, 0);
90
}
91
}
92
93
void Propeller_StageLoad(void)
94
{
95
Propeller->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Propeller.bin", SCOPE_STAGE);
96
97
Propeller->sfxFan = RSDK.GetSfx("FBZ/FBZFan.wav");
98
}
99
100
#if GAME_INCLUDE_EDITOR
101
void Propeller_EditorDraw(void)
102
{
103
RSDK_THIS(Propeller);
104
RSDK.SetSpriteAnimation(Propeller->aniFrames, 0, &self->animator, true, 0);
105
106
Propeller_Draw();
107
}
108
109
void Propeller_EditorLoad(void) { Propeller->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Propeller.bin", SCOPE_STAGE); }
110
#endif
111
112
void Propeller_Serialize(void) { RSDK_EDITABLE_VAR(Propeller, VAR_BOOL, fanEnabled); }
113
114