Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Cutscene/FXSpinRay.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: FXSpinRay Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectFXSpinRay *FXSpinRay;
11
12
void FXSpinRay_Update(void)
13
{
14
RSDK_THIS(FXSpinRay);
15
16
self->angle = ((self->angle & 0xFF) + self->spinSpeed) & 0xFF;
17
int32 angle = self->angle;
18
19
for (int32 i = 0; i < 20; i += 4) {
20
for (int32 v = 0; v < 4; ++v) {
21
self->vertices[i + v] = self->vertexPos[v];
22
Zone_RotateOnPivot(&self->vertices[i + v] , &self->vertexOffset, angle);
23
}
24
25
angle += 51;
26
}
27
28
StateMachine_Run(self->state);
29
30
Entity *parent = self->parent;
31
if (parent) {
32
self->position.x = parent->position.x + self->offsetPos.x;
33
self->position.y = parent->position.y + self->offsetPos.y;
34
}
35
}
36
37
void FXSpinRay_LateUpdate(void) {}
38
39
void FXSpinRay_StaticUpdate(void) {}
40
41
void FXSpinRay_Draw(void)
42
{
43
RSDK_THIS(FXSpinRay);
44
45
int32 scrX = self->position.x - (ScreenInfo->position.x << 16);
46
int32 scrY = self->position.y - (ScreenInfo->position.y << 16);
47
48
for (int32 i = 0; i < 20; i += 4) {
49
Vector2 vertices[4];
50
51
vertices[0].x = scrX + self->vertices[i + 0].x;
52
vertices[0].y = scrY + self->vertices[i + 0].y;
53
vertices[1].x = scrX + self->vertices[i + 1].x;
54
vertices[1].y = scrY + self->vertices[i + 1].y;
55
vertices[2].x = scrX + self->vertices[i + 2].x;
56
vertices[2].y = scrY + self->vertices[i + 2].y;
57
vertices[3].x = scrX + self->vertices[i + 3].x;
58
vertices[3].y = scrY + self->vertices[i + 3].y;
59
60
RSDK.DrawFace(vertices, 4, self->r, self->g, self->b, self->alpha, INK_ADD);
61
}
62
}
63
64
void FXSpinRay_Create(void *data)
65
{
66
RSDK_THIS(FXSpinRay);
67
68
if (!SceneInfo->inEditor) {
69
self->visible = true;
70
self->active = ACTIVE_NORMAL;
71
self->drawGroup = Zone->objectDrawGroup[1];
72
self->size = 0x600000;
73
74
self->vertexPos[0].x = -0xC0000;
75
self->vertexPos[1].x = self->size >> 3;
76
self->vertexPos[0].y = -self->size;
77
self->vertexPos[1].y = -self->size;
78
self->vertexPos[2].x = self->size >> 6;
79
self->vertexPos[3].x = -self->size >> 6;
80
self->vertexPos[2].y = -self->size >> 4;
81
self->vertexPos[3].y = -self->size >> 4;
82
83
self->spinSpeed = 8;
84
self->state = FXSpinRay_State_FadeIn;
85
86
self->r = 0xF0;
87
self->g = 0xF0;
88
self->b = 0xF0;
89
}
90
}
91
92
void FXSpinRay_StageLoad(void) {}
93
94
void FXSpinRay_State_FadeIn(void)
95
{
96
RSDK_THIS(FXSpinRay);
97
98
if (self->alpha >= 0x80)
99
self->state = FXSpinRay_State_Spinning;
100
else
101
self->alpha += 0x10;
102
}
103
104
void FXSpinRay_State_Spinning(void)
105
{
106
RSDK_THIS(FXSpinRay);
107
108
if (++self->timer == 16)
109
self->state = FXSpinRay_State_FadeOut;
110
}
111
112
void FXSpinRay_State_FadeOut(void)
113
{
114
RSDK_THIS(FXSpinRay);
115
116
if (self->alpha <= 0)
117
destroyEntity(self);
118
else
119
self->alpha -= 0x10;
120
}
121
122
#if GAME_INCLUDE_EDITOR
123
void FXSpinRay_EditorDraw(void) {}
124
125
void FXSpinRay_EditorLoad(void) {}
126
#endif
127
128
void FXSpinRay_Serialize(void) {}
129
130