Path: blob/master/SonicMania/Objects/Common/TilePlatform.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: TilePlatform Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectTilePlatform *TilePlatform;1011void TilePlatform_Update(void) { Platform_Update(); }1213void TilePlatform_LateUpdate(void) {}1415void TilePlatform_StaticUpdate(void) {}1617void TilePlatform_Draw(void)18{19RSDK_THIS(TilePlatform);2021RSDK.DrawTile(self->tiles, self->size.x >> 20, self->size.y >> 20, &self->drawPos, NULL, false);22}2324void TilePlatform_Create(void *data)25{26RSDK_THIS(TilePlatform);27self->collision = PLATFORM_C_TILED;28Platform_Create(NULL);2930if (!SceneInfo->inEditor) {31self->updateRange.x += 2 * self->size.x;32self->updateRange.y += 2 * self->size.y;3334self->hitbox.left = -(self->size.x >> 17);35self->hitbox.top = -(self->size.y >> 17);36self->hitbox.right = self->size.x >> 17;37self->hitbox.bottom = self->size.y >> 17;3839self->size.x += 0x80000;40self->size.y += 0x80000;41int32 originX = (self->targetPos.x >> 20) - (self->size.x >> 21);42int32 originY = (self->targetPos.y >> 20) - (self->size.y >> 21);4344int32 h = self->size.y >> 20;45int32 w = self->size.x >> 20;4647int32 id = 0;48if ((self->size.y & 0xFFF00000) > 0) {49for (int32 y = 0; y < h; ++y) {50if ((self->size.x & 0xFFF00000) > 0) {51for (int32 x = 0; x < w; ++x) {52id = x + y * (self->size.x >> 20);53self->tiles[id] = RSDK.GetTile(Zone->moveLayer, originX + x, originY + y);54}55}56}57}58}59}6061void TilePlatform_StageLoad(void) {}6263#if GAME_INCLUDE_EDITOR64void TilePlatform_EditorDraw(void)65{66RSDK_THIS(TilePlatform);6768DrawHelpers_DrawRectOutline(self->position.x, self->position.y, self->size.x, self->size.y, 0xFFFF00);6970if (showGizmos()) {71RSDK_DRAWING_OVERLAY(true);7273DrawHelpers_DrawRectOutline(self->targetPos.x, self->targetPos.y, self->size.x, self->size.y, 0xFFFF00);7475DrawHelpers_DrawArrow(self->targetPos.x, self->targetPos.y, self->position.x, self->position.y, 0xFFFF00, INK_NONE, 0xFF);7677RSDK_DRAWING_OVERLAY(false);78}79}8081void TilePlatform_EditorLoad(void)82{8384RSDK_ACTIVE_VAR(TilePlatform, type);85RSDK_ENUM_VAR("Fixed", PLATFORM_FIXED);86RSDK_ENUM_VAR("Fall", PLATFORM_FALL);87RSDK_ENUM_VAR("Linear", PLATFORM_LINEAR);88RSDK_ENUM_VAR("Circular", PLATFORM_CIRCULAR);89RSDK_ENUM_VAR("Swing", PLATFORM_SWING);90RSDK_ENUM_VAR("Path", PLATFORM_PATH);91RSDK_ENUM_VAR("Push", PLATFORM_PUSH);92}93#endif9495void TilePlatform_Serialize(void)96{97RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, type);98RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, amplitude);99RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, speed);100RSDK_EDITABLE_VAR(TilePlatform, VAR_BOOL, hasTension);101RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, targetPos);102RSDK_EDITABLE_VAR(TilePlatform, VAR_ENUM, childCount);103RSDK_EDITABLE_VAR(TilePlatform, VAR_VECTOR2, size);104RSDK_EDITABLE_VAR(TilePlatform, VAR_INT32, angle);105}106107108