function Sound() {} Sound.prototype.Schema = "Lists the sound groups associated with this unit." + "" + "" + "actor/human/movement/walk.xml" + "actor/human/movement/walk.xml" + "attack/weapon/sword.xml" + "actor/human/death/death.xml" + "" + "" + "" + "" + /* TODO: make this more specific, like a list of specific elements */ "" + "" + "" + "" + "" + ""; Sound.prototype.Init = function() { }; Sound.prototype.Serialize = null; // we have no dynamic state to save Sound.prototype.GetSoundGroup = function(name) { return this.template.SoundGroups[name] || ""; }; Sound.prototype.PlaySoundGroup = function(name) { if (name in this.template.SoundGroups) { // Replace the "{lang}" codes with this entity's civ ID var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); if (!cmpIdentity) return; var lang = cmpIdentity.GetLang(); // Replace the "{gender}" codes with this entity's gender ID var gender = cmpIdentity.GetGender(); var soundName = this.template.SoundGroups[name].replace(/\{lang\}/g, lang) .replace(/\{gender\}/g, gender); var cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager); if (cmpSoundManager) cmpSoundManager.PlaySoundGroup(soundName, this.entity); } }; Engine.RegisterComponentType(IID_Sound, "Sound", Sound);