2020-08-22 17:08:56 +01:00
|
|
|
|
using QSB.Animation;
|
|
|
|
|
using QSB.Tools;
|
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
|
|
|
|
|
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 bool IsReady { get; set; }
|
|
|
|
|
public PlayerHUDMarker HudMarker { get; set; }
|
2021-01-27 10:20:03 +00:00
|
|
|
|
public State State { get; set; } // TODO : decide if this is worth it (instead of having seperate variables for each thing)
|
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; }
|
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; }
|
2020-12-22 09:13:08 +00:00
|
|
|
|
public QSBFlashlight FlashLight => CameraBody?.GetComponentInChildren<QSBFlashlight>();
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
|
|
|
|
|
public QSBTool Translator => GetToolByType(ToolType.Translator);
|
|
|
|
|
public QSBTool ProbeLauncher => GetToolByType(ToolType.ProbeLauncher);
|
2020-09-22 21:11:29 +01:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
// Conversation
|
|
|
|
|
public int CurrentDialogueID { get; set; }
|
|
|
|
|
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;
|
2020-07-30 21:57:39 +02:00
|
|
|
|
|
2021-01-18 12:33:07 +00:00
|
|
|
|
// Misc
|
|
|
|
|
public bool IsInMoon;
|
|
|
|
|
public bool IsInShrine;
|
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public PlayerInfo(uint id)
|
|
|
|
|
{
|
|
|
|
|
PlayerId = id;
|
|
|
|
|
CurrentDialogueID = -1;
|
|
|
|
|
}
|
2020-07-30 21:57:39 +02:00
|
|
|
|
|
2020-12-02 21:23:01 +00: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-07-30 21:57:39 +02:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public void UpdateStateObjects()
|
|
|
|
|
{
|
|
|
|
|
if (OWInput.GetInputMode() == InputMode.None)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
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-12-14 16:24:52 +00:00
|
|
|
|
QSBCore.Helper.Events.Unity.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
|
2020-12-02 21:23:01 +00:00
|
|
|
|
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(FlagsHelper.IsSet(State, State.Suit)));
|
|
|
|
|
}
|
2020-08-09 21:46:51 +01:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public bool GetState(State state)
|
2020-12-14 16:24:52 +00:00
|
|
|
|
=> FlagsHelper.IsSet(State, state);
|
2020-08-07 20:39:07 +01:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private QSBTool GetToolByType(ToolType type)
|
|
|
|
|
{
|
2020-12-22 09:13:08 +00:00
|
|
|
|
return CameraBody?.GetComponentsInChildren<QSBTool>()
|
2020-12-02 21:23:01 +00:00
|
|
|
|
.FirstOrDefault(x => x.Type == type);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-28 15:59:24 +02:00
|
|
|
|
}
|