103 lines
1.8 KiB
C#
Raw Normal View History

2021-12-14 22:53:53 +00:00
using QSB.Player;
2022-02-18 05:33:48 -08:00
using QSB.PlayerBodySetup.Remote;
2022-01-29 01:24:15 -08:00
using QSB.Utility;
2021-12-14 22:53:53 +00:00
using UnityEngine;
2020-07-29 22:04:50 +01:00
namespace QSB.Tools;
public class QSBTool : PlayerTool
2020-07-29 22:04:50 +01:00
{
public PlayerInfo Player { get; set; }
public ToolType Type { get; set; }
public GameObject ToolGameObject { get; set; }
[SerializeField]
private QSBDitheringAnimator _ditheringAnimator;
public DampedSpringQuat MoveSpring
2020-12-02 21:23:01 +00:00
{
get => _moveSpring;
set => _moveSpring = value;
}
2020-12-02 21:23:01 +00:00
public Transform StowTransform
{
get => _stowTransform;
set => _stowTransform = value;
}
2020-12-02 21:23:01 +00:00
public Transform HoldTransform
{
get => _holdTransform;
set => _holdTransform = value;
}
2020-12-02 21:23:01 +00:00
public float ArrivalDegrees
{
get => _arrivalDegrees;
set => _arrivalDegrees = value;
}
2020-12-02 21:23:01 +00:00
protected bool _isDitheringOut;
public override void Start()
{
base.Start();
ToolGameObject?.SetActive(false);
2022-02-24 23:13:31 -08:00
_ditheringAnimator.SetVisible(false);
}
2020-12-02 21:23:01 +00:00
public virtual void OnEnable() => ToolGameObject?.SetActive(true);
2022-01-01 00:38:17 +00:00
public virtual void OnDisable()
{
if (!_isDitheringOut)
2022-01-01 00:38:17 +00:00
{
ToolGameObject?.SetActive(false);
}
}
2022-01-01 00:38:17 +00:00
public void ChangeEquipState(bool equipState)
{
if (equipState)
2022-01-01 00:38:17 +00:00
{
EquipTool();
return;
2022-01-01 00:38:17 +00:00
}
2020-12-02 21:23:01 +00:00
UnequipTool();
}
2021-06-18 22:38:32 +01:00
public override void EquipTool()
{
base.EquipTool();
2021-12-14 22:53:53 +00:00
2022-02-24 23:13:31 -08:00
if (_ditheringAnimator != null)
2021-12-14 22:53:53 +00:00
{
ToolGameObject?.SetActive(true);
2022-02-24 23:13:31 -08:00
_ditheringAnimator.SetVisible(true, .2f);
2021-12-14 22:53:53 +00:00
}
Player.AudioController.PlayEquipTool();
}
2022-01-01 00:38:17 +00:00
public override void UnequipTool()
{
base.UnequipTool();
2022-01-01 00:38:17 +00:00
2022-02-24 23:13:31 -08:00
if (_ditheringAnimator != null)
2022-01-01 00:38:17 +00:00
{
_isDitheringOut = true;
2022-02-24 23:13:31 -08:00
_ditheringAnimator.SetVisible(false, .2f);
Delay.RunWhen(() => _ditheringAnimator.FullyInvisible, FinishDitherOut);
2022-01-01 00:38:17 +00:00
}
Player.AudioController.PlayUnequipTool();
}
public virtual void FinishDitherOut()
{
ToolGameObject?.SetActive(false);
_isDitheringOut = false;
2020-12-02 21:23:01 +00:00
}
2022-02-24 23:13:31 -08:00
}