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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
class daElectricLine : public dEn_c {
int onCreate();
int onDelete();
int onExecute();
int onDraw();
mHeapAllocator_c allocator;
nw4r::g3d::ResFile resFile;
dEn_c *Needles;
u32 delay;
u32 timer;
char loops;
static daElectricLine *build();
USING_STATES(daElectricLine);
DECLARE_STATE(Activate);
DECLARE_STATE(Deactivate);
DECLARE_STATE(Die);
};
daElectricLine *daElectricLine::build() {
void *buffer = AllocFromGameHeap1(sizeof(daElectricLine));
return new(buffer) daElectricLine;
}
///////////////////////
// Externs and States
///////////////////////
extern "C" void *PlaySound(dStageActor_c *, int soundID);
extern "C" void *PlaySoundAsync(dStageActor_c *, int soundID);
extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
CREATE_STATE(daElectricLine, Activate);
CREATE_STATE(daElectricLine, Deactivate);
CREATE_STATE(daElectricLine, Die);
int daElectricLine::onCreate() {
Vec temppos = this->pos;
temppos.x += 24.0;
// Settings for rotation: 0 = facing right, 1 = facing left, 2 = facing up, 3 = facing down
char settings = 0;
if (this->settings & 0x1) {
settings = 1;
temppos.x -= 32.0;
}
Needles = (daNeedles*)create(NEEDLE_FOR_KOOPA_JR_B, settings, &temppos, &this->rot, 0);
Needles->doStateChange(&daNeedles::StateID_DemoWait);
// Needles->aPhysics.info.category1 = 0x3;
// Needles->aPhysics.info.bitfield1 = 0x4F;
// Needles->aPhysics.info.bitfield2 = 0xffbafffe;
// Delay in 1/6ths of a second
this->delay = (this->settings >> 16) * 10;
this->loops = (this->settings >> 4);
// State Changers
doStateChange(&StateID_Activate);
this->onExecute();
return true;
}
int daElectricLine::onDelete() {
return true;
}
int daElectricLine::onExecute() {
acState.execute();
return true;
}
int daElectricLine::onDraw() {
return true;
}
// States:
//
// DemoWait - all nullsubs, does nothing
// DemoAwake - moves the spikes in their respective directions
// Idle - Fires off an infinity of effects for some reason.
// Die - removes physics, then nullsubs
///////////////
// Activate State
///////////////
void daElectricLine::beginState_Activate() {
this->timer = this->delay;
Needles->doStateChange(&daNeedles::StateID_Idle);
}
void daElectricLine::executeState_Activate() {
if (this->loops) {
this->timer--;
if (this->timer == 0) {
this->loops += 1;
doStateChange(&StateID_Deactivate);
}
}
}
void daElectricLine::endState_Activate() { }
///////////////
// Deactivate State
///////////////
void daElectricLine::beginState_Deactivate() {
this->timer = this->delay;
Needles->removeMyActivePhysics();
Needles->doStateChange(&daNeedles::StateID_DemoWait);
}
void daElectricLine::executeState_Deactivate() {
this->timer--;
if (this->timer == 0) {
doStateChange(&StateID_Activate);
}
}
void daElectricLine::endState_Deactivate() {
Needles->addMyActivePhysics();
}
///////////////
// Die State
///////////////
void daElectricLine::beginState_Die() { Needles->doStateChange(&daNeedles::StateID_Die); }
void daElectricLine::executeState_Die() { }
void daElectricLine::endState_Die() { }
|