quantum-space-buddies/QSB/PlayerInfo.cs

46 lines
1.2 KiB
C#
Raw Normal View History

using System.Linq;
using QSB.Animation;
using QSB.Utility;
using UnityEngine;
2020-07-28 13:59:24 +00:00
namespace QSB
{
public class PlayerInfo
{
public uint NetId { get; }
2020-07-28 13:59:24 +00:00
public GameObject Body { get; set; }
public GameObject Camera { get; set; }
public QSBFlashlight FlashLight => Camera.GetComponentInChildren<QSBFlashlight>();
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
public QSBTool Translator => GetToolByType(ToolType.Translator);
2020-07-28 13:59:24 +00:00
public string Name { get; set; }
public bool IsReady { get; set; }
2020-07-28 13:59:24 +00:00
public Transform ReferenceSector { get; set; }
public State State { get; private set; }
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;
}
private QSBTool GetToolByType(ToolType type)
{
return Camera.GetComponentsInChildren<QSBTool>().First(x => x.Type == type);
}
2020-07-28 13:59:24 +00:00
}
}