Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Helpers/MathHelpers.h
338 views
1
#ifndef OBJ_MATHHELPERS_H
2
#define OBJ_MATHHELPERS_H
3
4
#include "Game.h"
5
6
// Object Class
7
struct ObjectMathHelpers {
8
RSDK_OBJECT
9
};
10
11
// Entity Class
12
struct EntityMathHelpers {
13
RSDK_ENTITY
14
};
15
16
// Object Entity
17
extern ObjectMathHelpers *MathHelpers;
18
19
// Standard Entity Events
20
void MathHelpers_Update(void);
21
void MathHelpers_LateUpdate(void);
22
void MathHelpers_StaticUpdate(void);
23
void MathHelpers_Draw(void);
24
void MathHelpers_Create(void *data);
25
void MathHelpers_StageLoad(void);
26
#if GAME_INCLUDE_EDITOR
27
void MathHelpers_EditorDraw(void);
28
void MathHelpers_EditorLoad(void);
29
#endif
30
void MathHelpers_Serialize(void);
31
32
// Extra Entity Functions
33
34
// Lerp
35
void MathHelpers_LerpToPos(Vector2 *pos, int32 percent, int32 posX, int32 posY);
36
void MathHelpers_Lerp(Vector2 *pos, int32 percent, int32 startX, int32 startY, int32 endX, int32 endY);
37
void MathHelpers_LerpSin1024(Vector2 *pos, int32 percent, int32 startX, int32 startY, int32 endX, int32 endY);
38
void MathHelpers_Lerp2Sin1024(Vector2 *pos, int32 percent, int32 startX, int32 startY, int32 endX, int32 endY);
39
void MathHelpers_LerpSin512(Vector2 *pos, int32 percent, int32 startX, int32 startY, int32 endX, int32 endY);
40
41
// Bezier/Sqrt
42
Vector2 MathHelpers_GetBezierPoint(int32 percent, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4);
43
int32 MathHelpers_SquareRoot(uint32 num);
44
int32 MathHelpers_Distance(int32 x1, int32 y1, int32 x2, int32 y2);
45
int32 MathHelpers_GetBezierCurveLength(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4);
46
47
// "Collisions"
48
bool32 MathHelpers_PointInHitbox(int32 thisX, int32 thisY, int32 otherX, int32 otherY, int32 direction, Hitbox *hitbox);
49
bool32 MathHelpers_PositionBoxesIntersect(int32 otherX1, int32 otherY1, int32 otherX2, int32 otherY2, int32 thisX1, int32 thisY1, int32 thisX2,
50
int32 thisY2);
51
int32 MathHelpers_GetInteractionDir(int32 otherX1, int32 otherY1, int32 otherX2, int32 otherY2, int32 thisX, int32 thisY);
52
bool32 MathHelpers_CheckValidIntersect(int32 otherX1, int32 otherY1, int32 otherX2, int32 otherY2, int32 thisX, int32 thisY);
53
int32 MathHelpers_CheckPositionOverlap(int32 otherX1, int32 otherY1, int32 otherX2, int32 otherY2, int32 thisX1, int32 thisY1, int32 thisX2,
54
int32 thisY2);
55
56
int32 MathHelpers_GetEdgeDistance(int32 distance, int32 radius);
57
bool32 MathHelpers_ConstrainToBox(Vector2 *pos, int32 x, int32 y, Vector2 boxPos, Hitbox hitbox);
58
59
// RSDKv5U changed how the setPos param works, so this is added for compatibility
60
uint8 MathHelpers_CheckBoxCollision(void *thisEntity, Hitbox *thisHitbox, void *otherEntity, Hitbox *otherHitbox);
61
62
#endif //! OBJ_MATHHELPERS_H
63
64