Path: blob/master/SonicMania/Objects/UFO/UFO_SpeedLines.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: UFO_SpeedLines Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectUFO_SpeedLines *UFO_SpeedLines;1011void UFO_SpeedLines_Update(void) {}1213void UFO_SpeedLines_LateUpdate(void)14{15RSDK_THIS(UFO_SpeedLines);1617EntityUFO_Player *player = RSDK_GET_ENTITY(SLOT_PLAYER1, UFO_Player);1819if (UFO_Setup->machLevel > 1 && player->groundVel > 0xC0000) {20self->visible = true;2122for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {23if (self->lineAlpha[l] < 0x100)24self->lineAlpha[l] += 0x20;2526if (self->lineX[l] >= player->position.x - 0x800000) {27if (self->lineX[l] > 0x800000 + player->position.x) {28self->lineX[l] -= 0x1000000;29self->lineAlpha[l] = 0;30}31}32else {33self->lineX[l] += 0x1000000;34self->lineAlpha[l] = 0;35}3637if (self->lineZ[l] < player->position.y - 0x800000) {38self->lineZ[l] += 0x1000000;39self->lineAlpha[l] = 0;40}41else if (self->lineZ[l] > 0x800000 + player->position.y) {42self->lineZ[l] -= 0x1000000;43self->lineAlpha[l] = 0;44}45}46}47else {48for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {49if (self->lineAlpha[l] <= 0)50self->visible = false;51else52self->lineAlpha[l] -= 8;53}54}55}5657void UFO_SpeedLines_StaticUpdate(void) {}5859void UFO_SpeedLines_Draw(void)60{61RSDK_THIS(UFO_SpeedLines);6263Matrix *m = &UFO_Camera->matWorld;6465for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {66int32 x = self->lineX[l] >> 8;67int32 y = self->lineY[l] >> 8;68int32 z = self->lineZ[l] >> 8;6970int32 depth = m->values[2][3] + (y * m->values[2][1] >> 8) + (z * m->values[2][2] >> 8) + (x * m->values[2][0] >> 8);71if (depth >= 0x400) {72int32 drawY = m->values[1][3] + (y * m->values[1][1] >> 8) + (z * m->values[1][2] >> 8) + (x * m->values[1][0] >> 8);73int32 drawX = m->values[0][3] + (y * m->values[0][1] >> 8) + (z * m->values[0][2] >> 8) + (x * m->values[0][0] >> 8);7475RSDK.DrawLine(ScreenInfo->center.x + (drawX << 8) / depth, ScreenInfo->center.y - (drawY << 8) / depth,76ScreenInfo->center.x + (drawX << 8) / (depth + 0x2000), ScreenInfo->center.y - (drawY << 8) / (depth + 0x2000), 0xD0E0F0,77self->lineAlpha[l], INK_ALPHA, true);78}79}80}8182void UFO_SpeedLines_Create(void *data)83{84RSDK_THIS(UFO_SpeedLines);85if (!SceneInfo->inEditor) {86self->visible = true;87self->drawFX = FX_SCALE | FX_FLIP;88self->drawGroup = 5;89self->active = ACTIVE_NORMAL;9091EntityUFO_Player *player = RSDK_GET_ENTITY(SLOT_PLAYER1, UFO_Player);9293for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {94self->lineX[l] = player->position.x + RSDK.Rand(-0x800000, 0x800000);95self->lineY[l] = RSDK.Rand(0x100000, 0x1000000);96self->lineZ[l] = player->position.y + RSDK.Rand(-0x800000, 0x800000);97}98}99}100101void UFO_SpeedLines_StageLoad(void) { RSDK.ResetEntitySlot(SLOT_UFO_SPEEDLINES, UFO_SpeedLines->classID, NULL); }102103#if GAME_INCLUDE_EDITOR104void UFO_SpeedLines_EditorDraw(void) {}105106void UFO_SpeedLines_EditorLoad(void) {}107#endif108109void UFO_SpeedLines_Serialize(void) {}110111112