From be117ccc40c1a5fbd32715ca99a39ff33c683614 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 1 Nov 2020 12:26:09 +0000 Subject: [PATCH] add more stuff --- QSB/Instruments/InstrumentType.cs | 1 + QSB/Instruments/InstrumentsManager.cs | 14 ++++++++++++-- QSB/Instruments/QSBCamera/CameraController.cs | 2 ++ QSB/PlayerInfo.cs | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/QSB/Instruments/InstrumentType.cs b/QSB/Instruments/InstrumentType.cs index 9401d84a..6bba48c5 100644 --- a/QSB/Instruments/InstrumentType.cs +++ b/QSB/Instruments/InstrumentType.cs @@ -7,6 +7,7 @@ namespace QSB.Instruments { public enum InstrumentType { + NONE, CHERT, ESKER, FELDSPAR, diff --git a/QSB/Instruments/InstrumentsManager.cs b/QSB/Instruments/InstrumentsManager.cs index 059acb79..c7691915 100644 --- a/QSB/Instruments/InstrumentsManager.cs +++ b/QSB/Instruments/InstrumentsManager.cs @@ -1,4 +1,5 @@ -using QSB.Instruments.QSBCamera; +using QSB.Events; +using QSB.Instruments.QSBCamera; using UnityEngine; namespace QSB.Instruments @@ -17,7 +18,16 @@ namespace QSB.Instruments { if (Input.GetKeyDown(KeyCode.Keypad9)) { - CameraManager.Instance.ToggleViewMode(); + if (!PlayerRegistry.LocalPlayer.PlayingInstrument) + { + CameraManager.Instance.SwitchTo3rdPerson(); + GlobalMessenger.FireEvent(EventNames.QSBPlayInstrument, InstrumentType.REIBECK, true); + } + else + { + CameraManager.Instance.SwitchTo1stPerson(); + GlobalMessenger.FireEvent(EventNames.QSBPlayInstrument, InstrumentType.REIBECK, false); + } } } } diff --git a/QSB/Instruments/QSBCamera/CameraController.cs b/QSB/Instruments/QSBCamera/CameraController.cs index c33964b9..5129e2c9 100644 --- a/QSB/Instruments/QSBCamera/CameraController.cs +++ b/QSB/Instruments/QSBCamera/CameraController.cs @@ -34,10 +34,12 @@ namespace QSB.Instruments.QSBCamera Vector3 localTargetPoint; if (Physics.Raycast(origin, transform.TransformDirection(localDirection), out RaycastHit outRay, RayLength, LayerMask.GetMask("Default"))) { + // Raycast hit collider, get target from hitpoint. localTargetPoint = transform.InverseTransformPoint(outRay.point) * PercentToMove; } else { + // Raycast didn't hit collider, get target from camera direction localTargetPoint = localDirection * RayLength * PercentToMove; } var targetDistance = Vector3.Distance(origin, transform.TransformPoint(localTargetPoint)); diff --git a/QSB/PlayerInfo.cs b/QSB/PlayerInfo.cs index e469facc..6c18d0b1 100644 --- a/QSB/PlayerInfo.cs +++ b/QSB/PlayerInfo.cs @@ -1,4 +1,5 @@ using QSB.Animation; +using QSB.Instruments; using QSB.Tools; using QSB.TransformSync; using QSB.Utility; @@ -10,6 +11,12 @@ namespace QSB public class PlayerInfo { public uint PlayerId { get; } + public string Name { get; set; } + public bool IsReady { get; set; } + public PlayerHUDMarker HudMarker { get; set; } + public State State { get; set; } + + // Body Objects public GameObject Camera { get; set; } public GameObject Body { get; set; } @@ -21,12 +28,13 @@ namespace QSB public QSBTool Translator => GetToolByType(ToolType.Translator); public QSBTool ProbeLauncher => GetToolByType(ToolType.ProbeLauncher); - public PlayerHUDMarker HudMarker { get; set; } - public string Name { get; set; } - public bool IsReady { get; set; } + // Conversation public int CurrentDialogueID { get; set; } public GameObject CurrentDialogueBox { get; set; } - public State State { get; set; } + + // Instruments + public InstrumentType CurrentInstrument { get; set; } + public bool PlayingInstrument => CurrentInstrument != InstrumentType.NONE; public PlayerInfo(uint id) {