void NoteUserCommunication(string key, DataStore.IValue value) { var comVal = value as CommunicationValue; if (comVal == null) { return; } // if we're standing by, then ignore anything that's not a direct address. if (DataStore.GetBoolValue("me:standingBy")) { if (!comVal.val.directAddress) { return; } DataStore.SetValue("me:standingBy", new DataStore.BoolValue(false), this, "noted direct address"); } ComCommand cmd = comVal.val as ComCommand; if (cmd != null) { HandleCommand(cmd); } }
void NoteUserSpeech(string key, DataStore.IValue value) { string input = value.ToString().Trim(); if (string.IsNullOrEmpty(input)) { return; } // Initialize a parser with the raw input var parser = new Parser(); ParseState st = parser.InitState(input); // Apply parsing rules until we can do no more int rule; while ((rule = parser.NextStep(st)) > 0) { //Print(st.ToString() + " {" + rule + "}"); } SetValue("user:parse", st.TreeForm(), "parsed: " + input); // Now, attempt to grok the input (convert it to a Communication) Communication comm = Grok.GrokInput(input, st); SetValue("user:communication", new CommunicationValue(comm), comm.ToString()); }
/// <summary> /// Set a value in the data store, and also update our module display (if any). /// </summary> /// <param name="key">Key of interest</param> /// <param name="value">Value to store</param> /// <param name="comment">Comment explaining the change</param> protected void SetValue(string key, DataStore.IValue value, string comment) { this.comment = comment; if (DataStore.SetValue(key, value, this, comment) && display != null) { display.ShowUpdate(key, value, comment); } }
public void ShowUpdate(string key, DataStore.IValue value, string comment) { if (key != null && value != null) { valueUpdateText.text = key + " := " + value.ToString(); } commentText.text = "\"" + comment + "\""; lastHighlightTime = Time.time; }
void NoteMeAttending(string key, DataStore.IValue value) { string attending = value.ToString(); lookingAtUser = (attending == "user"); if (lookingAtUser && !holdingEyesClosed) { targetOpenLevel = 0.7f; } UpdateDisplayComment(); }
void NoteStandingBy(string key, DataStore.IValue value) { if ((value as DataStore.BoolValue).val) { mode = Mode.Disengaged; } else { mode = Mode.Engaged; target = Camera.main.transform.position; } }
void NoteMeIntentEyesClosed(string key, DataStore.IValue value) { holdingEyesClosed = (value as DataStore.BoolValue).val; if (holdingEyesClosed) { targetOpenLevel = 0; } else { targetOpenLevel = 0.7f; } UpdateDisplayComment(); }
void NoteSpeechIntent(string key, DataStore.IValue value) { var speech = value.ToString(); if (string.IsNullOrEmpty(speech)) { StopSpeaking(); } else { Speak(speech); } }
void NoteUserSpeech(string key, DataStore.IValue value) { // Parse the user's speech. string speech = value.ToString(); if (!string.IsNullOrEmpty(speech)) { UpdateParse(speech); } else { SetValue("user:parse", "", "speech is empty"); } }
void NoteLookOrPointAt(string key, DataStore.IValue value) { if (value.ToString() == "userPoint" && key == "me:intent:lookAt") { mode = Mode.Looking; } else if (value.ToString() == "userPoint" && key == "me:intent:pointAt") { mode = Mode.Pointing; } else if (mode != Mode.Off) { mode = Mode.Off; SetValue("me:intent:target", "", "mode := Mode.Off"); SetValue("me:intent:action", "", "mode := Mode.Off"); } }
void NotePointAt(string key, DataStore.IValue value) { string atWhat = value.ToString(); if (string.IsNullOrEmpty(atWhat)) { if (mode == Mode.LookingAtMyPoint) { mode = Mode.Engaged; target = Camera.main.transform.position; } } else { mode = Mode.LookingAtMyPoint; } }
void NoteUserCommunication(string key, DataStore.IValue value) { var comVal = value as CommunicationValue; if (comVal == null) { return; } // if we're standing by, then ignore anything that's not a direct address. if (DataStore.GetBoolValue("me:standingBy")) { if (!comVal.val.directAddress) { return; } // Note that we do NOT change me:standingBy here. That's the // responsibility of CommandsModule. Doing it in both places // causes grief. } HandleInput(comVal.val); }
void NoteLookAt(string key, DataStore.IValue value) { string atWhat = value.ToString(); if (atWhat == "userPoint") { mode = Mode.LookingAtUserPoint; } else if (atWhat == "user") { mode = Mode.Engaged; target = Camera.main.transform.position; } else if (string.IsNullOrEmpty(atWhat)) { // Nothing specific to look at; check attention. if (DataStore.GetStringValue("me:attending") == "user") { mode = Mode.Engaged; target = Camera.main.transform.position; } else { mode = Mode.Disengaged; target = idleGazePosition.position; } } else { Transform t = lookableObjects.Find(atWhat); if (t != null) { mode = Mode.LookingAtObject; target = t.position; } } }
/// <summary> /// Handle a change in a DataStore value. (This method is hooked up /// as a DataStore.onValueChanged receiver in the Start method above). /// </summary> /// <param name="key">key whose value has changed</param> private void ValueChanged(string key) { // Pass the change on to any subscribers. List <Client> clients; if (subscribersByKey.TryGetValue(key, out clients)) { DataStore.IValue value = DataStore.GetValue(key); string msg = null; if (value is DataStore.IntValue) { msg = string.Format("SETI {0} {1}", key, ((DataStore.IntValue)value).val); } else if (value is DataStore.IntValue) { msg = string.Format("SETB {0} {1}", key, ((DataStore.BoolValue)value).val ? "T" : "F"); } else if (value is DataStore.StringValue) { msg = string.Format("SETS {0} {1}", key, ((DataStore.StringValue)value).val); } else if (value is DataStore.Vector3Value) { Vector3 v = ((DataStore.Vector3Value)value).val; msg = string.Format("SETV {0} {1} {2} {3}", key, v.x, v.y, v.z); } if (msg == null) { return; } foreach (Client client in clients) { client.WriteLine(msg); } } }
void NoteChange(string key, DataStore.IValue value) { lastChangedKey = key; lastChangedValue = value; changeCount++; }
void Handler(string key, DataStore.IValue value) { // May add some handler here for different settings. Need to discuss. }
void NoteScreenOrDeskMode(string key, DataStore.IValue value) { // May add some handler here for different settings. Need to discuss. }
public bool Equals(DataStore.IValue other) { return(other is CommunicationValue && val.Equals(((CommunicationValue)other).val)); }
public bool Equals(DataStore.IValue other) { return(other is WordValue && val.Equals(((WordValue)other).val)); }