Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Global/EncoreRoute.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: EncoreRoute Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
#if MANIA_USE_PLUS
11
ObjectEncoreRoute *EncoreRoute;
12
13
void EncoreRoute_Update(void)
14
{
15
RSDK_THIS(EncoreRoute);
16
17
uint8 layerSrc = -1;
18
uint8 layerDest = -1;
19
20
switch (self->layerSrc) {
21
case EROUTE_LAYER_FGLOW: layerSrc = Zone->fgLayer[0]; break;
22
case EROUTE_LAYER_FGHIGH: layerSrc = Zone->fgLayer[1]; break;
23
case EROUTE_LAYER_MOVE: layerSrc = Zone->moveLayer; break;
24
case EROUTE_LAYER_SCRATCH: layerSrc = Zone->scratchLayer; break;
25
default: break;
26
}
27
28
switch (self->layerDest) {
29
case EROUTE_LAYER_FGLOW: layerDest = Zone->fgLayer[0]; break;
30
case EROUTE_LAYER_FGHIGH: layerDest = Zone->fgLayer[1]; break;
31
case EROUTE_LAYER_MOVE: layerDest = Zone->moveLayer; break;
32
case EROUTE_LAYER_SCRATCH: layerDest = Zone->scratchLayer; break;
33
default: break;
34
}
35
36
int32 srcX = self->offset.x >> 16;
37
int32 srcY = self->offset.y >> 16;
38
int32 dstX = self->position.x >> 20;
39
int32 dstY = self->position.y >> 20;
40
41
for (int32 y = 0; y < (self->size.y >> 16); ++y) {
42
for (int32 x = 0; x < (self->size.x >> 16); ++x) {
43
uint16 tile = RSDK.GetTile(layerSrc, srcX + x, srcY + y);
44
RSDK.SetTile(layerDest, dstX + x, dstY + y, tile);
45
}
46
}
47
48
destroyEntity(self);
49
}
50
51
void EncoreRoute_LateUpdate(void) {}
52
53
void EncoreRoute_StaticUpdate(void) {}
54
55
void EncoreRoute_Draw(void) {}
56
57
void EncoreRoute_Create(void *data)
58
{
59
RSDK_THIS(EncoreRoute);
60
61
self->active = ACTIVE_ALWAYS;
62
}
63
64
void EncoreRoute_StageLoad(void) {}
65
66
#if GAME_INCLUDE_EDITOR
67
void EncoreRoute_EditorDraw(void)
68
{
69
RSDK_THIS(EncoreRoute);
70
71
Vector2 drawPos;
72
73
self->drawFX = FX_FLIP;
74
self->active = ACTIVE_NORMAL;
75
76
Vector2 *positions[2] = { &self->position, &self->offset };
77
78
Vector2 size;
79
size.x = TILE_SIZE * self->size.x;
80
size.y = TILE_SIZE * self->size.y;
81
82
int32 count = showGizmos() ? 2 : 1;
83
for (int32 i = 0; i < count; ++i) {
84
if (i >= 1)
85
RSDK_DRAWING_OVERLAY(true);
86
87
drawPos.x = positions[i]->x + (size.x >> 1);
88
drawPos.y = positions[i]->y + (size.y >> 1);
89
90
DrawHelpers_DrawRectOutline(drawPos.x, drawPos.y, size.x, size.y, 0xFFFF00);
91
92
drawPos.x = positions[i]->x;
93
drawPos.y = positions[i]->y;
94
95
self->direction = FLIP_NONE;
96
RSDK.DrawSprite(&EncoreRoute->animator, &drawPos, false);
97
98
drawPos.x += size.x;
99
self->direction = FLIP_X;
100
RSDK.DrawSprite(&EncoreRoute->animator, &drawPos, false);
101
102
drawPos.y += size.y;
103
self->direction = FLIP_XY;
104
RSDK.DrawSprite(&EncoreRoute->animator, &drawPos, false);
105
106
drawPos.x -= size.x;
107
self->direction = FLIP_Y;
108
RSDK.DrawSprite(&EncoreRoute->animator, &drawPos, false);
109
110
if (i >= 1)
111
RSDK_DRAWING_OVERLAY(false);
112
}
113
114
if (showGizmos()) {
115
// Point to where the tiles come from
116
RSDK_DRAWING_OVERLAY(true);
117
DrawHelpers_DrawArrow(self->offset.x + (size.x >> 1), self->offset.y + (size.y >> 1), self->position.x + (size.x >> 1),
118
self->position.y + (size.y >> 1), 0xE0E0E0, INK_NONE, 0xFF);
119
RSDK_DRAWING_OVERLAY(false);
120
}
121
}
122
123
void EncoreRoute_EditorLoad(void)
124
{
125
EncoreRoute->aniFrames = RSDK.LoadSpriteAnimation("Global/TicMark.bin", SCOPE_STAGE);
126
RSDK.SetSpriteAnimation(EncoreRoute->aniFrames, 0, &EncoreRoute->animator, true, 0);
127
128
RSDK_ACTIVE_VAR(EncoreRoute, layerSrc);
129
RSDK_ENUM_VAR("FG Low", EROUTE_LAYER_FGLOW);
130
RSDK_ENUM_VAR("FG High", EROUTE_LAYER_FGHIGH);
131
RSDK_ENUM_VAR("Move", EROUTE_LAYER_MOVE);
132
RSDK_ENUM_VAR("Scratch", EROUTE_LAYER_SCRATCH);
133
134
RSDK_ACTIVE_VAR(EncoreRoute, layerDest);
135
RSDK_ENUM_VAR("FG Low", EROUTE_LAYER_FGLOW);
136
RSDK_ENUM_VAR("FG High", EROUTE_LAYER_FGHIGH);
137
RSDK_ENUM_VAR("Move", EROUTE_LAYER_MOVE);
138
RSDK_ENUM_VAR("Scratch", EROUTE_LAYER_SCRATCH);
139
140
RSDK_ACTIVE_VAR(EncoreRoute, frameID);
141
RSDK_ENUM_VAR("(Unused)", EROUTE_FRAME_UNUSED);
142
}
143
#endif
144
145
void EncoreRoute_Serialize(void)
146
{
147
RSDK_EDITABLE_VAR(EncoreRoute, VAR_VECTOR2, offset);
148
RSDK_EDITABLE_VAR(EncoreRoute, VAR_VECTOR2, size);
149
RSDK_EDITABLE_VAR(EncoreRoute, VAR_UINT8, layerSrc);
150
RSDK_EDITABLE_VAR(EncoreRoute, VAR_UINT8, layerDest);
151
RSDK_EDITABLE_VAR(EncoreRoute, VAR_ENUM, frameID);
152
}
153
#endif
154
155