Path: blob/master/SonicMania/Objects/FBZ/Propeller.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: Propeller Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectPropeller *Propeller;1011void Propeller_Update(void)12{13RSDK_THIS(Propeller);1415RSDK.ProcessAnimation(&self->animator);16Hitbox *hitboxHurt = RSDK.GetHitbox(&self->animator, 0);1718self->hitboxFan.top = (RSDK.Sin256(2 * Zone->timer) >> 4) - 64;19self->hitboxFan.bottom = -8;2021self->hitboxTrigger.top = -96;22self->hitboxTrigger.bottom = -8;2324foreach_active(Player, player)25{26int32 playerID = RSDK.GetEntitySlot(player);27bool32 propellerActive = false;2829int32 anim = player->animator.animationID;30if (anim != ANI_SHAFT_SWING && anim != ANI_HURT && self->fanEnabled31&& RSDK.CheckObjectCollisionTouchBox(self, &self->hitboxFan, player, &self->hitboxPlayer)) {32propellerActive = true;33RSDK.SetSpriteAnimation(player->aniFrames, ANI_FAN, &player->animator, false, 0);34player->state = Player_State_Air;35player->onGround = false;36player->velocity.y = 0;37player->position.y += (self->position.y + (self->hitboxFan.top << 16) - player->position.y) >> 4;38}3940if (RSDK.CheckObjectCollisionTouchBox(self, &self->hitboxTrigger, player, &self->hitboxPlayer)) {41if (!((1 << playerID) & self->activePlayers) && propellerActive) {42RSDK.PlaySfx(Propeller->sfxFan, false, 0xFF);43self->activePlayers |= (1 << playerID);44}45}46else {47self->activePlayers &= ~(1 << playerID);48}4950if (Player_CheckCollisionTouch(player, self, hitboxHurt))51Player_Hurt(player, self);52}53}5455void Propeller_LateUpdate(void) {}5657void Propeller_StaticUpdate(void) {}5859void Propeller_Draw(void)60{61RSDK_THIS(Propeller);6263RSDK.DrawSprite(&self->animator, NULL, false);64}6566void Propeller_Create(void *data)67{68RSDK_THIS(Propeller);6970if (!SceneInfo->inEditor) {71self->active = ACTIVE_BOUNDS;72self->visible = true;73self->drawGroup = Zone->objectDrawGroup[1];74self->updateRange.x = 0x800000;75self->updateRange.y = 0x800000;7677self->hitboxPlayer.left = -1;78self->hitboxPlayer.top = -1;79self->hitboxPlayer.right = 1;80self->hitboxPlayer.bottom = 1;8182self->hitboxTrigger.left = -104;83self->hitboxTrigger.right = 104;8485self->hitboxFan.left = -104;86self->hitboxFan.right = 104;8788RSDK.SetSpriteAnimation(Propeller->aniFrames, 0, &self->animator, true, 0);89}90}9192void Propeller_StageLoad(void)93{94Propeller->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Propeller.bin", SCOPE_STAGE);9596Propeller->sfxFan = RSDK.GetSfx("FBZ/FBZFan.wav");97}9899#if GAME_INCLUDE_EDITOR100void Propeller_EditorDraw(void)101{102RSDK_THIS(Propeller);103RSDK.SetSpriteAnimation(Propeller->aniFrames, 0, &self->animator, true, 0);104105Propeller_Draw();106}107108void Propeller_EditorLoad(void) { Propeller->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Propeller.bin", SCOPE_STAGE); }109#endif110111void Propeller_Serialize(void) { RSDK_EDITABLE_VAR(Propeller, VAR_BOOL, fanEnabled); }112113114