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
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include "player.h"
#include "effects.h"
#include <sfx.h>
extern "C" void *PlaySound(dEn_c *, int soundID);
class daFakeStarCoin : public dEn_c {
int onCreate();
int onExecute();
int onDelete();
int onDraw();
mHeapAllocator_c allocator;
m3d::mdl_c bodyModel;
u64 eventFlag;
s32 timer;
u32 delay;
u32 effect;
u8 type;
static daFakeStarCoin *build();
void updateModelMatrices();
void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
};
void daFakeStarCoin::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
PlaySound(this, SE_EMY_CS_TERESA_BEAT_YOU);
CreateEffect(377, &this->pos);
this->Delete();
}
daFakeStarCoin *daFakeStarCoin::build() {
void *buffer = AllocFromGameHeap1(sizeof(daFakeStarCoin));
return new(buffer) daFakeStarCoin;
}
int daFakeStarCoin::onCreate() {
allocator.link(-1, GameHeaps[0], 0, 0x20);
nw4r::g3d::ResFile rf(getResource("star_coin", "g3d/star_coin.brres"));
bodyModel.setup(rf.GetResMdl("star_coinA"), &allocator, 0x224, 1, 0);
SetupTextures_Map(&bodyModel, 0);
allocator.unlink();
ActivePhysics::Info HitMeBaby;
HitMeBaby.xDistToCenter = 0.0;
HitMeBaby.yDistToCenter = -3.0;
HitMeBaby.xDistToEdge = 12.0;
HitMeBaby.yDistToEdge = 15.0;
HitMeBaby.category1 = 0x5;
HitMeBaby.category2 = 0x0;
HitMeBaby.bitfield1 = 0x4F;
HitMeBaby.bitfield2 = 0x200;
HitMeBaby.unkShort1C = 0;
HitMeBaby.callback = &dEn_c::collisionCallback;
this->aPhysics.initWithStruct(this, &HitMeBaby);
this->aPhysics.addToList();
this->scale.x = 1.0;
this->scale.y = 1.0;
this->scale.z = 1.0;
this->pos.x -= 120.0;
this->pos.z = 3300.0;
this->onExecute();
return true;
}
int daFakeStarCoin::onDelete() {
return true;
}
int daFakeStarCoin::onDraw() {
bodyModel.scheduleForDrawing();
return true;
}
void daFakeStarCoin::updateModelMatrices() {
matrix.translation(pos.x, pos.y, pos.z);
matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
bodyModel.setDrawMatrix(matrix);
bodyModel.setScale(&scale);
bodyModel.calcWorld(false);
}
int daFakeStarCoin::onExecute() {
updateModelMatrices();
this->rot.x += 0x200;
return true;
}
|