/// <summary>
 /// Resets the API.
 /// </summary>
 public void Reset()
 {
     //Reset services.
     try { Events = new Events.EventHandler(); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'Events'.", ex); }
     try { Commander = new CommanderStatus(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'Commander'.", ex); }
     try { Location = new LocationStatus(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'Location'.", ex); }
     try { DiscordRichPresence = new RichPresenceClient(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'DiscordRichPresence'.", ex); }
     try { StatusWatcher = new StatusWatcher(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'StatusWatcher'.", ex); }
     try { CargoWatcher = new CargoWatcher(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'CargoWatcher'.", ex); }
     try { Status = EliteAPI.Status.GameStatus.FromFile(new FileInfo(JournalDirectory + "//Status.json"), this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'Status'.", ex); }
     try { JournalParser = new JournalParser(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'JournalParser'.", ex); }
     try { MaterialWatcher = new MaterialWatcher(this); } catch (Exception ex) { Logger.Log(Severity.Warning, "Couldn't instantiate service 'MaterialWatcher'.", ex); }
     JournalParser.processedLogs = new List <string>();
 }
示例#2
0
    void ConsumeData(object sender, EventArgs e)
    {
        if (((RestEventArgs)e).Content is string)
        {
            if ((((RestEventArgs)e).Content.ToString() != string.Empty) &&
                (((RestEventArgs)e).Content.ToString() != lastReceivedData))
            {
                Debug.Log(((RestEventArgs)e).Content);
                CommanderStatus dict = JsonUtility.FromJson <CommanderStatus>(((RestEventArgs)e).Content.ToString());
                if (dict != null)
                {
//					Debug.Log(string.Format("input: \"{0}\", question: \"{1}\", utter: \"{2}\"",dict.input,dict.question,dict.utter));
                    lastReceivedData = ((RestEventArgs)e).Content.ToString();

                    if (dict.input != string.Empty)
                    {
                        ((InputController)(GameObject.Find("IOController").GetComponent("InputController")))
                        .inputString = dict.input.Trim();
                        ((InputController)(GameObject.Find("IOController").GetComponent("InputController")))
                        .MessageReceived(dict.input.Trim());
                    }
                    else if (dict.question != string.Empty)
                    {
                        if (Regex.IsMatch(dict.question, @"The .+ block\?"))
                        {
                            string     color        = dict.question.Split()[1];
                            MethodInfo methodToCall = preds.GetType().GetMethod(color.ToUpper());
                            object     obj          = methodToCall.Invoke(preds, new object[] { world.availableObjs.ToArray() });
                            if (obj != null)
                            {
                                world.ReachFor(GameObject.Find(obj as string));
                            }

                            world.RespondAndUpdate(dict.question);
                        }
                        else if (Regex.IsMatch(dict.question, @".*<.+; .+; .+>\?"))
                        {
                            string coord = Regex.Match(dict.question, @"<.+; .+; .+>").Value;
                            world.RespondAndUpdate(Regex.Replace(dict.question, @"<.+; .+; .+>", "here"));
                            world.ReachFor(GlobalHelper.ParsableToVector(coord));
                        }
                        else
                        {
                            world.RespondAndUpdate(dict.question);
                        }
                    }
                    else if (dict.utter != string.Empty)
                    {
                        world.RespondAndUpdate(dict.utter);
                    }
                    else if (dict.hide != string.Empty)
                    {
                        GameObject obj = GameObject.Find(dict.hide);
                        if (obj != null)
                        {
                            preds.DISABLE(new object[] { obj });
                        }
                    }
                    else if (dict.show != string.Empty)
                    {
                        for (int i = 0; i < objSelector.disabledObjects.Count; i++)
                        {
                            if (objSelector.disabledObjects[i].name == dict.show)
                            {
                                preds.ENABLE(new object[] { objSelector.disabledObjects[i] });
                            }
                        }
                    }
                    else if (dict.anim != string.Empty)
                    {
                        world.MoveToPerform();
                        world.gestureController.PerformGesture(dict.anim);
                    }
                }
            }
        }
    }