ReplacePatch.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using MelonLoader;
  2. using UnityEngine;
  3. namespace AudioMgr
  4. {
  5. public class ReplacePatch
  6. {
  7. private Clip _audioClip;
  8. private string _eventID;
  9. private GameObject _emitterObject;
  10. private AudioMaster.SourceType _sourceType;
  11. private Shot _shotSource;
  12. private Queue _queueSource;
  13. private ClipManager _clipManager;
  14. public ReplacePatch(string eventID, ClipManager clipManager, string clipString, AudioMaster.SourceType sourceType)
  15. {
  16. _eventID = eventID;
  17. _audioClip = clipManager.GetClip(clipString);
  18. _sourceType = sourceType;
  19. _sourceType = sourceType;
  20. _clipManager = clipManager;
  21. }
  22. public void SetEmitterObject(GameObject emitterObject)
  23. {
  24. if (_emitterObject == null)
  25. {
  26. _emitterObject = emitterObject;
  27. _shotSource = AudioMaster.CreateShot(_emitterObject, _sourceType);
  28. // _queueSource = AudioMaster.CreateQueue(_emitterObject, _clipManager, 2f, Queue.Loop.All,AudioMaster.SourceType.SFX);
  29. }
  30. }
  31. public void PlayOneshot(GameObject emitterObject)
  32. {
  33. SetEmitterObject(emitterObject);
  34. _shotSource.PlayOneshot(_audioClip);
  35. }
  36. public void PlayQueue(GameObject emitterObject)
  37. {
  38. SetEmitterObject(emitterObject);
  39. _queueSource.Play();
  40. }
  41. public string eventID
  42. {
  43. get
  44. {
  45. return _eventID;
  46. }
  47. }
  48. public GameObject emitterObject
  49. {
  50. get
  51. {
  52. return _emitterObject;
  53. }
  54. }
  55. }
  56. }