156 lines
4.9 KiB
C#
Raw Normal View History

2021-04-26 14:30:21 +01:00
using QSB.Animation.Player;
2021-05-07 14:58:37 +01:00
using QSB.Animation.Player.Thrusters;
2021-03-31 10:30:51 +01:00
using QSB.CampfireSync.WorldObjects;
2021-08-08 20:06:38 +01:00
using QSB.ClientServerStateSync;
2021-04-21 11:02:17 +01:00
using QSB.Player.TransformSync;
2021-04-11 17:08:18 +01:00
using QSB.ProbeSync;
2021-02-21 18:25:25 +00:00
using QSB.QuantumSync;
2021-03-30 17:28:05 +01:00
using QSB.RoastingSync;
2020-08-22 17:08:56 +01:00
using QSB.Tools;
2021-07-26 22:55:09 +01:00
using QSB.Tools.ProbeLauncherTool;
2021-07-10 18:59:37 +01:00
using QSB.Utility;
2020-08-21 14:04:13 +01:00
using System.Linq;
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-18 19:07:54 +01:00
public PlayerState PlayerStates { get; set; } = new PlayerState();
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
2020-12-22 09:13:08 +00:00
public OWCamera Camera { get; set; }
public GameObject CameraBody { get; set; }
2020-12-02 21:23:01 +00:00
public GameObject Body { get; set; }
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-08-22 16:54:48 +01:00
public QSBFlashlight FlashLight
2021-08-08 20:06:38 +01: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-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; }
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);
public bool PlayingInstrument => AnimationSync.CurrentType != AnimationType.PlayerSuited
&& AnimationSync.CurrentType != AnimationType.PlayerUnsuited;
2021-05-07 14:58:37 +01:00
public JetpackAccelerationSync JetpackAcceleration { get; set; }
2021-01-18 12:33:07 +00:00
// Misc
2021-08-22 16:40:50 +01:00
public bool IsInMoon; // MOVE : move into PlayerStates?
public bool IsInShrine; // MOVE : move into PlayerStates?
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-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)
{
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalProbeLauncher in PlayerInfo for non local player!", OWML.Common.MessageType.Warning);
return null;
}
return CameraBody.transform.Find("ProbeLauncher").GetComponent<PlayerProbeLauncher>();
}
}
2021-08-22 16:54:48 +01:00
public Flashlight LocalFlashlight
2021-07-10 18:59:37 +01:00
{
get
{
if (QSBPlayerManager.LocalPlayer != this)
{
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalFlashlight in PlayerInfo for non local player!", OWML.Common.MessageType.Warning);
return null;
}
return Locator.GetFlashlight();
}
}
public Signalscope LocalSignalscope
{
get
{
if (QSBPlayerManager.LocalPlayer != this)
{
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalSignalscope in PlayerInfo for non local player!", OWML.Common.MessageType.Warning);
return null;
}
return CameraBody.transform.Find("Signalscope").GetComponent<Signalscope>();
}
}
public NomaiTranslator LocalTranslator
{
get
{
if (QSBPlayerManager.LocalPlayer != this)
{
DebugLog.ToConsole($"Warning - Tried to access local-only property LocalTranslator in PlayerInfo for non local player!", OWML.Common.MessageType.Warning);
return null;
}
return CameraBody.transform.Find("NomaiTranslatorProp").GetComponent<NomaiTranslator>();
}
}
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-12-02 21:23:01 +00:00
public void UpdateStateObjects()
{
if (OWInput.GetInputMode() == InputMode.None)
{
return;
}
2021-06-18 22:38:32 +01:00
2021-04-18 18:42:22 +01:00
FlashLight?.UpdateState(PlayerStates.FlashlightActive);
Translator?.ChangeEquipState(PlayerStates.TranslatorEquipped);
ProbeLauncher?.ChangeEquipState(PlayerStates.ProbeLauncherEquipped);
Signalscope?.ChangeEquipState(PlayerStates.SignalscopeEquipped);
2021-03-13 10:17:52 +00:00
QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
2021-04-18 18:42:22 +01:00
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(PlayerStates.SuitedUp));
2020-12-02 21:23:01 +00:00
}
2020-08-09 21:46:51 +01:00
2021-07-12 22:02:50 +01:00
private QSBTool GetToolByType(ToolType type) => CameraBody?.GetComponentsInChildren<QSBTool>()
2020-12-02 21:23:01 +00:00
.FirstOrDefault(x => x.Type == type);
}
2020-07-28 15:59:24 +02:00
}