/**
 * @param editor Editor
 * @param object THREE.Object3D
 * @constructor
 */
class PlaySoundCommand {
  constructor() {
    this.type = 'PlaySoundCommand'
    this.PlayType = {
      Alarm: 'Alarm',
      Clash: 'Clash'
    }
    this.AlarmList = []
    this.isAlarm = false
  }

  /**
   * 系统声音
   * @param type 报警Alarm， 碰撞Clash 。。。。。。。
   * @param state 报警/解除报警
   * @param ModelId 模型ID
   */
  exec(type, state = true, ModelId) {
    switch (type) {
      case this.PlayType.Alarm:
        if (state) {
          if (!this.isAlarm) this.playAlarmSound(true)
          if (this.AlarmList.indexOf(ModelId) === -1) this.AlarmList.push(ModelId)
          this.isAlarm = true
        } else {
          this.AlarmList = this.AlarmList.filter(res => { return res !== ModelId })
          if (this.AlarmList.length === 0) {
            this.playAlarmSound(false)
            this.isAlarm = false
          }
        }
        break
      case this.PlayType.Clash:
        break
      default:
        break
    }
  }

  /**
   *
   */
  playAlarmSound(play = true) {
    // const audio = document.getElementById('alarm')
    // play ? audio.play() : audio.pause()
  }
  playClashSound(play) {
    const audio = document.getElementById('clash')
    play ? audio.play() : audio.pause()
  }
}

export { PlaySoundCommand }
