public static SetReceivingEnabled ( int group, bool enabled ) : void | ||
group | int | |
enabled | bool | |
Результат | void |
void DoReconnect() { PhotonNetwork.SetSendingEnabled(0, true); PhotonNetwork.SetReceivingEnabled(0, true); LeaveRoom(); PhotonNetwork.JoinRandomRoom(); }
/// <summary> /// Unsubscribes from old and subscribes to new interest groups. /// </summary> private void UpdateInterestGroups() { foreach (int groupId in previousActiveCells) { PhotonNetwork.SetReceivingEnabled(groupId, false); PhotonNetwork.SetSendingEnabled(groupId, false); } foreach (int groupId in activeCells) { PhotonNetwork.SetReceivingEnabled(groupId, true); PhotonNetwork.SetSendingEnabled(groupId, true); } }
/// <summary> /// Unsubscribes from old and subscribes to new interest groups. /// </summary> private void UpdateInterestGroups() { List <int> disable = new List <int>(0); foreach (int groupId in previousActiveCells) { if (!activeCells.Contains(groupId)) { disable.Add(groupId); } } PhotonNetwork.SetReceivingEnabled(activeCells.ToArray(), disable.ToArray()); PhotonNetwork.SetSendingEnabled(activeCells.ToArray(), disable.ToArray()); }
private void Start() { if (!this.pView.isMine || !PhotonNetwork.inRoom) { return; } if (this.cullArea.NumberOfSubdivisions == 0) { this.pView.group = this.cullArea.FIRST_GROUP_ID; PhotonNetwork.SetReceivingEnabled(this.cullArea.FIRST_GROUP_ID, true); PhotonNetwork.SetSendingEnabled(this.cullArea.FIRST_GROUP_ID, true); } else { this.CheckGroupsChanged(); this.InvokeRepeating("UpdateActiveGroup", 0.0f, 1f / (float)PhotonNetwork.sendRateOnSerialize); } }
private void UpdateInterestGroups() { using (List <int> .Enumerator enumerator = this.previousActiveCells.GetEnumerator()) { while (enumerator.MoveNext()) { int current = enumerator.Current; PhotonNetwork.SetReceivingEnabled(current, false); PhotonNetwork.SetSendingEnabled(current, false); } } using (List <int> .Enumerator enumerator = this.activeCells.GetEnumerator()) { while (enumerator.MoveNext()) { int current = enumerator.Current; PhotonNetwork.SetReceivingEnabled(current, true); PhotonNetwork.SetSendingEnabled(current, true); } } }
/// <summary> /// Initializes the right interest group or prepares the permanent change of the interest group of the PhotonView component. /// </summary> private void Start() { if (!pView.isMine) { return; } if (PhotonNetwork.inRoom) { if (cullArea.NumberOfSubdivisions == 0) { pView.group = cullArea.FIRST_GROUP_ID; PhotonNetwork.SetReceivingEnabled(cullArea.FIRST_GROUP_ID, true); PhotonNetwork.SetSendingEnabled(cullArea.FIRST_GROUP_ID, true); } else { CheckGroupsChanged(); InvokeRepeating("UpdateActiveGroup", 0.0f, 1.0f / PhotonNetwork.sendRateOnSerialize); } } }
/// <summary> /// Initializes the right interest group or prepares the permanent change of the interest group of the PhotonView component. /// </summary> private void Start() { if (!pView.isMine) { return; } if (PhotonNetwork.inRoom) { if (cullArea.NumberOfSubdivisions == 0) { pView.group = cullArea.FIRST_GROUP_ID; PhotonNetwork.SetReceivingEnabled(cullArea.FIRST_GROUP_ID, true); PhotonNetwork.SetSendingEnabled(cullArea.FIRST_GROUP_ID, true); } else { // This is used to continuously update the active group. pView.ObservedComponents.Add(this); } } }
void OnLevelWasLoaded(int level) { ApplyCustomRenderSettings(); if (IN_GAME_MAIN_CAMERA.Gametype == GameType.Singleplayer || PhotonNetwork.offlineMode) { string difficulty = IN_GAME_MAIN_CAMERA.Difficulty switch { 0 => "Normal", 1 => "Hard", 2 => "Abnormal", _ => "Training" }; DiscordRPC.SetPresence(new Discord.Activity { Details = $"Playing offline.", State = $"{FengGameManagerMKII.Level.Name} / {difficulty}" }); } if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnReset(); } if (HasJoinedRoom) { return; } HasJoinedRoom = true; string joinMessage = Properties.JoinMessage.Value.NGUIToUnity(); if (joinMessage.StripNGUI().Length < 1) { joinMessage = Properties.JoinMessage.Value; } if (joinMessage.Length < 1) { return; } Commands.Find("say").Execute(InRoomChat.Instance, joinMessage.Split(' ')); } void OnPhotonPlayerConnected(PhotonPlayer player) { if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnPlayerJoin(player); } Logger.Info($"({player.Id}) " + player.Username.NGUIToUnity() + " connected.".AsColor("00FF00")); } void OnPhotonPlayerDisconnected(PhotonPlayer player) { if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnPlayerLeave(player); } Logger.Info($"({player.Id}) " + player.Username.NGUIToUnity() + " disconnected.".AsColor("FF0000")); } void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps) { NetworkChecker.OnPlayerPropertyModification(playerAndUpdatedProps); ModDetector.OnPlayerPropertyModification(playerAndUpdatedProps); } void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { NetworkChecker.OnRoomPropertyModification(propertiesThatChanged); PhotonPlayer sender = null; if (propertiesThatChanged.ContainsKey("sender") && propertiesThatChanged["sender"] is PhotonPlayer player) { sender = player; } if (sender != null && !sender.isMasterClient) { return; } if (propertiesThatChanged.ContainsKey("Map") && propertiesThatChanged["Map"] is string mapName) { LevelInfo levelInfo = LevelInfo.GetInfo(mapName); if (levelInfo != null) { FengGameManagerMKII.Level = levelInfo; } } if (propertiesThatChanged.ContainsKey("Lighting") && propertiesThatChanged["Lighting"] is string lightLevel && GExtensions.TryParseEnum(lightLevel, out DayLight time)) { Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().SetLighting(time); } } void OnJoinedLobby() { // TODO: Begin working on Friend system with Photon Friend API PhotonNetwork.playerName = Properties.PhotonUserId.Value; } void OnJoinedRoom() { HasJoinedRoom = false; // TODO: Potentially use custom event/group combo to sync game-settings whilst not triggering other mods int[] groups = new int[byte.MaxValue]; for (int i = 0; i < byte.MaxValue; i++) { groups[i] = i + 1; } PhotonNetwork.SetReceivingEnabled(groups, null); PhotonNetwork.SetSendingEnabled(groups, null); PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable { { CustomPropertyName, Build } }); StartCoroutine(CoUpdateMyPing()); string[] roomInfo = PhotonNetwork.room.name.Split('`'); if (roomInfo.Length < 7) { return; } DiscordRPC.SetPresence(new Discord.Activity { Details = $"Playing in {(roomInfo[5].Length < 1 ? string.Empty : "[PWD]")} {roomInfo[0].StripNGUI()}", State = $"({NetworkHelper.GetRegionCode().ToUpper()}) {roomInfo[1]} / {roomInfo[2].ToUpper()}" }); }
// Replay callbacks void DisableSending() { PhotonNetwork.SetSendingEnabled(0, false); PhotonNetwork.SetReceivingEnabled(0, false); }
void RecalculateGroups() { Vector2 posVector = GetPosition(); int posX = (int)(posVector.x); int posZ = (int)(posVector.y); //Very Close Groups int offsetDiff = veryCloseBlockSize / 2; List <int> newListenList = new List <int> (); int group = 0; if (enableNearUpdates) { group = GetGroupFor(posX + offsetDiff, posZ + offsetDiff, GroupType.veryClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX + offsetDiff, posZ - offsetDiff, GroupType.veryClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX - offsetDiff, posZ + offsetDiff, GroupType.veryClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX - offsetDiff, posZ - offsetDiff, GroupType.veryClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } } //Reasonably close offsetDiff = reasonableCloseBlockSize / 2; if (enableFarUpdates) { group = GetGroupFor(posX + offsetDiff, posZ + offsetDiff, GroupType.reasonablyClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX + offsetDiff, posZ - offsetDiff, GroupType.reasonablyClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX - offsetDiff, posZ + offsetDiff, GroupType.reasonablyClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } group = GetGroupFor(posX - offsetDiff, posZ - offsetDiff, GroupType.reasonablyClose); if (!newListenList.Contains(group)) { newListenList.Add(group); } } List <int> removeList = new List <int> (); foreach (int g in currentListenList) { if (!newListenList.Contains(g)) { if (g < 100 || g >= 250) { Debug.LogError("Error culling removing incorect group " + g + ". Expectng 100-249"); } removeList.Add(g); } } List <int> enableList = new List <int> (); foreach (int b in newListenList) { if (!currentListenList.Contains(b)) { enableList.Add(b); } } #region debug /* * if(enableList.Count>0 || removeList.Count>0){ * string debug = posX+", "+posZ+" ADD: "; * foreach(int b in enableList){ * debug += " "+b; * } * debug += " REMOVE: "; * foreach(int b in removeList){ * debug += " "+b; * } * Debug.Log (debug); * } */ #endregion PhotonNetwork.SetReceivingEnabled(enableList.ToArray(), removeList.ToArray()); currentListenList = newListenList; }
public void OnJoinedRoom(AOTEventArgs args) { int[] groups = new int[255]; for (int i = 0; i < groups.Length; i++) { groups[i] = i + 1; } PhotonNetwork.SetReceivingEnabled(groups, new int[0]); Debug.Log("OnJoinedRoom >> " + PhotonNetwork.room.Name); var strArray = PhotonNetwork.room.Name.Split('`'); gameTimesUp = false; Level = LevelInfo.GetInfo(strArray[1]); switch (strArray[2].ToLower()) { case "normal": difficulty = 0; break; case "hard": difficulty = 1; break; case "abnormal": difficulty = 2; break; default: difficulty = 1; break; } IN_GAME_MAIN_CAMERA.Difficulty = difficulty; time = int.Parse(strArray[3]) * 60; logic.ServerTimeBase = time; logic.ServerTime = time; switch (strArray[4].ToLower()) { case "day": case "день": IN_GAME_MAIN_CAMERA.DayLight = DayLight.Day; break; case "dawn": case "вечер": IN_GAME_MAIN_CAMERA.DayLight = DayLight.Dawn; break; case "night": case "ночь": IN_GAME_MAIN_CAMERA.DayLight = DayLight.Night; break; default: IN_GAME_MAIN_CAMERA.DayLight = DayLight.Dawn; break; } IN_GAME_MAIN_CAMERA.GameMode = Level.Mode; PhotonNetwork.LoadLevel(Level.MapName); if (PhotonNetwork.IsMasterClient) { GameModes.Load(); GameModes.ForceChange(); GameModes.SendRpc(); } var player = PhotonNetwork.player; player.RCIgnored = false; player.UIName = User.Name; player.GuildName = User.AllGuildNames; player.Kills = player.Deaths = player.MaximumDamage = player.TotalDamage = 0; player.RCteam = 0; player.Dead = true; player.IsTitan = false; localRacingResult = string.Empty; needChooseSide = true; foreach (var info in killInfoList) { info.destroy(); } killInfoList.Clear(); RCManager.racingSpawnPointSet = false; if (!PhotonNetwork.IsMasterClient) { BasePV.RPC("RequireStatus", PhotonTargets.MasterClient); } foreach (var her in heroes) { if (her.BasePV != null && her.BasePV.owner.GameObject == null) { her.BasePV.owner.GameObject = her.baseG; } } PhotonNetwork.SetModProperties(); }