From ceb3b77d6b00e89db29d1dba44ffa6135f953af1 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Wed, 11 Nov 2020 08:31:20 +0000 Subject: [PATCH] renamed "direction" to "isGoingUp" --- QSB/ElevatorSync/Events/ElevatorEvent.cs | 6 +-- QSB/ElevatorSync/QSBElevator.cs | 7 ++- QSB/Instruments/InstrumentsManager.cs | 47 ++++++++++++++------ QSB/QSB.cs | 4 ++ QSB/QSB.csproj | 1 + QSB/QSBInputManager.cs | 55 ++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 QSB/QSBInputManager.cs diff --git a/QSB/ElevatorSync/Events/ElevatorEvent.cs b/QSB/ElevatorSync/Events/ElevatorEvent.cs index 81a980ee..4a7060fc 100644 --- a/QSB/ElevatorSync/Events/ElevatorEvent.cs +++ b/QSB/ElevatorSync/Events/ElevatorEvent.cs @@ -12,11 +12,11 @@ namespace QSB.ElevatorSync.Events public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBStartLift, Handler); - private void Handler(int id, bool direction) => SendEvent(CreateMessage(id, direction)); + private void Handler(int id, bool isGoingUp) => SendEvent(CreateMessage(id, isGoingUp)); - private BoolWorldObjectMessage CreateMessage(int id, bool direction) => new BoolWorldObjectMessage + private BoolWorldObjectMessage CreateMessage(int id, bool isGoingUp) => new BoolWorldObjectMessage { - State = direction, + State = isGoingUp, ObjectId = id }; diff --git a/QSB/ElevatorSync/QSBElevator.cs b/QSB/ElevatorSync/QSBElevator.cs index 2d442c23..c04d023d 100644 --- a/QSB/ElevatorSync/QSBElevator.cs +++ b/QSB/ElevatorSync/QSBElevator.cs @@ -30,15 +30,14 @@ namespace QSB.ElevatorSync _owAudioSourceLP = _elevator.GetValue("_owAudioSourceLP"); } - public void RemoteCall(bool direction) + public void RemoteCall(bool isGoingUp) { - SetDirection(direction); + SetDirection(isGoingUp); RemoteStartLift(); } - private void SetDirection(bool direction) + private void SetDirection(bool isGoingUp) { - var isGoingUp = direction; var targetPos = isGoingUp ? _endLocalPos : _startLocalPos; _elevator.SetValue("_goingToTheEnd", isGoingUp); _elevator.SetValue("_targetLocalPos", targetPos); diff --git a/QSB/Instruments/InstrumentsManager.cs b/QSB/Instruments/InstrumentsManager.cs index 0b8dd768..0a2a3e2d 100644 --- a/QSB/Instruments/InstrumentsManager.cs +++ b/QSB/Instruments/InstrumentsManager.cs @@ -2,6 +2,7 @@ using QSB.EventsCore; using QSB.Instruments.QSBCamera; using QSB.Player; +using QSB.Utility; using UnityEngine; namespace QSB.Instruments @@ -15,24 +16,44 @@ namespace QSB.Instruments { Instance = this; gameObject.AddComponent(); + + QSBInputManager.ChertTaunt += () => StartInstrument(AnimationType.Chert); + QSBInputManager.EskerTaunt += () => StartInstrument(AnimationType.Esker); + QSBInputManager.FeldsparTaunt += () => StartInstrument(AnimationType.Feldspar); + QSBInputManager.GabbroTaunt += () => StartInstrument(AnimationType.Gabbro); + QSBInputManager.RiebeckTaunt += () => StartInstrument(AnimationType.Riebeck); + QSBInputManager.SolanumTaunt += () => StartInstrument(AnimationType.Solanum); } - private void Update() + private void OnDestroy() { - if (Input.GetKeyDown(KeyCode.Keypad9)) + QSBInputManager.ChertTaunt -= () => StartInstrument(AnimationType.Chert); + QSBInputManager.EskerTaunt -= () => StartInstrument(AnimationType.Esker); + QSBInputManager.FeldsparTaunt -= () => StartInstrument(AnimationType.Feldspar); + QSBInputManager.GabbroTaunt -= () => StartInstrument(AnimationType.Gabbro); + QSBInputManager.RiebeckTaunt -= () => StartInstrument(AnimationType.Riebeck); + QSBInputManager.SolanumTaunt -= () => StartInstrument(AnimationType.Solanum); + } + + public void StartInstrument(AnimationType type) + { + if (QSBPlayerManager.LocalPlayer.PlayingInstrument) { - if (!QSBPlayerManager.LocalPlayer.PlayingInstrument) - { - _savedType = QSBPlayerManager.LocalPlayer.Animator.CurrentType; - CameraManager.Instance.SwitchTo3rdPerson(); - SwitchToType(AnimationType.Chert); - } - else - { - CameraManager.Instance.SwitchTo1stPerson(); - SwitchToType(_savedType); - } + return; } + _savedType = QSBPlayerManager.LocalPlayer.Animator.CurrentType; + CameraManager.Instance.SwitchTo3rdPerson(); + SwitchToType(type); + } + + public void ReturnToPlayer() + { + if (!QSBPlayerManager.LocalPlayer.PlayingInstrument) + { + return; + } + CameraManager.Instance.SwitchTo1stPerson(); + SwitchToType(_savedType); } public void SwitchToType(AnimationType type) diff --git a/QSB/QSB.cs b/QSB/QSB.cs index f07f5140..8cad180f 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -16,6 +16,7 @@ namespace QSB { public class QSB : ModBehaviour { + public static IModBehaviour ModBehaviour { get; private set; } public static IModHelper Helper { get; private set; } public static string DefaultServerIP { get; private set; } public static int Port { get; private set; } @@ -30,6 +31,8 @@ namespace QSB var instance = TextTranslation.Get().GetValue("m_table"); instance.theUITable[(int)UITextType.PleaseUseController] = "Quantum Space Buddies is best experienced with friends..."; + + ModBehaviour = this; } private void Start() @@ -55,6 +58,7 @@ namespace QSB gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); + gameObject.AddComponent(); Helper.Events.Unity.RunWhen(() => PlayerData.IsLoaded(), RebuildSettingsSave); } diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 93cd3d95..b474cfbf 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -163,6 +163,7 @@ + diff --git a/QSB/QSBInputManager.cs b/QSB/QSBInputManager.cs new file mode 100644 index 00000000..f32d70d3 --- /dev/null +++ b/QSB/QSBInputManager.cs @@ -0,0 +1,55 @@ +using OWML.Common; +using QSB.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace QSB +{ + public delegate void TauntEvent(); + + public class QSBInputManager : MonoBehaviour + { + public static QSBInputManager Instance; + public static event TauntEvent ChertTaunt; + public static event TauntEvent EskerTaunt; + public static event TauntEvent FeldsparTaunt; + public static event TauntEvent GabbroTaunt; + public static event TauntEvent RiebeckTaunt; + public static event TauntEvent SolanumTaunt; + + public void Awake() + { + Instance = this; + if (Input.GetKeyDown(KeyCode.T)) + { + if (Input.GetKeyDown(KeyCode.Alpha1)) + { + ChertTaunt?.Invoke(); + } + if (Input.GetKeyDown(KeyCode.Alpha2)) + { + EskerTaunt?.Invoke(); + } + if (Input.GetKeyDown(KeyCode.Alpha3)) + { + FeldsparTaunt?.Invoke(); + } + if (Input.GetKeyDown(KeyCode.Alpha4)) + { + GabbroTaunt?.Invoke(); + } + if (Input.GetKeyDown(KeyCode.Alpha5)) + { + RiebeckTaunt?.Invoke(); + } + if (Input.GetKeyDown(KeyCode.Alpha6)) + { + SolanmTaunt?.Invoke(); + } + } + } + } +}