Path: blob/master/SonicMania/Objects/UFO/UFO_Dust.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: UFO_Dust Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectUFO_Dust *UFO_Dust;1011void UFO_Dust_Update(void) {}1213void UFO_Dust_LateUpdate(void)14{15RSDK_THIS(UFO_Dust);1617RSDK.ProcessAnimation(&self->animator);1819if (self->animator.frameID == self->animator.frameCount - 1) {20destroyEntity(self);21}22else {23int32 x = self->position.x >> 8;24int32 y = self->height >> 8;25int32 z = self->position.y >> 8;2627Matrix *mat = &UFO_Camera->matWorld;2829self->worldX = mat->values[0][3] + (y * mat->values[0][1] >> 8) + (z * mat->values[0][2] >> 8) + (x * mat->values[0][0] >> 8);30self->worldY = mat->values[1][3] + (y * mat->values[1][1] >> 8) + (z * mat->values[1][2] >> 8) + (x * mat->values[1][0] >> 8);31self->zdepth = mat->values[2][3] + (y * mat->values[2][1] >> 8) + (z * mat->values[2][2] >> 8) + (x * mat->values[2][0] >> 8);32}33}3435void UFO_Dust_StaticUpdate(void) {}3637void UFO_Dust_Draw(void)38{39RSDK_THIS(UFO_Dust);4041if (self->zdepth >= 0x400) {42Vector2 drawPos;43drawPos.x = (ScreenInfo->center.x + (self->worldX << 8) / self->zdepth) << 16;44drawPos.y = (ScreenInfo->center.y - (self->worldY << 8) / self->zdepth) << 16;4546self->scale.x = 0x1000000 / self->zdepth;47self->scale.y = 0x1000000 / self->zdepth;48RSDK.DrawSprite(&self->animator, &drawPos, true);49}50}5152void UFO_Dust_Create(void *data)53{54RSDK_THIS(UFO_Dust);5556if (!SceneInfo->inEditor) {57self->visible = true;58self->drawFX = FX_SCALE | FX_FLIP;59self->drawGroup = 4;60self->active = ACTIVE_RBOUNDS;61self->updateRange.x = 0x400;62self->updateRange.y = 0x400;6364self->position.x += RSDK.Rand(-0x80000, 0x80000);65self->position.y += RSDK.Rand(-0x80000, 0x80000);66self->height = RSDK.Rand(0x40000, 0x100000);6768RSDK.SetSpriteAnimation(UFO_Dust->aniFrames, 0, &self->animator, true, 0);69}70}7172void UFO_Dust_StageLoad(void) { UFO_Dust->aniFrames = RSDK.LoadSpriteAnimation("SpecialUFO/Dust.bin", SCOPE_STAGE); }7374#if GAME_INCLUDE_EDITOR75void UFO_Dust_EditorDraw(void) {}7677void UFO_Dust_EditorLoad(void) {}78#endif7980void UFO_Dust_Serialize(void) { RSDK_EDITABLE_VAR(UFO_Dust, VAR_ENUM, height); }818283