81 lines
2.3 KiB
C#
Raw Normal View History

2020-08-22 17:08:56 +01:00
using QSB.Animation;
using QSB.Tools;
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 bool IsReady { get; set; }
public PlayerHUDMarker HudMarker { get; set; }
public State State { get; set; }
2020-11-01 12:26:09 +00:00
2020-12-02 21:23:01 +00:00
// Body Objects
public GameObject Camera { get; set; }
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; }
public QSBFlashlight FlashLight => Camera?.GetComponentInChildren<QSBFlashlight>();
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-12-02 21:23:01 +00:00
public PlayerInfo(uint id)
{
PlayerId = id;
CurrentDialogueID = -1;
}
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-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-12-02 21:23:01 +00:00
private QSBTool GetToolByType(ToolType type)
{
return Camera?.GetComponentsInChildren<QSBTool>()
.FirstOrDefault(x => x.Type == type);
}
}
2020-07-28 15:59:24 +02:00
}