using QSB.EventsCore; using QSB.Instruments.QSBCamera; using QSB.Player; using UnityEngine; namespace QSB.Instruments { public class InstrumentsManager : MonoBehaviour { public static InstrumentsManager Instance; private RuntimeAnimatorController RiebeckController; private RuntimeAnimatorController ChertController; private RuntimeAnimatorController GabbroController; private RuntimeAnimatorController FeldsparController; private void Awake() { Instance = this; gameObject.AddComponent(); QSBSceneManager.OnSceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(OWScene scene, bool inUniverse) { var reibeckRoot = GameObject.Find("Traveller_HEA_Riebeck_ANIM_Talking"); RiebeckController = reibeckRoot.GetComponent().runtimeAnimatorController; var chertRoot = GameObject.Find("Traveller_HEA_Chert_ANIM_Chatter_Chipper"); ChertController = chertRoot.GetComponent().runtimeAnimatorController; var gabbroRoot = GameObject.Find("Traveller_HEA_Gabbro_ANIM_IdleFlute"); GabbroController = gabbroRoot.GetComponent().runtimeAnimatorController; var feldsparRoot = GameObject.Find("Traveller_HEA_Feldspar_ANIM_Talking"); FeldsparController = feldsparRoot.GetComponent().runtimeAnimatorController; } private void Update() { if (Input.GetKeyDown(KeyCode.Keypad9)) { if (!QSBPlayerManager.LocalPlayer.PlayingInstrument) { CameraManager.Instance.SwitchTo3rdPerson(); SwitchToInstrument(InstrumentType.RIEBECK); var animator = Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2").GetComponent(); animator.runtimeAnimatorController = ChertController; animator.SetTrigger("Playing"); } else { CameraManager.Instance.SwitchTo1stPerson(); SwitchToInstrument(InstrumentType.NONE); } } } public void SwitchToInstrument(InstrumentType type) { QSBPlayerManager.LocalPlayer.CurrentInstrument = type; GlobalMessenger.FireEvent(EventNames.QSBPlayInstrument, type); } } }