Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/UFO/UFO_Dust.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: UFO_Dust Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectUFO_Dust *UFO_Dust;
11
12
void UFO_Dust_Update(void) {}
13
14
void UFO_Dust_LateUpdate(void)
15
{
16
RSDK_THIS(UFO_Dust);
17
18
RSDK.ProcessAnimation(&self->animator);
19
20
if (self->animator.frameID == self->animator.frameCount - 1) {
21
destroyEntity(self);
22
}
23
else {
24
int32 x = self->position.x >> 8;
25
int32 y = self->height >> 8;
26
int32 z = self->position.y >> 8;
27
28
Matrix *mat = &UFO_Camera->matWorld;
29
30
self->worldX = mat->values[0][3] + (y * mat->values[0][1] >> 8) + (z * mat->values[0][2] >> 8) + (x * mat->values[0][0] >> 8);
31
self->worldY = mat->values[1][3] + (y * mat->values[1][1] >> 8) + (z * mat->values[1][2] >> 8) + (x * mat->values[1][0] >> 8);
32
self->zdepth = mat->values[2][3] + (y * mat->values[2][1] >> 8) + (z * mat->values[2][2] >> 8) + (x * mat->values[2][0] >> 8);
33
}
34
}
35
36
void UFO_Dust_StaticUpdate(void) {}
37
38
void UFO_Dust_Draw(void)
39
{
40
RSDK_THIS(UFO_Dust);
41
42
if (self->zdepth >= 0x400) {
43
Vector2 drawPos;
44
drawPos.x = (ScreenInfo->center.x + (self->worldX << 8) / self->zdepth) << 16;
45
drawPos.y = (ScreenInfo->center.y - (self->worldY << 8) / self->zdepth) << 16;
46
47
self->scale.x = 0x1000000 / self->zdepth;
48
self->scale.y = 0x1000000 / self->zdepth;
49
RSDK.DrawSprite(&self->animator, &drawPos, true);
50
}
51
}
52
53
void UFO_Dust_Create(void *data)
54
{
55
RSDK_THIS(UFO_Dust);
56
57
if (!SceneInfo->inEditor) {
58
self->visible = true;
59
self->drawFX = FX_SCALE | FX_FLIP;
60
self->drawGroup = 4;
61
self->active = ACTIVE_RBOUNDS;
62
self->updateRange.x = 0x400;
63
self->updateRange.y = 0x400;
64
65
self->position.x += RSDK.Rand(-0x80000, 0x80000);
66
self->position.y += RSDK.Rand(-0x80000, 0x80000);
67
self->height = RSDK.Rand(0x40000, 0x100000);
68
69
RSDK.SetSpriteAnimation(UFO_Dust->aniFrames, 0, &self->animator, true, 0);
70
}
71
}
72
73
void UFO_Dust_StageLoad(void) { UFO_Dust->aniFrames = RSDK.LoadSpriteAnimation("SpecialUFO/Dust.bin", SCOPE_STAGE); }
74
75
#if GAME_INCLUDE_EDITOR
76
void UFO_Dust_EditorDraw(void) {}
77
78
void UFO_Dust_EditorLoad(void) {}
79
#endif
80
81
void UFO_Dust_Serialize(void) { RSDK_EDITABLE_VAR(UFO_Dust, VAR_ENUM, height); }
82
83