public static void SnapLines(Player p, Color c) { Vector3 w2s = FUNC.W2S(p.PlayerBones.RootJoint.position); if (FUNC.isInScreenYZ(w2s)) { Drawing.DrawLine( new Vector2( (Screen.width / 2), Screen.height ), new Vector2( w2s.x, Screen.height - w2s.y ), c ); } }
public static void Players() { try { #region [INITIALS] - to skip data overflow (incase) float deltaDistance = 25f; string playerDisplayName = ""; float devLabel = 1f; string Status = ""; var LabelSize = new GUIStyle { fontSize = 12 }; Color playerColor = Constants.Colors.ESP.npc; float distancesAxisY_0 = 0; float distancesAxisY_1 = 0; float distancesAxisY_2 = 0; Color Backup; #endregion var e = Cons.Main._players.GetEnumerator(); while (e.MoveNext()) { var player = e.Current; if (FUNC.isInScreenYZ(FUNC.W2S(player.Transform.position))) { //fix for colors not holds after leaving screen Calculations.PlayerType playerType = Calculations.PlayerType.Scav; playerDisplayName = Calculations.PlayerName(player, ref playerType); playerColor = Calculations.PlayerColor(playerType); #region [Snap.Lines] if (Cons.Bools.SnapLines && player != Cons.Main._localPlayer) { Calculations.SnapLines(player, playerColor); } #endregion if (FUNC.isInScreenRestricted(FUNC.W2S(player.Transform.position))) { float dTO = FastMath.FD(Camera.main.transform.position, player.Transform.position); // main head vector 3d (x,y,z) Vector3 pHeadVector = FUNC.W2S(player.PlayerBones.Head.position); // setting head size comparing head position and neck position and multiplying by 1.5 (actually its head size) float find_sizebox = Math.Abs(pHeadVector.y - FUNC.W2S(player.PlayerBones.Neck.position).y) * 1.5f; // size of the head - its not good but its scaling without much maths // making sure head will not be too big find_sizebox = (find_sizebox > 30f) ? 30f : find_sizebox; float half_sizebox = (find_sizebox > 30f) ? 15f : find_sizebox / 2f; // size of fonts depending on distance int FontSize = 12; FastMath.DistSizer(dTO, ref FontSize, ref deltaDistance, ref devLabel); LabelSize.fontSize = FontSize; //create 3 size table of distances for texts (name, status, weapon) distancesAxisY_0 = deltaDistance + 10f; distancesAxisY_1 = distancesAxisY_0 + FontSize + 1; distancesAxisY_2 = distancesAxisY_1 + FontSize + 1; Status = Calculations.GetPlayerTotalHealth(player); // Health here #region BONE-DUMP /*if (dTO < 20f) * { * //string forDump = ""; * try * { * for (int i = 0; i < 134; i++) * { * if ((i > 13 && i <= 27) || i == 38 || i == 39 || i == 40 || i == 41 || (i >= 66 && i <= 70) || i == 132) * { * string name = ""; * try * { * name = FUNC.Bones.SkeletonBoneName(player.PlayerBones.AnimatedTransform.Original.gameObject.GetComponent<PlayerBody>().SkeletonRootJoint, i); * name = name.Split('/')[name.Split('/').Length - 1]; * Vector3 pos = FUNC.W2S(FUNC.Bones.GetBonePosByID(player, i)); * Drawing.Text(new Rect(pos.x, Screen.height - pos.y, 20f, 20f), i.ToString()); * } * catch (Exception) * { * name = "bad"; * } * //forDump = forDump + name + " - " + i + Environment.NewLine; * } * } * } * catch (Exception ex) * { * ErrorHandler.Catch("DUMPED", ex); * } * //ErrorHandler.Dump("DUMPED", forDump); * }*/ #endregion #region [BONE-ESP] if (Cons.Bools.ShowBones) { Calculations.PlayerBones(dTO, player); } #endregion if (playerType != Calculations.PlayerType.TeamMate) { Backup = GUI.color; GUI.color = Color.red; Drawing.Special.DrawPoint(pHeadVector.x - half_sizebox, (float)(Screen.height - pHeadVector.y) - half_sizebox, find_sizebox, Constants.Colors.Red); GUI.color = Backup; } #region [VISIBILITY-CHECK] string isVisible = ""; if (Raycast.BodyRaycastCheck(player.gameObject, pHeadVector)) { isVisible = "+"; } #endregion #region [Group-Num] int gInt; string groupID = ""; try { if (Types.GroupTable.TryGetValue(player.GroupId, out gInt)) { groupID = "{" + gInt + "}"; } } catch (Exception) { } #endregion #region [INIT-Texts] string nameNickname = $"{playerDisplayName}{groupID}"; string playerStatus = $"{isVisible}[{(int)dTO}m] {Status}"; string WeaponName = ""; #endregion #region [TRY-DecodeWeaponName] try { WeaponName = player.Weapon.ShortName.Localized(); } catch (Exception) { WeaponName = "No Weapon"; } #endregion // set colors now LabelSize.normal.textColor = playerColor; #region Slot 0 - Player Name (vector, size, drawing) if (nameNickname != "") { Vector2 vector_playerName = GUI.skin.GetStyle(nameNickname).CalcSize(new GUIContent(nameNickname)); float player_NameText = (devLabel == 1f) ? vector_playerName.x : (vector_playerName.x / devLabel); Drawing.Special.DrawText( nameNickname, pHeadVector.x - player_NameText / 2f, (float)Screen.height - FUNC.W2S(player.PlayerBones.Head.position).y - distancesAxisY_0, vector_playerName, LabelSize, playerColor ); } #endregion #region Slot 1 - Status (distance, health) Vector2 vector_playerStatus = GUI.skin.GetStyle(playerStatus).CalcSize(new GUIContent(playerStatus)); float player_TextWidth = (devLabel == 1f) ? vector_playerStatus.x : (vector_playerStatus.x / devLabel); Drawing.Special.DrawText( playerStatus, pHeadVector.x - player_TextWidth / 2f, (float)Screen.height - FUNC.W2S(player.PlayerBones.Head.position).y - distancesAxisY_1, vector_playerStatus, LabelSize, playerColor ); #endregion #region Slot 2 - Weapon Name (vector, size, drawing) - if not empty if (WeaponName != "") { Vector2 vector_WeaponName = GUI.skin.GetStyle(WeaponName).CalcSize(new GUIContent(WeaponName)); float player_WeaponName = (devLabel == 1f) ? vector_WeaponName.x : (vector_WeaponName.x / devLabel); Drawing.Special.DrawText( WeaponName, pHeadVector.x - player_TextWidth / 2f, (float)Screen.height - FUNC.W2S(player.PlayerBones.Head.position).y - distancesAxisY_2, vector_WeaponName, LabelSize, playerColor ); } #endregion } } } } catch (Exception e) { ErrorHandler.Catch("e5p_Players_Draw_Players", e); } }