Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Cutscene/CutsceneRules.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: CutsceneRules Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectCutsceneRules *CutsceneRules = NULL;
11
12
// NOTE:
13
// I'm not actually sure *what* this object was for
14
// CutsceneRules_SetupEntity was always inlined so I can't say for sure that it was a real func
15
// CutsceneRules_DrawCutsceneBounds is a func I added for editor drawing help
16
// I've never seen definitive proof of any funcs this object may have once had so be it what you will
17
18
void CutsceneRules_Update(void) {}
19
20
void CutsceneRules_LateUpdate(void) {}
21
22
void CutsceneRules_StaticUpdate(void) {}
23
24
void CutsceneRules_Draw(void) {}
25
26
void CutsceneRules_Create(void *data) {}
27
28
void CutsceneRules_StageLoad(void) {}
29
30
bool32 CutsceneRules_IsAct1(void)
31
{
32
if ((RSDK.CheckSceneFolder("GHZ") && !Zone->actID) || (RSDK.CheckSceneFolder("CPZ") && !Zone->actID) || RSDK.CheckSceneFolder("SPZ1")
33
|| (RSDK.CheckSceneFolder("FBZ") && !Zone->actID) || RSDK.CheckSceneFolder("PSZ1") || RSDK.CheckSceneFolder("SSZ1")
34
|| (RSDK.CheckSceneFolder("HCZ") && !Zone->actID) || (RSDK.CheckSceneFolder("MSZ") && !Zone->actID)
35
|| (RSDK.CheckSceneFolder("OOZ") && !Zone->actID) || RSDK.CheckSceneFolder("LRZ1") || (RSDK.CheckSceneFolder("MMZ") && !Zone->actID)
36
|| RSDK.CheckSceneFolder("TMZ1")) {
37
return true;
38
}
39
40
return false;
41
}
42
bool32 CutsceneRules_IsAct2(void)
43
{
44
if ((RSDK.CheckSceneFolder("GHZ") && Zone->actID == 1) || (RSDK.CheckSceneFolder("CPZ") && Zone->actID == 1) || RSDK.CheckSceneFolder("SPZ2")
45
|| (RSDK.CheckSceneFolder("FBZ") && Zone->actID == 1) || RSDK.CheckSceneFolder("PSZ2") || RSDK.CheckSceneFolder("SSZ2")
46
|| (RSDK.CheckSceneFolder("HCZ") && Zone->actID == 1) || (RSDK.CheckSceneFolder("MSZ") && Zone->actID == 1) || RSDK.CheckSceneFolder("OOZ2")
47
|| RSDK.CheckSceneFolder("LRZ3") || (RSDK.CheckSceneFolder("MMZ") && Zone->actID == 1) || RSDK.CheckSceneFolder("TMZ2")) {
48
return true;
49
}
50
51
return false;
52
}
53
54
bool32 CutsceneRules_IsIntroEnabled(void) { return isMainGameMode() && globals->enableIntro && !CutsceneRules_CheckStageReload(); }
55
56
bool32 CutsceneRules_IsAct1Regular(void) { return isMainGameMode() && CutsceneRules_IsAct1(); }
57
58
bool32 CutsceneRules_CheckStageReload(void)
59
{
60
if (StarPost) {
61
for (int32 p = 0; p < Player->playerCount; ++p) {
62
if (StarPost->postIDs[p])
63
return true;
64
}
65
}
66
67
if (SpecialRing && globals->specialRingID > 0) {
68
foreach_all(SpecialRing, specialRing)
69
{
70
if (specialRing->id > 0 && globals->specialRingID == specialRing->id)
71
return true;
72
}
73
}
74
75
return false;
76
}
77
bool32 CutsceneRules_CheckPlayerPos(int32 x1, int32 y1, int32 x2, int32 y2)
78
{
79
Vector2 playerPos;
80
81
if (Player) {
82
foreach_all(Player, player)
83
{
84
if (CHECK_CHARACTER_ID(player->characterID, 1)) {
85
playerPos = player->position;
86
}
87
}
88
}
89
90
return playerPos.x >= x1 && playerPos.y >= y1 && playerPos.x <= x2 && playerPos.y <= y2;
91
}
92
93
// Extra Helpers
94
void CutsceneRules_SetupEntity(void *e, Vector2 *size, Hitbox *hitbox)
95
{
96
EntityCutsceneRules *entity = (EntityCutsceneRules *)e;
97
98
if (!size->x)
99
size->x = WIDE_SCR_XSIZE << 16;
100
101
if (!size->y)
102
size->y = SCREEN_YSIZE << 16;
103
104
entity->updateRange.x = TO_FIXED(128) + size->x;
105
entity->updateRange.y = TO_FIXED(128) + size->y;
106
107
hitbox->left = -size->x >> 17;
108
hitbox->top = -size->y >> 17;
109
hitbox->right = size->x >> 17;
110
hitbox->bottom = size->y >> 17;
111
}
112
113
void CutsceneRules_DrawCutsceneBounds(void *e, Vector2 *size)
114
{
115
EntityCutsceneRules *entity = (EntityCutsceneRules *)e;
116
DrawHelpers_DrawRectOutline(entity->position.x, entity->position.y, size->x, size->y, 0xFFFF00);
117
}
118
119
#if GAME_INCLUDE_EDITOR
120
void CutsceneRules_EditorDraw(void) {}
121
122
void CutsceneRules_EditorLoad(void) {}
123
#endif
124
125
void CutsceneRules_Serialize(void) {}
126
127