SetSendingEnabled() public static method

Enable/disable sending on given group (applied to PhotonViews)
public static SetSendingEnabled ( int group, bool enabled ) : void
group int
enabled bool
return void
    private void Update()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            time = Time.time;

            Debug.Log($"Pilot (mine) sends event 100 to interest group 11: " + time);

            PhotonNetwork.SetSendingEnabled(new byte[0], LauncherEvents.InterestGroups);

            var content           = new object[] { "pilot " + time };
            var raiseEventOptions = new RaiseEventOptions {
                Receivers = ReceiverGroup.Others, InterestGroup = 11
            };                                                                                                    //We can only send to 1 interest group at once.

            PhotonNetwork.RaiseEvent(100, content, raiseEventOptions, SendOptions.SendReliable);
        }
    }
Beispiel #2
0
    /// <summary>
    ///     Initializes the right interest group or prepares the permanent change of the interest group of the PhotonView component.
    /// </summary>
    private void Start()
    {
        if (!this.pView.isMine)
        {
            return;
        }

        if (PhotonNetwork.inRoom)
        {
            if (this.cullArea.NumberOfSubdivisions == 0)
            {
                this.pView.group = this.cullArea.FIRST_GROUP_ID;

                PhotonNetwork.SetInterestGroups(this.cullArea.FIRST_GROUP_ID, true);
                PhotonNetwork.SetSendingEnabled(this.cullArea.FIRST_GROUP_ID, true);
            }
            else
            {
                // This is used to continuously update the active group.
                this.pView.ObservedComponents.Add(this);
            }
        }
    }
Beispiel #3
0
        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);
 }