Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/MMZ/ConveyorWheel.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: ConveyorWheel Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectConveyorWheel *ConveyorWheel;
11
12
void ConveyorWheel_Update(void)
13
{
14
RSDK_THIS(ConveyorWheel);
15
16
foreach_active(Player, player)
17
{
18
if (Player_CheckCollisionTouch(player, self, &ConveyorWheel->hitbox)) {
19
if (player->state == Player_State_KnuxGlideDrop || player->state == Player_State_KnuxGlideSlide)
20
player->state = Player_State_Ground;
21
22
if (self->direction)
23
player->groundVel = CLAMP(player->groundVel, -0xF0000, -0x40000);
24
else
25
player->groundVel = CLAMP(player->groundVel, 0x40000, 0xF0000);
26
}
27
}
28
29
self->angle = (self->angle + 4) & 0x1FF;
30
}
31
32
void ConveyorWheel_LateUpdate(void) {}
33
34
void ConveyorWheel_StaticUpdate(void) {}
35
36
void ConveyorWheel_Draw(void) {}
37
38
void ConveyorWheel_Create(void *data)
39
{
40
RSDK_THIS(ConveyorWheel);
41
42
self->drawFX |= FX_FLIP;
43
self->active = ACTIVE_BOUNDS;
44
self->visible = true;
45
self->updateRange.x = 0x400000;
46
self->updateRange.y = 0x400000;
47
self->drawGroup = Zone->objectDrawGroup[1];
48
49
RSDK.SetSpriteAnimation(ConveyorWheel->aniFrames, 0, &self->animator, true, 0);
50
}
51
52
void ConveyorWheel_StageLoad(void)
53
{
54
if (RSDK.CheckSceneFolder("MMZ"))
55
ConveyorWheel->aniFrames = RSDK.LoadSpriteAnimation("MMZ/ConveyorWheel.bin", SCOPE_STAGE);
56
57
ConveyorWheel->hitbox.left = -49;
58
ConveyorWheel->hitbox.top = -49;
59
ConveyorWheel->hitbox.right = 49;
60
ConveyorWheel->hitbox.bottom = 49;
61
}
62
63
#if GAME_INCLUDE_EDITOR
64
void ConveyorWheel_EditorDraw(void)
65
{
66
RSDK_THIS(ConveyorWheel);
67
68
RSDK.DrawSprite(&self->animator, NULL, false);
69
70
if (showGizmos()) {
71
RSDK_DRAWING_OVERLAY(true);
72
73
DrawHelpers_DrawHitboxOutline(self->position.x, self->position.y, &ConveyorWheel->hitbox, FLIP_NONE, 0xFF0000);
74
75
RSDK_DRAWING_OVERLAY(false);
76
}
77
}
78
79
void ConveyorWheel_EditorLoad(void)
80
{
81
ConveyorWheel->aniFrames = RSDK.LoadSpriteAnimation("MMZ/ConveyorWheel.bin", SCOPE_STAGE);
82
83
ConveyorWheel->hitbox.left = -49;
84
ConveyorWheel->hitbox.top = -49;
85
ConveyorWheel->hitbox.right = 49;
86
ConveyorWheel->hitbox.bottom = 49;
87
88
RSDK_ACTIVE_VAR(ConveyorWheel, direction);
89
RSDK_ENUM_VAR("Right", FLIP_NONE);
90
RSDK_ENUM_VAR("Left", FLIP_X);
91
}
92
#endif
93
94
void ConveyorWheel_Serialize(void) { RSDK_EDITABLE_VAR(ConveyorWheel, VAR_UINT8, direction); }
95
96