Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/BSS/BSS_Collected.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: BSS_Collected Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectBSS_Collected *BSS_Collected;
11
12
void BSS_Collected_Update(void)
13
{
14
RSDK_THIS(BSS_Collected);
15
16
EntityBSS_Setup *setup = RSDK_GET_ENTITY(SLOT_BSS_SETUP, BSS_Setup);
17
int32 fieldPos = self->position.y + (BSS_PLAYFIELD_W * self->position.x);
18
19
switch (self->type) {
20
case BSS_COLLECTED_RING:
21
++BSS_Setup->ringID;
22
BSS_Setup->ringID &= 0xF;
23
24
if (++self->timer >= 16 && setup->state == BSS_Setup_State_GlobeMoveZ) {
25
BSS_Setup->playField[fieldPos] = BSS_NONE;
26
destroyEntity(self);
27
}
28
break;
29
30
case BSS_COLLECTED_BLUE:
31
if (BSS_Setup->sphereCount <= 0) {
32
if (BSS_Setup->playField[fieldPos] == BSS_BLUE_STOOD)
33
BSS_Setup->playField[fieldPos] = BSS_SPHERE_RED;
34
35
destroyEntity(self);
36
}
37
else {
38
if (setup->globeTimer < 32 || setup->globeTimer > 224)
39
self->type = BSS_COLLECTED_BLUE_STOOD;
40
}
41
break;
42
43
case BSS_COLLECTED_BLUE_STOOD:
44
if (setup->state == BSS_Setup_State_GlobeMoveZ) {
45
if (setup->globeTimer > 32 && setup->globeTimer < 224) {
46
if (BSS_Setup->playField[fieldPos] == BSS_BLUE_STOOD)
47
BSS_Setup->playField[fieldPos] = BSS_SPHERE_RED;
48
49
destroyEntity(self);
50
}
51
}
52
break;
53
54
case BSS_COLLECTED_GREEN:
55
if (setup->globeTimer < 32 || setup->globeTimer > 224) {
56
self->timer = 10;
57
self->type = BSS_COLLECTED_GREEN_STOOD;
58
}
59
break;
60
61
case BSS_COLLECTED_GREEN_STOOD:
62
if (setup->state == BSS_Setup_State_GlobeMoveZ && --self->timer <= 0) {
63
if (BSS_Setup->playField[fieldPos] == BSS_SPHERE_GREEN_STOOD)
64
BSS_Setup->playField[fieldPos] = BSS_SPHERE_BLUE;
65
66
destroyEntity(self);
67
}
68
break;
69
70
case BSS_COLLECTED_PINK:
71
if (setup->state == BSS_Setup_State_GlobeMoveZ) {
72
if (setup->playerPos.x != self->position.x || setup->playerPos.y != self->position.y) {
73
if (BSS_Setup->playField[fieldPos] == BSS_SPHERE_PINK_STOOD)
74
BSS_Setup->playField[fieldPos] = BSS_SPHERE_PINK;
75
76
destroyEntity(self);
77
}
78
}
79
break;
80
81
default: break;
82
}
83
}
84
85
void BSS_Collected_LateUpdate(void) {}
86
87
void BSS_Collected_StaticUpdate(void) {}
88
89
void BSS_Collected_Draw(void) {}
90
91
void BSS_Collected_Create(void *data)
92
{
93
RSDK_THIS(BSS_Collected);
94
95
if (!SceneInfo->inEditor) {
96
self->active = ACTIVE_NORMAL;
97
self->type = VOID_TO_INT(data);
98
}
99
}
100
101
void BSS_Collected_StageLoad(void) {}
102
103
#if GAME_INCLUDE_EDITOR
104
void BSS_Collected_EditorDraw(void) {}
105
106
void BSS_Collected_EditorLoad(void) {}
107
#endif
108
109
void BSS_Collected_Serialize(void) {}
110
111