void OnGUI() { if (Mod.Properties.ShowLog.Value) { if (boxStyle == null) { boxStyle = new GUIStyle(GUI.skin.box); Texture2D flat = new Texture2D(1, 1); flat.SetPixel(0, 0, new Color(0.125f, 0.125f, 0.125f, 0.6f)); flat.Apply(); boxStyle.normal.background = flat; } GUI.SetNextControlName(string.Empty); if (Mod.Properties.LogBackground.Value) { GUILayout.BeginArea(new Rect(Screen.width - 331f, Screen.height - 255f, 330f, 225f), boxStyle); } else { GUILayout.BeginArea(new Rect(Screen.width - 331f, Screen.height - 255f, 330f, 225f)); } GUILayout.FlexibleSpace(); Mod.Logger.ScrollPosition = GUILayout.BeginScrollView(Mod.Logger.ScrollPosition); GUIStyle labelStyle = new GUIStyle(GUI.skin.label) { margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0) }; foreach (string message in Mod.Logger.Messages) { try { GUILayout.Label(message, labelStyle); } catch { } } GUILayout.EndScrollView(); string coords = "N/A"; if (IN_GAME_MAIN_CAMERA.Gametype == GameType.Multiplayer) { if (!GameHelper.IsDead(PhotonNetwork.player)) { Photon.MonoBehaviour mb = GameHelper.IsPT(PhotonNetwork.player) ? (Photon.MonoBehaviour)GameHelper.GetPT(PhotonNetwork.player) : (Photon.MonoBehaviour)GameHelper.GetHero(PhotonNetwork.player); if (mb != null) { coords = $"{MathHelper.Floor(mb.transform.position.x)} / {MathHelper.Floor(mb.transform.position.y)} / {MathHelper.Floor(mb.transform.position.z)}"; } } } GUILayout.Label($"FPS: {MathHelper.Floor(1f / Time.smoothDeltaTime)} X/Y/Z {coords}"); GUILayout.EndArea(); } }
public override void Execute(InRoomChat irc, string[] args) { if (FengGameManagerMKII.Level.Mode == GameMode.Racing) { irc.AddLine("Teleport can NOT be used while in Racing.".AsColor("FF0000")); return; } if (args.Length > 3) // Player(s) -> Coordinate { if (!float.TryParse(args[1], out float x) || !float.TryParse(args[2], out float y) || !float.TryParse(args[3], out float z)) { return; } if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase)) { foreach (PhotonPlayer player in PhotonNetwork.playerList) { Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { continue; } mb.photonView.RPC("moveToRPC", player, x, y, z); } GameHelper.Broadcast($"Teleported everyone to {x:F3} / {y:F3} / {z:F3}"); } else if (int.TryParse(args[0], out int id)) { PhotonPlayer player = PhotonPlayer.Find(id); if (player == null) { return; } Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { return; } mb.photonView.RPC("moveToRPC", player, x, y, z); FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"Teleported you to {x:F3} {y:F3} {z:F3}", string.Empty); } } else if (args.Length > 2) // You -> Coordinate { if (!float.TryParse(args[0], out float x) || !float.TryParse(args[1], out float y) || !float.TryParse(args[2], out float z)) { return; } Photon.MonoBehaviour mb = PhotonNetwork.player.IsTitan ? (Photon.MonoBehaviour)PhotonNetwork.player.GetTitan() : (Photon.MonoBehaviour)PhotonNetwork.player.GetHero(); if (mb == null) { return; } mb.transform.position = new UnityEngine.Vector3(x, y, z); irc.AddLine($"Teleported you to {x:F3} {y:F3} {z:F3}"); } else if (args.Length > 1) // Player(s) -> Target { if (!int.TryParse(args[1], out int targetId)) { return; } PhotonPlayer target = PhotonPlayer.Find(targetId); if (target == null) { return; } Photon.MonoBehaviour targetMb = target.IsTitan ? (Photon.MonoBehaviour)target.GetTitan() : (Photon.MonoBehaviour)target.GetHero(); if (targetMb == null) { return; } if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase)) { foreach (PhotonPlayer player in PhotonNetwork.playerList) { Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { continue; } mb.photonView.RPC("moveToRPC", player, targetMb.transform.position.x, targetMb.transform.position.y, targetMb.transform.position.z); } GameHelper.Broadcast($"Teleported everyone to #{targetId}"); } else if (int.TryParse(args[0], out int id)) { PhotonPlayer player = PhotonPlayer.Find(id); if (player == null) { return; } Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { return; } mb.photonView.RPC("moveToRPC", player, targetMb.transform.position.x, targetMb.transform.position.y, targetMb.transform.position.z); FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"Teleported you to #{targetId}", string.Empty); } } else if (args.Length > 0)// All -> You or You -> Target { Photon.MonoBehaviour myMb = PhotonNetwork.player.IsTitan ? (Photon.MonoBehaviour)PhotonNetwork.player.GetTitan() : (Photon.MonoBehaviour)PhotonNetwork.player.GetHero(); if (myMb == null) { return; } if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase)) { foreach (PhotonPlayer player in PhotonNetwork.playerList) { Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { continue; } mb.photonView.RPC("moveToRPC", player, myMb.transform.position.x, myMb.transform.position.y, myMb.transform.position.z); } GameHelper.Broadcast("Teleported everyone to MasterClient!"); } else if (int.TryParse(args[0], out int id)) { PhotonPlayer player = PhotonPlayer.Find(id); if (player == null) { return; } Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero(); if (mb == null) { return; } myMb.transform.position = mb.transform.position; irc.AddLine($"Teleported you to #{id}"); } } }
public override void Draw() { if (Mod.Properties.ShowLog.Value && !Application.loadedLevelName.Equals("SnapShot") && !Application.loadedLevelName.Equals("characterCreation")) { if (Mod.Properties.LogBackground.Value) { GUILayout.BeginArea(new Rect(Screen.width - 331f, Screen.height - 255f, 330f, 225f), GuiSkins.Box); } else { GUILayout.BeginArea(new Rect(Screen.width - 331f, Screen.height - 255f, 330f, 225f)); } GUILayout.FlexibleSpace(); Mod.Logger.ScrollPosition = GUILayout.BeginScrollView(Mod.Logger.ScrollPosition); GUIStyle labelStyle = new GUIStyle(GUI.skin.label) { margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0) }; foreach (Logger.Entry entry in Mod.Logger.Entries) { try { DateTime date = GameHelper.Epoch.AddMilliseconds(entry.Timestamp).ToLocalTime(); string entryText = "[" + date.ToString("HH:mm:ss") + "] " + entry.ToString(); GUILayout.Label(entryText, labelStyle); } catch { } } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.Label($"{Mod.FpsCounter.FrameCount} FPS"); if (IN_GAME_MAIN_CAMERA.Gametype != GameType.Stop) { string coords = "n/a"; Photon.MonoBehaviour myObj = null; if (IN_GAME_MAIN_CAMERA.Gametype == GameType.Singleplayer) { if (FengGameManagerMKII.Instance.Heroes.Count > 0) { myObj = FengGameManagerMKII.Instance.Heroes[0]; } } else { if (PhotonNetwork.player.IsTitan) { myObj = PhotonNetwork.player.GetTitan(); } else { myObj = PhotonNetwork.player.GetHero(); } } if (myObj != null) { coords = $"X {MathHelper.Floor(myObj.transform.position.x)} Y {MathHelper.Floor(myObj.transform.position.y)} Z {MathHelper.Floor(myObj.transform.position.z)}"; } GUILayout.Label(coords); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } }