Path: blob/master/SonicMania/Objects/PGZ/Ink.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: Ink Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectInk *Ink;1011void Ink_Update(void)12{13RSDK_THIS(Ink);1415RSDK.ProcessAnimation(&self->splashAnimator);1617foreach_active(Player, player)18{19int32 playerID = RSDK.GetEntitySlot(player);2021Player_CheckCollisionBox(player, self, &Ink->hitboxBottleL);22Player_CheckCollisionBox(player, self, &Ink->hitboxBottleR);2324if (Player_CheckCollisionBox(player, self, &Ink->hitboxBottleBottom) == C_TOP) {25if (!((1 << playerID) & self->inkedPlayers)) {26self->inkedPlayers |= 1 << playerID;2728switch (player->characterID) {29default: break;3031// Bug Details:32// This actually wont work on sonic specifically, it uses the "old" sonic palette33// This palette starts at index 2, instead of index 64 like usual34// Fix:35// to fix this up to work as "intended", simply replace the "PLAYER_PALETTE_INDEX_SONIC_OLD"s with "PLAYER_PALETTE_INDEX_SONIC"36case ID_SONIC:37RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_SONIC_OLD, 0, PLAYER_PALETTE_INDEX_SONIC_OLD,38PLAYER_PRIMARY_COLOR_COUNT);39break;4041case ID_TAILS:42RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_TAILS, 0, PLAYER_PALETTE_INDEX_TAILS, PLAYER_PRIMARY_COLOR_COUNT);43break;4445case ID_KNUCKLES:46RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_KNUX, 0, PLAYER_PALETTE_INDEX_KNUX, 6);47break;4849// This is an unused object that was scrapped before plus was created, so there's no mighty/ray code50// I've created a mock-up of what mighty/ray code could've looked like, had it been implemented:51// case ID_MIGHTY: RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_MIGHTY, 0, PLAYER_PALETTE_INDEX_MIGHTY,52// PLAYER_PRIMARY_COLOR_COUNT); break; case ID_RAY: RSDK.CopyPalette(3 + self->type, PLAYER_PALETTE_INDEX_RAY, 0,53// PLAYER_PALETTE_INDEX_RAY, PLAYER_PRIMARY_COLOR_COUNT); break;54}5556Ink->playerColors[playerID] = 1 + self->type;57RSDK.SetSpriteAnimation(Ink->aniFrames, 6 + self->type, &self->splashAnimator, true, 0);58}59}60else {61self->inkedPlayers &= ~(1 << playerID);62}63}64}6566void Ink_LateUpdate(void) {}6768void Ink_StaticUpdate(void) {}6970void Ink_Draw(void)71{72RSDK_THIS(Ink);7374self->inkEffect = INK_SUB;75RSDK.DrawSprite(&self->splashAnimator, NULL, false);76RSDK.DrawSprite(&self->contentAnimator, NULL, false);7778self->inkEffect = INK_NONE;79RSDK.DrawSprite(&self->bottleAnimator, NULL, false);80}8182void Ink_Create(void *data)83{84RSDK_THIS(Ink);8586if (!SceneInfo->inEditor) {87self->active = ACTIVE_BOUNDS;88self->visible = true;89self->drawGroup = Zone->objectDrawGroup[0];90self->alpha = 0x180;91self->updateRange.x = 0x800000;92self->updateRange.y = 0x800000;93RSDK.SetSpriteAnimation(Ink->aniFrames, self->type, &self->bottleAnimator, true, 0);94RSDK.SetSpriteAnimation(Ink->aniFrames, self->type + 3, &self->contentAnimator, true, 0);95}96}9798void Ink_StageLoad(void)99{100if (RSDK.CheckSceneFolder("PSZ1"))101Ink->aniFrames = RSDK.LoadSpriteAnimation("PSZ1/Ink.bin", SCOPE_STAGE);102103Ink->hitboxBottleL.left = -24;104Ink->hitboxBottleL.top = -30;105Ink->hitboxBottleL.right = -16;106Ink->hitboxBottleL.bottom = 30;107108Ink->hitboxBottleR.left = 16;109Ink->hitboxBottleR.top = -30;110Ink->hitboxBottleR.right = 24;111Ink->hitboxBottleR.bottom = 30;112113Ink->hitboxBottleBottom.left = -24;114Ink->hitboxBottleBottom.top = 26;115Ink->hitboxBottleBottom.right = 24;116Ink->hitboxBottleBottom.bottom = 30;117118for (int32 p = 0; p < PLAYER_COUNT; ++p) Ink->playerColors[p] = 0;119}120121#if GAME_INCLUDE_EDITOR122void Ink_EditorDraw(void)123{124RSDK_THIS(Ink);125126self->alpha = 0x180;127self->updateRange.x = 0x800000;128self->updateRange.y = 0x800000;129RSDK.SetSpriteAnimation(Ink->aniFrames, self->type, &self->bottleAnimator, true, 0);130RSDK.SetSpriteAnimation(Ink->aniFrames, self->type + 3, &self->contentAnimator, true, 0);131132Ink_Draw();133}134135void Ink_EditorLoad(void)136{137Ink->aniFrames = RSDK.LoadSpriteAnimation("PSZ1/Ink.bin", SCOPE_STAGE);138139RSDK_ACTIVE_VAR(Ink, type);140RSDK_ENUM_VAR("Cyan", INK_C);141RSDK_ENUM_VAR("Magenta", INK_M);142RSDK_ENUM_VAR("Yellow", INK_Y);143}144#endif145146void Ink_Serialize(void) { RSDK_EDITABLE_VAR(Ink, VAR_UINT8, type); }147148149