PlayerPresence.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    public void Update()
    {
        if (networkView.isMine)
        {
            WeaponIndicatorScript.Instance.ShouldRender = Possession != null;
            UpdateShouldCameraSpin();

            Relay.Instance.OptionsMenu.ShouldDisplaySpectateButton = !IsSpectating;

            if (Possession == null)
            {
                if (Input.GetButtonDown("Fire") && !IsSpectating)
                {
                    IndicateRespawn();
                }
            }

            // Update player labels
            if (Camera.current != null)
            {
                foreach (var playerScript in PlayerScript.UnsafeAllEnabledPlayerScripts)
                {
                    if (playerScript == null) continue;
                    Vector3 position = Camera.current.WorldToScreenPoint(InfoPointForPlayerScript(playerScript));
                    Vector2 prevScreenPosition;
                    if (!LastGUIDebugPositions.TryGetValue(playerScript, out prevScreenPosition))
                    {
                        prevScreenPosition = (Vector2) position;
                    }
                    Vector2 newScreenPosition = Vector2.Lerp(prevScreenPosition, (Vector2) position,
                        1f - Mathf.Pow(0.0000000001f, Time.deltaTime));
                    LastGUIDebugPositions[playerScript] = newScreenPosition;
                }
            }

            IsDoingMenuStuff = Relay.Instance.MessageLog.HasInputOpen;

            // Debug visibility info for other playerscripts
            if (Possession != null)
            {
                foreach (var character in PlayerScript.UnsafeAllEnabledPlayerScripts)
                {
                    if (character != Possession)
                    {
                        bool canSee = Possession.CanSeeOtherPlayer(character);
                        if (canSee)
                        {
                            ScreenSpaceDebug.AddMessageOnce("VISIBLE", character.transform.position);
                        }
                    }
                }
            }

            // Leaderboard show/hide
            // Always show when not possessing anything
            // Never show when already showing options screen
            if (Possession == null || TimeToHoldLeaderboardFor >= 0f)
            {
                Server.Leaderboard.Show = true;
            }
            // Otherwise, show when holding tab
            else
            {
                Server.Leaderboard.Show = Input.GetKey("tab") && !Relay.Instance.ShowOptions;
            }

            TimeToHoldLeaderboardFor -= Time.deltaTime;

			// TODO test this in a multiplayer environment 
			// if game is no longer active, i.e., round end or host forced end, then
			if (!this.Server.IsGameActive)
			{
				// force mouse state to be unlocked
				//playerScript.lockMouse = false;
				Cursor.visible = true;
				Cursor.lockState = CursorLockMode.None;
			}

            //if (!Relay.Instance.ShowOptions && Possession != null && !ShouldDisplayJoinPanel)
           //     playerScript.lockMouse = true;

           // if (ShouldDisplayJoinPanel || Relay.Instance.ShowOptions || !Server.IsGameActive)
            //    playerScript.lockMouse = false;

            // Update ping
            Ping = uLink.Network.GetAveragePing(Server.networkView.owner);
        }

        if (Possession != null)
        {
            // toggle bubble
            Possession.TextBubbleVisible = IsDoingMenuStuff;
        }

        if (Input.GetKeyDown("f11"))
            ScreenSpaceDebug.LogMessageSizes();

        TimeSinceLastRespawnRequest += Time.deltaTime;
    }