2023-06-08 14:09:50 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using BITKit.Sensors;
|
|
|
|
namespace BITKit.Entities
|
|
|
|
{
|
2023-10-30 01:25:53 +08:00
|
|
|
public class EntityAudioObject : EntityBehavior, IAudioObject
|
2023-06-08 14:09:50 +08:00
|
|
|
{
|
|
|
|
float volume;
|
|
|
|
public override void OnStart()
|
|
|
|
{
|
2023-10-30 01:25:53 +08:00
|
|
|
UnityEntity.AddListener<AudioSO>(OnAuioSO);
|
2023-06-08 14:09:50 +08:00
|
|
|
}
|
|
|
|
public override void OnFixedUpdate(float deltaTime)
|
|
|
|
{
|
|
|
|
volume = Mathf.Lerp(volume, 0, deltaTime);
|
|
|
|
}
|
|
|
|
public float GetVolume()
|
|
|
|
{
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
void OnAuioSO(AudioSO so)
|
|
|
|
{
|
|
|
|
if (so.distance > volume)
|
|
|
|
volume = so.distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|