Esempio n. 1
0
        public static void UpdateEntry(PlayerNet playerNet, PlayerEntry entry, bool bypassActive = false)
        {
            entry.timeSinceLastUpdate.Restart();

            // Update values but not text even if playerlist not active and before decode
            entry.distance = (entry.player.transform.position - Player.prop_Player_0.transform.position).magnitude;
            entry.fps      = MelonUtils.Clamp((int)(1000f / playerNet.field_Private_Byte_0), -99, 999);
            entry.ping     = playerNet.prop_VRCPlayer_0.prop_Int16_0;

            if (!(MenuManager.playerList.active || bypassActive))
            {
                return;
            }

            StringBuilder tempString = new StringBuilder();

            try
            {
                updateDelegate?.Invoke(playerNet, entry, ref tempString);
            }
            catch (Exception ex)
            {
                MelonLogger.Error($"Errored while updating {entry.apiUser.displayName}'s entry:\n{ex}");
            }

            entry.textComponent.text = entry.TrimExtra(tempString.ToString());
        }
Esempio n. 2
0
 private static void AddDistance(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     if (VRCUtils.AreRiskyFunctionsAllowed)
     {
         if (entry.distance < 100)
         {
             tempString.Append(entry.distance.ToString("N1").PadRight(4) + "m");
         }
         else if (entry.distance < 10000)
         {
             tempString.Append((entry.distance / 1000).ToString("N1").PadRight(3) + "km");
         }
         else if (entry.distance < 999900)
         {
             tempString.Append((entry.distance / 1000).ToString("N0").PadRight(3) + "km");
         }
         else
         {
             tempString.Append((entry.distance / 9.461e+15).ToString("N2").PadRight(3) + "ly"); // If its too large for kilometers ***just convert to light years***
         }
     }
     else
     {
         entry.distance = 0;
         tempString.Append("0.0 m");
     }
     tempString.Append(separator);
 }
Esempio n. 3
0
        public void ConnectionListener()
        {
            listener.Start();

            while (running)
            {
                PlayerNet net = null;
                try
                {
                    TcpClient client = listener.AcceptTcpClient();

                    net = new PlayerNet(p1);

                    Task task = new Task(new Action <object>(net.Run), client);
                    task.Start();
                }
                catch (Exception)
                {
                    throw;
                }

                if (playerNetOne == null)
                {
                    playerNetOne = net;
                }
                else if (playerNetTwo == null)
                {
                    playerNetTwo = net;
                }
            }
        }
Esempio n. 4
0
        public override void Init(object[] parameters)
        {
            player    = (Player)parameters[0];
            userID    = player.field_Private_APIUser_0.id;
            playerNet = player.GetComponent <PlayerNet>();

            gameObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(new Action(() => OpenPlayerInQuickMenu(player)));
        }
Esempio n. 5
0
    public void OnSend()
    {
        // get our player

        //One way of doing it
        // PlayerNet pleaseWork = NetworkClient.connection.identity.GetComponent<PlayerNet>();
        // pleaseWork.CmdSend("");
        localPlayer = ClientScene.localPlayer.GetComponent <PlayerNet>();
        localPlayer.VoteVoted();
    }
Esempio n. 6
0
 private static void AddOwnedObjectsSafe(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     if (entry.ownedObjects > (int)(totalObjects * 0.75))
     {
         tempString.Append(entry.ownedObjects.ToString().PadRight(highestOwnedObjectsLength) + separator);
     }
     else
     {
         tempString.Append("0".PadRight(highestOwnedObjectsLength) + separator);
     }
 }
Esempio n. 7
0
 void OnTriggerEnter(Collider hit)
 {
     if (hit.tag == "Player")
     {
         PlayerHP  enemy = hit.GetComponent <PlayerHP>();
         PlayerNet stun  = hit.GetComponent <PlayerNet>(); //dodanie stuna
         enemy.TakeDamage(dmg);
         stun.DisableCC();
     }
     Destroy(gameObject);
 }
Esempio n. 8
0
 protected static void AddPing(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append("<color=" + PlayerUtils.GetPingColor(entry.ping) + ">");
     if (entry.ping < 9999 && entry.ping > -999)
     {
         tempString.Append(entry.ping.ToString().PadRight(4) + "ms</color>");
     }
     else
     {
         tempString.Append(((double)(entry.ping / 1000)).ToString("N1").PadRight(5) + "s</color>");
     }
     tempString.Append(separator);
 }
Esempio n. 9
0
 protected static void AddFps(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append("<color=" + PlayerUtils.GetFpsColor(entry.fps) + ">");
     if (entry.fps == 0)
     {
         tempString.Append("?¿?</color>");
     }
     else
     {
         tempString.Append(entry.fps.ToString().PadRight(3) + "</color>");
     }
     tempString.Append(separator);
 }
Esempio n. 10
0
 private void Awake()
 {
     player = GetComponent <PlayerNet>();
 }
Esempio n. 11
0
 public void SetFocusNet(PlayerNet xNet)
 {
     mxPlayerNet = xNet;
 }
Esempio n. 12
0
    void OnGUI()
    {
        if (null != GetPlayerNet() && mxPlayerNet.GetPlayerState() == PlayerNet.PLAYER_STATE.E_PLAYER_GAMEING)
        {
            mxObjectElement.OnGUI(AFCKernel.Instance, 1024, 768);
            mxObjectElement.OnOpratorGUI(1024, 768);
        }

        if (null != GetPlayerNet())
        {
            switch (GetPlayerNet().GetPlayerState())
            {
            case PlayerNet.PLAYER_STATE.E_NONE:
            {
                if (strTargetIP.Length > 0)
                {
                    mxPlayerNet.mxNet.StartConnect(strTargetIP, nPort);
                    mxPlayerNet.ChangePlayerState(PlayerNet.PLAYER_STATE.E_WAITING_CONNET_NET);
                }
            }

            break;

            case PlayerNet.PLAYER_STATE.E_WAITING_CONNET_NET:
            {
                // Wait Reciving Connect event ,when connect sucessful ,enter status :E_CONNET_NET_SUCESS_WAITING_ACCOUNT
            }

            break;

            case PlayerNet.PLAYER_STATE.E_CONNET_NET_SUCESS_WAITING_ACCOUNT:
            {
                // wait user input account;
                mxPlayerNet.strAccount  = GUI.TextField(new Rect(10, 10, 150, 50), mxPlayerNet.strAccount);
                mxPlayerNet.strPassword = GUI.TextField(new Rect(10, 100, 150, 50), mxPlayerNet.strPassword);
                if (GUI.Button(new Rect(10, 200, 150, 50), "Login"))
                {
                    mxPlayerNet.mxSender.LoginPB(mxPlayerNet.strAccount, mxPlayerNet.strPassword, "");
                    mxPlayerNet.ChangePlayerState(PlayerNet.PLAYER_STATE.E_PLAYER_LOGINING_WAITING_lOGINRESULT);
                }
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_LOGINING_WAITING_lOGINRESULT:
            {
                // wait receiving msg EGMI_ACK_LOGIN, when receiving this msg,if receiving error result , show a error,and enter E_CONNET_NET_SUCESS_WAITING_ACCOUNT  status
                // if login successful, enter E_PLAYER_LOGIN_SUCCESSFUL_WAITING_WORLD_LIST  status
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_LOGIN_SUCCESSFUL:
            {
                // if login successful, enter E_PLAYER_LOGIN_SUCCESSFUL_WAITING_WORLD_LIST  status
                PlayerSender sender = mxPlayerNet.mxSender;
                if (null != sender)
                {
                    mxPlayerNet.ChangePlayerState(PlayerNet.PLAYER_STATE.E_PLAYER_WAITING_WORLD_LIST);
                    sender.RequireWorldList();
                }
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_WAITING_WORLD_LIST:
            {
                // wait receiving msg EGMI_ACK_WORLD_LIST, when receiving this msg,if receiving error result , show a error,and enter E_CONNET_NET_SUCESS_WAITING_ACCOUNT  status
                // if successful, enter E_PLAYER_WORLD_LIST_SUCCESSFUL_WAITING_SELECT_WORLD  status
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_WORLD_LIST_SUCCESSFUL_WAITING_SELECT_WORLD:
            {
                // show world list
                // wait user select world;
                int nHeight = 50;
                for (int i = 0; i < mxPlayerNet.aWorldList.Count; ++i)
                {
                    ServerInfo xInfo = (ServerInfo)mxPlayerNet.aWorldList[i];
                    if (GUI.Button(new Rect(10, i * nHeight, 150, nHeight), System.Text.Encoding.Default.GetString(xInfo.name)))
                    {
                        AFStart.Instance.GetPlayerNet().nServerID = xInfo.server_id;
                        mxPlayerNet.mxSender.RequireConnectWorld(xInfo.server_id);
                        mxPlayerNet.ChangePlayerState(PlayerNet.PLAYER_STATE.E_PLAYER_SELECT_WORLD_WAIT_WORK_KEY);
                    }
                }
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_GET_WORLD_KEY_SUCCESSFUL:
            {
                string strWorpdIP  = AFStart.Instance.GetPlayerNet().strWorldIP;
                string strWorpdKey = AFStart.Instance.GetPlayerNet().strKey;
                string strAccount  = AFStart.Instance.GetPlayerNet().strKey;
                int    nPort       = AFStart.Instance.GetPlayerNet().nWorldPort;

                PlayerNet xPlayerNet = new PlayerNet();
                xPlayerNet.strWorldIP = strWorpdIP;
                xPlayerNet.strKey     = strWorpdKey;
                xPlayerNet.strAccount = strAccount;
                xPlayerNet.nWorldPort = nPort;

                xPlayerNet.ChangePlayerState(PlayerNet.PLAYER_STATE.E_START_CONNECT_TO_GATE);

                xPlayerNet.mxNet.RegisteredConnectDelegation(OnGateConnect);
                xPlayerNet.mxNet.RegisteredDisConnectDelegation(OnGateDisConnect);
                xPlayerNet.mxNet.StartConnect(xPlayerNet.strWorldIP, nPort);
                SetFocusNet(xPlayerNet);
            }
            break;

            case PlayerNet.PLAYER_STATE.E_START_CONNECT_TO_GATE_SUCESS_FUL:
            {
                GetPlayerNet().mxSender.RequireVerifyWorldKey(GetPlayerNet().strAccount, GetPlayerNet().strKey);
                GetPlayerNet().ChangePlayerState(PlayerNet.PLAYER_STATE.E_WATING_VERIFY);
            }
            break;

            case PlayerNet.PLAYER_STATE.E_WATING_VERIFY:
            {
                //wait receiving msg EGMI_ACK_CONNECT_KEY, if receive failed ,show error  enter none status
                //if have receiving  successful Enter E_VERIFY_KEY_SUCCESS_FULL status;
            }
            break;

            case PlayerNet.PLAYER_STATE.E_VERIFY_KEY_SUCCESS_FULL:
            {
                // wait user select server;
                int nWidth = 200;
                for (int i = 0; i < mxPlayerNet.aServerList.Count; ++i)
                {
                    ServerInfo xInfo = (ServerInfo)mxPlayerNet.aServerList[i];
                    if (GUI.Button(new Rect(nWidth, i * 50, 150, 50), System.Text.Encoding.Default.GetString(xInfo.name)))
                    {
                        GetPlayerNet().nServerID = xInfo.server_id;
                        GetFocusSender().RequireSelectServer(xInfo.server_id);
                        GetPlayerNet().ChangePlayerState(PlayerNet.PLAYER_STATE.E_WAIT_ROLELIST);
                    }
                }
            }
            break;

            case PlayerNet.PLAYER_STATE.E_WAIT_ROLELIST:
            {
                // wait receiving EGMI_ACK_SELECT_SERVER msg,
                // when receiving this msg, send req role list;
                // and waiting EGMI_ACK_ROLE_LIST msg, if sucessful ,enter E_HAS_PLAYER_ROLELIST status;
            }
            break;

            case PlayerNet.PLAYER_STATE.E_GETROLELIST_SUCCESSFUL:
            {
                //AFCRenderInterface.Instance.LoadScene("SelectScene");
                GetPlayerNet().ChangePlayerState(PlayerNet.PLAYER_STATE.E_WAIT_SELECT_ROLE);
            }
            break;

            case PlayerNet.PLAYER_STATE.E_WAIT_SELECT_ROLE:
            {
                if (mxPlayerNet.aCharList.Count > 0)
                {
                    for (int i = 0; i < mxPlayerNet.aCharList.Count; ++i)
                    {
                        AFMsg.RoleLiteInfo xLiteInfo = (AFMsg.RoleLiteInfo)mxPlayerNet.aCharList[i];
                        if (GUI.Button(new Rect(200, i * 50, 150, 50), System.Text.Encoding.Default.GetString(xLiteInfo.noob_name)))
                        {
                            mxPlayerNet.strRoleName    = System.Text.Encoding.Default.GetString(xLiteInfo.noob_name);
                            GetPlayerNet().nMainRoleID = PlayerReciver.PBToAF(xLiteInfo.id);
                            GetPlayerNet().ChangePlayerState(PlayerNet.PLAYER_STATE.E_PLAYER_WAITING_TO_GAME);
                            mxPlayerNet.mxSender.RequireEnterGameServer(AFStart.Instance.GetPlayerNet().nMainRoleID, mxPlayerNet.strAccount, mxPlayerNet.strRoleName, mxPlayerNet.nServerID);
                        }
                    }
                }
                else
                {
                    mxPlayerNet.strRoleName = GUI.TextField(new Rect(10, 10, 150, 50), mxPlayerNet.strRoleName);
                    if (GUI.Button(new Rect(10, 200, 150, 50), "CreateRole"))
                    {
                        GetPlayerNet().ChangePlayerState(PlayerNet.PLAYER_STATE.E_WAIT_CREATE_ROLE);
                        mxPlayerNet.mxSender.RequireCreateRole(mxPlayerNet.strAccount, mxPlayerNet.strRoleName, 0, 0, mxPlayerNet.nServerID);
                    }
                }
            }
            break;

            case PlayerNet.PLAYER_STATE.E_WAIT_CREATE_ROLE:
            {
                // wait receive EGMI_ACK_ROLE_LIST ,  when receive msg, enter E_WAIT_SELECT_ROLE status;
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_WAITING_TO_GAME:
            {
                // wait receive EGMI_ACK_SWAP_SCENE ,  when receive msg, enter E_PLAYER_GAMEING status;
            }
            break;

            case PlayerNet.PLAYER_STATE.E_PLAYER_GAMEING:
                //AFCSectionManager.Instance.SetGameState(AFCSectionManager.UI_SECTION_STATE.UISS_GAMEING);
                break;

            default:
                break;
            }
        }
        else
        {
            PlayerNet xPlayerNet = new PlayerNet();
            xPlayerNet.mxNet.RegisteredConnectDelegation(OnConfigConnect);
            SetFocusNet(xPlayerNet);
        }
    }
Esempio n. 13
0
        protected override void ProcessText(object[] parameters = null)
        {
            if (player == null)
            {
                Remove();                 // Sometimes ppl will desync causing the leave event to not call
            }
            if (playerNet != null)
            {
                if (Config.pingToggle.Value)
                {
                    short ping = playerNet.prop_Int16_0;
                    AddColor(GetPingColor(ping));
                    if (ping < 9999 && ping > -999)
                    {
                        AddEndColor(ping.ToString().PadRight(4) + "ms");
                    }
                    else
                    {
                        AddEndColor(((double)(ping / 1000)).ToString("N1").PadRight(5) + "s");
                    }
                    AddSpacer();
                }

                // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone
                if (Config.fpsToggle.Value)
                {
                    int fps = Mathf.Clamp((int)(1000f / playerNet.field_Private_Byte_0), -99, 999);

                    AddColor(GetFpsColor(fps));
                    if (playerNet.field_Private_Byte_0 == 0)
                    {
                        AddEndColor("?¿?");
                    }
                    else
                    {
                        AddEndColor(fps.ToString().PadRight(3));
                    }
                    AddSpacer();
                }
            }
            else
            {
                if (Config.pingToggle.Value)
                {
                    AddColoredText("#ff0000", "?¿?".PadRight(4));
                    AddSpacer();
                }

                // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone
                if (Config.fpsToggle.Value)
                {
                    AddColoredText("#ff0000", "?¿?".PadRight(3));
                    AddSpacer();
                }

                playerNet = player.GetComponent <PlayerNet>();
            }

            if (Config.platformToggle.Value)
            {
                AddText(ParsePlatform(player).PadRight(2));
                AddSpacer();
            }

            if (Config.perfToggle.Value)
            {
                PerformanceRating rating = player.field_Internal_VRCPlayer_0.prop_VRCAvatarManager_0.prop_AvatarPerformanceStats_0.field_Private_ArrayOf_PerformanceRating_0[(int)AvatarPerformanceCategory.Overall]; // Get from cache so it doesnt calculate perf all at once
                AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, rating)), ParsePerformanceText(rating));
                AddSpacer();
            }

            if (Config.distanceToggle.Value)
            {
                if (worldAllowed)
                {
                    float distance = (player.transform.position - Player.prop_Player_0.transform.position).magnitude;
                    if (distance < 100)
                    {
                        AddText(distance.ToString("N1").PadRight(4) + "m");
                    }
                    else if (distance < 10000)
                    {
                        AddText((distance / 1000).ToString("N1").PadRight(3) + "km");
                    }
                    else if (distance < 999900)
                    {
                        AddText((distance / 1000).ToString("N0").PadRight(3) + "km");
                    }
                    else
                    {
                        AddText((distance / 9.461e+15).ToString("N2").PadRight(3) + "ly"); // If its too large for kilometers ***just convert to light years***
                    }
                }
                else
                {
                    AddText("0.0 m");
                }
                AddSpacer();
            }

            if (Config.photonIdToggle.Value)
            {
                AddText(player.field_Internal_VRCPlayer_0.field_Private_PhotonView_0.field_Private_Int32_0.ToString().PadRight(highestPhotonIdLength));
                AddSpacer();
            }

            if (Config.displayNameToggle.Value) // Why?
            {
                switch (Config.DisplayNameColorMode)
                {
                case PlayerListMod.DisplayNameColorMode.TrustAndFriends:
                    AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.None:
                    AddText(player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.TrustOnly:
                    // ty bono for this (https://github.com/ddakebono/)
                    spoofFriend = true;
                    AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.FriendsOnly:
                    if (APIUser.IsFriendsWith(player.field_Private_APIUser_0.id))
                    {
                        AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    }
                    else
                    {
                        AddText(player.field_Private_APIUser_0.displayName);
                    }
                    break;
                }
                AddSpacer();
            }

            if (textComponent.text.Length > 0)
            {
                if (Config.condensedText.Value)
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 1, 1);
                }
                else
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 3, 3);
                }
            }

            if (!Config.numberedList.Value)
            {
                if (Config.condensedText.Value)
                {
                    AddTextToBeginning("-");
                }
                else
                {
                    AddTextToBeginning(" - ");
                }
            }
            else
            if (Config.condensedText.Value)
            {
                AddTextToBeginning($"{gameObject.transform.GetSiblingIndex() - 1}.".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 1));     // Pad by weird amount because we cant include the header and disabled template in total number of gameobjects
            }
            else
            {
                AddTextToBeginning($"{gameObject.transform.GetSiblingIndex() - 1}. ".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 2));
            }
        }
Esempio n. 14
0
 private static void AddDisplayName(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append("<color=" + entry.playerColor + ">" + entry.apiUser.displayName + "</color>" + separator);
 }
Esempio n. 15
0
 private static void AddPerf(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append(entry.perfString + separator);
 }
Esempio n. 16
0
 private static void AddOwnedObjects(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append(entry.ownedObjects.ToString().PadRight(highestOwnedObjectsLength) + separator);
 }
Esempio n. 17
0
 private static void AddPhotonId(PlayerNet playerNet, PlayerEntry entry, ref StringBuilder tempString)
 {
     tempString.Append(playerNet.prop_PhotonView_0.field_Private_Int32_0.ToString().PadRight(highestPhotonIdLength) + separator);
 }