Example #1
0
        public override void onRecognized(SpeechRecognitionEngine engine, SpeechRecognizedEventArgs e)
        {
            String text = e.Result.Text;

            String bp = "";

            foreach (String key in items.Keys.OrderByDescending(x => x.Length))
            {
                if (text.Contains(key))
                {
                    bp = items[key];
                    break;
                }
            }

            int level = 150;

            try
            {
                level = GrammarUtils.wordsToNumber(String.Join(" ", text.Split(' ').ToList().Select(word => word.Trim()).Where(word => GrammarUtils.wordToNum.ContainsKey(word))));
            }
            catch
            {
                //no numeric words
            }

            MainWindow.sendCommand($"admincheat SpawnDino \"{bp}\" 1 1 0 {level}");
        }
Example #2
0
        public override void onRecognized(SpeechRecognitionEngine engine, SpeechRecognizedEventArgs e)
        {
            String text = e.Result.Text;

            var data = items[items.Keys.OrderByDescending(k => k.Length).Where(k => text.Contains(k)).First()];

            String bp = "";

            if (data is String)
            {
                bp = data;
            }
            else if (data is JObject)
            {
                bp = data["bp"];
            }
            else
            {
                throw new Exception("Unsupported class type " + data.GetType());
            }

            int quantity = 1;

            try
            {
                quantity = GrammarUtils.wordsToNumber(String.Join(" ", text.Split(' ').ToList().Select(word => word.Trim()).Where(word => GrammarUtils.wordToNum.ContainsKey(word))));
            }
            catch
            {
                //no numeric words
            }

            int numSpawns = 1;

            if (data is JObject && data["spawn_cap"] != null)
            {
                int spawnCount = data["spawn_cap"];
                numSpawns = quantity / spawnCount;
                quantity  = spawnCount;
            }

            int quality = 1;

            if (text.Contains("badass"))
            {
                quality = 100;
            }

            MainWindow.sendCommand($"admincheat GiveItem \"{bp}\" {quantity} {quality} 0");
            if (numSpawns > 1)
            {
                Thread.Sleep(100);
                RepeatCommand.repeatPriorCommand(numSpawns - 1);
            }
        }