public void Update() { _time += Time.deltaTime; if (!(_time > 1f)) { return; } UpdateStatus(); DiscordRPC.UpdatePresence(_presence); _time = 0f; }
public void Start() { if (_ignoreStart) { return; } _ignoreStart = true; _presence = new DiscordRPC.RichPresence { details = "", startTimestamp = StartTime, largeImageKey = "anarchyicon", largeImageText = "", smallImageKey = "", smallImageText = "" }; _handlers = default; DiscordRPC.Initialize(DiscordClientID, ref _handlers, true, null); DiscordRPC.UpdatePresence(_presence); UpdateStatus(); }
public static void UpdateStatus() { if (!PhotonNetwork.inRoom) { if (PhotonNetwork.InsideLobby) { _presence.state = "In lobby: " + Regex.Replace(PhotonNetwork.ServerAddress, "app\\-|\\.exitgamescloud\\.com|\\:\\d+", "").ToUpper().Replace("WS://", "").Replace("WSS://", ""); _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = "anarchyicon"; } else if (IN_GAME_MAIN_CAMERA.GameType != GameType.Stop) { _presence.state = "Solo: " + FengGameManagerMKII.Level.Name; _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = FengGameManagerMKII.Level.DiscordName; _presence.largeImageText = FengGameManagerMKII.Level.Name; } else { _presence.state = "In menu"; _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = "anarchyicon"; } } else { var text = PhotonNetwork.room.Name.Split('`')[0].RemoveHex(); _presence.state = "Multiplayer: " + ((text.Length > 30) ? (text.Remove(27) + "...") : text); _presence.partySize = PhotonNetwork.room.PlayerCount; _presence.partyMax = PhotonNetwork.room.MaxPlayers; _presence.largeImageKey = FengGameManagerMKII.Level.DiscordName; _presence.largeImageText = FengGameManagerMKII.Level.Name; } DiscordRPC.UpdatePresence(_presence); }
public static void UpdateStatus() { if (!canUpdate) { return; } if (!PhotonNetwork.inRoom) { if (PhotonNetwork.InsideLobby) { _presence.state = "In lobby: " + Regex.Replace(PhotonNetwork.ServerAddress, "app\\-|\\.exitgamescloud\\.com|\\:\\d+", "").ToUpper().Replace("WS://", "").Replace("WSS://", ""); switch (PhotonNetwork.ServerAddress.Split(':')[0]) { case "142.44.242.29": _presence.state = "In lobby: USA"; break; case "135.125.239.180": _presence.state = "In lobby: Europe"; break; case "51.79.164.137": _presence.state = "In lobby: Asia"; break; case "172.107.193.233": _presence.state = "In lobby: South America"; break; default: break; } _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = "anarchyicon"; } else if (IN_GAME_MAIN_CAMERA.GameType != GameType.Stop) { _presence.state = "Solo: " + FengGameManagerMKII.Level.Name; _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = FengGameManagerMKII.Level.DiscordName; _presence.largeImageText = FengGameManagerMKII.Level.Name; } else { _presence.state = "In menu"; _presence.partySize = 0; _presence.partyMax = 0; _presence.largeImageKey = "anarchyicon"; } } else { var text = PhotonNetwork.room.Name.Split('`')[0].RemoveHex(); _presence.state = "Multiplayer: " + ((text.Length > 30) ? (text.Remove(27) + "...") : text); _presence.partySize = PhotonNetwork.room.PlayerCount; _presence.partyMax = PhotonNetwork.room.MaxPlayers; _presence.largeImageKey = FengGameManagerMKII.Level.DiscordName; _presence.largeImageText = FengGameManagerMKII.Level.Name; } DiscordRPC.UpdatePresence(_presence); }