This commit is contained in:
Mister_Nebula 2022-01-01 00:38:17 +00:00
parent a0fc1ee1a8
commit 4330f75583
4 changed files with 82 additions and 7 deletions

View File

@ -114,10 +114,10 @@ namespace QSB.Player
=> new(Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight));
public static void ShowAllPlayers()
=> PlayerList.Where(x => x != LocalPlayer).ToList().ForEach(x => x.DitheringAnimator.SetVisible(true, 0.5f));
=> PlayerList.Where(x => x != LocalPlayer && x.DitheringAnimator != null).ToList().ForEach(x => x.DitheringAnimator.SetVisible(true, 0.5f));
public static void HideAllPlayers()
=> PlayerList.Where(x => x != LocalPlayer).ToList().ForEach(x => x.DitheringAnimator.SetVisible(true, 0.5f));
=> PlayerList.Where(x => x != LocalPlayer && x.DitheringAnimator != null).ToList().ForEach(x => x.DitheringAnimator.SetVisible(true, 0.5f));
public static PlayerInfo GetClosestPlayerToWorldPoint(Vector3 worldPoint, bool includeLocalPlayer) => includeLocalPlayer
? GetClosestPlayerToWorldPoint(PlayerList, worldPoint)

View File

@ -153,7 +153,14 @@ namespace QSB.RespawnSync
return;
}
player.DitheringAnimator.SetVisible(false, 1);
if (player.DitheringAnimator != null)
{
player.DitheringAnimator.SetVisible(false, 1);
}
else
{
DebugLog.ToConsole($"Warning - {player.PlayerId}.DitheringAnimator is null!", OWML.Common.MessageType.Warning);
}
}
public void OnPlayerRespawn(PlayerInfo player)
@ -169,7 +176,14 @@ namespace QSB.RespawnSync
_playersPendingRespawn.Remove(player);
UpdateRespawnNotification();
player.DitheringAnimator.SetVisible(true, 1);
if (player.DitheringAnimator != null)
{
player.DitheringAnimator.SetVisible(true, 1);
}
else
{
DebugLog.ToConsole($"Warning - {player.PlayerId}.DitheringAnimator is null!", OWML.Common.MessageType.Warning);
}
}
public void RespawnSomePlayer()

View File

@ -1,4 +1,5 @@
using QSB.Player;
using QSB.Utility;
using UnityEngine;
namespace QSB.Tools
@ -7,7 +8,20 @@ namespace QSB.Tools
{
public PlayerInfo Player { get; set; }
public ToolType Type { get; set; }
public GameObject ToolGameObject { get; set; }
public GameObject ToolGameObject
{
get => _toolGameObject;
set
{
_toolGameObject = value;
QSBCore.UnityEvents.FireInNUpdates(
() => DitheringAnimator = _toolGameObject.AddComponent<DitheringAnimator>(),
5);
}
}
private GameObject _toolGameObject;
public DitheringAnimator DitheringAnimator { get; set; }
public DampedSpringQuat MoveSpring
{
@ -33,8 +47,23 @@ namespace QSB.Tools
set => _arrivalDegrees = value;
}
protected bool _isDitheringOut;
public override void Start()
{
base.Start();
ToolGameObject?.SetActive(false);
}
public virtual void OnEnable() => ToolGameObject?.SetActive(true);
public virtual void OnDisable() => ToolGameObject?.SetActive(false);
public virtual void OnDisable()
{
if (!_isDitheringOut)
{
ToolGameObject?.SetActive(false);
}
}
public void ChangeEquipState(bool equipState)
{
@ -50,13 +79,34 @@ namespace QSB.Tools
public override void EquipTool()
{
base.EquipTool();
if (DitheringAnimator != null && DitheringAnimator._renderers != null)
{
ToolGameObject?.SetActive(true);
DitheringAnimator.SetVisible(true, 5f);
}
Player.AudioController.PlayEquipTool();
}
public override void UnequipTool()
{
base.UnequipTool();
if (DitheringAnimator != null && DitheringAnimator._renderers != null)
{
_isDitheringOut = true;
DitheringAnimator.SetVisible(false, 5f);
QSBCore.UnityEvents.RunWhen(() => DitheringAnimator._visibleFraction == 0, FinishDitherOut);
}
Player.AudioController.PlayUnequipTool();
}
public virtual void FinishDitherOut()
{
ToolGameObject?.SetActive(false);
_isDitheringOut = false;
}
}
}

View File

@ -25,7 +25,12 @@ namespace QSB.Tools.TranslatorTool
}
public override void OnDisable()
=> _translatorProp.OnFinishUnequipAnimation();
{
if (!_isDitheringOut)
{
_translatorProp.OnFinishUnequipAnimation();
}
}
public override void EquipTool()
{
@ -39,6 +44,12 @@ namespace QSB.Tools.TranslatorTool
_translatorProp.OnUnequipTool();
}
public override void FinishDitherOut()
{
base.FinishDitherOut();
_translatorProp.OnFinishUnequipAnimation();
}
public override void Update()
{
base.Update();