Path: blob/master/SonicMania/Objects/FBZ/FoldingPlatform.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: FoldingPlatform Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectFoldingPlatform *FoldingPlatform;1011void FoldingPlatform_Update(void)12{13RSDK_THIS(FoldingPlatform);1415int32 timer = (Zone->timer + self->intervalOffset) % self->interval;1617if (timer >= self->duration) {18if (timer >= self->duration + 8) {19self->animator.frameID = 0;20}21else {22self->active = ACTIVE_NORMAL;23self->timer = timer - self->duration;24self->state = FoldingPlatform_State_Disappear;25self->animator.frameID = 4 - ((timer - self->duration) >> 1);26}27}28else {29self->active = ACTIVE_NORMAL;30self->timer = timer;31if (timer > 8)32self->animator.frameID = 4;33else34self->animator.frameID = timer >> 1;35self->state = FoldingPlatform_State_Appear;36}3738if (self->animator.frameID == 4) {39self->stateCollide = Platform_Collision_Platform;40self->collision = PLATFORM_C_PLATFORM;41}42else {43self->stateCollide = Platform_Collision_None;44self->collision = PLATFORM_C_NONE;45}4647Platform_Update();48}4950void FoldingPlatform_LateUpdate(void) {}5152void FoldingPlatform_StaticUpdate(void) {}5354void FoldingPlatform_Draw(void)55{56RSDK_THIS(FoldingPlatform);5758RSDK.DrawSprite(&self->animator, &self->drawPos, false);59}6061void FoldingPlatform_Create(void *data)62{63RSDK_THIS(FoldingPlatform);6465if (!self->interval)66self->interval = 480;6768if (!self->duration)69self->duration = 240;7071self->collision = PLATFORM_C_PLATFORM;72Platform_Create(NULL);7374RSDK.SetSpriteAnimation(Platform->aniFrames, 2, &self->animator, true, 0);75self->drawFX = FX_FLIP;76self->scale.x = 0x000;77self->scale.y = 0x200;78self->state = Platform_State_Fixed;79}8081void FoldingPlatform_StageLoad(void) {}8283void FoldingPlatform_State_Appear(void)84{85RSDK_THIS(FoldingPlatform);8687if (!(++self->timer & 1)) {88if (self->animator.frameID < 4)89self->animator.frameID++;90}9192if (self->timer == self->duration)93self->state = FoldingPlatform_State_Disappear;94}9596void FoldingPlatform_State_Disappear(void)97{98RSDK_THIS(FoldingPlatform);99100--self->timer;101if (!(self->timer & 1)) {102if (self->animator.frameID > 0) {103self->animator.frameID--;104}105}106107if (!self->animator.frameID) {108self->active = ACTIVE_BOUNDS;109self->state = Platform_State_Fixed;110}111}112113#if GAME_INCLUDE_EDITOR114void FoldingPlatform_EditorDraw(void)115{116RSDK_THIS(FoldingPlatform);117RSDK.SetSpriteAnimation(Platform->aniFrames, 2, &self->animator, true, 4);118self->drawPos = self->position;119120FoldingPlatform_Draw();121}122123void FoldingPlatform_EditorLoad(void)124{125RSDK_ACTIVE_VAR(FoldingPlatform, direction);126RSDK_ENUM_VAR("Right", FLIP_NONE);127RSDK_ENUM_VAR("Left", FLIP_X);128}129#endif130131void FoldingPlatform_Serialize(void)132{133RSDK_EDITABLE_VAR(FoldingPlatform, VAR_ENUM, childCount);134RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, interval);135RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, intervalOffset);136RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT8, direction);137RSDK_EDITABLE_VAR(FoldingPlatform, VAR_UINT16, duration);138}139140141