Пример #1
0
        void OnPlayerChat(PlayerEvent e)
        {
            List <string> ForbiddenWordsList = Config["ForbiddenWords"] as List <string>;
            Player        player             = e.Player;
            string        message            = e.ToString();
            string        censored           = "";
            bool          isCensored         = false;

            if (message.StartsWith("/"))
            {
                return;
            }
            foreach (string word in ForbiddenWordsList)
            {
                censored = "";
                for (int i = 0; i < word.Length; i++)
                {
                    censored = censored + "*";
                }

                if (message.ToLower().Contains(word.ToLower()))
                {
                    message    = message.ToLower().Replace(word.ToLower(), censored);
                    isCensored = true;
                }
            }
            if (isCensored)
            {
                BroadcastChat(player.DisplayName, message);
                e.Cancel();
            }
        }
Пример #2
0
    public void logEvent(PlayerEvent label, bool midlevel, Dictionary <string, string> customAttributes = null, Dictionary <string, double> customMetrics = null)
    {
        if (!ENABLED)
        {
            return;
        }
        //Debug.Log("Logging custom event\n");

        CustomEvent customEvent = new CustomEvent("custom_event");


        customEvent.AddAttribute("eventtype", label.ToString());

        customEvent.AddMetric("level", Central.Instance.current_lvl);

        if (midlevel)
        {
            customEvent.AddMetric("health", Peripheral.Instance.GetHealth());
            customEvent.AddMetric("wave_time", Moon.Instance.TIME);
            customEvent.AddAttribute("difficulty", Peripheral.Instance.difficulty.ToString());
        }
        else
        {
            customEvent.AddMetric("wave_time", -1);
        }

        customEvent.AddAttribute("app_version", Application.version);

        customEvent.AddAttribute("device",
                                 SystemInfo.deviceType + " " + SystemInfo.deviceName + " " + SystemInfo.deviceModel);
        customEvent.AddAttribute("device_id", SystemInfo.deviceUniqueIdentifier);


        foreach (string key in customAttributes.Keys)
        {
            customEvent.AddAttribute(key, customAttributes[key].ToString());
        }

        foreach (string key in customMetrics.Keys)
        {
            customEvent.AddMetric(key, customMetrics[key]);
        }
        AnalyticsManager.RecordEvent(customEvent);
    }
Пример #3
0
        private void OnPlayerChat(PlayerEvent e)
        {
            #region Null Checks
            if (e == null)
            {
                return;
            }
            if (e.Cancelled)
            {
                return;
            }
            if (e.Player.IsServer)
            {
                return;
            }
            #endregion

            Player player = e.Player;
            Log(player.Id + " - " + player.Name + " - " + e.ToString(), "ChatLog");
        }
Пример #4
0
        void OnPlayerChat(PlayerEvent e)
        {
            List <string> ForbiddenWordsList = Config["ForbiddenWords"] as List <string>;
            Player        player             = e.Player;
            string        message            = e.ToString();
            string        censored           = "";
            bool          isCensored         = false;

            if (message.StartsWith("/"))
            {
                return;
            }

            string filteredMessage = GetFilteredMesssage(message);

            if (message != filteredMessage)
            {
                BroadcastChat(player.DisplayName, filteredMessage);
                e.Cancel();
            }
        }
Пример #5
0
        private void WaitUntil (PlayerEvent? @event, PlayerState? state, System.Action action)
        {
            if (action == null) {
                throw new ArgumentNullException ("action");
            }
            if (@event == null && state == null) {
                throw new ArgumentException ("Event or state must be non-null");
            }
            if (@event != null && state != null) {
                throw new ArgumentException ("Event and state cannot be both non-null");
            }

            object lock_object = new object ();
            string evnt_or_state_desc = @event != null ? @event.Value.ToString () : state.Value.ToString ();

            Exception exception = null;


            Func<PlayerEventArgs, bool> matches = (a) => {
                if (a == null) {
                    throw new ArgumentNullException ("a");
                }
                var sca = a as PlayerEventStateChangeArgs;
                PlayerEvent? last_event = a.Event;
                PlayerState? last_state = null;
                if (sca != null) {
                    last_state = sca.Current;
                }

                return (@event != null && @event.Value.Equals (last_event.Value))
                || (state != null && last_state != null && state.Value.Equals (last_state.Value));
            };
            var args_queue = new Queue<PlayerEventArgs> ();

            var reset_event = new ManualResetEvent (false);
            reset_event.Reset ();

            var handler = new PlayerEventHandler (a => {
                try {
                    lock (lock_object) {
                        args_queue.Enqueue (a);
                    }
                } catch (Exception ex) {
                    exception = ex;
                }
                reset_event.Set ();
            });
            service.ConnectEvent (handler);

            bool return_early = (state != null && service.CurrentState.Equals (state.Value));
            action ();
            if (return_early) {
                return;
            }

            const int seconds = 3;
            int count = 0;
            const int max_count = 10;

            string event_or_state_desc = @event != null ? @event.ToString () : state.ToString ();

            bool found = false;
            do {
                if (!reset_event.WaitOne (TimeSpan.FromSeconds (seconds))) {
                    Assert.Fail (String.Format ("Waited {0}s for {1} at iteration {2}, but didn't happen",
                                                seconds, evnt_or_state_desc, count));
                    break;
                }
                lock (lock_object) {
                    while (args_queue.Count > 0) {
                        var arg = args_queue.Dequeue ();
                        if (matches (arg)) {
                            found = true;
                            break;
                        }
                        count++;
                    }
                }

                if (exception != null) {
                    throw exception;
                }
                if (count > max_count) {
                    Assert.Fail (String.Format ("More than {0} events/states happened, but not {1}", max_count, event_or_state_desc));
                }
            } while (!found);

            service.DisconnectEvent (handler);
        }