Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/MMZ/VanishPlatform.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: VanishPlatform Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectVanishPlatform *VanishPlatform;
11
12
void VanishPlatform_Update(void)
13
{
14
RSDK_THIS(VanishPlatform);
15
16
if (!((Zone->timer + self->intervalOffset) % self->interval) && self->state == Platform_State_Fixed) {
17
self->active = ACTIVE_NORMAL;
18
self->timer = self->duration;
19
self->state = VanishPlatform_State_Appear;
20
}
21
22
if (self->scale.x <= 336) {
23
self->stateCollide = Platform_Collision_None;
24
self->collision = PLATFORM_C_NONE;
25
}
26
else {
27
self->stateCollide = Platform_Collision_Platform;
28
self->collision = PLATFORM_C_PLATFORM;
29
}
30
31
Platform_Update();
32
}
33
34
void VanishPlatform_LateUpdate(void) {}
35
36
void VanishPlatform_StaticUpdate(void) {}
37
38
void VanishPlatform_Draw(void)
39
{
40
RSDK_THIS(VanishPlatform);
41
42
RSDK.DrawSprite(&self->animator, &self->drawPos, false);
43
}
44
45
void VanishPlatform_Create(void *data)
46
{
47
RSDK_THIS(VanishPlatform);
48
49
self->collision = PLATFORM_C_PLATFORM;
50
Platform_Create(NULL);
51
52
RSDK.SetSpriteAnimation(Platform->aniFrames, 3, &self->animator, true, 0);
53
54
self->drawFX = FX_SCALE;
55
self->scale.x = 0;
56
self->scale.y = 0x200;
57
self->state = Platform_State_Fixed;
58
}
59
60
void VanishPlatform_StageLoad(void) {}
61
62
void VanishPlatform_State_Appear(void)
63
{
64
RSDK_THIS(VanishPlatform);
65
66
if (self->scale.x < 0x200)
67
self->scale.x += 22;
68
69
if (--self->timer <= 0)
70
self->state = VanishPlatform_State_Disappear;
71
}
72
73
void VanishPlatform_State_Disappear(void)
74
{
75
RSDK_THIS(VanishPlatform);
76
77
if (self->scale.x <= 0) {
78
self->active = ACTIVE_BOUNDS;
79
self->state = Platform_State_Fixed;
80
}
81
else {
82
self->scale.x -= 22;
83
}
84
}
85
86
#if GAME_INCLUDE_EDITOR
87
void VanishPlatform_EditorDraw(void)
88
{
89
RSDK_THIS(VanishPlatform);
90
91
self->drawPos = self->position;
92
self->drawFX = FX_NONE;
93
94
VanishPlatform_Draw();
95
96
if (showGizmos()) {
97
RSDK_DRAWING_OVERLAY(true);
98
99
for (int32 s = SceneInfo->entitySlot + 1, i = 0; i < self->childCount; ++i) {
100
Entity *child = RSDK_GET_ENTITY_GEN(s + i);
101
if (!child)
102
continue;
103
104
DrawHelpers_DrawArrow(self->position.x, self->position.y, child->position.x, child->position.y, 0xE0E0E0, INK_NONE, 0xFF);
105
}
106
107
RSDK_DRAWING_OVERLAY(false);
108
}
109
}
110
111
void VanishPlatform_EditorLoad(void) {}
112
#endif
113
114
void VanishPlatform_Serialize(void)
115
{
116
RSDK_EDITABLE_VAR(VanishPlatform, VAR_ENUM, childCount);
117
RSDK_EDITABLE_VAR(VanishPlatform, VAR_UINT16, interval);
118
RSDK_EDITABLE_VAR(VanishPlatform, VAR_UINT16, intervalOffset);
119
RSDK_EDITABLE_VAR(VanishPlatform, VAR_UINT16, duration);
120
}
121
122