void CCompChoppyThrower::ReceiveMessage(SMessage &msg) { if (msg.m_type == EMT_SHOOT && m_lastShot >= GetCooldown()) { SShootMsg &shootMsg = static_cast<SShootMsg &>(msg); if (shootMsg.GetWeaponId() == GetId()) { SGetWorldMsg worldMsg; m_owner->ReceiveMessage(worldMsg); CWorld * world = worldMsg.GetWorld(); SGetRotMsg rotMsg; m_owner->ReceiveMessage(rotMsg); SGetPosMsg posMsg; m_owner->ReceiveMessage(posMsg); SGetEnergyMsg getEnergyMsg; m_owner->ReceiveMessage(getEnergyMsg); if (rotMsg.Modified() && getEnergyMsg.Modified() && getEnergyMsg.GetEnergy() - GetEnergyConsumed() > 0) { world->AddEntity(world->GetEntitiesFactory().SpawnEntity( new SBotParams(m_owner->GetSide(), GetImg(), posMsg.GetX(), posMsg.GetY(), m_botLifeTime, GetDamage(), m_speed))); SUpdateEnergyMsg updateEnergyMsg(-GetEnergyConsumed()); m_owner->ReceiveMessage(updateEnergyMsg); m_lastShot = 0; AudioBuffer * buffer = new AudioBuffer("data/sounds/fusion_blaster_shoot.wav"); AudioSource * shootAudio = new AudioSource(buffer); shootAudio->Play(); } } } }
uint8 CEntitiesFactory::Init(CWorld &world) { uint8 ret = 0; Init(); m_world = &world; for (std::vector<SEntityParams *>::iterator itr = g_entitiesParams.begin(); itr != g_entitiesParams.end(); ++itr) { CEntity * et = SpawnEntity(*itr); world.AddEntity(et); } return ret; }