Merge remote-tracking branch 'origin/mobius-why-did-you-name-this-inflation-controller-mobius-why' into mobius-why-did-you-name-this-inflation-controller-mobius-why

This commit is contained in:
JohnCorby 2021-12-31 19:41:06 -08:00
commit 8da6cb44db
6 changed files with 84 additions and 28 deletions

View File

@ -35,6 +35,7 @@ namespace QSB.Player
public bool IsInShrine { get; set; }
public IQSBQuantumObject EntangledObject { get; set; }
public QSBPlayerAudioController AudioController { get; set; }
public DitheringAnimator DitheringAnimator { get; set; }
// Body Objects
public OWCamera Camera

View File

@ -114,27 +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 => ChangePlayerVisibility(x.PlayerId, true));
=> 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 => ChangePlayerVisibility(x.PlayerId, false));
public static void ChangePlayerVisibility(uint playerId, bool visible)
{
var player = GetPlayer(playerId);
player.Visible = visible;
if (player.Body == null)
{
DebugLog.ToConsole($"Warning - Player {playerId} has a null player model!", MessageType.Warning);
return;
}
foreach (var renderer in player.Body.GetComponentsInChildren<Renderer>())
{
renderer.enabled = visible;
}
}
=> 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

@ -167,11 +167,9 @@ namespace QSB.Player.TransformSync
GetComponent<AnimationSync>().InitRemote(REMOTE_Traveller_HEA_Player_v2);
GetComponent<InstrumentsManager>().InitRemote(REMOTE_Player_Body.transform);
var marker = REMOTE_Player_Body.AddComponent<PlayerHUDMarker>();
marker.Init(Player);
REMOTE_Player_Body.AddComponent<PlayerHUDMarker>().Init(Player);
REMOTE_Player_Body.AddComponent<PlayerMapMarker>().PlayerName = Player.Name;
Player.DitheringAnimator = REMOTE_Player_Body.AddComponent<DitheringAnimator>();
Player.AudioController = PlayerAudioManager.InitRemote(REMOTE_Player_Body.transform);
/*

View File

@ -153,7 +153,14 @@ namespace QSB.RespawnSync
return;
}
QSBPlayerManager.ChangePlayerVisibility(player.PlayerId, false);
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();
QSBPlayerManager.ChangePlayerVisibility(player.PlayerId, true);
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

@ -7,7 +7,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 +46,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 +78,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();