2020-08-22 17:08:56 +01:00
|
|
|
|
using QSB.Animation;
|
|
|
|
|
using QSB.Tools;
|
2020-08-17 21:33:09 +01:00
|
|
|
|
using QSB.TransformSync;
|
2020-07-30 21:57:39 +02: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
|
|
|
|
|
|
|
|
|
namespace QSB
|
|
|
|
|
{
|
|
|
|
|
public class PlayerInfo
|
|
|
|
|
{
|
2020-09-04 20:09:25 +01:00
|
|
|
|
public uint PlayerId { get; }
|
2020-07-28 15:59:24 +02:00
|
|
|
|
public GameObject Camera { get; set; }
|
2020-10-23 19:06:11 +01:00
|
|
|
|
public GameObject Body { get; set; }
|
2020-09-22 21:11:29 +01:00
|
|
|
|
|
|
|
|
|
// Tools
|
2020-08-07 20:39:07 +01:00
|
|
|
|
public GameObject ProbeBody { get; set; }
|
|
|
|
|
public QSBProbe Probe { get; set; }
|
2020-08-17 21:28:38 +01:00
|
|
|
|
public QSBFlashlight FlashLight => Camera?.GetComponentInChildren<QSBFlashlight>();
|
2020-07-30 21:57:39 +02:00
|
|
|
|
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
|
|
|
|
|
public QSBTool Translator => GetToolByType(ToolType.Translator);
|
2020-08-07 20:39:07 +01:00
|
|
|
|
public QSBTool ProbeLauncher => GetToolByType(ToolType.ProbeLauncher);
|
2020-09-22 21:11:29 +01:00
|
|
|
|
|
2020-08-17 21:33:09 +01:00
|
|
|
|
public PlayerHUDMarker HudMarker { get; set; }
|
2020-07-28 15:59:24 +02:00
|
|
|
|
public string Name { get; set; }
|
2020-08-09 21:46:51 +01:00
|
|
|
|
public bool IsReady { get; set; }
|
2020-10-23 19:06:11 +01:00
|
|
|
|
public int CurrentDialogueID { get; set; }
|
|
|
|
|
public GameObject CurrentDialogueBox { get; set; }
|
2020-08-10 11:45:24 +01:00
|
|
|
|
public State State { get; set; }
|
2020-07-30 21:57:39 +02:00
|
|
|
|
|
2020-09-04 20:09:25 +01:00
|
|
|
|
public PlayerInfo(uint id)
|
2020-07-30 21:57:39 +02:00
|
|
|
|
{
|
2020-09-29 21:34:46 +01:00
|
|
|
|
DebugLog.DebugWrite($"Creating PlayerInfo with id {id}");
|
2020-08-26 20:50:30 +01:00
|
|
|
|
PlayerId = id;
|
2020-10-23 19:06:11 +01:00
|
|
|
|
CurrentDialogueID = -1;
|
2020-07-30 21:57:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-10 11:45:24 +01:00
|
|
|
|
public void UpdateStateObjects()
|
2020-08-09 21:46:51 +01:00
|
|
|
|
{
|
2020-08-13 22:06:34 +01:00
|
|
|
|
if (OWInput.GetInputMode() == InputMode.None)
|
2020-08-10 11:45:24 +01:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-16 17:35:27 +02: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-26 20:50:30 +01:00
|
|
|
|
QSB.Helper.Events.Unity.RunWhen(() => PlayerRegistry.GetSyncObject<AnimationSync>(PlayerId) != null,
|
|
|
|
|
() => PlayerRegistry.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(FlagsHelper.IsSet(State, State.Suit)));
|
2020-08-09 21:46:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 20:39:07 +01:00
|
|
|
|
public bool GetState(State state)
|
|
|
|
|
{
|
|
|
|
|
return FlagsHelper.IsSet(State, state);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 21:57:39 +02:00
|
|
|
|
private QSBTool GetToolByType(ToolType type)
|
|
|
|
|
{
|
2020-08-17 18:58:45 +02:00
|
|
|
|
return Camera?.GetComponentsInChildren<QSBTool>()
|
|
|
|
|
.FirstOrDefault(x => x.Type == type);
|
2020-07-30 21:57:39 +02:00
|
|
|
|
}
|
2020-07-28 15:59:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|