Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Cutscene/ChaosEmerald.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: ChaosEmerald Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectChaosEmerald *ChaosEmerald;
11
12
void ChaosEmerald_Update(void)
13
{
14
RSDK_THIS(ChaosEmerald);
15
16
StateMachine_Run(self->state);
17
}
18
19
void ChaosEmerald_LateUpdate(void) {}
20
21
void ChaosEmerald_StaticUpdate(void) {}
22
23
void ChaosEmerald_Draw(void)
24
{
25
RSDK_THIS(ChaosEmerald);
26
27
for (int32 c = 0; c < 36; ++c) {
28
ChaosEmerald->colorStorage[c] = RSDK.GetPaletteEntry(0, c + 128);
29
RSDK.SetPaletteEntry(0, c + 128, ChaosEmerald->emeraldColors[c]);
30
}
31
32
RSDK.DrawSprite(&self->animator, NULL, false);
33
34
for (int32 c = 0; c < 36; ++c) {
35
RSDK.SetPaletteEntry(0, c + 0x80, ChaosEmerald->colorStorage[c]);
36
}
37
}
38
39
void ChaosEmerald_Create(void *data)
40
{
41
RSDK_THIS(ChaosEmerald);
42
43
self->active = ACTIVE_BOUNDS;
44
self->drawGroup = Zone->objectDrawGroup[1];
45
self->originPos = self->position;
46
self->visible = true;
47
self->drawFX = FX_FLIP;
48
self->updateRange.x = 0x800000;
49
self->updateRange.y = 0x800000;
50
self->state = ChaosEmerald_State_None;
51
RSDK.SetSpriteAnimation(ChaosEmerald->aniFrames, 0, &self->animator, true, self->type);
52
}
53
54
void ChaosEmerald_StageLoad(void) { ChaosEmerald->aniFrames = RSDK.LoadSpriteAnimation("Cutscene/Emeralds.bin", SCOPE_STAGE); }
55
56
void ChaosEmerald_State_None(void)
57
{
58
// hello
59
}
60
void ChaosEmerald_State_Rotate(void)
61
{
62
RSDK_THIS(ChaosEmerald);
63
64
self->angle += self->groundVel;
65
self->position.x = self->radius * RSDK.Cos256(self->angle >> 8) + self->originPos.x;
66
self->position.y = self->radius * RSDK.Sin256(self->angle >> 8) + self->originPos.y;
67
}
68
69
#if GAME_INCLUDE_EDITOR
70
void ChaosEmerald_EditorDraw(void)
71
{
72
RSDK_THIS(ChaosEmerald);
73
74
RSDK.SetSpriteAnimation(ChaosEmerald->aniFrames, 0, &self->animator, true, self->type);
75
RSDK.DrawSprite(&self->animator, NULL, false);
76
}
77
78
void ChaosEmerald_EditorLoad(void)
79
{
80
ChaosEmerald->aniFrames = RSDK.LoadSpriteAnimation("Cutscene/Emeralds.bin", SCOPE_STAGE);
81
82
RSDK_ACTIVE_VAR(ChaosEmerald, type);
83
RSDK_ENUM_VAR("Green", CHAOSEMERALD_GREEN);
84
RSDK_ENUM_VAR("Yellow", CHAOSEMERALD_YELLOW);
85
RSDK_ENUM_VAR("Blue", CHAOSEMERALD_BLUE);
86
RSDK_ENUM_VAR("Purple", CHAOSEMERALD_PURPLE);
87
RSDK_ENUM_VAR("Gray", CHAOSEMERALD_GRAY);
88
RSDK_ENUM_VAR("Cyan", CHAOSEMERALD_CYAN);
89
RSDK_ENUM_VAR("Red", CHAOSEMERALD_RED);
90
}
91
#endif
92
93
void ChaosEmerald_Serialize(void) { RSDK_EDITABLE_VAR(ChaosEmerald, VAR_UINT8, type); }
94
95