Path: blob/master/SonicMania/Objects/Global/ImageTrail.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: ImageTrail Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectImageTrail *ImageTrail;1011void ImageTrail_Update(void) {}1213void ImageTrail_LateUpdate(void)14{15RSDK_THIS(ImageTrail);1617EntityPlayer *player = self->player;1819if (!player || (player->classID != self->playerClassID && player->classID != DebugMode->classID)) {20destroyEntity(self);21}22else {23// Check for fadeouts/destroy triggers24if (player->superState == SUPERSTATE_SUPER) {25self->baseAlpha = 0x100;26}27#if MANIA_USE_PLUS28else if (player->speedShoesTimer < 16 && player->state == Player_State_MightyHammerDrop) {29self->fadeoutTimer = 16;30}31#endif32else if (self->fadeoutTimer <= 0 && player->speedShoesTimer < 32) {33self->baseAlpha = 8 * player->speedShoesTimer;34if (!self->baseAlpha)35destroyEntity(self);36}37else if (self->fadeoutTimer > 0) {38self->fadeoutTimer--;39self->baseAlpha = 16 * self->fadeoutTimer;40if (!self->baseAlpha)41destroyEntity(self);42}43}4445// if we destroyed this entity, skip any more logic46if (!self->classID)47return;4849// Update recordings50for (int32 i = IMAGETRAIL_TRACK_COUNT - 1; i > 0; --i) {51self->statePos[i].x = self->statePos[i - 1].x;52self->statePos[i].y = self->statePos[i - 1].y;53self->stateRotation[i] = self->stateRotation[i - 1];54self->stateScale[i] = self->stateScale[i - 1];55self->stateDirection[i] = self->stateDirection[i - 1];56self->stateVisible[i] = self->stateVisible[i - 1];57memcpy(&self->stateAnimator[i], &self->stateAnimator[i - 1], sizeof(Animator));58}5960self->statePos[0].x = self->currentPos.x;61self->statePos[0].y = self->currentPos.y;62self->stateRotation[0] = self->currentRotation;63self->stateDirection[0] = self->currentDirection;64self->stateScale[0] = self->currentScale;65self->stateVisible[0] = self->currentVisible;66memcpy(&self->stateAnimator[0], &self->currentAnimator, sizeof(Animator));6768// Record Player69self->drawGroup = player->drawGroup - 1;70self->currentPos.x = player->position.x;71self->currentPos.y = player->position.y;72self->currentRotation = player->rotation;73self->currentDirection = player->direction;74memcpy(&self->currentAnimator, &player->animator, sizeof(Animator));75if (player->isChibi || !(player->drawFX & FX_SCALE))76self->currentScale = 0x200;77else78self->currentScale = player->scale.x;7980// Check if we have enough speed to be visible81if (abs(player->velocity.x) >= TO_FIXED(1) || abs(player->velocity.y) >= TO_FIXED(1))82self->currentVisible = player->visible;83else84self->currentVisible = false;85}8687void ImageTrail_StaticUpdate(void) {}8889void ImageTrail_Draw(void)90{91RSDK_THIS(ImageTrail);9293// int32 alpha[3] = { 0xA0 * self->baseAlpha >> 8, self->baseAlpha >> 1, 0x60 * self->baseAlpha >> 8 };94int32 alpha = 0x60 * self->baseAlpha >> 8;95int32 inc = 0x40 / (IMAGETRAIL_TRACK_COUNT / 3);9697for (int32 i = (IMAGETRAIL_TRACK_COUNT / 3); i >= 0; --i) {98int32 id = (i * 3) - (i - 1);99if (self->stateVisible[id]) {100if (self->stateScale[id] != 0x200) {101self->drawFX |= FX_SCALE;102self->scale.x = self->stateScale[id];103self->scale.y = self->stateScale[id];104}105self->alpha = alpha;106alpha += inc;107self->rotation = self->stateRotation[id];108self->direction = self->stateDirection[id];109RSDK.DrawSprite(&self->stateAnimator[id], &self->statePos[id], false);110self->drawFX &= ~FX_SCALE;111}112}113}114115void ImageTrail_Create(void *data)116{117RSDK_THIS(ImageTrail);118119if (!SceneInfo->inEditor) {120EntityPlayer *player = (EntityPlayer *)data;121self->active = ACTIVE_ALWAYS;122self->visible = true;123self->player = player;124self->playerClassID = player->classID; // dunno what this is for, maybe a v4 leftover where frames were per-object?125self->baseAlpha = 0x100;126self->drawFX = FX_FLIP | FX_SCALE | FX_ROTATE;127self->inkEffect = INK_ALPHA;128129for (int32 i = IMAGETRAIL_TRACK_COUNT - 1; i >= 0; --i) {130self->statePos[i].x = player->position.x;131self->statePos[i].y = player->position.y;132self->stateRotation[i] = player->rotation;133self->stateDirection[i] = player->direction;134self->stateVisible[i] = false;135}136}137}138139void ImageTrail_StageLoad(void) {}140141#if GAME_INCLUDE_EDITOR142void ImageTrail_EditorDraw(void) {}143144void ImageTrail_EditorLoad(void) {}145#endif146147void ImageTrail_Serialize(void) {}148149150