2021-10-25 10:42:25 +01:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Animation.Player;
|
2021-12-14 22:53:53 +00:00
|
|
|
|
using QSB.Audio;
|
2021-08-08 20:06:38 +01:00
|
|
|
|
using QSB.ClientServerStateSync;
|
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;
|
2020-08-22 17:08:56 +01:00
|
|
|
|
using QSB.Tools;
|
2021-07-10 18:59:37 +01:00
|
|
|
|
using QSB.Utility;
|
2020-08-21 14:04:13 +01:00
|
|
|
|
using System.Linq;
|
2020-07-28 15:59:24 +02:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.Player;
|
|
|
|
|
|
2022-03-24 15:02:31 +00:00
|
|
|
|
public partial class PlayerInfo
|
2020-07-28 15:59:24 +02:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// the player transform sync's net id
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint PlayerId { get; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public PlayerHUDMarker HudMarker { get; set; }
|
|
|
|
|
public PlayerTransformSync TransformSync { get; }
|
|
|
|
|
public ClientState State { get; set; }
|
|
|
|
|
public EyeState EyeState { get; set; }
|
|
|
|
|
public bool IsDead { get; set; }
|
|
|
|
|
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; }
|
|
|
|
|
public bool IsLocalPlayer => TransformSync.isLocalPlayer;
|
2022-03-07 13:25:41 -08:00
|
|
|
|
public ThrusterLightTracker ThrusterLightTracker;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public PlayerInfo(PlayerTransformSync transformSync)
|
|
|
|
|
{
|
|
|
|
|
PlayerId = transformSync.netId;
|
|
|
|
|
TransformSync = transformSync;
|
|
|
|
|
AnimationSync = transformSync.GetComponent<AnimationSync>();
|
|
|
|
|
}
|
2021-12-10 14:54:51 +00:00
|
|
|
|
|
2022-03-28 12:54:20 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// called on player transform sync uninit.
|
|
|
|
|
/// (BOTH authority and non-authority)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
IsDead = default;
|
|
|
|
|
IsReady = default;
|
|
|
|
|
IsInMoon = default;
|
|
|
|
|
IsInShrine = default;
|
|
|
|
|
IsInEyeShuttle = default;
|
|
|
|
|
HudMarker = default;
|
|
|
|
|
EyeState = default;
|
|
|
|
|
EntangledObject = default;
|
|
|
|
|
AudioController = default;
|
|
|
|
|
ThrusterLightTracker = default;
|
|
|
|
|
|
|
|
|
|
JetpackAcceleration = default;
|
|
|
|
|
_ditheringAnimator = default;
|
|
|
|
|
|
|
|
|
|
_camera = default;
|
|
|
|
|
_body = default;
|
|
|
|
|
|
|
|
|
|
CurrentCharacterDialogueTreeId = -1;
|
|
|
|
|
CurrentDialogueBox = default;
|
|
|
|
|
|
|
|
|
|
InDreamWorld = default;
|
|
|
|
|
AssignedSimulationLantern = default;
|
|
|
|
|
|
|
|
|
|
ProbeBody = default;
|
|
|
|
|
Probe = default;
|
|
|
|
|
_handPivot = default;
|
|
|
|
|
Marshmallow = default;
|
|
|
|
|
Campfire = default;
|
|
|
|
|
HeldItem = default;
|
|
|
|
|
FlashlightActive = default;
|
|
|
|
|
SuitedUp = default;
|
|
|
|
|
ProbeLauncherEquipped = default;
|
|
|
|
|
SignalscopeEquipped = default;
|
|
|
|
|
TranslatorEquipped = default;
|
|
|
|
|
ProbeActive = default;
|
|
|
|
|
RoastingStick = default;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public void UpdateObjectsFromStates()
|
|
|
|
|
{
|
|
|
|
|
if (OWInput.GetInputMode() == InputMode.None)
|
|
|
|
|
{
|
|
|
|
|
// ? why is this here lmao
|
|
|
|
|
return;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2021-12-10 14:54:51 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (CameraBody == null)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-10 14:54:51 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
FlashLight?.UpdateState(FlashlightActive);
|
|
|
|
|
Translator?.ChangeEquipState(TranslatorEquipped);
|
|
|
|
|
ProbeLauncher?.ChangeEquipState(ProbeLauncherEquipped);
|
|
|
|
|
Signalscope?.ChangeEquipState(SignalscopeEquipped);
|
|
|
|
|
AnimationSync.SetSuitState(SuitedUp);
|
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08: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();
|
|
|
|
|
}
|
2022-01-21 22:21:45 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
new PlayerInformationMessage().Send();
|
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08: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;
|
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
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;
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|
2022-01-21 22:21:45 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var tool = tools.FirstOrDefault(x => x.Type == type);
|
|
|
|
|
|
|
|
|
|
if (tool == null)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DebugLog.ToConsole($"Warning - No tool found on player {PlayerId} matching ToolType {type}.", MessageType.Warning);
|
|
|
|
|
}
|
2022-01-21 22:21:45 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
return tool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetVisible(bool visible, float seconds = 0)
|
|
|
|
|
{
|
|
|
|
|
if (IsLocalPlayer)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (!_ditheringAnimator)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - {PlayerId}.DitheringAnimator is null!", MessageType.Warning);
|
|
|
|
|
return;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
_ditheringAnimator.SetVisible(visible, seconds);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2022-03-06 01:01:02 -08:00
|
|
|
|
|
2022-03-11 00:58:14 -08:00
|
|
|
|
public override string ToString() => $"{PlayerId}:{GetType().Name} ({Name})";
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|