Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Common/TilePlatform.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: TilePlatform Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectTilePlatform *TilePlatform;
11
12
void TilePlatform_Update(void) { Platform_Update(); }
13
14
void TilePlatform_LateUpdate(void) {}
15
16
void TilePlatform_StaticUpdate(void) {}
17
18
void TilePlatform_Draw(void)
19
{
20
RSDK_THIS(TilePlatform);
21
22
RSDK.DrawTile(self->tiles, self->size.x >> 20, self->size.y >> 20, &self->drawPos, NULL, false);
23
}
24
25
void TilePlatform_Create(void *data)
26
{
27
RSDK_THIS(TilePlatform);
28
self->collision = PLATFORM_C_TILED;
29
Platform_Create(NULL);
30
31
if (!SceneInfo->inEditor) {
32
self->updateRange.x += 2 * self->size.x;
33
self->updateRange.y += 2 * self->size.y;
34
35
self->hitbox.left = -(self->size.x >> 17);
36
self->hitbox.top = -(self->size.y >> 17);
37
self->hitbox.right = self->size.x >> 17;
38
self->hitbox.bottom = self->size.y >> 17;
39
40
self->size.x += 0x80000;
41
self->size.y += 0x80000;
42
int32 originX = (self->targetPos.x >> 20) - (self->size.x >> 21);
43
int32 originY = (self->targetPos.y >> 20) - (self->size.y >> 21);
44
45
int32 h = self->size.y >> 20;
46
int32 w = self->size.x >> 20;
47
48
int32 id = 0;
49
if ((self->size.y & 0xFFF00000) > 0) {
50
for (int32 y = 0; y < h; ++y) {
51
if ((self->size.x & 0xFFF00000) > 0) {
52
for (int32 x = 0; x < w; ++x) {
53
id = x + y * (self->size.x >> 20);
54
self->tiles[id] = RSDK.GetTile(Zone->moveLayer, originX + x, originY + y);
55
}
56
}
57
}
58
}
59
}
60
}
61
62
void TilePlatform_StageLoad(void) {}
63
64
#if GAME_INCLUDE_EDITOR
65
void TilePlatform_EditorDraw(void)
66
{
67
RSDK_THIS(TilePlatform);
68
69
DrawHelpers_DrawRectOutline(self->position.x, self->position.y, self->size.x, self->size.y, 0xFFFF00);
70
71
if (showGizmos()) {
72
RSDK_DRAWING_OVERLAY(true);
73
74
DrawHelpers_DrawRectOutline(self->targetPos.x, self->targetPos.y, self->size.x, self->size.y, 0xFFFF00);
75
76
DrawHelpers_DrawArrow(self->targetPos.x, self->targetPos.y, self->position.x, self->position.y, 0xFFFF00, INK_NONE, 0xFF);
77
78
RSDK_DRAWING_OVERLAY(false);
79
}
80
}
81
82
void TilePlatform_EditorLoad(void)
83
{
84
85
RSDK_ACTIVE_VAR(TilePlatform, type);
86
RSDK_ENUM_VAR("Fixed", PLATFORM_FIXED);
87
RSDK_ENUM_VAR("Fall", PLATFORM_FALL);
88
RSDK_ENUM_VAR("Linear", PLATFORM_LINEAR);
89
RSDK_ENUM_VAR("Circular", PLATFORM_CIRCULAR);
90
RSDK_ENUM_VAR("Swing", PLATFORM_SWING);
91
RSDK_ENUM_VAR("Path", PLATFORM_PATH);
92
RSDK_ENUM_VAR("Push", PLATFORM_PUSH);
93
}
94
#endif
95
96
void TilePlatform_Serialize(void)
97
{
98
RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, type);
99
RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, amplitude);
100
RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, speed);
101
RSDK_EDITABLE_VAR(TilePlatform, VAR_BOOL, hasTension);
102
RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, targetPos);
103
RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, childCount);
104
RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, size);
105
RSDK_EDITABLE_VAR(TilePlatform, VAR_INT32, angle);
106
}
107
108