diff options
Diffstat (limited to 'Thronefall_v1.0/Decompile/GlobalAudioListener.cs')
-rw-r--r-- | Thronefall_v1.0/Decompile/GlobalAudioListener.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/GlobalAudioListener.cs b/Thronefall_v1.0/Decompile/GlobalAudioListener.cs new file mode 100644 index 0000000..28a5019 --- /dev/null +++ b/Thronefall_v1.0/Decompile/GlobalAudioListener.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +public class GlobalAudioListener : MonoBehaviour +{ + public static GlobalAudioListener instance; + + private PlayerInteraction bufferedPlayerInteraction; + + private Transform bufferedTargetTransform; + + private Vector3 offset = new Vector3(0f, 2f, 0f); + + private void Awake() + { + if (instance != null) + { + Object.Destroy(base.gameObject); + return; + } + instance = this; + Object.DontDestroyOnLoad(base.gameObject); + } + + private void Update() + { + PlayerInteraction playerInteraction = PlayerInteraction.instance; + if (bufferedPlayerInteraction != playerInteraction) + { + if (playerInteraction == null) + { + bufferedTargetTransform = null; + } + else + { + bufferedTargetTransform = playerInteraction.transform; + } + } + if (bufferedTargetTransform != null) + { + base.transform.position = bufferedTargetTransform.position + offset; + } + else + { + base.transform.position = Vector3.zero; + } + bufferedPlayerInteraction = playerInteraction; + } +} |