86 lines
3.1 KiB
C#
Raw Normal View History

2021-04-26 14:30:21 +01:00
using QSB.Animation.Player;
2021-05-07 14:58:37 +01:00
using QSB.Animation.Player.Thrusters;
2021-03-31 10:30:51 +01:00
using QSB.CampfireSync.WorldObjects;
2021-04-21 11:02:17 +01:00
using QSB.Player.TransformSync;
2021-04-11 17:08:18 +01:00
using QSB.ProbeSync;
2021-02-21 18:25:25 +00:00
using QSB.QuantumSync;
2021-03-30 17:28:05 +01:00
using QSB.RoastingSync;
2020-08-22 17:08:56 +01:00
using QSB.Tools;
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 PlayerHUDMarker HudMarker { get; set; }
2021-04-18 19:07:54 +01:00
public PlayerState PlayerStates { get; set; } = new PlayerState();
2021-04-21 11:02:17 +01:00
public PlayerTransformSync TransformSync { get; set; }
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; }
2021-03-30 17:28:05 +01:00
public GameObject RoastingStick { get; set; }
public bool Visible { 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);
2021-02-26 10:23:08 +00:00
public Transform ItemSocket => CameraBody.transform.Find("ItemSocket");
public Transform ScrollSocket => CameraBody.transform.Find("ScrollSocket");
public Transform SharedStoneSocket => CameraBody.transform.Find("SharedStoneSocket");
public Transform WarpCoreSocket => CameraBody.transform.Find("WarpCoreSocket");
public Transform VesselCoreSocket => CameraBody.transform.Find("VesselCoreSocket");
2021-03-30 17:28:05 +01:00
public QSBMarshmallow Marshmallow { get; set; }
2021-03-31 10:30:51 +01:00
public QSBCampfire Campfire { get; set; }
2020-09-22 21:11:29 +01:00
2020-12-02 21:23:01 +00:00
// Conversation
2021-04-29 18:30:45 +01:00
public int CurrentCharacterDialogueTreeId { get; set; }
2020-12-02 21:23:01 +00:00
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;
2021-05-07 14:58:37 +01:00
public JetpackAccelerationSync JetpackAcceleration { get; set; }
2021-01-18 12:33:07 +00:00
// Misc
2021-04-18 18:46:55 +01:00
public bool IsInMoon; // TODO : move into PlayerStates?
public bool IsInShrine; // TODO : move into PlayerStates?
2021-02-21 18:25:25 +00:00
public IQSBQuantumObject EntangledObject;
2021-01-18 12:33:07 +00:00
2020-12-02 21:23:01 +00:00
public PlayerInfo(uint id)
{
PlayerId = id;
2021-04-29 18:30:45 +01:00
CurrentCharacterDialogueTreeId = -1;
2020-12-02 21:23:01 +00:00
}
2020-12-02 21:23:01 +00:00
public void UpdateStateObjects()
{
if (OWInput.GetInputMode() == InputMode.None)
{
return;
}
2021-06-18 22:38:32 +01:00
2021-04-18 18:42:22 +01:00
FlashLight?.UpdateState(PlayerStates.FlashlightActive);
Translator?.ChangeEquipState(PlayerStates.TranslatorEquipped);
ProbeLauncher?.ChangeEquipState(PlayerStates.ProbeLauncherEquipped);
Signalscope?.ChangeEquipState(PlayerStates.SignalscopeEquipped);
2021-03-13 10:17:52 +00:00
QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
2021-04-18 18:42:22 +01:00
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(PlayerStates.SuitedUp));
2020-12-02 21:23:01 +00:00
}
2020-08-09 21:46:51 +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
}