2021-10-25 10:42:25 +01:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Animation.Player;
|
2021-05-07 14:58:37 +01:00
|
|
|
|
using QSB.Animation.Player.Thrusters;
|
2021-12-14 22:53:53 +00:00
|
|
|
|
using QSB.Audio;
|
2021-03-31 10:30:51 +01:00
|
|
|
|
using QSB.CampfireSync.WorldObjects;
|
2021-08-08 20:06:38 +01:00
|
|
|
|
using QSB.ClientServerStateSync;
|
2021-11-01 15:49:00 +00:00
|
|
|
|
using QSB.ItemSync.WorldObjects.Items;
|
2021-12-22 17:38:08 -08:00
|
|
|
|
using QSB.Messaging;
|
2021-12-23 17:07:29 -08:00
|
|
|
|
using QSB.Player.Messages;
|
|
|
|
|
using QSB.Player.TransformSync;
|
|
|
|
|
using QSB.QuantumSync.WorldObjects;
|
2021-03-30 17:28:05 +01:00
|
|
|
|
using QSB.RoastingSync;
|
2020-08-22 17:08:56 +01:00
|
|
|
|
using QSB.Tools;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
using QSB.Tools.FlashlightTool;
|
2021-07-26 22:55:09 +01:00
|
|
|
|
using QSB.Tools.ProbeLauncherTool;
|
2021-11-09 17:46:46 +00:00
|
|
|
|
using QSB.Tools.ProbeTool;
|
2021-07-10 18:59:37 +01:00
|
|
|
|
using QSB.Utility;
|
2020-08-21 14:04:13 +01:00
|
|
|
|
using System.Linq;
|
2020-07-30 21:57:39 +02:00
|
|
|
|
using UnityEngine;
|
2020-07-28 15:59:24 +02:00
|
|
|
|
|
2020-11-03 21:33:48 +00:00
|
|
|
|
namespace QSB.Player
|
2020-07-28 15:59:24 +02:00
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public class PlayerInfo
|
|
|
|
|
{
|
|
|
|
|
public uint PlayerId { get; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public PlayerHUDMarker HudMarker { get; set; }
|
2021-04-21 11:02:17 +01:00
|
|
|
|
public PlayerTransformSync TransformSync { get; set; }
|
2020-11-01 12:26:09 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
// Body Objects
|
2021-10-25 10:42:25 +01:00
|
|
|
|
public OWCamera Camera
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2021-11-20 11:48:46 +00:00
|
|
|
|
if (_camera == null && IsReady)
|
2021-10-25 10:42:25 +01:00
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - {PlayerId}.Camera is null!", MessageType.Warning);
|
|
|
|
|
}
|
2021-11-20 11:48:46 +00:00
|
|
|
|
|
2021-10-25 10:42:25 +01:00
|
|
|
|
return _camera;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - Setting {PlayerId}.Camera to null.", MessageType.Warning);
|
|
|
|
|
}
|
2021-11-20 11:48:46 +00:00
|
|
|
|
|
2021-10-25 10:42:25 +01:00
|
|
|
|
_camera = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private OWCamera _camera;
|
|
|
|
|
|
2020-12-22 09:13:08 +00:00
|
|
|
|
public GameObject CameraBody { get; set; }
|
2021-10-25 10:42:25 +01:00
|
|
|
|
public GameObject Body
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2021-11-20 11:48:46 +00:00
|
|
|
|
if (_body == null && IsReady)
|
2021-10-25 10:42:25 +01:00
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning);
|
|
|
|
|
}
|
2021-11-20 19:49:50 +00:00
|
|
|
|
|
2021-10-25 10:42:25 +01:00
|
|
|
|
return _body;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - Setting {PlayerId}.Body to null.", MessageType.Warning);
|
|
|
|
|
}
|
2021-11-20 19:49:50 +00:00
|
|
|
|
|
2021-10-25 10:42:25 +01:00
|
|
|
|
_body = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private GameObject _body;
|
|
|
|
|
|
2021-03-30 17:28:05 +01:00
|
|
|
|
public GameObject RoastingStick { get; set; }
|
2021-06-23 21:44:18 +01:00
|
|
|
|
public bool Visible { get; set; } = true;
|
2020-09-22 21:11:29 +01:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
// Tools
|
|
|
|
|
public GameObject ProbeBody { get; set; }
|
|
|
|
|
public QSBProbe Probe { get; set; }
|
2021-11-25 15:32:34 +00:00
|
|
|
|
public QSBFlashlight FlashLight
|
2021-11-21 13:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (CameraBody == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CameraBody.GetComponentInChildren<QSBFlashlight>();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
|
|
|
|
|
public QSBTool Translator => GetToolByType(ToolType.Translator);
|
2021-07-26 22:55:09 +01:00
|
|
|
|
public QSBProbeLauncherTool ProbeLauncher => (QSBProbeLauncherTool)GetToolByType(ToolType.ProbeLauncher);
|
2021-07-19 14:58:28 +01:00
|
|
|
|
public Transform ItemSocket => CameraBody.transform.Find("REMOTE_ItemSocket");
|
|
|
|
|
public Transform ScrollSocket => CameraBody.transform.Find("REMOTE_ScrollSocket");
|
|
|
|
|
public Transform SharedStoneSocket => CameraBody.transform.Find("REMOTE_SharedStoneSocket");
|
|
|
|
|
public Transform WarpCoreSocket => CameraBody.transform.Find("REMOTE_WarpCoreSocket");
|
|
|
|
|
public Transform VesselCoreSocket => CameraBody.transform.Find("REMOTE_VesselCoreSocket");
|
2021-11-01 15:49:00 +00:00
|
|
|
|
public Transform SimpleLanternSocket => CameraBody.transform.Find("REMOTE_SimpleLanternSocket");
|
|
|
|
|
public Transform DreamLanternSocket => CameraBody.transform.Find("REMOTE_DreamLanternSocket");
|
|
|
|
|
public Transform SlideReelSocket => CameraBody.transform.Find("REMOTE_SlideReelSocket");
|
|
|
|
|
public Transform VisionTorchSocket => CameraBody.transform.Find("REMOTE_VisionTorchSocket");
|
2021-03-30 17:28:05 +01:00
|
|
|
|
public QSBMarshmallow Marshmallow { get; set; }
|
2021-03-31 10:30:51 +01:00
|
|
|
|
public QSBCampfire Campfire { get; set; }
|
2021-10-30 16:14:38 +01:00
|
|
|
|
public IQSBOWItem HeldItem { get; set; }
|
2020-09-22 21:11:29 +01:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
// Conversation
|
2021-04-29 18:30:45 +01:00
|
|
|
|
public int CurrentCharacterDialogueTreeId { get; set; }
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public GameObject CurrentDialogueBox { get; set; }
|
2020-11-01 12:26:09 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
// Animation
|
|
|
|
|
public AnimationSync AnimationSync => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId);
|
2021-11-20 19:49:50 +00:00
|
|
|
|
public bool PlayingInstrument => AnimationSync.CurrentType is not AnimationType.PlayerSuited
|
|
|
|
|
and not AnimationType.PlayerUnsuited;
|
2021-05-07 14:58:37 +01:00
|
|
|
|
public JetpackAccelerationSync JetpackAcceleration { get; set; }
|
2020-07-30 21:57:39 +02:00
|
|
|
|
|
2021-01-18 12:33:07 +00:00
|
|
|
|
// Misc
|
2021-12-23 11:37:37 +00:00
|
|
|
|
// CLEANUP : this file is very messy. especially this bit
|
2021-11-20 11:48:46 +00:00
|
|
|
|
public bool IsReady { get; set; }
|
2021-12-18 10:33:18 +00:00
|
|
|
|
public bool IsInMoon;
|
|
|
|
|
public bool IsInShrine;
|
2021-02-21 18:25:25 +00:00
|
|
|
|
public IQSBQuantumObject EntangledObject;
|
2021-06-25 13:17:10 +01:00
|
|
|
|
public bool IsDead { get; set; }
|
2021-08-08 19:57:58 +01:00
|
|
|
|
public ClientState State { get; set; }
|
2021-11-20 11:48:46 +00:00
|
|
|
|
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; }
|
2021-12-14 22:53:53 +00:00
|
|
|
|
public QSBPlayerAudioController AudioController { get; set; }
|
2021-12-23 11:37:37 +00:00
|
|
|
|
public EyeState EyeState { get; set; }
|
2021-01-18 12:33:07 +00:00
|
|
|
|
|
2021-07-10 18:59:37 +01:00
|
|
|
|
// Local only
|
|
|
|
|
public PlayerProbeLauncher LocalProbeLauncher
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (QSBPlayerManager.LocalPlayer != this)
|
|
|
|
|
{
|
2021-10-25 10:42:25 +01:00
|
|
|
|
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalProbeLauncher in PlayerInfo for non local player!", MessageType.Warning);
|
2021-07-10 18:59:37 +01:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 22:13:39 +00:00
|
|
|
|
return CameraBody?.transform.Find("ProbeLauncher").GetComponent<PlayerProbeLauncher>();
|
2021-07-10 18:59:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-22 16:54:48 +01:00
|
|
|
|
public Flashlight LocalFlashlight
|
2021-07-10 18:59:37 +01:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (QSBPlayerManager.LocalPlayer != this)
|
|
|
|
|
{
|
2021-10-25 10:42:25 +01:00
|
|
|
|
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalFlashlight in PlayerInfo for non local player!", MessageType.Warning);
|
2021-07-10 18:59:37 +01:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Locator.GetFlashlight();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Signalscope LocalSignalscope
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (QSBPlayerManager.LocalPlayer != this)
|
|
|
|
|
{
|
2021-10-25 10:42:25 +01:00
|
|
|
|
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalSignalscope in PlayerInfo for non local player!", MessageType.Warning);
|
2021-07-10 18:59:37 +01:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 22:13:39 +00:00
|
|
|
|
return CameraBody?.transform.Find("Signalscope").GetComponent<Signalscope>();
|
2021-07-10 18:59:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NomaiTranslator LocalTranslator
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (QSBPlayerManager.LocalPlayer != this)
|
|
|
|
|
{
|
2021-10-25 10:42:25 +01:00
|
|
|
|
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalTranslator in PlayerInfo for non local player!", MessageType.Warning);
|
2021-07-10 18:59:37 +01:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 22:13:39 +00:00
|
|
|
|
return CameraBody?.transform.Find("NomaiTranslatorProp").GetComponent<NomaiTranslator>();
|
2021-07-10 18:59:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public PlayerInfo(uint id)
|
|
|
|
|
{
|
|
|
|
|
PlayerId = id;
|
2021-04-29 18:30:45 +01:00
|
|
|
|
CurrentCharacterDialogueTreeId = -1;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-07-30 21:57:39 +02:00
|
|
|
|
|
2021-11-21 13:52:29 +00:00
|
|
|
|
public void UpdateObjectsFromStates()
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (OWInput.GetInputMode() == InputMode.None)
|
2021-12-11 20:06:02 +00:00
|
|
|
|
{
|
|
|
|
|
// ? why is this here lmao
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CameraBody == null)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-18 22:38:32 +01:00
|
|
|
|
|
2021-11-20 11:48:46 +00:00
|
|
|
|
FlashLight?.UpdateState(FlashlightActive);
|
|
|
|
|
Translator?.ChangeEquipState(TranslatorEquipped);
|
|
|
|
|
ProbeLauncher?.ChangeEquipState(ProbeLauncherEquipped);
|
|
|
|
|
Signalscope?.ChangeEquipState(SignalscopeEquipped);
|
2021-03-13 10:17:52 +00:00
|
|
|
|
QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
|
2021-11-20 11:48:46 +00:00
|
|
|
|
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(SuitedUp));
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-08-09 21:46:51 +01:00
|
|
|
|
|
2021-11-21 13:52:29 +00:00
|
|
|
|
public void UpdateStatesFromObjects()
|
|
|
|
|
{
|
|
|
|
|
if (Locator.GetFlashlight() == null || Locator.GetPlayerBody() == null)
|
|
|
|
|
{
|
|
|
|
|
FlashlightActive = false;
|
|
|
|
|
SuitedUp = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlashlightActive = Locator.GetFlashlight()._flashlightOn;
|
|
|
|
|
SuitedUp = Locator.GetPlayerBody().GetComponent<PlayerSpacesuit>().IsWearingSuit(true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 17:38:08 -08:00
|
|
|
|
new PlayerInformationMessage().Send();
|
2021-11-21 13:52:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 14:54:51 +00:00
|
|
|
|
private QSBTool GetToolByType(ToolType type)
|
|
|
|
|
{
|
|
|
|
|
if (CameraBody == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - Tried to GetToolByType({type}) on player {PlayerId}, but CameraBody was null.", MessageType.Warning);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tools = CameraBody.GetComponentsInChildren<QSBTool>();
|
|
|
|
|
|
|
|
|
|
if (tools == null || tools.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - Couldn't find any QSBTools for player {PlayerId}.", MessageType.Warning);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tool = tools.FirstOrDefault(x => x.Type == type);
|
|
|
|
|
|
|
|
|
|
if (tool == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - No tool found on player {PlayerId} matching ToolType {type}.", MessageType.Warning);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tool;
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-07-28 15:59:24 +02:00
|
|
|
|
}
|