Path: blob/master/SonicMania/Objects/SSZ/JunctionWheel.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: JunctionWheel Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectJunctionWheel *JunctionWheel;1011void JunctionWheel_Update(void)12{13RSDK_THIS(JunctionWheel);1415if (RSDK_GET_ENTITY((SceneInfo->entitySlot - 1), Button)->currentlyActive)16self->spinDir ^= 1;1718if (self->spinDir)19self->rotation += 4;20else21self->rotation -= 4;2223self->rotation &= 0x1FF;2425int32 direction = ((self->rotation + 48) >> 6) & 7;2627foreach_active(Player, player)28{29if (player->state == Player_State_Static) {30if (Player_CheckCollisionTouch(player, self, &JunctionWheel->hitboxWheelRange)) {31player->position.x = player->groundVel * RSDK.Cos512(self->rotation) + self->position.x;32player->position.y = player->groundVel * RSDK.Sin512(self->rotation) + self->position.y;3334if (player->groundVel < -0x1000)35player->groundVel += 0x200;3637if (player->groundVel == -0x1000) {38if (self->rotation == 0x180) {39player->state = Player_State_Air;40player->tileCollisions = TILECOLLISION_DOWN;41player->groundVel = 0;42player->velocity.x = 0;43player->velocity.y = 0x80000;44player->onGround = false;45RSDK.PlaySfx(Player->sfxRelease, false, 255);46}4748if (self->spinDir == 1 && self->rotation == 0x11C) {49player->state = Player_State_Air;50player->tileCollisions = TILECOLLISION_DOWN;51player->groundVel = 0x80000;52player->velocity.x = 0x80000;53player->velocity.y = 0x40000;54player->onGround = false;55RSDK.PlaySfx(Player->sfxRelease, false, 255);56}57}58}59}60else {61switch (direction) {62case 1:63Player_CheckCollisionBox(player, self, &JunctionWheel->hitboxSolidR);6465if (Player_CheckCollisionTouch(player, self, &JunctionWheel->hitboxEntryR)) {66player->state = Player_State_Static;67RSDK.SetSpriteAnimation(player->aniFrames, ANI_JUMP, &player->animator, false, 0);68player->onGround = false;69player->groundVel = -0x1C00;7071player->tileCollisions = TILECOLLISION_NONE;72player->nextAirState = StateMachine_None;73player->nextGroundState = StateMachine_None;74player->velocity.x = 0;75player->velocity.y = 0;76RSDK.PlaySfx(Player->sfxRoll, false, 255);77}78break;7980case 0:81case 2:82case 3:83case 4:84case 6:85case 7:86if (player->position.y < self->position.y)87Player_CheckCollisionBox(player, self, &JunctionWheel->hitboxSolidL);8889Player_CheckCollisionBox(player, self, &JunctionWheel->hitboxSolidR);90break;9192case 5:93if (player->velocity.x <= 0) {94Player_CheckCollisionBox(player, self, &JunctionWheel->hitboxSolidL);9596if (Player_CheckCollisionTouch(player, self, &JunctionWheel->hitboxEntryL)) {97player->state = Player_State_Static;98RSDK.SetSpriteAnimation(player->aniFrames, ANI_JUMP, &player->animator, false, 0);99100player->onGround = false;101player->groundVel = -0x1800;102103player->tileCollisions = TILECOLLISION_NONE;104player->nextAirState = StateMachine_None;105player->nextGroundState = StateMachine_None;106player->velocity.x = 0;107player->velocity.y = 0;108RSDK.PlaySfx(Player->sfxRoll, false, 255);109}110}111break;112}113114if (player->velocity.y < 0 || (player->onGround && player->collisionMode))115Player_CheckCollisionBox(player, self, &JunctionWheel->hitboxSolidB);116}117}118}119120void JunctionWheel_LateUpdate(void) {}121122void JunctionWheel_StaticUpdate(void) {}123124void JunctionWheel_Draw(void)125{126RSDK_THIS(JunctionWheel);127128RSDK.DrawSprite(&self->slotAnimator, NULL, false);129RSDK.DrawSprite(&self->maskAnimator, NULL, false);130}131132void JunctionWheel_Create(void *data)133{134RSDK_THIS(JunctionWheel);135self->visible = true;136self->drawGroup = Zone->objectDrawGroup[0];137self->active = ACTIVE_BOUNDS;138self->updateRange.x = 0x800000;139self->updateRange.y = 0x800000;140self->drawFX = FX_ROTATE;141142RSDK.SetSpriteAnimation(JunctionWheel->aniFrames, 0, &self->slotAnimator, true, 0);143RSDK.SetSpriteAnimation(JunctionWheel->aniFrames, 1, &self->maskAnimator, true, 0);144}145146void JunctionWheel_StageLoad(void)147{148if (RSDK.CheckSceneFolder("SSZ1"))149JunctionWheel->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/JunctionWheel.bin", SCOPE_STAGE);150151JunctionWheel->hitboxWheelRange.left = -192;152JunctionWheel->hitboxWheelRange.top = -192;153JunctionWheel->hitboxWheelRange.right = 192;154JunctionWheel->hitboxWheelRange.bottom = 192;155156JunctionWheel->hitboxSolidL.left = -40;157JunctionWheel->hitboxSolidL.top = -56;158JunctionWheel->hitboxSolidL.right = -16;159JunctionWheel->hitboxSolidL.bottom = 32;160161JunctionWheel->hitboxSolidR.left = 16;162JunctionWheel->hitboxSolidR.top = -56;163JunctionWheel->hitboxSolidR.right = 40;164JunctionWheel->hitboxSolidR.bottom = 32;165166JunctionWheel->hitboxSolidB.left = -40;167JunctionWheel->hitboxSolidB.top = 32;168JunctionWheel->hitboxSolidB.right = 40;169JunctionWheel->hitboxSolidB.bottom = 56;170171JunctionWheel->hitboxEntryR.left = -40;172JunctionWheel->hitboxEntryR.top = -40;173JunctionWheel->hitboxEntryR.right = -16;174JunctionWheel->hitboxEntryR.bottom = -8;175176JunctionWheel->hitboxEntryL.left = 16;177JunctionWheel->hitboxEntryL.top = 8;178JunctionWheel->hitboxEntryL.right = 38;179JunctionWheel->hitboxEntryL.bottom = 40;180}181182#if GAME_INCLUDE_EDITOR183void JunctionWheel_EditorDraw(void)184{185RSDK_THIS(JunctionWheel);186187JunctionWheel_Draw();188189if (showGizmos()) {190RSDK_DRAWING_OVERLAY(true);191192// May also be something like a SSZ/SDashWheel since Common/Button doesn't exist in SSZ1 object list193EntityButton *button = RSDK_GET_ENTITY(SceneInfo->entitySlot - 1, Button);194195if (button) {196DrawHelpers_DrawArrow(button->position.x, button->position.y, self->position.x, self->position.y, 0xFFFF00, INK_NONE, 0xFF);197}198199RSDK_DRAWING_OVERLAY(false);200}201}202203void JunctionWheel_EditorLoad(void) { JunctionWheel->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/JunctionWheel.bin", SCOPE_STAGE); }204#endif205206void JunctionWheel_Serialize(void) {}207208209