Path: blob/master/SonicMania/Objects/Common/ForceUnstick.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: ForceUnstick Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectForceUnstick *ForceUnstick;1011void ForceUnstick_Update(void)12{13RSDK_THIS(ForceUnstick);1415foreach_active(Player, player)16{17if (Player_CheckCollisionTouch(player, self, &self->hitbox)) {18player->collisionMode = CMODE_FLOOR;1920if (self->breakClimb && player->state == Player_State_KnuxWallClimb) {21RSDK.SetSpriteAnimation(player->aniFrames, ANI_GLIDE_DROP, &player->animator, false, 2);22player->state = Player_State_KnuxGlideDrop;23}24}25}2627self->visible = DebugMode->debugActive;28}2930void ForceUnstick_LateUpdate(void) {}3132void ForceUnstick_StaticUpdate(void) {}3334void ForceUnstick_Draw(void) { ForceUnstick_DrawSprites(); }3536void ForceUnstick_Create(void *data)37{38RSDK_THIS(ForceUnstick);3940if (!SceneInfo->inEditor) {41self->updateRange.x = self->width << 19;42self->updateRange.y = self->height << 19;4344self->hitbox.right = 8 * self->width + 8;45self->hitbox.left = -self->hitbox.right;46self->hitbox.bottom = 8 * self->height + 8;47self->hitbox.top = -self->hitbox.bottom;4849self->visible = false;50self->active = ACTIVE_BOUNDS;51self->drawGroup = Zone->objectDrawGroup[1];52}53}5455void ForceUnstick_StageLoad(void)56{57ForceUnstick->aniFrames = RSDK.LoadSpriteAnimation("Global/ItemBox.bin", SCOPE_STAGE);58RSDK.SetSpriteAnimation(ForceUnstick->aniFrames, 2, &ForceUnstick->animator, true, 6);59}6061void ForceUnstick_DrawSprites(void)62{63RSDK_THIS(ForceUnstick);6465Vector2 drawPos;66drawPos.x = self->position.x - (self->width << 19);67drawPos.y = self->position.y - (self->height << 19);6869ForceUnstick->animator.frameID = self->breakClimb ? 9 : 6;70for (int32 y = 0; y < self->height + 1; ++y) {71for (int32 x = 0; x < self->width + 1; ++x) {72RSDK.DrawSprite(&ForceUnstick->animator, &drawPos, false);73drawPos.x += TO_FIXED(16);74}75drawPos.x += -TO_FIXED(16) - (self->width << 20);76drawPos.y += TO_FIXED(16);77}78}7980#if GAME_INCLUDE_EDITOR81void ForceUnstick_EditorDraw(void) { ForceUnstick_DrawSprites(); }8283void ForceUnstick_EditorLoad(void)84{85ForceUnstick->aniFrames = RSDK.LoadSpriteAnimation("Global/ItemBox.bin", SCOPE_STAGE);86RSDK.SetSpriteAnimation(ForceUnstick->aniFrames, 2, &ForceUnstick->animator, true, 6);87}88#endif8990void ForceUnstick_Serialize(void)91{92RSDK_EDITABLE_VAR(ForceUnstick, VAR_UINT8, width);93RSDK_EDITABLE_VAR(ForceUnstick, VAR_UINT8, height);94RSDK_EDITABLE_VAR(ForceUnstick, VAR_BOOL, breakClimb);95}969798