1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/**
* @file boneProjectile.c
* @ingroup Projectiles
*
* @brief Bone Projectile
*/
#include "collision.h"
#include "enemy.h"
#include "entity.h"
#include "physics.h"
extern void (*const BoneProjectile_Functions[])(Entity*);
extern void (*const BoneProjectile_Actions[])(Entity*);
void sub_080A82D8(Entity*);
void BoneProjectile(Entity* this) {
BoneProjectile_Functions[GetNextFunction(this)](this);
}
void BoneProjectile_OnTick(Entity* this) {
BoneProjectile_Actions[this->action](this);
}
void BoneProjectile_OnCollision(Entity* this) {
if (this->contactFlags == CONTACT_NOW) {
DeleteEntity(this);
} else {
sub_080A82D8(this);
}
}
void BoneProjectile_Init(Entity* this) {
this->action = 1;
this->timer = 60;
this->z.HALF.HI = -2;
InitializeAnimation(this, 0);
}
void BoneProjectile_Action1(Entity* this) {
GetNextFrame(this);
ProcessMovement3(this);
if (this->collisions == COL_NONE) {
if (IsProjectileOffScreen(this)) {
DeleteEntity(this);
} else {
UpdateCollisionLayer(this);
if (--this->timer == 0) {
this->action = 2;
this->speed = 0x120;
}
}
} else {
sub_080A82D8(this);
}
}
void BoneProjectile_Action2(Entity* this) {
GetNextFrame(this);
ProcessMovement3(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 3;
COLLISION_OFF(this);
this->speed = 0xe0;
this->zVelocity = Q_16_16(0.875);
}
}
void BoneProjectile_Action3(Entity* this) {
this->spriteSettings.draw ^= 1;
LinearMoveUpdate(this);
GetNextFrame(this);
if (BounceUpdate(this, Q_8_8(24.0)) == BOUNCE_DONE_ALL) {
DeleteEntity(this);
}
}
void BoneProjectile_Action4(Entity* this) {
GetNextFrame(this);
LinearMoveUpdate(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
DeleteEntity(this);
}
}
void sub_080A82D8(Entity* this) {
this->action = 4;
COLLISION_OFF(this);
this->zVelocity = Q_16_16(1.0);
this->direction ^= DirectionSouth;
this->speed = 0x80;
}
void (*const BoneProjectile_Functions[])(Entity*) = {
BoneProjectile_OnTick, BoneProjectile_OnCollision, DeleteEntity, DeleteEntity, DeleteEntity,
};
void (*const BoneProjectile_Actions[])(Entity*) = {
BoneProjectile_Init, BoneProjectile_Action1, BoneProjectile_Action2, BoneProjectile_Action3, BoneProjectile_Action4,
};
|