Path: blob/master/SonicMania/Objects/PGZ/PSZ2Setup.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: PSZ2Setup Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectPSZ2Setup *PSZ2Setup;1011void PSZ2Setup_Update(void) {}1213void PSZ2Setup_LateUpdate(void) {}1415void PSZ2Setup_StaticUpdate(void)16{17if (--PSZ2Setup->petalAniDuration < 1) {18++PSZ2Setup->petalAniFrame;19PSZ2Setup->petalAniFrame &= 7;20PSZ2Setup->petalAniDuration = PSZ2Setup->petalAniDurationTable[PSZ2Setup->petalAniFrame];2122int32 sheetY = 32 * PSZ2Setup->petalAniFrame;23RSDK.DrawAniTiles(PSZ2Setup->aniTiles1, 260, 0, sheetY, 64, 32);24RSDK.DrawAniTiles(PSZ2Setup->aniTiles1, 268, 80, sheetY, 48, 16);25RSDK.DrawAniTiles(PSZ2Setup->aniTiles1, 271, 64, sheetY + 16, 64, 16);26RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 159, 0, sheetY, 16, 32);27RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 276, 16, sheetY, 32, 16);28RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 281, 16, sheetY + 16, 32, 16);29RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 279, 48, sheetY, 32, 16);30RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 286, 48, sheetY + 16, 32, 16);31RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 284, 80, sheetY, 32, 16);32RSDK.DrawAniTiles(PSZ2Setup->aniTiles2, 289, 80, sheetY + 16, 32, 16);33}3435RSDK.SetLimitedFade(0, 1, 2, abs(RSDK.Sin256(16 * Zone->timer)), 224, 227);3637if (PSZ2Setup->petalBehaviourActive) {38if (PSZ2Setup->petalTimer <= 0) {39foreach_active(Player, player)40{41Hitbox *playerHitbox = Player_GetHitbox(player);4243uint16 tile = RSDK.GetTile(Zone->fgLayer[0], player->position.x >> 20, (player->position.y + (playerHitbox->bottom << 16)) >> 20);44bool32 isLowLayer = true;45if (tile == (uint16)-1) {46tile = RSDK.GetTile(Zone->fgLayer[1], player->position.x >> 20, (player->position.y + (playerHitbox->bottom << 16)) >> 20);47isLowLayer = false;48}4950if (RSDK.GetTileFlags(tile, player->collisionPlane)) {51if (abs(player->groundVel) >= 0x60000 || player->state == Player_State_DropDash) {52RSDK_THIS(PSZ2Setup); // not sure what this is meant to be since this is a StaticUpdate event...5354EntityPetalPile *pile = CREATE_ENTITY(PetalPile, self, player->position.x, player->position.y + (playerHitbox->bottom << 16));55pile->leafPattern = PETALPILE_PATTERN_4;56pile->tileLayer = isLowLayer;57pile->pileSize.x = 0x40000;58pile->pileSize.y = 0x40000;59pile->noRemoveTiles = true;60pile->petalRadius = 0xB5555;61pile->petalDir = 2 * (player->direction != FLIP_NONE) - 1;62pile->petalVel = player->groundVel >> 1;63PSZ2Setup->petalTimer = 3;64}65}66}67}68else {69PSZ2Setup->petalTimer--;70}71}72}7374void PSZ2Setup_Draw(void) {}7576void PSZ2Setup_Create(void *data) {}7778void PSZ2Setup_StageLoad(void)79{80PSZ2Setup->petalBehaviourActive = false;8182GenericTrigger->callbacks[GENERICTRIGGER_PSZ2_PETALSINACTIVE] = PSZ2Setup_Trigger_DeactivatePetalBehaviour;83GenericTrigger->callbacks[GENERICTRIGGER_PSZ2_PETALSACTIVE] = PSZ2Setup_Trigger_ActivatePetalBehaviour;8485PSZ2Setup->aniTiles1 = RSDK.LoadSpriteSheet("PSZ2/AniTiles.gif", SCOPE_STAGE);86PSZ2Setup->aniTiles2 = RSDK.LoadSpriteSheet("PSZ2/AniTiles2.gif", SCOPE_STAGE);8788if (!isMainGameMode() || !globals->atlEnabled || CutsceneRules_CheckStageReload()) {89Zone->cameraBoundsL[0] = 1024;90Zone->cameraBoundsL[1] = 1024;91Zone->cameraBoundsL[2] = 1024;92Zone->cameraBoundsL[3] = 1024;93FXFade_StopAll();94}95else {96Zone->cameraBoundsB[0] = 1556;97Zone->cameraBoundsB[1] = 1556;98Zone->cameraBoundsB[2] = 1556;99Zone->cameraBoundsB[3] = 1556;100PSZ2Setup_ActTransitionLoad();101}102103if (isMainGameMode() && CutsceneRules_IsAct2())104Zone->stageFinishCallback = PSZ2Setup_StageFinish_EndAct2;105106#if MANIA_USE_PLUS107if (SceneInfo->filter & FILTER_ENCORE)108RSDK.LoadPalette(0, "EncorePSZ2.act", 0b0000000011111111);109110// Fun Fact: Pre-Plus didn't have animal types set for PGZ! It'd always be flickies due to that being the default value!111Animals->animalTypes[0] = ANIMAL_POCKY;112Animals->animalTypes[1] = ANIMAL_BECKY;113#endif114}115116void PSZ2Setup_Trigger_ActivatePetalBehaviour(void) { PSZ2Setup->petalBehaviourActive = true; }117118void PSZ2Setup_Trigger_DeactivatePetalBehaviour(void) { PSZ2Setup->petalBehaviourActive = false; }119120void PSZ2Setup_ActTransitionLoad(void)121{122SaveGame_LoadPlayerState();123Zone_ReloadStoredEntities(472 << 16, 1556 << 16, false);124125globals->recallEntities = false;126globals->restartMilliseconds = 0;127globals->restartSeconds = 0;128globals->restartMinutes = 0;129memset(globals->atlEntityData, 0, TEMPENTITY_START * sizeof(int32));130131Zone->cameraBoundsL[0] = 0;132Zone->cameraBoundsR[0] = 944;133Zone->cameraBoundsT[0] = 0;134Zone->cameraBoundsB[0] = 1556;135Zone->cameraBoundsL[1] = 0;136Zone->cameraBoundsR[1] = 944;137Zone->cameraBoundsT[1] = 0;138Zone->cameraBoundsB[1] = 1556;139Zone->cameraBoundsL[2] = 0;140Zone->cameraBoundsR[2] = 944;141Zone->cameraBoundsT[2] = 0;142Zone->cameraBoundsB[2] = 1556;143Zone->cameraBoundsL[3] = 0;144Zone->cameraBoundsR[3] = 944;145Zone->cameraBoundsT[3] = 0;146Zone->cameraBoundsB[3] = 1556;147}148149void PSZ2Setup_StageFinish_EndAct2(void) { CREATE_ENTITY(PSZ2Outro, NULL, 0, 0); }150151#if GAME_INCLUDE_EDITOR152void PSZ2Setup_EditorDraw(void) {}153154void PSZ2Setup_EditorLoad(void)155{156RSDK_ACTIVE_VAR(GenericTrigger, triggerID);157RSDK_ENUM_VAR("Stop Petal Behaviour", GENERICTRIGGER_PSZ2_PETALSINACTIVE);158RSDK_ENUM_VAR("Start Petal Behaviour", GENERICTRIGGER_PSZ2_PETALSACTIVE);159}160#endif161162void PSZ2Setup_Serialize(void) {}163164165