Пример #1
0
        public ChatMessage CreateOutgoingMessage(string text)
        {
            ChatMessage message = new ChatMessage(text);
            KeyValuePair <LocalizedText, ChatCommandId> keyValuePair = _localizedCommands.FirstOrDefault((KeyValuePair <LocalizedText, ChatCommandId> pair) => HasLocalizedCommand(message, pair.Key));
            ChatCommandId value = keyValuePair.Value;

            if (keyValuePair.Key != null)
            {
                message.SetCommand(value);
                message.Text = RemoveCommandPrefix(message.Text, keyValuePair.Key);
                _commands[value].ProcessOutgoingMessage(message);
            }
            else
            {
                bool flag = false;
                KeyValuePair <LocalizedText, NetworkText> keyValuePair2 = _aliases.FirstOrDefault((KeyValuePair <LocalizedText, NetworkText> pair) => HasLocalizedCommand(message, pair.Key));
                while (keyValuePair2.Key != null)
                {
                    flag          = true;
                    message       = new ChatMessage(keyValuePair2.Value.ToString());
                    keyValuePair2 = _aliases.FirstOrDefault((KeyValuePair <LocalizedText, NetworkText> pair) => HasLocalizedCommand(message, pair.Key));
                }
                if (flag)
                {
                    return(CreateOutgoingMessage(message.Text));
                }
            }
            return(message);
        }
Пример #2
0
        public ChatMessage CreateOutgoingMessage(string text)
        {
            ChatMessage message = new ChatMessage(text);
            KeyValuePair <LocalizedText, ChatCommandId> keyValuePair1 = this._localizedCommands.FirstOrDefault <KeyValuePair <LocalizedText, ChatCommandId> >((Func <KeyValuePair <LocalizedText, ChatCommandId>, bool>)(pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key)));
            ChatCommandId commandId = keyValuePair1.Value;

            if (keyValuePair1.Key != null)
            {
                message.SetCommand(commandId);
                message.Text = ChatCommandProcessor.RemoveCommandPrefix(message.Text, keyValuePair1.Key);
                this._commands[commandId].ProcessOutgoingMessage(message);
            }
            else
            {
                bool flag = false;
                for (KeyValuePair <LocalizedText, NetworkText> keyValuePair2 = this._aliases.FirstOrDefault <KeyValuePair <LocalizedText, NetworkText> >((Func <KeyValuePair <LocalizedText, NetworkText>, bool>)(pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key))); keyValuePair2.Key != null; keyValuePair2 = this._aliases.FirstOrDefault <KeyValuePair <LocalizedText, NetworkText> >((Func <KeyValuePair <LocalizedText, NetworkText>, bool>)(pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key))))
                {
                    flag    = true;
                    message = new ChatMessage(keyValuePair2.Value.ToString());
                }
                if (flag)
                {
                    return(this.CreateOutgoingMessage(message.Text));
                }
            }
            return(message);
        }
Пример #3
0
 public void SetCommand(ChatCommandId commandId)
 {
     if (this.IsConsumed)
     {
         throw new InvalidOperationException("Message has already been consumed.");
     }
     this.CommandId = commandId;
 }
Пример #4
0
 public void SetCommand <T>() where T : IChatCommand
 {
     if (this.IsConsumed)
     {
         throw new InvalidOperationException("Message has already been consumed.");
     }
     this.CommandId = ChatCommandId.FromType <T>();
 }
Пример #5
0
        // Token: 0x06001348 RID: 4936 RVA: 0x0041B430 File Offset: 0x00419630
        public ChatCommandProcessor AddDefaultCommand <T>() where T : IChatCommand, new()
        {
            this.AddCommand <T>();
            ChatCommandId key = ChatCommandId.FromType <T>();

            this._defaultCommand = this._commands[key];
            return(this);
        }
Пример #6
0
        // Token: 0x0600134B RID: 4939 RVA: 0x0041B508 File Offset: 0x00419708
        public bool ProcessOutgoingMessage(ChatMessage message)
        {
            KeyValuePair <LocalizedText, ChatCommandId> keyValuePair = this._localizedCommands.FirstOrDefault((KeyValuePair <LocalizedText, ChatCommandId> pair) => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key));
            ChatCommandId value = keyValuePair.Value;

            if (keyValuePair.Key != null)
            {
                message.SetCommand(value);
                message.Text = ChatCommandProcessor.RemoveCommandPrefix(message.Text, keyValuePair.Key);
                return(true);
            }
            return(false);
        }
Пример #7
0
        public bool ProcessOutgoingMessage(ChatMessage message)
        {
            KeyValuePair <LocalizedText, ChatCommandId> keyValuePair = this._localizedCommands.FirstOrDefault <KeyValuePair <LocalizedText, ChatCommandId> >((Func <KeyValuePair <LocalizedText, ChatCommandId>, bool>)(pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key)));
            ChatCommandId commandId = keyValuePair.Value;

            if (keyValuePair.Key == null)
            {
                return(false);
            }
            message.SetCommand(commandId);
            message.Text = ChatCommandProcessor.RemoveCommandPrefix(message.Text, keyValuePair.Key);
            return(true);
        }
Пример #8
0
        public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new()
        {
            string        commandKey = "ChatCommand." + ((ChatCommandAttribute)AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>()).Name;
            ChatCommandId index      = ChatCommandId.FromType <T>();

            this._commands[index] = (IChatCommand)Activator.CreateInstance <T>();
            if (Language.Exists(commandKey))
            {
                this._localizedCommands.Add(Language.GetText(commandKey), index);
            }
            else
            {
                commandKey += "_";
                foreach (LocalizedText key in Language.FindAll((LanguageSearchFilter)((key, text) => key.StartsWith(commandKey))))
                {
                    this._localizedCommands.Add(key, index);
                }
            }
            return(this);
        }
Пример #9
0
        public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new()
        {
            ChatCommandAttribute cacheableAttribute = AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>();
            string        commandKey    = "ChatCommand." + cacheableAttribute.Name;
            ChatCommandId chatCommandId = ChatCommandId.FromType <T>();

            _commands[chatCommandId] = new T();
            if (Language.Exists(commandKey))
            {
                _localizedCommands.Add(Language.GetText(commandKey), chatCommandId);
            }
            else
            {
                commandKey += "_";
                LocalizedText[] array = Language.FindAll((string key, LocalizedText text) => key.StartsWith(commandKey));
                foreach (LocalizedText key2 in array)
                {
                    _localizedCommands.Add(key2, chatCommandId);
                }
            }
            return(this);
        }
Пример #10
0
        // Token: 0x06001347 RID: 4935 RVA: 0x0041B370 File Offset: 0x00419570
        public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new()
        {
            ChatCommandAttribute cacheableAttribute = AttributeUtilities.GetCacheableAttribute <T, ChatCommandAttribute>();
            string        commandKey    = "ChatCommand." + cacheableAttribute.Name;
            ChatCommandId chatCommandId = ChatCommandId.FromType <T>();

            this._commands[chatCommandId] = Activator.CreateInstance <T>();
            if (Language.Exists(commandKey))
            {
                this._localizedCommands.Add(Language.GetText(commandKey), chatCommandId);
            }
            else
            {
                commandKey += "_";
                LocalizedText[] array = Language.FindAll((string key, LocalizedText text) => key.StartsWith(commandKey));
                for (int i = 0; i < array.Length; i++)
                {
                    LocalizedText key2 = array[i];
                    this._localizedCommands.Add(key2, chatCommandId);
                }
            }
            return(this);
        }
Пример #11
0
        public ChatCommandProcessor AddCommand <T>() where T : IChatCommand, new()
        {
            var commandKey = "ChatCommand." +
                             AttributeUtilities
                             .GetCacheableAttribute <T, ChatCommandAttribute>().Name;
            var index = ChatCommandId.FromType <T>();

            _commands[index] = new T();
            if (Language.Exists(commandKey))
            {
                _localizedCommands.Add(Language.GetText(commandKey), index);
            }
            else
            {
                commandKey += "_";
                foreach (var key in Language.FindAll((key, text) =>
                                                     key.StartsWith(commandKey)))
                {
                    _localizedCommands.Add(key, index);
                }
            }

            return(this);
        }
Пример #12
0
        public bool ProcessOutgoingMessage(ChatMessage message)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            ChatCommandProcessor.\u003C\u003Ec__DisplayClass5 cDisplayClass5 = new ChatCommandProcessor.\u003C\u003Ec__DisplayClass5();
            // ISSUE: reference to a compiler-generated field
            cDisplayClass5.message = message;
            // ISSUE: reference to a compiler-generated field
            cDisplayClass5.\u003C\u003E4__this = this;
            // ISSUE: method pointer
            KeyValuePair <LocalizedText, ChatCommandId> keyValuePair = (KeyValuePair <LocalizedText, ChatCommandId>)Enumerable.FirstOrDefault <KeyValuePair <LocalizedText, ChatCommandId> >((IEnumerable <M0>) this._localizedCommands, (Func <M0, bool>) new Func <KeyValuePair <LocalizedText, ChatCommandId>, bool>((object)cDisplayClass5, __methodptr(\u003CProcessOutgoingMessage\u003Eb__4)));
            ChatCommandId commandId = keyValuePair.Value;

            if (keyValuePair.Key == null)
            {
                return(false);
            }
            // ISSUE: reference to a compiler-generated field
            cDisplayClass5.message.SetCommand(commandId);
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            cDisplayClass5.message.Text = ChatCommandProcessor.RemoveCommandPrefix(cDisplayClass5.message.Text, keyValuePair.Key);
            return(true);
        }
Пример #13
0
        public static ChatMessage Deserialize(BinaryReader reader)
        {
            ChatCommandId commandId = ChatCommandId.Deserialize(reader);

            return(new ChatMessage(reader.ReadString(), commandId));
        }
Пример #14
0
 private ChatMessage(string message, ChatCommandId commandId)
 {
     this.CommandId = commandId;
     this.Text      = message;
 }
Пример #15
0
 public ChatMessage(string message)
 {
     this.CommandId = ChatCommandId.FromType <SayChatCommand>();
     this.Text      = message;
 }
Пример #16
0
 public ChatCommandProcessor AddDefaultCommand <T>() where T : IChatCommand, new()
 {
     AddCommand <T>();
     _defaultCommand = _commands[ChatCommandId.FromType <T>()];
     return(this);
 }
Пример #17
0
 private ChatMessage(string message, ChatCommandId commandId)
 {
     CommandId = commandId;
     Text      = message;
 }
Пример #18
0
 public void SetCommand(ChatCommandId commandId)
 {
     this.CommandId = commandId;
 }
Пример #19
0
 public void SetCommand <T>() where T : IChatCommand
 {
     this.CommandId = ChatCommandId.FromType <T>();
 }
Пример #20
0
 public ChatMessage(string message)
 {
     CommandId  = ChatCommandId.FromType <SayChatCommand>();
     Text       = message;
     IsConsumed = false;
 }