Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/FBZ/PropellerShaft.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: PropellerShaft Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectPropellerShaft *PropellerShaft;
11
12
void PropellerShaft_Update(void)
13
{
14
RSDK_THIS(PropellerShaft);
15
16
foreach_active(Player, player)
17
{
18
int32 playerID = RSDK.GetEntitySlot(player);
19
20
if ((1 << playerID) & self->activePlayers) {
21
if (!Player_CheckCollisionTouch(player, self, &self->hitbox)) {
22
player->state = Player_State_Air;
23
self->playerTimers[playerID] = 30;
24
self->activePlayers &= ~(1 << playerID);
25
}
26
else {
27
if (player->up) {
28
if (player->position.y > self->position.y - (self->size << 16) + 0x80000)
29
player->position.y -= 0x10000;
30
}
31
32
if (player->down) {
33
if (player->position.y < self->position.y + ((self->size - 8) << 16))
34
player->position.y += 0x10000;
35
}
36
37
if (player->jumpPress) {
38
self->activePlayers &= ~(1 << playerID);
39
self->playerTimers[playerID] = 30;
40
player->velocity.x = player->left ? -0x100000 : 0x100000;
41
player->velocity.y = -0x18000;
42
RSDK.SetSpriteAnimation(player->aniFrames, ANI_JUMP, &player->animator, false, 0);
43
player->drawGroup = Zone->playerDrawGroup[0];
44
player->state = Player_State_Air;
45
}
46
}
47
}
48
else {
49
if (self->playerTimers[playerID]) {
50
self->playerTimers[playerID]--;
51
}
52
else {
53
if (Player_CheckCollisionTouch(player, self, &self->hitbox)) {
54
self->activePlayers |= 1 << playerID;
55
RSDK.PlaySfx(Player->sfxGrab, false, 255);
56
player->velocity.x = 0;
57
player->velocity.y = 0;
58
player->groundVel = 0;
59
60
player->position.x = self->position.x;
61
if (player->position.y < self->position.y - (self->size << 16) + 0x90000)
62
player->position.y = self->position.y - (self->size << 16) + 0x90000;
63
64
if (player->position.y > ((self->size - 9) << 16) + self->position.y)
65
player->position.y = ((self->size - 9) << 16) + self->position.y;
66
67
RSDK.SetSpriteAnimation(player->aniFrames, ANI_SHAFT_SWING, &player->animator, false, 0);
68
player->rotation = 0;
69
player->direction = FLIP_NONE;
70
player->onGround = false;
71
player->groundedStore = false;
72
player->nextGroundState = StateMachine_None;
73
player->nextAirState = StateMachine_None;
74
player->state = Player_State_Static;
75
}
76
}
77
}
78
}
79
}
80
81
void PropellerShaft_LateUpdate(void)
82
{
83
RSDK_THIS(PropellerShaft);
84
85
foreach_active(Player, player)
86
{
87
if (((1 << RSDK.GetEntitySlot(player)) & self->activePlayers)) {
88
if (player->animator.frameID > 5)
89
player->drawGroup = Zone->playerDrawGroup[0] - 3;
90
else
91
player->drawGroup = Zone->playerDrawGroup[0];
92
}
93
}
94
}
95
96
void PropellerShaft_StaticUpdate(void) {}
97
98
void PropellerShaft_Draw(void) {}
99
100
void PropellerShaft_Create(void *data)
101
{
102
RSDK_THIS(PropellerShaft);
103
104
if (!SceneInfo->inEditor) {
105
self->active = ACTIVE_BOUNDS;
106
self->visible = true;
107
self->drawGroup = Zone->objectDrawGroup[1];
108
self->updateRange.x = 0x400000;
109
self->updateRange.y = self->size << 16;
110
111
self->hitbox.left = -8;
112
self->hitbox.top = -self->size;
113
self->hitbox.right = 8;
114
self->hitbox.bottom = self->size;
115
}
116
}
117
118
void PropellerShaft_StageLoad(void) {}
119
120
#if GAME_INCLUDE_EDITOR
121
void PropellerShaft_EditorDraw(void)
122
{
123
RSDK_THIS(PropellerShaft);
124
self->drawGroup = Zone->objectDrawGroup[1];
125
126
DrawHelpers_DrawRectOutline(self->position.x, self->position.y, 16 << 16, self->size << 17, 0xFFFF00);
127
}
128
129
void PropellerShaft_EditorLoad(void) {}
130
#endif
131
132
void PropellerShaft_Serialize(void) { RSDK_EDITABLE_VAR(PropellerShaft, VAR_ENUM, size); }
133
134