Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Cutscene/FXTrail.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: FXTrail Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectFXTrail *FXTrail;
11
12
void FXTrail_Update(void) {}
13
14
void FXTrail_LateUpdate(void)
15
{
16
RSDK_THIS(FXTrail);
17
18
Entity *parent = self->parent;
19
20
if (parent && self->animatorPtr && parent->classID) {
21
// Update recordings
22
for (int32 i = FXTRAIL_TRACK_COUNT - 1; i > 0; --i) {
23
self->statePos[i].x = self->statePos[i - 1].x;
24
self->statePos[i].y = self->statePos[i - 1].y;
25
self->stateRotation[i] = self->stateRotation[i - 1];
26
self->stateDirection[i] = self->stateDirection[i - 1];
27
self->stateVisible[i] = self->stateVisible[i - 1];
28
memcpy(&self->stateAnim[i], &self->stateAnim[i - 1], sizeof(Animator));
29
}
30
31
self->statePos[0].x = self->currentPos.x;
32
self->statePos[0].y = self->currentPos.y;
33
self->stateRotation[0] = self->currentRotation;
34
self->stateDirection[0] = self->currentDirection;
35
self->stateVisible[0] = self->currentVisible;
36
memcpy(&self->stateAnim[0], &self->currentAnim, sizeof(Animator));
37
38
// Record Parent
39
self->drawGroup = parent->drawGroup - 1;
40
self->currentPos.x = parent->position.x;
41
self->currentPos.y = parent->position.y;
42
self->currentRotation = parent->rotation;
43
self->currentDirection = parent->direction;
44
memcpy(&self->currentAnim, self->animatorPtr, sizeof(Animator));
45
}
46
else {
47
destroyEntity(self);
48
}
49
}
50
51
void FXTrail_StaticUpdate(void) {}
52
53
void FXTrail_Draw(void)
54
{
55
RSDK_THIS(FXTrail);
56
57
int32 alpha = 0x60 * self->baseAlpha >> 8;
58
int32 inc = 0x40 / (IMAGETRAIL_TRACK_COUNT / 3);
59
60
for (int32 i = 2; i >= 0; --i) {
61
int32 id = (i * 3) - (i - 1);
62
if (self->stateVisible[id]) {
63
self->alpha = alpha;
64
self->rotation = self->stateRotation[id];
65
self->direction = self->stateDirection[id];
66
RSDK.DrawSprite(&self->stateAnim[id], &self->statePos[id], false);
67
68
self->drawFX &= ~FX_SCALE;
69
alpha += inc;
70
}
71
}
72
}
73
74
void FXTrail_Create(void *data)
75
{
76
RSDK_THIS(FXTrail);
77
if (!SceneInfo->inEditor) {
78
Entity *parent = (Entity *)data;
79
80
self->active = ACTIVE_ALWAYS;
81
self->visible = true;
82
self->parent = parent;
83
self->baseAlpha = 0x100;
84
self->drawFX = FX_FLIP | FX_ROTATE;
85
self->inkEffect = INK_ALPHA;
86
87
for (int32 i = FXTRAIL_TRACK_COUNT - 1; i >= 0; --i) {
88
self->statePos[i].x = parent->position.x;
89
self->statePos[i].y = parent->position.y;
90
self->stateRotation[i] = parent->rotation;
91
self->stateDirection[i] = parent->direction;
92
self->stateVisible[i] = false;
93
}
94
}
95
}
96
97
void FXTrail_StageLoad(void) {}
98
99
#if GAME_INCLUDE_EDITOR
100
void FXTrail_EditorDraw(void) {}
101
102
void FXTrail_EditorLoad(void) {}
103
#endif
104
105
void FXTrail_Serialize(void) {}
106
107