Path: blob/master/SonicMania/Objects/HCZ/Pointdexter.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: Pointdexter Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectPointdexter *Pointdexter;1011void Pointdexter_Update(void)12{13RSDK_THIS(Pointdexter);1415StateMachine_Run(self->state);16}1718void Pointdexter_LateUpdate(void) {}1920void Pointdexter_StaticUpdate(void) {}2122void Pointdexter_Draw(void)23{24RSDK_THIS(Pointdexter);2526RSDK.DrawSprite(&self->animator, NULL, false);27}2829void Pointdexter_Create(void *data)30{31RSDK_THIS(Pointdexter);3233self->visible = true;34self->drawGroup = Zone->objectDrawGroup[0];35self->drawFX |= FX_FLIP;36self->startPos = self->position;37self->startDir = self->direction;38self->active = ACTIVE_BOUNDS;39self->updateRange.x = 0x800000;40self->updateRange.y = 0x800000;4142RSDK.SetSpriteAnimation(Pointdexter->aniFrames, 0, &self->animator, true, 0);43self->state = Pointdexter_State_Init;44}4546void Pointdexter_StageLoad(void)47{48if (RSDK.CheckSceneFolder("HCZ"))49Pointdexter->aniFrames = RSDK.LoadSpriteAnimation("HCZ/Pointdexter.bin", SCOPE_STAGE);5051Pointdexter->hitbox.left = -16;52Pointdexter->hitbox.top = -6;53Pointdexter->hitbox.right = 16;54Pointdexter->hitbox.bottom = 6;5556DEBUGMODE_ADD_OBJ(Pointdexter);57}5859void Pointdexter_DebugSpawn(void)60{61RSDK_THIS(DebugMode);6263CREATE_ENTITY(Pointdexter, NULL, self->position.x, self->position.y);64}6566void Pointdexter_DebugDraw(void)67{68RSDK.SetSpriteAnimation(Pointdexter->aniFrames, 0, &DebugMode->animator, true, 0);69RSDK.DrawSprite(&DebugMode->animator, NULL, false);70}7172void Pointdexter_CheckOffScreen(void)73{74RSDK_THIS(Pointdexter);7576if (!RSDK.CheckOnScreen(self, NULL) && !RSDK.CheckPosOnScreen(&self->startPos, &self->updateRange)) {77self->position = self->startPos;78self->direction = self->startDir;79Pointdexter_Create(NULL);80}81}8283void Pointdexter_CheckPlayerCollisions(void)84{85RSDK_THIS(Pointdexter);8687foreach_active(Player, player)88{89if (Player_CheckBadnikTouch(player, self, &Pointdexter->hitbox)) {90if (self->animator.frameID != 2 || player->invincibleTimer || player->blinkTimer91#if MANIA_USE_PLUS92|| player->state == Player_State_MightyHammerDrop93#endif94) {95Player_CheckBadnikBreak(player, self, true);96}97#if MANIA_USE_PLUS98else if (!Player_CheckMightyUnspin(player, 0x200, 2, &player->uncurlTimer))99#else100else101#endif102Player_Hurt(player, self);103}104}105}106107void Pointdexter_State_Init(void)108{109RSDK_THIS(Pointdexter);110111if (self->position.y >= Water->waterLevel) {112self->active = ACTIVE_NORMAL;113self->velocity.x = self->direction == FLIP_NONE ? -0x4000 : 0x4000;114self->timer = 0;115116self->state = Pointdexter_State_Swimming;117Pointdexter_State_Swimming();118}119else {120destroyEntity(self);121}122}123124void Pointdexter_State_Swimming(void)125{126RSDK_THIS(Pointdexter);127128self->position.x += self->velocity.x;129130if (!--self->timer) {131self->direction ^= FLIP_X;132self->velocity.x = -self->velocity.x;133self->timer = 0;134}135136self->position.y += 32 * RSDK.Sin256(self->angle);137self->angle = (self->angle + 2) & 0xFF;138139RSDK.ProcessAnimation(&self->animator);140141Pointdexter_CheckPlayerCollisions();142Pointdexter_CheckOffScreen();143}144145#if GAME_INCLUDE_EDITOR146void Pointdexter_EditorDraw(void) { Pointdexter_Draw(); }147148void Pointdexter_EditorLoad(void)149{150Pointdexter->aniFrames = RSDK.LoadSpriteAnimation("HCZ/Pointdexter.bin", SCOPE_STAGE);151152RSDK_ACTIVE_VAR(Pointdexter, direction);153RSDK_ENUM_VAR("Left", FLIP_NONE);154RSDK_ENUM_VAR("Right", FLIP_X);155}156#endif157158void Pointdexter_Serialize(void) { RSDK_EDITABLE_VAR(Pointdexter, VAR_UINT8, direction); }159160161