Skip to content

Commit

Permalink
Remove HUD from network players
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed May 13, 2024
1 parent d7fc232 commit 9283349
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 2 additions & 5 deletions Assets/Scripts/Augment/AugmentImplementations/Telescope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public class Telescope : GunExtension
void Start()
{
gunController = transform.parent.GetComponent<GunController>();
if (!gunController)
return;

if (!gunController.Player)
if (!gunController || !gunController.Player || !gunController.Player.HUDController)
return;

var playerMovement = gunController.Player.GetComponent<PlayerMovement>();
Expand Down Expand Up @@ -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>();
playerMovement.ZoomFov = originalZoomFov;
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Augment/BulletModifiers/HackingModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
7 changes: 7 additions & 0 deletions Assets/Scripts/Control&Input/Peer2PeerTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rigidbody>().isKinematic = true;

// Create display gun structure
var gunHolderParent = new GameObject("GunHolderParent").transform;
gunHolderParent.parent = player.transform;
gunHolderParent.position = cameraOffset.position;
Expand Down
9 changes: 6 additions & 3 deletions Assets/Scripts/Gamestate/PlayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -242,7 +243,8 @@ void OnDestroy()
{
playerMovement.onMove -= UpdateHudOnMove;
}
identity.onChipChange -= hudController.OnChipChange;
if (hudController)
identity.onChipChange -= hudController.OnChipChange;
}

private void UpdateAimTarget(GunStats stats)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9283349

Please sign in to comment.