Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Puyo/PuyoBean.h
338 views
1
#ifndef OBJ_PUYOBEAN_H
2
#define OBJ_PUYOBEAN_H
3
4
#include "Game.h"
5
6
#define PUYO_PLAYFIELD_W (6)
7
#define PUYO_PLAYFIELD_H (14)
8
9
typedef enum {
10
PUYOBEAN_BLUE = 0,
11
PUYOBEAN_GREEN = 6,
12
PUYOBEAN_PURPLE = 12,
13
PUYOBEAN_RED = 18,
14
PUYOBEAN_YELLOW = 24,
15
PUYOBEAN_JUNK = 30,
16
} PuyoBeanTypes;
17
18
typedef enum {
19
PUYOBEAN_ANI_FLASH,
20
PUYOBEAN_ANI_IDLE,
21
PUYOBEAN_ANI_BOUNCE,
22
PUYOBEAN_ANI_CONNECT,
23
PUYOBEAN_ANI_POP,
24
PUYOBEAN_ANI_DEBRIS,
25
} PuyoBeanAniIDs;
26
27
// Object Class
28
struct ObjectPuyoBean {
29
RSDK_OBJECT
30
TABLE(int32 fallDelays[5], { 16, 12, 8, 4, 2 });
31
Hitbox hitboxBean;
32
int32 comboChainCount[2];
33
int32 disableBeanLink[2];
34
EntityPuyoBean *playfield[256];
35
int32 beanLinkCount;
36
Vector2 beanLinkPositions[256];
37
bool32 beanLinkTable[84]; // PUYO_PLAYFIELD_W * PUYO_PLAYFIELD_H
38
int32 shinkDelay;
39
Animator junkBeanAnimator;
40
uint16 aniFrames;
41
uint16 sfxLand;
42
uint16 sfxRotate;
43
uint16 chainFrames[6];
44
uint16 sfxJunk;
45
uint16 sfxFall;
46
};
47
48
// Entity Class
49
struct EntityPuyoBean {
50
RSDK_ENTITY
51
StateMachine(state);
52
int32 playerID;
53
int32 type;
54
int32 linkSides;
55
int32 linkCount;
56
EntityPuyoBean *linkBeans[4];
57
int32 timer;
58
int32 popTimer;
59
int32 moveTimer;
60
int32 fallTimer;
61
int32 fallDelay;
62
int32 rotateSpeed;
63
int32 unused1;
64
int32 rotationDir;
65
int32 idleTimer;
66
int32 connectTimer;
67
int32 selectedLevel;
68
Vector2 stillPos;
69
Vector2 unused2;
70
Vector2 origin;
71
int32 targetAngle;
72
bool32 forceRotationActive;
73
bool32 isJunk;
74
EntityPuyoBean *partner;
75
StateMachine(stateInput);
76
int32 controllerID;
77
bool32 down;
78
bool32 left;
79
bool32 right;
80
bool32 rotateRight;
81
bool32 rotateLeft;
82
bool32 forceRotateLeft;
83
bool32 forceRotateRight;
84
Animator beanAnimator;
85
};
86
87
// Object Struct
88
extern ObjectPuyoBean *PuyoBean;
89
90
// Standard Entity Events
91
void PuyoBean_Update(void);
92
void PuyoBean_LateUpdate(void);
93
void PuyoBean_StaticUpdate(void);
94
void PuyoBean_Draw(void);
95
void PuyoBean_Create(void *data);
96
void PuyoBean_StageLoad(void);
97
#if GAME_INCLUDE_EDITOR
98
void PuyoBean_EditorDraw(void);
99
void PuyoBean_EditorLoad(void);
100
#endif
101
void PuyoBean_Serialize(void);
102
103
// Extra Entity Functions
104
EntityPuyoBean *PuyoBean_GetPuyoBean(int32 playerID, int32 x, int32 y);
105
void PuyoBean_Input_Player(void);
106
void PuyoBean_DestroyPuyoBeans(void);
107
void PuyoBean_HandleBeanLinks(void);
108
void PuyoBean_CheckBeanLinks(EntityPuyoBean *bean, EntityPuyoBean *curLink);
109
void PuyoBean_HandleMoveBounds(void);
110
bool32 PuyoBean_CheckAIRotationDisabled(EntityPuyoBean *bean);
111
void PuyoBean_CheckCollisions(void);
112
int32 PuyoBean_GetBeanChainRemovalCount(int32 playerID, EntityPuyoBean *bean, int32 x, int32 y);
113
int32 PuyoBean_GetAvailableLinks(int32 playerID, EntityPuyoBean *bean, int32 x, int32 y);
114
bool32 PuyoBean_CheckLinkPosAvailable(int32 playerID, int32 x, int32 y);
115
void PuyoBean_SetupBeanLinkTable(int32 playerID, int32 x, int32 y, bool32 useTempTable);
116
uint8 PuyoBean_GetColumnHeight(int32 playerID, int32 column, EntityPuyoBean *bean, EntityPuyoBean *partner);
117
void PuyoBean_CalculateStillPos(EntityPuyoBean *bean);
118
119
// States
120
void PuyoBean_State_PartnerControlled(void);
121
void PuyoBean_State_Controlled(void);
122
void PuyoBean_State_BeanIdle(void);
123
void PuyoBean_State_Falling(void);
124
void PuyoBean_State_BeanLand(void);
125
void PuyoBean_State_JunkLand(void);
126
void PuyoBean_State_JunkIdle(void);
127
void PuyoBean_State_JunkPopped(void);
128
void PuyoBean_State_BeginBeanPop(void);
129
void PuyoBean_State_BeanPop(void);
130
void PuyoBean_State_MatchLoseFall(void);
131
132
#endif //! OBJ_PUYOBEAN_H
133
134