Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Sound.js
Show All 29 Lines | Sound.prototype.GetSoundGroup = function(name) | ||||
return this.template.SoundGroups[name] || ""; | return this.template.SoundGroups[name] || ""; | ||||
}; | }; | ||||
Sound.prototype.PlaySoundGroup = function(name) | Sound.prototype.PlaySoundGroup = function(name) | ||||
{ | { | ||||
if (name in this.template.SoundGroups) | if (name in this.template.SoundGroups) | ||||
{ | { | ||||
// Replace the "{lang}" codes with this entity's civ ID | // Replace the "{lang}" codes with this entity's civ ID | ||||
var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | ||||
if (!cmpIdentity) | if (!cmpIdentity) | ||||
return; | return; | ||||
var lang = cmpIdentity.GetLang(); | let lang = cmpIdentity.GetLang(); | ||||
// Replace the "{gender}" codes with this entity's gender ID | // Replace the "{phenotype}" codes with this entity's phenotype ID | ||||
var gender = cmpIdentity.GetGender(); | let phenotype = cmpIdentity.GetPhenotype(); | ||||
var soundName = this.template.SoundGroups[name].replace(/\{lang\}/g, lang) | let soundName = this.template.SoundGroups[name].replace(/\{lang\}/g, lang) | ||||
.replace(/\{gender\}/g, gender); | .replace(/\{phenotype\}/g, phenotype); | ||||
var cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager); | let cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager); | ||||
if (cmpSoundManager) | if (cmpSoundManager) | ||||
cmpSoundManager.PlaySoundGroup(soundName, this.entity); | cmpSoundManager.PlaySoundGroup(soundName, this.entity); | ||||
} | } | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_Sound, "Sound", Sound); | Engine.RegisterComponentType(IID_Sound, "Sound", Sound); |
Wildfire Games · Phabricator