#include #include #include #include "player.h" #include "effects.h" #include 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_Enemy(&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->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; }