private void SendNotificationToEveryone(
     MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum message,
     int param1 = -1,
     int param2 = -1)
 {
     this.ShowNotification(message, param1, param2);
     GameNetwork.BeginBroadcastModuleEvent();
     GameNetwork.WriteMessage((GameNetworkMessage) new NotificationMessage((int)message, param1, param2));
     GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
 }
 private TextObject ToNotificationString(
     MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum value,
     NotificationProperty attribute,
     params int[] parameters)
 {
     if (parameters.Length != 0)
     {
         this.SetGameTextVariables(value, parameters);
     }
     return(GameTexts.FindText(attribute.StringId));
 }
        private void ShowNotification(
            MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum notification,
            params int[] parameters)
        {
            if (GameNetwork.IsDedicatedServer)
            {
                return;
            }
            NotificationProperty attribute = (NotificationProperty)((IEnumerable <object>)notification.GetType().GetField(notification.ToString()).GetCustomAttributes(typeof(NotificationProperty), false)).Single <object>();

            if (attribute == null)
            {
                return;
            }
            int[] array = ((IEnumerable <int>)parameters).Where <int>((Func <int, bool>)(x => x != -1)).ToArray <int>();
            InformationManager.AddQuickInformation(this.ToNotificationString(notification, attribute, array), soundEventPath: this.ToSoundString(notification, attribute, array));
        }
        private void SetGameTextVariables(
            MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum message,
            params int[] parameters)
        {
            if (parameters.Length == 0)
            {
                return;
            }
            switch (message)
            {
            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.BattleWarmupEnding:
                GameTexts.SetVariable("SECONDS_LEFT", parameters[0]);
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.BattleYouHaveXTheRound:
                Team team1 = parameters[0] == 0 ? Mission.Current.AttackerTeam : Mission.Current.DefenderTeam;
                Team team2 = GameNetwork.IsMyPeerReady ? GameNetwork.MyPeer.GetComponent <MissionPeer>().Team : (Team)null;
                if (team2 == null)
                {
                    break;
                }
                GameTexts.SetVariable("IS_WINNER", team2 == team1 ? 1 : 0);
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXRemoved:
                GameTexts.SetVariable("PARAM1", ((char)parameters[0]).ToString());
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXRemaining:
                GameTexts.SetVariable("PARAM1", ((char)parameters[0]).ToString());
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagsWillBeRemoved:
                GameTexts.SetVariable("PARAM1", parameters[0]);
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXCapturedByYourTeam:
            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXCapturedByOtherTeam:
                GameTexts.SetVariable("PARAM1", ((char)parameters[0]).ToString());
                break;

            case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.GoldCarriedFromPreviousRound:
                GameTexts.SetVariable("PARAM1", parameters[0].ToString());
                break;
            }
        }
 private void SendNotificationToPeer(
     NetworkCommunicator peer,
     MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum message,
     int param1 = -1,
     int param2 = -1)
 {
     if (peer.IsServerPeer)
     {
         this.ShowNotification(message, param1, param2);
     }
     else
     {
         GameNetwork.BeginModuleEventAsServer(peer);
         GameNetwork.WriteMessage((GameNetworkMessage) new NotificationMessage((int)message, param1, param2));
         GameNetwork.EndModuleEventAsServer();
     }
 }
 private void HandleNewNotification(
     MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum notification,
     int param1      = -1,
     int param2      = -1,
     Team syncToTeam = null,
     NetworkCommunicator syncToPeer = null)
 {
     if (syncToPeer != null)
     {
         this.SendNotificationToPeer(syncToPeer, notification, param1, param2);
     }
     else if (syncToTeam != null)
     {
         this.SendNotificationToTeam(syncToTeam, notification, param1, param2);
     }
     else
     {
         this.SendNotificationToEveryone(notification, param1, param2);
     }
 }
        private void SendNotificationToTeam(
            Team team,
            MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum message,
            int param1 = -1,
            int param2 = -1)
        {
            NetworkCommunicator myPeer      = GameNetwork.MyPeer;
            MissionPeer         missionPeer = myPeer != null?myPeer.GetComponent <MissionPeer>() : (MissionPeer)null;

            if (!GameNetwork.IsDedicatedServer && (missionPeer?.Team != null && missionPeer.Team.IsEnemyOf(team)))
            {
                this.ShowNotification(message, param1, param2);
            }
            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                if (peer.Team != null && !peer.IsMine && !peer.Team.IsEnemyOf(team))
                {
                    GameNetwork.BeginModuleEventAsServer(peer.Peer);
                    GameNetwork.WriteMessage((GameNetworkMessage) new NotificationMessage((int)message, param1, param2));
                    GameNetwork.EndModuleEventAsServer();
                }
            }
        }
        private string ToSoundString(
            MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum value,
            NotificationProperty attribute,
            params int[] parameters)
        {
            string str = string.Empty;

            if (attribute.SoundIdTwo.IsStringNoneOrEmpty())
            {
                str = attribute.SoundIdOne;
            }
            else
            {
                switch (value)
                {
                case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.BattleYouHaveXTheRound:
                    Team team1 = parameters[0] == 0 ? Mission.Current.AttackerTeam : Mission.Current.DefenderTeam;
                    Team team2 = GameNetwork.IsMyPeerReady ? GameNetwork.MyPeer.GetComponent <MissionPeer>().Team : (Team)null;
                    str = attribute.SoundIdOne;
                    if (team2 != null && team2 != team1)
                    {
                        str = attribute.SoundIdTwo;
                        break;
                    }
                    break;

                case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXCapturedByYourTeam:
                    str = attribute.SoundIdOne;
                    break;

                case MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.FlagXCapturedByOtherTeam:
                    str = attribute.SoundIdTwo;
                    break;
                }
            }
            return(str);
        }