// Say something with a custom resolver public void Say(ScriptResolver resolver, string scriptName, Event theEvent = null, int?priority = null, bool?wait = null) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string script = resolver.resolve(scriptName, dict); if (script != null) { SpeechService.Instance.Say(EDDI.Instance.Ship, script, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority)); } }
// Say something with a custom resolver public void Say(ScriptResolver resolver, Ship ship, string scriptName, Event theEvent = null, int?priority = null, string voice = null, bool?wait = null, bool sayOutLoud = true) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string speech = resolver.resolve(scriptName, dict); if (speech != null) { if (subtitles) { // Log a tidied version of the speech log(Regex.Replace(speech, "<.*?>", string.Empty)); } if (sayOutLoud && !(subtitles && subtitlesOnly)) { SpeechService.Instance.Say(ship, speech, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority), voice); } } }
// Say something with a custom resolver public void Say(ScriptResolver resolver, Ship ship, string scriptName, Event theEvent = null, int?priority = null, string voice = null, bool sayOutLoud = true, bool invokedFromVA = false) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string speech = resolver.resolve(scriptName, dict); if (speech != null) { if (subtitles) { // Log a tidied version of the speech string tidiedSpeech = Regex.Replace(speech, "<.*?>", string.Empty).Trim(); if (!string.IsNullOrEmpty(tidiedSpeech)) { log(tidiedSpeech); } } if (sayOutLoud && !(subtitles && subtitlesOnly)) { SpeechService.Instance.Say(ship, speech, (priority == null ? resolver.priority(scriptName) : (int)priority), voice, false, theEvent?.type, invokedFromVA); } } }
public void TestResolverSimple() { Dictionary<string, Script> scripts = new Dictionary<string, Script>(); scripts.Add("test", new Script("test", null, false, "Hello {name}")); ScriptResolver resolver = new ScriptResolver(scripts); Dictionary<string, Cottle.Value> dict = new Dictionary<string, Cottle.Value>(); dict["name"] = "world"; string result = resolver.resolve("test", dict); Assert.AreEqual("Hello world", result); }
// Say something with a custom resolver public void Say(ScriptResolver resolver, string scriptName, Event theEvent = null, int? priority = null, bool? wait = null) { Dictionary<string, Cottle.Value> dict = createVariables(theEvent); string script = resolver.resolve(scriptName, dict); if (script != null) { SpeechService.Instance.Say(EDDI.Instance.Ship, script, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority)); } }