blob: c9bc5ae61fa6208cda2c6fba710c4e1a1d913504 (
plain)
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
|
#include <game.h>
class dSpriteSpawner_c : public dStageActor_c {
public:
static dSpriteSpawner_c *build();
u64 classicEventOverride;
Actors profileID;
bool respawn;
u32 childSettings;
u32 childID;
int onCreate();
int onExecute();
};
/*****************************************************************************/
// Glue Code
dSpriteSpawner_c *dSpriteSpawner_c::build() {
void *buffer = AllocFromGameHeap1(sizeof(dSpriteSpawner_c));
dSpriteSpawner_c *c = new(buffer) dSpriteSpawner_c;
return c;
}
int dSpriteSpawner_c::onCreate() {
char classicEventNum = (settings >> 28) & 0xF;
classicEventOverride = (classicEventNum == 0) ? 0 : ((u64)1 << (classicEventNum - 1));
profileID = (Actors)((settings >> 16) & 0x7FF);
respawn = (settings >> 27) & 1;
u16 tempSet = settings & 0xFFFF;
childSettings =
(tempSet & 3) | ((tempSet & 0xC) << 2) |
((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) |
((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) |
((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
return true;
}
int dSpriteSpawner_c::onExecute() {
u64 effectiveFlag = classicEventOverride | spriteFlagMask;
if (dFlagMgr_c::instance->flags & effectiveFlag) {
if (!childID) {
dStageActor_c *newAc = dStageActor_c::create(profileID, childSettings, &pos, 0, 0);
childID = newAc->id;
}
} else {
if (respawn)
return true;
if (childID) {
dStageActor_c *ac = (dStageActor_c*)fBase_c::search(childID);
if (ac) {
pos = ac->pos;
ac->Delete(1);
}
childID = 0;
}
}
if (respawn) {
if (childID) {
dStageActor_c *ac = (dStageActor_c*)fBase_c::search(childID);
if (!ac) {
dStageActor_c *newAc = dStageActor_c::create(profileID, childSettings, &pos, 0, 0);
childID = newAc->id;
}
}
}
return true;
}
|