diff --git a/QSB/Player/PlayerInfo.cs b/QSB/Player/PlayerInfo.cs index 6c4141da..3dad0d01 100644 --- a/QSB/Player/PlayerInfo.cs +++ b/QSB/Player/PlayerInfo.cs @@ -1,27 +1,18 @@ using OWML.Common; using QSB.Animation.Player; -using QSB.Animation.Player.Thrusters; using QSB.Audio; -using QSB.CampfireSync.WorldObjects; using QSB.ClientServerStateSync; -using QSB.ItemSync.WorldObjects.Items; using QSB.Messaging; using QSB.Player.Messages; using QSB.Player.TransformSync; -using QSB.PlayerBodySetup.Remote; using QSB.QuantumSync.WorldObjects; -using QSB.RoastingSync; using QSB.Tools; -using QSB.Tools.FlashlightTool; -using QSB.Tools.ProbeLauncherTool; -using QSB.Tools.ProbeTool; using QSB.Utility; using System.Linq; -using UnityEngine; namespace QSB.Player; -public class PlayerInfo +public partial class PlayerInfo { /// /// the player transform sync's net id @@ -30,191 +21,18 @@ public class PlayerInfo public string Name { get; set; } public PlayerHUDMarker HudMarker { get; set; } public PlayerTransformSync TransformSync { get; } - public AnimationSync AnimationSync { get; } public ClientState State { get; set; } public EyeState EyeState { get; set; } public bool IsDead { get; set; } - public bool Visible => IsLocalPlayer || _ditheringAnimator == null || _ditheringAnimator.FullyVisible; public bool IsReady { get; set; } public bool IsInMoon { get; set; } public bool IsInShrine { get; set; } public bool IsInEyeShuttle { get; set; } public IQSBQuantumObject EntangledObject { get; set; } public QSBPlayerAudioController AudioController { get; set; } - internal QSBDitheringAnimator _ditheringAnimator; - public bool IsLocalPlayer => TransformSync.isLocalPlayer; - - // Body Objects - public OWCamera Camera - { - get - { - if (_camera == null && IsReady) - { - DebugLog.ToConsole($"Warning - {PlayerId}.Camera is null!", MessageType.Warning); - } - - return _camera; - } - set - { - if (value == null) - { - DebugLog.ToConsole($"Warning - Setting {PlayerId}.Camera to null.", MessageType.Warning); - } - - _camera = value; - } - } - private OWCamera _camera; - - public GameObject CameraBody { get; set; } - - public GameObject Body - { - get - { - if (_body == null && IsReady) - { - DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning); - } - - return _body; - } - set - { - if (value == null) - { - DebugLog.ToConsole($"Warning - Setting {PlayerId}.Body to null.", MessageType.Warning); - } - - _body = value; - } - } - private GameObject _body; - public ThrusterLightTracker ThrusterLightTracker; - public GameObject RoastingStick { get; set; } - - // Tools - public GameObject ProbeBody { get; set; } - public QSBProbe Probe { get; set; } - public QSBFlashlight FlashLight => CameraBody == null ? null : CameraBody.GetComponentInChildren(); - public QSBTool Signalscope => GetToolByType(ToolType.Signalscope); - public QSBTool Translator => GetToolByType(ToolType.Translator); - public QSBProbeLauncherTool ProbeLauncher => (QSBProbeLauncherTool)GetToolByType(ToolType.ProbeLauncher); - private Transform _handPivot; - public Transform HandPivot - { - get - { - if (_handPivot == null) - { - _handPivot = Body.transform.Find( - // TODO : kill me for my sins - "REMOTE_Traveller_HEA_Player_v2/" + - "Traveller_Rig_v01:Traveller_Trajectory_Jnt/" + - "Traveller_Rig_v01:Traveller_ROOT_Jnt/" + - "Traveller_Rig_v01:Traveller_Spine_01_Jnt/" + - "Traveller_Rig_v01:Traveller_Spine_02_Jnt/" + - "Traveller_Rig_v01:Traveller_Spine_Top_Jnt/" + - "Traveller_Rig_v01:Traveller_RT_Arm_Clavicle_Jnt/" + - "Traveller_Rig_v01:Traveller_RT_Arm_Shoulder_Jnt/" + - "Traveller_Rig_v01:Traveller_RT_Arm_Elbow_Jnt/" + - "Traveller_Rig_v01:Traveller_RT_Arm_Wrist_Jnt/" + - "REMOTE_ItemCarryTool/" + - "HandPivot" - ); - } - - return _handPivot; - } - } - public Transform ItemSocket => HandPivot.Find("REMOTE_ItemSocket"); - public Transform ScrollSocket => HandPivot.Find("REMOTE_ScrollSocket"); - public Transform SharedStoneSocket => HandPivot.Find("REMOTE_SharedStoneSocket"); - public Transform WarpCoreSocket => HandPivot.Find("REMOTE_WarpCoreSocket"); - public Transform VesselCoreSocket => HandPivot.Find("REMOTE_VesselCoreSocket"); - public Transform SimpleLanternSocket => HandPivot.Find("REMOTE_SimpleLanternSocket"); - public Transform DreamLanternSocket => HandPivot.Find("REMOTE_DreamLanternSocket"); - public Transform SlideReelSocket => HandPivot.Find("REMOTE_SlideReelSocket"); - public Transform VisionTorchSocket => HandPivot.Find("REMOTE_VisionTorchSocket"); - public QSBMarshmallow Marshmallow { get; set; } - public QSBCampfire Campfire { get; set; } - public IQSBItem HeldItem { get; set; } - public bool FlashlightActive { get; set; } - public bool SuitedUp { get; set; } - public bool ProbeLauncherEquipped { get; set; } - public bool SignalscopeEquipped { get; set; } - public bool TranslatorEquipped { get; set; } - public bool ProbeActive { get; set; } - - // Conversation - public int CurrentCharacterDialogueTreeId { get; set; } = -1; - public GameObject CurrentDialogueBox { get; set; } - - // Animation - public JetpackAccelerationSync JetpackAcceleration { get; set; } - - // Local only - public PlayerProbeLauncher LocalProbeLauncher - { - get - { - if (!IsLocalPlayer) - { - DebugLog.ToConsole($"Warning - Tried to access local-only property LocalProbeLauncher in PlayerInfo for non local player!", MessageType.Warning); - return null; - } - - return CameraBody?.transform.Find("ProbeLauncher").GetComponent(); - } - } - - public Flashlight LocalFlashlight - { - get - { - if (!IsLocalPlayer) - { - DebugLog.ToConsole($"Warning - Tried to access local-only property LocalFlashlight in PlayerInfo for non local player!", MessageType.Warning); - return null; - } - - return Locator.GetFlashlight(); - } - } - - public Signalscope LocalSignalscope - { - get - { - if (!IsLocalPlayer) - { - DebugLog.ToConsole($"Warning - Tried to access local-only property LocalSignalscope in PlayerInfo for non local player!", MessageType.Warning); - return null; - } - - return CameraBody?.transform.Find("Signalscope").GetComponent(); - } - } - - public NomaiTranslator LocalTranslator - { - get - { - if (!IsLocalPlayer) - { - DebugLog.ToConsole($"Warning - Tried to access local-only property LocalTranslator in PlayerInfo for non local player!", MessageType.Warning); - return null; - } - - return CameraBody?.transform.Find("NomaiTranslatorProp").GetComponent(); - } - } - public PlayerInfo(PlayerTransformSync transformSync) { PlayerId = transformSync.netId; diff --git a/QSB/Player/PlayerInfoParts/Animation.cs b/QSB/Player/PlayerInfoParts/Animation.cs new file mode 100644 index 00000000..ee3619df --- /dev/null +++ b/QSB/Player/PlayerInfoParts/Animation.cs @@ -0,0 +1,13 @@ +using QSB.Animation.Player; +using QSB.Animation.Player.Thrusters; +using QSB.PlayerBodySetup.Remote; + +namespace QSB.Player; + +public partial class PlayerInfo +{ + public bool Visible => IsLocalPlayer || _ditheringAnimator == null || _ditheringAnimator.FullyVisible; + public AnimationSync AnimationSync { get; } + public JetpackAccelerationSync JetpackAcceleration { get; set; } + internal QSBDitheringAnimator _ditheringAnimator; +} diff --git a/QSB/Player/PlayerInfoParts/Body.cs b/QSB/Player/PlayerInfoParts/Body.cs new file mode 100644 index 00000000..8399c971 --- /dev/null +++ b/QSB/Player/PlayerInfoParts/Body.cs @@ -0,0 +1,56 @@ +using OWML.Common; +using QSB.Utility; +using UnityEngine; + +namespace QSB.Player; + +public partial class PlayerInfo +{ + public OWCamera Camera + { + get + { + if (_camera == null && IsReady) + { + DebugLog.ToConsole($"Warning - {PlayerId}.Camera is null!", MessageType.Warning); + } + + return _camera; + } + set + { + if (value == null) + { + DebugLog.ToConsole($"Warning - Setting {PlayerId}.Camera to null.", MessageType.Warning); + } + + _camera = value; + } + } + private OWCamera _camera; + + public GameObject CameraBody { get; set; } + + public GameObject Body + { + get + { + if (_body == null && IsReady) + { + DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning); + } + + return _body; + } + set + { + if (value == null) + { + DebugLog.ToConsole($"Warning - Setting {PlayerId}.Body to null.", MessageType.Warning); + } + + _body = value; + } + } + private GameObject _body; +} diff --git a/QSB/Player/PlayerInfoParts/Conversation.cs b/QSB/Player/PlayerInfoParts/Conversation.cs new file mode 100644 index 00000000..7712e9e8 --- /dev/null +++ b/QSB/Player/PlayerInfoParts/Conversation.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace QSB.Player; + +public partial class PlayerInfo +{ + public int CurrentCharacterDialogueTreeId { get; set; } = -1; + public GameObject CurrentDialogueBox { get; set; } +} diff --git a/QSB/Player/PlayerInfoParts/LocalTools.cs b/QSB/Player/PlayerInfoParts/LocalTools.cs new file mode 100644 index 00000000..8d13124e --- /dev/null +++ b/QSB/Player/PlayerInfoParts/LocalTools.cs @@ -0,0 +1,63 @@ +using OWML.Common; +using QSB.Utility; + +namespace QSB.Player; + +public partial class PlayerInfo +{ + public PlayerProbeLauncher LocalProbeLauncher + { + get + { + if (!IsLocalPlayer) + { + DebugLog.ToConsole($"Warning - Tried to access local-only property LocalProbeLauncher in PlayerInfo for non local player!", MessageType.Warning); + return null; + } + + return CameraBody?.transform.Find("ProbeLauncher").GetComponent(); + } + } + + public Flashlight LocalFlashlight + { + get + { + if (!IsLocalPlayer) + { + DebugLog.ToConsole($"Warning - Tried to access local-only property LocalFlashlight in PlayerInfo for non local player!", MessageType.Warning); + return null; + } + + return Locator.GetFlashlight(); + } + } + + public Signalscope LocalSignalscope + { + get + { + if (!IsLocalPlayer) + { + DebugLog.ToConsole($"Warning - Tried to access local-only property LocalSignalscope in PlayerInfo for non local player!", MessageType.Warning); + return null; + } + + return CameraBody?.transform.Find("Signalscope").GetComponent(); + } + } + + public NomaiTranslator LocalTranslator + { + get + { + if (!IsLocalPlayer) + { + DebugLog.ToConsole($"Warning - Tried to access local-only property LocalTranslator in PlayerInfo for non local player!", MessageType.Warning); + return null; + } + + return CameraBody?.transform.Find("NomaiTranslatorProp").GetComponent(); + } + } +} diff --git a/QSB/Player/PlayerInfoParts/Tools.cs b/QSB/Player/PlayerInfoParts/Tools.cs new file mode 100644 index 00000000..9c5c34d4 --- /dev/null +++ b/QSB/Player/PlayerInfoParts/Tools.cs @@ -0,0 +1,66 @@ +using QSB.CampfireSync.WorldObjects; +using QSB.ItemSync.WorldObjects.Items; +using QSB.RoastingSync; +using QSB.Tools; +using QSB.Tools.FlashlightTool; +using QSB.Tools.ProbeLauncherTool; +using QSB.Tools.ProbeTool; +using UnityEngine; + +namespace QSB.Player; + +public partial class PlayerInfo +{ + public GameObject ProbeBody { get; set; } + public QSBProbe Probe { get; set; } + public QSBFlashlight FlashLight => CameraBody == null ? null : CameraBody.GetComponentInChildren(); + public QSBTool Signalscope => GetToolByType(ToolType.Signalscope); + public QSBTool Translator => GetToolByType(ToolType.Translator); + public QSBProbeLauncherTool ProbeLauncher => (QSBProbeLauncherTool)GetToolByType(ToolType.ProbeLauncher); + private Transform _handPivot; + public Transform HandPivot + { + get + { + if (_handPivot == null) + { + _handPivot = Body.transform.Find( + // TODO : kill me for my sins + "REMOTE_Traveller_HEA_Player_v2/" + + "Traveller_Rig_v01:Traveller_Trajectory_Jnt/" + + "Traveller_Rig_v01:Traveller_ROOT_Jnt/" + + "Traveller_Rig_v01:Traveller_Spine_01_Jnt/" + + "Traveller_Rig_v01:Traveller_Spine_02_Jnt/" + + "Traveller_Rig_v01:Traveller_Spine_Top_Jnt/" + + "Traveller_Rig_v01:Traveller_RT_Arm_Clavicle_Jnt/" + + "Traveller_Rig_v01:Traveller_RT_Arm_Shoulder_Jnt/" + + "Traveller_Rig_v01:Traveller_RT_Arm_Elbow_Jnt/" + + "Traveller_Rig_v01:Traveller_RT_Arm_Wrist_Jnt/" + + "REMOTE_ItemCarryTool/" + + "HandPivot" + ); + } + + return _handPivot; + } + } + public Transform ItemSocket => HandPivot.Find("REMOTE_ItemSocket"); + public Transform ScrollSocket => HandPivot.Find("REMOTE_ScrollSocket"); + public Transform SharedStoneSocket => HandPivot.Find("REMOTE_SharedStoneSocket"); + public Transform WarpCoreSocket => HandPivot.Find("REMOTE_WarpCoreSocket"); + public Transform VesselCoreSocket => HandPivot.Find("REMOTE_VesselCoreSocket"); + public Transform SimpleLanternSocket => HandPivot.Find("REMOTE_SimpleLanternSocket"); + public Transform DreamLanternSocket => HandPivot.Find("REMOTE_DreamLanternSocket"); + public Transform SlideReelSocket => HandPivot.Find("REMOTE_SlideReelSocket"); + public Transform VisionTorchSocket => HandPivot.Find("REMOTE_VisionTorchSocket"); + public QSBMarshmallow Marshmallow { get; set; } + public QSBCampfire Campfire { get; set; } + public IQSBItem HeldItem { get; set; } + public bool FlashlightActive { get; set; } + public bool SuitedUp { get; set; } + public bool ProbeLauncherEquipped { get; set; } + public bool SignalscopeEquipped { get; set; } + public bool TranslatorEquipped { get; set; } + public bool ProbeActive { get; set; } + public GameObject RoastingStick { get; set; } +}