Path: blob/master/SonicMania/Objects/Global/Dust.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: Dust Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectDust *Dust;1011void Dust_Update(void) {}1213void Dust_LateUpdate(void)14{15RSDK_THIS(Dust);1617StateMachine_Run(self->state);18}1920void Dust_StaticUpdate(void) {}2122void Dust_Draw(void)23{24RSDK_THIS(Dust);2526RSDK.DrawSprite(&self->animator, NULL, false);27}2829void Dust_Create(void *data)30{31RSDK_THIS(Dust);3233RSDK.SetSpriteAnimation(Dust->aniFrames, 0, &self->animator, true, 0);3435if (!SceneInfo->inEditor) {36self->active = ACTIVE_NORMAL;37self->visible = true;38self->drawFX = FX_FLIP | FX_ROTATE;39self->drawGroup = Zone->objectDrawGroup[1];40self->parent = (Entity *)data;41}42}4344void Dust_StageLoad(void) { Dust->aniFrames = RSDK.LoadSpriteAnimation("Global/Dust.bin", SCOPE_STAGE); }4546void Dust_State_SpinDash(void)47{48RSDK_THIS(Dust);4950EntityPlayer *player = (EntityPlayer *)self->parent;51if (!player) {52destroyEntity(self);53}54else {55Hitbox *playerHitbox = Player_GetHitbox(player);5657self->position.x = player->position.x;58self->position.y = player->position.y;59int32 bottom = playerHitbox->bottom << 16;60if (player->invertGravity)61self->position.y -= bottom;62else63self->position.y += bottom;64self->direction = player->direction;65self->drawGroup = player->drawGroup;66self->rotation = player->rotation;6768RSDK.ProcessAnimation(&self->animator);6970if (player->state != Player_State_Spindash)71destroyEntity(self);72}73}74void Dust_State_DustTrail(void)75{76RSDK_THIS(Dust);7778EntityPlayer *player = (EntityPlayer *)self->parent;79if (!player) {80destroyEntity(self);81}82else {83self->visible = false;84if (!self->timer && player->onGround) {85Hitbox *playerHitbox = Player_GetHitbox(player);86EntityDust *dust = CREATE_ENTITY(Dust, self, player->position.x, player->position.y);87dust->state = Dust_State_DustPuff;88dust->position.y += playerHitbox->bottom << 16;89dust->drawGroup = player->drawGroup;90}9192self->timer = (self->timer + 1) & 7;93if (player->animator.animationID != ANI_SKID)94destroyEntity(self);95}96}97void Dust_State_GlideTrail(void)98{99RSDK_THIS(Dust);100101EntityPlayer *player = (EntityPlayer *)self->parent;102if (!player) {103destroyEntity(self);104}105else {106self->visible = false;107if (!self->timer && player->onGround) {108Hitbox *playerHitbox = Player_GetHitbox(player);109EntityDust *dust = CREATE_ENTITY(Dust, self, player->position.x, player->position.y - TO_FIXED(4));110dust->state = Dust_State_DustPuff;111dust->position.y += playerHitbox->bottom << 16;112dust->drawGroup = player->drawGroup;113}114115self->timer = (self->timer + 1) & 7;116if (player->animator.animationID != ANI_GLIDE_SLIDE || !player->groundVel)117destroyEntity(self);118}119}120void Dust_State_DustPuff(void)121{122RSDK_THIS(Dust);123124self->position.x += self->velocity.x;125self->position.y += self->velocity.y;126127RSDK.ProcessAnimation(&self->animator);128129if (self->animator.frameID == self->animator.frameCount - 1)130destroyEntity(self);131}132#if MANIA_USE_PLUS133void Dust_State_DustPuff_Collide(void)134{135RSDK_THIS(Dust);136137self->position.x += self->velocity.x;138self->position.y += self->velocity.y;139140RSDK.ObjectTileGrip(self, self->collisionLayers, self->collisionMode, self->collisionPlane, 0, 0, 8);141142RSDK.ProcessAnimation(&self->animator);143144if (self->animator.frameID == self->animator.frameCount - 1)145destroyEntity(self);146}147#endif148void Dust_State_DustPuff_Friction(void)149{150RSDK_THIS(Dust);151152RSDK.ProcessAnimation(&self->animator);153154self->velocity.x -= 0x2000;155self->position.x += self->velocity.x;156self->position.y += self->velocity.y;157158if (self->animator.frameID == self->animator.frameCount - 1)159destroyEntity(self);160}161162#if GAME_INCLUDE_EDITOR163void Dust_EditorDraw(void) {}164165void Dust_EditorLoad(void) {}166#endif167168void Dust_Serialize(void) {}169170171