Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/PGZ/Ink.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: Ink Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectInk *Ink;
11
12
void Ink_Update(void)
13
{
14
RSDK_THIS(Ink);
15
16
RSDK.ProcessAnimation(&self->splashAnimator);
17
18
foreach_active(Player, player)
19
{
20
int32 playerID = RSDK.GetEntitySlot(player);
21
22
Player_CheckCollisionBox(player, self, &Ink->hitboxBottleL);
23
Player_CheckCollisionBox(player, self, &Ink->hitboxBottleR);
24
25
if (Player_CheckCollisionBox(player, self, &Ink->hitboxBottleBottom) == C_TOP) {
26
if (!((1 << playerID) & self->inkedPlayers)) {
27
self->inkedPlayers |= 1 << playerID;
28
29
switch (player->characterID) {
30
default: break;
31
32
// Bug Details:
33
// This actually wont work on sonic specifically, it uses the "old" sonic palette
34
// This palette starts at index 2, instead of index 64 like usual
35
// Fix:
36
// to fix this up to work as "intended", simply replace the "PLAYER_PALETTE_INDEX_SONIC_OLD"s with "PLAYER_PALETTE_INDEX_SONIC"
37
case ID_SONIC:
38
RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_SONIC_OLD, 0, PLAYER_PALETTE_INDEX_SONIC_OLD,
39
PLAYER_PRIMARY_COLOR_COUNT);
40
break;
41
42
case ID_TAILS:
43
RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_TAILS, 0, PLAYER_PALETTE_INDEX_TAILS, PLAYER_PRIMARY_COLOR_COUNT);
44
break;
45
46
case ID_KNUCKLES:
47
RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_KNUX, 0, PLAYER_PALETTE_INDEX_KNUX, 6);
48
break;
49
50
// This is an unused object that was scrapped before plus was created, so there's no mighty/ray code
51
// I've created a mock-up of what mighty/ray code could've looked like, had it been implemented:
52
// case ID_MIGHTY: RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_MIGHTY, 0, PLAYER_PALETTE_INDEX_MIGHTY,
53
// PLAYER_PRIMARY_COLOR_COUNT); break; case ID_RAY: RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_RAY, 0,
54
// PLAYER_PALETTE_INDEX_RAY, PLAYER_PRIMARY_COLOR_COUNT); break;
55
}
56
57
Ink->playerColors[playerID] = 1 + self->type;
58
RSDK.SetSpriteAnimation(Ink->aniFrames, 6 + self->type, &self->splashAnimator, true, 0);
59
}
60
}
61
else {
62
self->inkedPlayers &= ~(1 << playerID);
63
}
64
}
65
}
66
67
void Ink_LateUpdate(void) {}
68
69
void Ink_StaticUpdate(void) {}
70
71
void Ink_Draw(void)
72
{
73
RSDK_THIS(Ink);
74
75
self->inkEffect = INK_SUB;
76
RSDK.DrawSprite(&self->splashAnimator, NULL, false);
77
RSDK.DrawSprite(&self->contentAnimator, NULL, false);
78
79
self->inkEffect = INK_NONE;
80
RSDK.DrawSprite(&self->bottleAnimator, NULL, false);
81
}
82
83
void Ink_Create(void *data)
84
{
85
RSDK_THIS(Ink);
86
87
if (!SceneInfo->inEditor) {
88
self->active = ACTIVE_BOUNDS;
89
self->visible = true;
90
self->drawGroup = Zone->objectDrawGroup[0];
91
self->alpha = 0x180;
92
self->updateRange.x = 0x800000;
93
self->updateRange.y = 0x800000;
94
RSDK.SetSpriteAnimation(Ink->aniFrames, self->type, &self->bottleAnimator, true, 0);
95
RSDK.SetSpriteAnimation(Ink->aniFrames, self->type + 3, &self->contentAnimator, true, 0);
96
}
97
}
98
99
void Ink_StageLoad(void)
100
{
101
if (RSDK.CheckSceneFolder("PSZ1"))
102
Ink->aniFrames = RSDK.LoadSpriteAnimation("PSZ1/Ink.bin", SCOPE_STAGE);
103
104
Ink->hitboxBottleL.left = -24;
105
Ink->hitboxBottleL.top = -30;
106
Ink->hitboxBottleL.right = -16;
107
Ink->hitboxBottleL.bottom = 30;
108
109
Ink->hitboxBottleR.left = 16;
110
Ink->hitboxBottleR.top = -30;
111
Ink->hitboxBottleR.right = 24;
112
Ink->hitboxBottleR.bottom = 30;
113
114
Ink->hitboxBottleBottom.left = -24;
115
Ink->hitboxBottleBottom.top = 26;
116
Ink->hitboxBottleBottom.right = 24;
117
Ink->hitboxBottleBottom.bottom = 30;
118
119
for (int32 p = 0; p < PLAYER_COUNT; ++p) Ink->playerColors[p] = 0;
120
}
121
122
#if GAME_INCLUDE_EDITOR
123
void Ink_EditorDraw(void)
124
{
125
RSDK_THIS(Ink);
126
127
self->alpha = 0x180;
128
self->updateRange.x = 0x800000;
129
self->updateRange.y = 0x800000;
130
RSDK.SetSpriteAnimation(Ink->aniFrames, self->type, &self->bottleAnimator, true, 0);
131
RSDK.SetSpriteAnimation(Ink->aniFrames, self->type + 3, &self->contentAnimator, true, 0);
132
133
Ink_Draw();
134
}
135
136
void Ink_EditorLoad(void)
137
{
138
Ink->aniFrames = RSDK.LoadSpriteAnimation("PSZ1/Ink.bin", SCOPE_STAGE);
139
140
RSDK_ACTIVE_VAR(Ink, type);
141
RSDK_ENUM_VAR("Cyan", INK_C);
142
RSDK_ENUM_VAR("Magenta", INK_M);
143
RSDK_ENUM_VAR("Yellow", INK_Y);
144
}
145
#endif
146
147
void Ink_Serialize(void) { RSDK_EDITABLE_VAR(Ink, VAR_UINT8, type); }
148
149