Example #1
0
        public static SpeechEntry[] GetKeywords(string text)
        {
            if (!NewConfig.EncodeSpeech)
            {
                return(new SpeechEntry[0]);
            }
            if (m_Speech == null)
            {
                LoadSpeechTable();
            }
            text = text.ToLower();
            ArrayList dataStore = Engine.GetDataStore();

            SpeechEntry[] speech = m_Speech;
            int           length = speech.Length;

            for (int i = 0; i < length; i++)
            {
                SpeechEntry entry = speech[i];
                if (IsMatch(text, entry.m_Keywords))
                {
                    dataStore.Add(entry);
                }
            }
            dataStore.Sort();
            SpeechEntry[] entryArray2 = (SpeechEntry[])dataStore.ToArray(typeof(SpeechEntry));
            Engine.ReleaseDataStore(dataStore);
            return(entryArray2);
        }
Example #2
0
 public int CompareTo(object x)
 {
     if ((x == null) || (x.GetType() != typeof(SpeechEntry)))
     {
         return(-1);
     }
     if (x != this)
     {
         SpeechEntry entry = (SpeechEntry)x;
         if (this.m_KeywordID < entry.m_KeywordID)
         {
             return(-1);
         }
         if (this.m_KeywordID > entry.m_KeywordID)
         {
             return(1);
         }
     }
     return(0);
 }
Example #3
0
        public PUnicodeSpeech(string ToSay, bool encode) : base(0xad, "Unicode Speech")
        {
            byte toWrite = 0;
            int  textHue = World.CharData.TextHue;

            if (ToSay.StartsWith(": "))
            {
                toWrite = 2;
                textHue = World.CharData.EmoteHue;
                ToSay   = string.Format("*{0}*", ToSay.Substring(2));
            }
            else if (ToSay.StartsWith("; "))
            {
                toWrite = 8;
                textHue = World.CharData.WhisperHue;
                ToSay   = ToSay.Substring(2);
            }
            else if (ToSay.StartsWith("! "))
            {
                toWrite = 9;
                textHue = World.CharData.YellHue;
                ToSay   = ToSay.Substring(2);
            }
            else if (ToSay.StartsWith(@"\ "))
            {
                ToSay = string.Format("<OOC> {0}", ToSay.Substring(2));
            }
            SpeechEntry[] keywords = Strings.GetKeywords(ToSay);
            if (encode && (keywords.Length > 0))
            {
                toWrite = (byte)(toWrite | 0xc0);
            }
            ToSay = Engine.ConvertFont(ToSay);
            base.m_Stream.Write(toWrite);
            base.m_Stream.Write((short)textHue);
            base.m_Stream.Write((short)3);
            base.m_Stream.Write(Localization.Language, 4);
            if (!encode || (keywords.Length <= 0))
            {
                base.m_Stream.WriteUnicode(ToSay);
                base.m_Stream.Write((short)0);
            }
            else
            {
                base.m_Stream.Write((byte)(keywords.Length >> 4));
                int  num3  = keywords.Length & 15;
                bool flag  = false;
                int  index = 0;
                while (index < keywords.Length)
                {
                    SpeechEntry entry     = keywords[index];
                    int         keywordID = entry.m_KeywordID;
                    if (flag)
                    {
                        base.m_Stream.Write((byte)(keywordID >> 4));
                        num3 = keywordID & 15;
                    }
                    else
                    {
                        base.m_Stream.Write((byte)((num3 << 4) | ((keywordID >> 8) & 15)));
                        base.m_Stream.Write((byte)keywordID);
                    }
                    index++;
                    flag = !flag;
                }
                if (!flag)
                {
                    base.m_Stream.Write((byte)(num3 << 4));
                }
                base.m_Stream.Write(Encoding.UTF8.GetBytes(ToSay));
                base.m_Stream.Write((byte)0);
            }
        }