Path: blob/master/SonicMania/Objects/FBZ/LightBarrier.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: LightBarrier Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectLightBarrier *LightBarrier;1011void LightBarrier_Update(void) {}1213void LightBarrier_LateUpdate(void)14{15RSDK_THIS(LightBarrier);1617if (self->enabled) {18if (self->barrierAlpha < 0xA0)19self->barrierAlpha += 4;2021foreach_active(Player, player)22{23if (self->position.x > (ScreenInfo->position.x + ScreenInfo->center.x) << 16 || player->velocity.x < 0)24Player_CheckCollisionBox(player, self, &self->hitboxBarrier);25}2627self->timer = (self->timer + 2) & 0x3F;28self->alpha = self->barrierAlpha + (RSDK.Sin256(2 * Zone->timer) >> 3);29}30}3132void LightBarrier_StaticUpdate(void) {}3334void LightBarrier_Draw(void)35{36RSDK_THIS(LightBarrier);3738Vector2 drawPos = self->position;39self->inkEffect = INK_NONE;40self->direction = FLIP_NONE;4142drawPos.y += self->size << 15;43RSDK.DrawSprite(&self->emitterAnimator, &drawPos, false);4445drawPos.y -= self->size << 16;46self->direction = FLIP_Y;47RSDK.DrawSprite(&self->emitterAnimator, &drawPos, false);4849self->direction = FLIP_NONE;50if (self->enabled) {51self->inkEffect = INK_ADD;52int32 timer = self->timer;53SpriteFrame *frame = RSDK.GetFrame(LightBarrier->aniFrames, 0, 1);54drawPos.y += 0x80000;5556int32 size = self->size - 8;57for (int32 i = 8; i < size;) {58int32 height = 64 - timer;59if (64 - timer + i > size)60height = size - i;6162frame->sprY = timer + (self->sprY & 0xFFFF);63frame->height = height;64RSDK.DrawSprite(&self->barrierAnimator, &drawPos, false);6566i += height;67drawPos.y += height << 16;68timer = (timer + height) & 0x3F;69}70}71}7273void LightBarrier_Create(void *data)74{75RSDK_THIS(LightBarrier);7677self->drawFX = FX_FLIP;78if (!SceneInfo->inEditor) {79self->active = ACTIVE_BOUNDS;80self->visible = true;81self->drawGroup = Zone->objectDrawGroup[1];82self->updateRange.x = 0x800000;83self->updateRange.y = self->size << 15;8485RSDK.SetSpriteAnimation(LightBarrier->aniFrames, 0, &self->emitterAnimator, true, 0);86RSDK.SetSpriteAnimation(LightBarrier->aniFrames, 0, &self->barrierAnimator, true, 1);87SpriteFrame *frame = RSDK.GetFrame(LightBarrier->aniFrames, 0, 1);88self->sprY = frame->sprY;8990self->hitboxBarrier.left = -8;91self->hitboxBarrier.top = -(self->size >> 1);92self->hitboxBarrier.right = 8;93self->hitboxBarrier.bottom = self->size >> 1;9495if (self->enabled)96self->barrierAlpha = 0xA0;97}98}99100void LightBarrier_StageLoad(void) { LightBarrier->aniFrames = RSDK.LoadSpriteAnimation("FBZ/LightBarrier.bin", SCOPE_STAGE); }101102#if GAME_INCLUDE_EDITOR103void LightBarrier_EditorDraw(void)104{105RSDK_THIS(LightBarrier);106self->alpha = 0xA0;107108self->updateRange.x = 0x800000;109self->updateRange.y = self->size << 15;110111RSDK.SetSpriteAnimation(LightBarrier->aniFrames, 0, &self->emitterAnimator, true, 0);112RSDK.SetSpriteAnimation(LightBarrier->aniFrames, 0, &self->barrierAnimator, true, 1);113SpriteFrame *frame = RSDK.GetFrame(LightBarrier->aniFrames, 0, 1);114self->sprY = frame->sprY;115116LightBarrier_Draw();117118frame->sprY = self->sprY;119}120121void LightBarrier_EditorLoad(void) { LightBarrier->aniFrames = RSDK.LoadSpriteAnimation("FBZ/LightBarrier.bin", SCOPE_STAGE); }122#endif123124void LightBarrier_Serialize(void)125{126RSDK_EDITABLE_VAR(LightBarrier, VAR_ENUM, size);127RSDK_EDITABLE_VAR(LightBarrier, VAR_BOOL, enabled);128}129130131