Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Pinball/PBL_Sector.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: PBL_Sector Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
#if MANIA_USE_PLUS
11
ObjectPBL_Sector *PBL_Sector;
12
13
void PBL_Sector_Update(void)
14
{
15
RSDK_THIS(PBL_Sector);
16
17
if (self->timer <= 0) {
18
foreach_active(PBL_Player, player)
19
{
20
if (self->playerEntered) {
21
if (player->position.y <= self->position.y - self->size.y - 0x100000 && player->velocity.y < 0) {
22
foreach_active(PBL_HUD, hud) { PBL_HUD_DisplayMessage(hud, "GO! GO!", PBL_HUD_MSG_FLASH_CRANE); }
23
24
player->position.y = self->position.y - self->size.y - 0xC0000;
25
player->active = ACTIVE_NEVER;
26
RSDK.PlaySfx(PBL_Crane->sfxBackGlass, false, 255);
27
28
PBL_Setup_GiveScore(1000);
29
30
if (self->craneID >= PBL_Setup->sectorCount) {
31
self->active = ACTIVE_NEVER;
32
self->timer = 60;
33
}
34
else {
35
destroyEntity(self);
36
}
37
}
38
}
39
else {
40
if (abs(player->position.x - self->position.x) < self->size.x) {
41
if (abs(player->position.y - self->position.y) < self->size.y) {
42
EntityPBL_Camera *camera = RSDK_GET_ENTITY(SLOT_PBL_CAMERA, PBL_Camera);
43
camera->newCamBoundaryT = self->position.y - self->size.y;
44
camera->newCamBoundaryB = self->position.y + self->size.y;
45
46
self->playerEntered = true;
47
}
48
}
49
}
50
}
51
}
52
else {
53
self->timer--;
54
}
55
}
56
57
void PBL_Sector_LateUpdate(void) {}
58
59
void PBL_Sector_StaticUpdate(void) {}
60
61
void PBL_Sector_Draw(void) {}
62
63
void PBL_Sector_Create(void *data)
64
{
65
RSDK_THIS(PBL_Sector);
66
67
if (!SceneInfo->inEditor) {
68
self->updateRange.x = self->size.x;
69
self->updateRange.y = self->size.y;
70
71
if (self->craneID == PBL_Setup->sectorID) {
72
EntityPBL_Camera *camera = RSDK_GET_ENTITY(SLOT_PBL_CAMERA, PBL_Camera);
73
camera->curCamBoundaryT = self->position.y - self->size.y;
74
camera->newCamBoundaryT = self->position.y - self->size.y;
75
camera->curCamBoundaryB = self->position.y + self->size.y;
76
camera->newCamBoundaryB = self->position.y + self->size.y;
77
78
self->active = ACTIVE_NORMAL;
79
}
80
81
if (self->craneID > PBL_Setup->sectorCount)
82
PBL_Setup->sectorCount = self->craneID;
83
}
84
}
85
86
void PBL_Sector_StageLoad(void) {}
87
88
#if GAME_INCLUDE_EDITOR
89
void PBL_Sector_EditorDraw(void)
90
{
91
RSDK_THIS(PBL_Sector);
92
93
RSDK.SetSpriteAnimation(PBL_Sector->aniFrames, 0, &self->animator, true, 8);
94
RSDK.DrawSprite(&self->animator, NULL, false);
95
96
if (showGizmos()) {
97
RSDK_DRAWING_OVERLAY(true);
98
99
DrawHelpers_DrawRectOutline(self->position.x, self->position.y, self->size.x << 1, self->size.y << 1, 0xFFFF00);
100
101
RSDK_DRAWING_OVERLAY(false);
102
}
103
}
104
105
void PBL_Sector_EditorLoad(void) { PBL_Sector->aniFrames = RSDK.LoadSpriteAnimation("Editor/EditorIcons.bin", SCOPE_STAGE); }
106
#endif
107
108
void PBL_Sector_Serialize(void)
109
{
110
RSDK_EDITABLE_VAR(PBL_Sector, VAR_VECTOR2, size);
111
RSDK_EDITABLE_VAR(PBL_Sector, VAR_UINT8, craneID);
112
}
113
#endif
114
115