2020-08-21 13:04:13 +00:00
|
|
|
|
using QSB.Tools;
|
2020-08-17 20:33:09 +00:00
|
|
|
|
using QSB.TransformSync;
|
2020-07-30 19:57:39 +00:00
|
|
|
|
using QSB.Utility;
|
2020-08-21 13:04:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2020-08-21 20:31:42 +00:00
|
|
|
|
using QSB.Animation;
|
2020-07-30 19:57:39 +00:00
|
|
|
|
using UnityEngine;
|
2020-07-28 13:59:24 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB
|
|
|
|
|
{
|
|
|
|
|
public class PlayerInfo
|
|
|
|
|
{
|
2020-07-30 19:57:39 +00:00
|
|
|
|
public uint NetId { get; }
|
2020-07-28 13:59:24 +00:00
|
|
|
|
public GameObject Camera { get; set; }
|
2020-08-07 19:39:07 +00:00
|
|
|
|
public GameObject ProbeBody { get; set; }
|
|
|
|
|
public QSBProbe Probe { get; set; }
|
2020-08-17 20:28:38 +00:00
|
|
|
|
public QSBFlashlight FlashLight => Camera?.GetComponentInChildren<QSBFlashlight>();
|
2020-07-30 19:57:39 +00:00
|
|
|
|
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
|
|
|
|
|
public QSBTool Translator => GetToolByType(ToolType.Translator);
|
2020-08-07 19:39:07 +00:00
|
|
|
|
public QSBTool ProbeLauncher => GetToolByType(ToolType.ProbeLauncher);
|
2020-08-17 20:33:09 +00:00
|
|
|
|
public PlayerHUDMarker HudMarker { get; set; }
|
2020-07-28 13:59:24 +00:00
|
|
|
|
public string Name { get; set; }
|
2020-08-09 20:46:51 +00:00
|
|
|
|
public bool IsReady { get; set; }
|
2020-08-10 10:45:24 +00:00
|
|
|
|
public State State { get; set; }
|
2020-07-30 19:57:39 +00:00
|
|
|
|
|
|
|
|
|
public PlayerInfo(uint id)
|
|
|
|
|
{
|
|
|
|
|
NetId = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateState(State state, bool value)
|
|
|
|
|
{
|
|
|
|
|
var states = State;
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
FlagsHelper.Set(ref states, state);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlagsHelper.Unset(ref states, state);
|
|
|
|
|
}
|
|
|
|
|
State = states;
|
2020-08-18 18:35:08 +00:00
|
|
|
|
DebugLog.ToConsole($"State of player {NetId} is now : {Environment.NewLine}" +
|
|
|
|
|
$"{DebugLog.GenerateTable(Enum.GetNames(typeof(State)).ToList(), FlagsHelper.FlagsToListSet(State))}");
|
2020-07-30 19:57:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 10:45:24 +00:00
|
|
|
|
public void UpdateStateObjects()
|
2020-08-09 20:46:51 +00:00
|
|
|
|
{
|
2020-08-13 21:06:34 +00:00
|
|
|
|
if (OWInput.GetInputMode() == InputMode.None)
|
2020-08-10 10:45:24 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-16 15:35:27 +00:00
|
|
|
|
FlashLight?.UpdateState(FlagsHelper.IsSet(State, State.Flashlight));
|
|
|
|
|
Translator?.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator));
|
|
|
|
|
ProbeLauncher?.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher));
|
|
|
|
|
Signalscope?.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope));
|
2020-08-21 20:31:42 +00:00
|
|
|
|
PlayerRegistry.GetSyncObject<AnimationSync>(NetId)?.SetSuitState(FlagsHelper.IsSet(State, State.Suit));
|
2020-08-09 20:46:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 19:39:07 +00:00
|
|
|
|
public bool GetState(State state)
|
|
|
|
|
{
|
|
|
|
|
return FlagsHelper.IsSet(State, state);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 19:57:39 +00:00
|
|
|
|
private QSBTool GetToolByType(ToolType type)
|
|
|
|
|
{
|
2020-08-17 16:58:45 +00:00
|
|
|
|
return Camera?.GetComponentsInChildren<QSBTool>()
|
|
|
|
|
.FirstOrDefault(x => x.Type == type);
|
2020-07-30 19:57:39 +00:00
|
|
|
|
}
|
2020-07-28 13:59:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|