private void ChangeObjectState(StringValue newState, string objectID) { SimulationObjectProxy obj = objectProxies[objectID]; if (obj == null) { return; } string newStateName = newState.value; StateTableValue currentStateTable = obj["StateTable"].GetDataValue() as StateTableValue; foreach (String stateName in currentStateTable.states.Keys) { if (stateName == newStateName) { SendStateChangeEvent(objectID, newStateName); } } }
private void ProcessObject(SimulationEvent ev) { String id = ((StringValue)ev["ID"]).value; String objectType = ((StringValue)((AttributeCollectionValue)ev["Attributes"])["ClassName"]).value; AttributeCollectionValue atts = ev["Attributes"] as AttributeCollectionValue; SeamateObject seamateObject = null; if (_unrevealedObjects.ContainsKey(id)) { } else { _unrevealedObjects.Add(id, new SeamateObject(id)); Console.WriteLine("Added to UnrevealedObjects: " + id); } _unrevealedObjects[id].SetAttributes(atts); if (atts.attributes.ContainsKey("OwnerID")) { EstablishOwnership(id, ((StringValue)atts.attributes["OwnerID"]).value); } if (ev.parameters.ContainsKey("StateTable") && !_speciesPossibleStates.ContainsKey(objectType)) { _speciesPossibleStates.Add(objectType, new Dictionary <string, AttributeCollectionValue>()); StateTableValue stv = (StateTableValue)ev["StateTable"]; AttributeCollectionValue stateAttributes = null; foreach (String stateName in stv.states.Keys) { stateAttributes = (AttributeCollectionValue)stv[stateName]; _speciesPossibleStates[objectType].Add(stateName, new AttributeCollectionValue()); foreach (String att in stateAttributes.attributes.Keys) { _speciesPossibleStates[objectType][stateName].attributes.Add(att, DataValueFactory.BuildFromDataValue(stateAttributes[att])); } } } }