Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Helpers/ParticleHelpers.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: ParticleHelpers Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectParticleHelpers *ParticleHelpers = NULL;
11
12
void ParticleHelpers_Update(void) {}
13
14
void ParticleHelpers_LateUpdate(void) {}
15
16
void ParticleHelpers_StaticUpdate(void) {}
17
18
void ParticleHelpers_Draw(void) {}
19
20
void ParticleHelpers_Create(void *data) {}
21
22
void ParticleHelpers_StageLoad(void) {}
23
24
void ParticleHelpers_SetupFallingParticles(int32 x, int32 y, void (*callback)(EntityDebris *))
25
{
26
int32 pos = x - 0x80000;
27
for (int32 i = 0; i < 5; ++i) {
28
int32 spawnX = pos + (i << 18);
29
EntityDebris *debris = CREATE_ENTITY(Debris, Debris_State_Fall, spawnX, y);
30
debris->drawGroup = Zone->objectDrawGroup[1];
31
debris->gravityStrength = 0x3800;
32
debris->velocity.y = 0;
33
debris->velocity.x = 0x30 * ((spawnX - x) >> 8);
34
35
if (debris->position.x < x)
36
debris->direction = FLIP_X;
37
38
if (callback)
39
callback(debris);
40
}
41
}
42
43
void ParticleHelpers_SetupParticleFX(void *debrisState, void (*callback)(EntityDebris *), int32 speed, int32 xOffset, int32 yOffset, int32 maxX,
44
int32 maxY)
45
{
46
int32 x = ZONE_RAND(-(maxX >> 1), maxX >> 1) + xOffset;
47
int32 y = ZONE_RAND(-(maxY >> 1), maxY >> 1) + yOffset;
48
EntityDebris *debris = CREATE_ENTITY(Debris, debrisState, x, y);
49
50
debris->drawGroup = Zone->objectDrawGroup[1];
51
debris->gravityStrength = 0x3800;
52
debris->velocity.x = ((x - xOffset) >> 8) * (speed >> 8);
53
debris->velocity.y = ((y - yOffset) >> 8) * (speed >> 8);
54
55
if (debris->position.x < xOffset)
56
debris->direction = FLIP_X;
57
58
if (callback)
59
callback(debris);
60
}
61
62
#if GAME_INCLUDE_EDITOR
63
void ParticleHelpers_EditorDraw(void) {}
64
65
void ParticleHelpers_EditorLoad(void) {}
66
#endif
67
68
void ParticleHelpers_Serialize(void) {}
69
70