From 9283349c0b689b97500f8d80c2eaed0e92056e6c Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Sat, 11 May 2024 17:52:55 +0200 Subject: [PATCH] Remove HUD from network players --- .../Scripts/Augment/AugmentImplementations/Telescope.cs | 7 ++----- .../Scripts/Augment/BulletModifiers/HackingModifier.cs | 3 ++- Assets/Scripts/Control&Input/Peer2PeerTransport.cs | 7 +++++++ Assets/Scripts/Gamestate/PlayerManager.cs | 9 ++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Augment/AugmentImplementations/Telescope.cs b/Assets/Scripts/Augment/AugmentImplementations/Telescope.cs index 20e239efc..05833bdf7 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/Telescope.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/Telescope.cs @@ -20,10 +20,7 @@ public class Telescope : GunExtension void Start() { gunController = transform.parent.GetComponent(); - if (!gunController) - return; - - if (!gunController.Player) + if (!gunController || !gunController.Player || !gunController.Player.HUDController) return; var playerMovement = gunController.Player.GetComponent(); @@ -63,7 +60,7 @@ private void CancelZoom() private void OnDestroy() { - if (!gunController || !gunController.Player) + if (!gunController || !gunController.Player || !gunController.Player.HUDController) return; var playerMovement = gunController.Player.GetComponent(); playerMovement.ZoomFov = originalZoomFov; diff --git a/Assets/Scripts/Augment/BulletModifiers/HackingModifier.cs b/Assets/Scripts/Augment/BulletModifiers/HackingModifier.cs index 53d95d2b3..d1c14cfde 100644 --- a/Assets/Scripts/Augment/BulletModifiers/HackingModifier.cs +++ b/Assets/Scripts/Augment/BulletModifiers/HackingModifier.cs @@ -34,6 +34,7 @@ private void Hack(RaycastHit hit, ref ProjectileState state) // TODO: Actually disorient the AIs if (playerManager.identity.IsAI) return; - playerManager.HUDController.PopupSpammer.Spam(Mathf.FloorToInt(state.damage / damageToSpamAmount)); + if (playerManager.HUDController) + playerManager.HUDController.PopupSpammer.Spam(Mathf.FloorToInt(state.damage / damageToSpamAmount)); } } diff --git a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs index 2a93b8429..a51cc7674 100644 --- a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs +++ b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs @@ -309,6 +309,13 @@ private IEnumerator WaitAndInitializeFPSPlayer(InitializeFPSPlayerMessage messag StaticInfo.Singleton.StartingExtension); Debug.Log($"{playerManager.identity.Body}"); + // TODO do some other version of disabling HUD completely + Destroy(playerManager.HUDController); + + // Disable physics + playerManager.GetComponent().isKinematic = true; + + // Create display gun structure var gunHolderParent = new GameObject("GunHolderParent").transform; gunHolderParent.parent = player.transform; gunHolderParent.position = cameraOffset.position; diff --git a/Assets/Scripts/Gamestate/PlayerManager.cs b/Assets/Scripts/Gamestate/PlayerManager.cs index 42351d2cd..86f14436c 100644 --- a/Assets/Scripts/Gamestate/PlayerManager.cs +++ b/Assets/Scripts/Gamestate/PlayerManager.cs @@ -168,7 +168,8 @@ void OnDeath(HealthController healthController, float damage, DamageInfo info) aimAssistCollider.SetActive(false); TurnIntoRagdoll(info); aiTargetCollider.gameObject.SetActive(false); - hudController.DisplayDeathScreen(killer.identity); + if (hudController) + hudController.DisplayDeathScreen(killer.identity); playerShadow.gameObject.SetActive(false); } @@ -242,7 +243,8 @@ void OnDestroy() { playerMovement.onMove -= UpdateHudOnMove; } - identity.onChipChange -= hudController.OnChipChange; + if (hudController) + identity.onChipChange -= hudController.OnChipChange; } private void UpdateAimTarget(GunStats stats) @@ -363,7 +365,8 @@ public virtual void SetLayer(int playerIndex) // Set correct layer on self, mesh and gun (TODO) gameObject.layer = playerLayer; SetLayerOnSubtree(meshBase, playerLayer); - SetLayerOnSubtree(hudController.gameObject, LayerMask.NameToLayer("Gun " + playerIndex)); + if (hudController) + SetLayerOnSubtree(hudController.gameObject, LayerMask.NameToLayer("Gun " + playerIndex)); } public virtual void SetGun(Transform offset, bool isNetwork = false)