You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
using System.Collections.Generic;
|
|
using Entitas;
|
|
using Framw.AudioFramework;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public struct AudioData
|
|
{
|
|
public string soundId;
|
|
public bool isLoop;
|
|
public bool isStop;
|
|
public int soundIndex;
|
|
}
|
|
|
|
[Combat]
|
|
public class AudioComponent : IComponent, IReset
|
|
{
|
|
public int eid;
|
|
internal Queue<AudioData> audioDatas = new();
|
|
internal List<int> audioLoopIndexes = new();
|
|
|
|
public void PushAudioData(ref AudioData audioData)
|
|
{
|
|
var ent = Contexts.Combat.GetEntity(eid);
|
|
if (audioDatas.Count == 0)
|
|
{
|
|
ent.ReplaceComponent(CombatComponentsLookup.Audio, this);
|
|
}
|
|
audioDatas.Enqueue(audioData);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
audioDatas.Clear();
|
|
for (int i = 0; i < audioLoopIndexes.Count; i++)
|
|
{
|
|
SoundManager.Instance.StopLoop(audioLoopIndexes[i]);
|
|
}
|
|
audioLoopIndexes.Clear();
|
|
}
|
|
}
|
|
}
|