Path: blob/master/SonicMania/Objects/TMZ/TMZBarrier.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: TMZBarrier Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectTMZBarrier *TMZBarrier;1011void TMZBarrier_Update(void)12{13RSDK_THIS(TMZBarrier);1415if (self->cleared) {16TMZBarrier->clearedBarriers |= 1 << self->iD;1718if (self->type)19RSDK.CopyTileLayer(Zone->fgLayer[0], self->position.x >> 20, self->position.y >> 20, Zone->moveLayer, 59, 32, 2, 4);20else21RSDK.CopyTileLayer(Zone->fgLayer[0], self->position.x >> 20, self->position.y >> 20, Zone->moveLayer, 56, 32, 2, 9);2223destroyEntity(self);24}25}2627void TMZBarrier_LateUpdate(void) {}2829void TMZBarrier_StaticUpdate(void)30{31globals->tempFlags = TMZBarrier->clearedBarriers;3233if (TMZBarrier->postID != StarPost->postIDs[0]) {34TMZBarrier->postID = StarPost->postIDs[0];35globals->restartFlags = TMZBarrier->clearedBarriers;36}37}3839void TMZBarrier_Draw(void) {}4041void TMZBarrier_Create(void *data)42{43RSDK_THIS(TMZBarrier);4445if (!SceneInfo->inEditor)46self->active = ACTIVE_NORMAL;47}4849void TMZBarrier_StageLoad(void)50{51if (SceneInfo->minutes || SceneInfo->seconds || SceneInfo->milliseconds) {52if (SceneInfo->minutes != globals->tempMinutes || SceneInfo->seconds != globals->tempSeconds53|| SceneInfo->milliseconds != globals->tempMilliseconds) {54TMZBarrier->clearedBarriers = globals->restartFlags;55}56else {57TMZBarrier->clearedBarriers = globals->tempFlags;58}5960TMZBarrier->postID = StarPost->postIDs[0];61foreach_all(TMZBarrier, barrier)62{63if ((1 << barrier->iD) & TMZBarrier->clearedBarriers) {64if (barrier->type)65RSDK.CopyTileLayer(Zone->fgLayer[0], barrier->position.x >> 20, barrier->position.y >> 20, Zone->moveLayer, 59, 32, 2, 4);66else67RSDK.CopyTileLayer(Zone->fgLayer[0], barrier->position.x >> 20, barrier->position.y >> 20, Zone->moveLayer, 56, 32, 2, 9);6869destroyEntity(barrier);70}71}72}73else {74TMZBarrier->postID = 0;75TMZBarrier->clearedBarriers = 0;7677globals->restartFlags = 0;78globals->tempFlags = 0;79}80}8182#if GAME_INCLUDE_EDITOR83void TMZBarrier_EditorDraw(void)84{85RSDK_THIS(TMZBarrier);8687Animator animator;88RSDK.SetSpriteAnimation(TMZBarrier->postID, 0, &animator, true, self->type ? 3 : 4);8990RSDK.DrawSprite(&animator, NULL, false);9192if (showGizmos()) {93EntityWarpDoor *taggedDoor = NULL;94foreach_all(WarpDoor, door)95{96if (door->tag == self->warpTag) {97taggedDoor = door;98foreach_break;99}100}101102if (taggedDoor) {103RSDK_DRAWING_OVERLAY(true);104if (taggedDoor) {105DrawHelpers_DrawArrow(taggedDoor->position.x, taggedDoor->position.y, self->position.x, self->position.y, 0xFFFF00, INK_NONE, 0xFF);106}107RSDK_DRAWING_OVERLAY(false);108}109}110}111112void TMZBarrier_EditorLoad(void)113{114// borrowing this for "aniFrames" storage115TMZBarrier->postID = RSDK.LoadSpriteAnimation("TMZ1/Platform.bin", SCOPE_STAGE);116117RSDK_ACTIVE_VAR(TMZBarrier, type);118RSDK_ENUM_VAR("Long", TMZBARRIER_LONG);119RSDK_ENUM_VAR("Short", TMZBARRIER_SHORT);120121RSDK_ACTIVE_VAR(TMZBarrier, iD);122RSDK_ENUM_VAR("Barrier 1", 0);123RSDK_ENUM_VAR("Barrier 2", 1);124RSDK_ENUM_VAR("Barrier 3", 2);125RSDK_ENUM_VAR("Barrier 4", 3);126}127#endif128129void TMZBarrier_Serialize(void)130{131RSDK_EDITABLE_VAR(TMZBarrier, VAR_UINT8, type);132RSDK_EDITABLE_VAR(TMZBarrier, VAR_UINT8, warpTag);133RSDK_EDITABLE_VAR(TMZBarrier, VAR_UINT8, iD);134}135136137