Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/FBZ/FoldingPlatform.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: FoldingPlatform Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectFoldingPlatform *FoldingPlatform;
11
12
void FoldingPlatform_Update(void)
13
{
14
RSDK_THIS(FoldingPlatform);
15
16
int32 timer = (Zone->timer + self->intervalOffset) % self->interval;
17
18
if (timer >= self->duration) {
19
if (timer >= self->duration + 8) {
20
self->animator.frameID = 0;
21
}
22
else {
23
self->active = ACTIVE_NORMAL;
24
self->timer = timer - self->duration;
25
self->state = FoldingPlatform_State_Disappear;
26
self->animator.frameID = 4 - ((timer - self->duration) >> 1);
27
}
28
}
29
else {
30
self->active = ACTIVE_NORMAL;
31
self->timer = timer;
32
if (timer > 8)
33
self->animator.frameID = 4;
34
else
35
self->animator.frameID = timer >> 1;
36
self->state = FoldingPlatform_State_Appear;
37
}
38
39
if (self->animator.frameID == 4) {
40
self->stateCollide = Platform_Collision_Platform;
41
self->collision = PLATFORM_C_PLATFORM;
42
}
43
else {
44
self->stateCollide = Platform_Collision_None;
45
self->collision = PLATFORM_C_NONE;
46
}
47
48
Platform_Update();
49
}
50
51
void FoldingPlatform_LateUpdate(void) {}
52
53
void FoldingPlatform_StaticUpdate(void) {}
54
55
void FoldingPlatform_Draw(void)
56
{
57
RSDK_THIS(FoldingPlatform);
58
59
RSDK.DrawSprite(&self->animator, &self->drawPos, false);
60
}
61
62
void FoldingPlatform_Create(void *data)
63
{
64
RSDK_THIS(FoldingPlatform);
65
66
if (!self->interval)
67
self->interval = 480;
68
69
if (!self->duration)
70
self->duration = 240;
71
72
self->collision = PLATFORM_C_PLATFORM;
73
Platform_Create(NULL);
74
75
RSDK.SetSpriteAnimation(Platform->aniFrames, 2, &self->animator, true, 0);
76
self->drawFX = FX_FLIP;
77
self->scale.x = 0x000;
78
self->scale.y = 0x200;
79
self->state = Platform_State_Fixed;
80
}
81
82
void FoldingPlatform_StageLoad(void) {}
83
84
void FoldingPlatform_State_Appear(void)
85
{
86
RSDK_THIS(FoldingPlatform);
87
88
if (!(++self->timer & 1)) {
89
if (self->animator.frameID < 4)
90
self->animator.frameID++;
91
}
92
93
if (self->timer == self->duration)
94
self->state = FoldingPlatform_State_Disappear;
95
}
96
97
void FoldingPlatform_State_Disappear(void)
98
{
99
RSDK_THIS(FoldingPlatform);
100
101
--self->timer;
102
if (!(self->timer & 1)) {
103
if (self->animator.frameID > 0) {
104
self->animator.frameID--;
105
}
106
}
107
108
if (!self->animator.frameID) {
109
self->active = ACTIVE_BOUNDS;
110
self->state = Platform_State_Fixed;
111
}
112
}
113
114
#if GAME_INCLUDE_EDITOR
115
void FoldingPlatform_EditorDraw(void)
116
{
117
RSDK_THIS(FoldingPlatform);
118
RSDK.SetSpriteAnimation(Platform->aniFrames, 2, &self->animator, true, 4);
119
self->drawPos = self->position;
120
121
FoldingPlatform_Draw();
122
}
123
124
void FoldingPlatform_EditorLoad(void)
125
{
126
RSDK_ACTIVE_VAR(FoldingPlatform, direction);
127
RSDK_ENUM_VAR("Right", FLIP_NONE);
128
RSDK_ENUM_VAR("Left", FLIP_X);
129
}
130
#endif
131
132
void FoldingPlatform_Serialize(void)
133
{
134
RSDK_EDITABLE_VAR(FoldingPlatform, VAR_ENUM, childCount);
135
RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, interval);
136
RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, intervalOffset);
137
RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT8, direction);
138
RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, duration);
139
}
140
141