Now plays a "Empty sound", "reload sound" and "hit mark sound" on appropriate occasions.
This commit is contained in:
+1
-1
Submodule assets updated: 8d180f2a54...1e7adc749e
@@ -34,7 +34,8 @@ private:
|
|||||||
void fireRound();
|
void fireRound();
|
||||||
void spawnTracer();
|
void spawnTracer();
|
||||||
float traceRayDistance(glm::vec3 origin, glm::vec3 direction);
|
float traceRayDistance(glm::vec3 origin, glm::vec3 direction);
|
||||||
void playSound();
|
void playFireSound();
|
||||||
|
void playEmptySound();
|
||||||
void viewPunch();
|
void viewPunch();
|
||||||
void finishReload();
|
void finishReload();
|
||||||
void playShootAnimation();
|
void playShootAnimation();
|
||||||
|
|||||||
@@ -175,6 +175,9 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Spectator")) {
|
if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Spectator")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (m_PlayerIDs.find(e.Player.ID) == m_PlayerIDs.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
SpawnRequest req;
|
SpawnRequest req;
|
||||||
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
||||||
req.Team = cTeam["Team"];
|
req.Team = cTeam["Team"];
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ void AssaultWeaponBehaviour::Reload()
|
|||||||
|
|
||||||
// Don't reload if we're completly out of ammo
|
// Don't reload if we're completly out of ammo
|
||||||
if (ammo == 0) {
|
if (ammo == 0) {
|
||||||
|
playEmptySound();
|
||||||
|
m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +123,12 @@ void AssaultWeaponBehaviour::fireRound()
|
|||||||
if (magAmmo <= 0) {
|
if (magAmmo <= 0) {
|
||||||
Reload();
|
Reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire
|
// Fire
|
||||||
magAmmo -= 1;
|
magAmmo -= 1;
|
||||||
spawnTracer();
|
spawnTracer();
|
||||||
playSound();
|
playFireSound();
|
||||||
viewPunch();
|
viewPunch();
|
||||||
playShootAnimation();
|
playShootAnimation();
|
||||||
bool hit = shoot(cAssaultWeapon["BaseDamage"]);
|
bool hit = shoot(cAssaultWeapon["BaseDamage"]);
|
||||||
@@ -172,7 +174,7 @@ float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssaultWeaponBehaviour::playSound()
|
void AssaultWeaponBehaviour::playFireSound()
|
||||||
{
|
{
|
||||||
if (!IsClient) {
|
if (!IsClient) {
|
||||||
return;
|
return;
|
||||||
@@ -184,6 +186,19 @@ void AssaultWeaponBehaviour::playSound()
|
|||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AssaultWeaponBehaviour::playEmptySound()
|
||||||
|
{
|
||||||
|
if (!IsClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::PlaySoundOnEntity e;
|
||||||
|
e.EmitterID = m_Player.ID;
|
||||||
|
e.FilePath = "Audio/weapon/zeroAmmo.wav";
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
void AssaultWeaponBehaviour::viewPunch()
|
void AssaultWeaponBehaviour::viewPunch()
|
||||||
{
|
{
|
||||||
EntityWrapper playerCamera = m_Player.FirstChildByName("Camera");
|
EntityWrapper playerCamera = m_Player.FirstChildByName("Camera");
|
||||||
@@ -342,7 +357,7 @@ void AssaultWeaponBehaviour::showHitMarker()
|
|||||||
if (hitMarkerSpawner.Valid()) {
|
if (hitMarkerSpawner.Valid()) {
|
||||||
SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner);
|
SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner);
|
||||||
Events::PlaySoundOnEntity e;
|
Events::PlaySoundOnEntity e;
|
||||||
e.EmitterID = hitMarkerSpawner.ID; // This might not be the optimal spawner entity
|
e.EmitterID = m_Player.ID;
|
||||||
e.FilePath = "Audio/weapon/hitclick.wav";
|
e.FilePath = "Audio/weapon/hitclick.wav";
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user