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) | ||||
Stan: I wonder if all this shouldn't be handled in cmpidentity. To make the other components agnostic. | |||||
Not Done Inline ActionsWell, it seems odd to me that we would handle the soundName in "Identity.js". But if it is something that ought to be done, I'm okay with it, no strong opinion from my side ;) Freagarach: Well, it seems odd to me that we would handle the `soundName` in "Identity.js". But if it is… | |||||
.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
I wonder if all this shouldn't be handled in cmpidentity. To make the other components agnostic. That would simplify the code a lot here and in cmpvisual actor I think you wanted to do it