void ApplyTaskUpdate(TaskUpdateBundled taskUpdate) { // See if we have a task on this storypoint. StoryTask updateTask = GENERAL.GetTaskForPoint(taskUpdate.pointID); if (updateTask == null) { // If not, and we're a client, we create the task. // If we're the server, we ignore updates for task we no longer know about. if (GENERAL.AUTHORITY == AUTHORITY.LOCAL) { updateTask = new StoryTask(taskUpdate.pointID, SCOPE.GLOBAL); updateTask.ApplyUpdateMessage(taskUpdate); Log("Created an instance of global task " + updateTask.Instruction + " id " + updateTask.PointID); if (taskUpdate.pointID != "GLOBALS") { // Now find a pointer. StoryPointer updatePointer = GENERAL.GetStorylinePointerForPointID(taskUpdate.pointID); if (updatePointer == null) { updatePointer = new StoryPointer(); Log("Created a new pointer for task " + updateTask.Instruction); } updatePointer.PopulateWithTask(updateTask); Log("Populated pointer " + updatePointer.currentPoint.StoryLine + " with task " + updateTask.Instruction); DistributeTasks(new TaskArgs(updateTask)); } } } else { updateTask.ApplyUpdateMessage(taskUpdate); updateTask.scope = SCOPE.GLOBAL;//?? Verbose("Applied update to existing task " + updateTask.Instruction); } }
void setDefaults() { signoffs = 0; taskIntValues = new Dictionary <string, int>(); taskFloatValues = new Dictionary <string, float>(); taskQuaternionValues = new Dictionary <string, Quaternion>(); taskVector3Values = new Dictionary <string, Vector3>(); taskStringValues = new Dictionary <string, string>(); taskUshortValues = new Dictionary <string, ushort[]>(); taskByteValues = new Dictionary <string, byte[]>(); taskVector3ArrayValues = new Dictionary <string, Vector3[]>(); taskBoolArrayValues = new Dictionary <string, bool[]>(); taskStringArrayValues = new Dictionary <string, string[]>(); #if !SOLO taskValuesChangeMask = new Dictionary <string, bool>(); updateSend = new TaskUpdateBundled(); updateReceive = new TaskUpdateBundled(); #endif setStatus(TASKSTATUS.ACTIVE); }
public void ApplyUpdateMessage(TaskUpdateBundled update, bool changeMask = false) { // Log.Message ("Applying network task update."); // if (update.updatedIntNames.Contains ("status")) { // Log.Message ("incoming task status change, setting pointerstatus to taskupdated.", LOGLEVEL.VERBOSE); // // pointer.SetStatus (POINTERSTATUS.TASKUPDATED); // } //if (description == "userstream") //{ // int CurrentFrame = Time.frameCount; // if (CurrentFrame - LastUpdateFrame==0) // { // UpdatesPerFrame++; // } // if (CurrentFrame - LastUpdateFrame==1){ // // we're in the next frame // UpdateFrequency += "" + UpdatesPerFrame; // UpdatesPerFrame = 1; // } // if (CurrentFrame - LastUpdateFrame>1){ // // we've skipped a frame // for (int f=LastUpdateFrame+1 ;f<CurrentFrame;f++){ // UpdateFrequency += "" + 0; // } // UpdatesPerFrame = 1; // } // if (UpdateFrequency.Length > 30) // { // Debug.Log("update pattern:" + UpdateFrequency); // setStringValue("debug",UpdateFrequency); // UpdateFrequency = ""; // } // LastUpdateFrame = CurrentFrame; //} //MaxUpdatesPerFrame = Mathf.Max(MaxUpdatesPerFrame, UpdatesPerFrame); for (int i = 0; i < update.updatedIntNames.Count; i++) { taskIntValues[update.updatedIntNames[i]] = update.updatedIntValues[i]; taskValuesChangeMask[update.updatedIntNames[i]] = changeMask; } for (int i = 0; i < update.updatedFloatNames.Count; i++) { taskFloatValues[update.updatedFloatNames[i]] = update.updatedFloatValues[i]; taskValuesChangeMask[update.updatedFloatNames[i]] = changeMask; } for (int i = 0; i < update.updatedQuaternionNames.Count; i++) { taskQuaternionValues[update.updatedQuaternionNames[i]] = update.updatedQuaternionValues[i]; taskValuesChangeMask[update.updatedQuaternionNames[i]] = changeMask; } for (int i = 0; i < update.updatedVector3Names.Count; i++) { taskVector3Values[update.updatedVector3Names[i]] = update.updatedVector3Values[i]; taskValuesChangeMask[update.updatedVector3Names[i]] = changeMask; } for (int i = 0; i < update.updatedStringNames.Count; i++) { taskStringValues[update.updatedStringNames[i]] = update.updatedStringValues[i]; taskValuesChangeMask[update.updatedStringNames[i]] = changeMask; } for (int i = 0; i < update.updatedUshortNames.Count; i++) { taskUshortValues[update.updatedUshortNames[i]] = update.updatedUshortValues[i]; taskValuesChangeMask[update.updatedUshortNames[i]] = changeMask; } for (int i = 0; i < update.updatedByteNames.Count; i++) { taskByteValues[update.updatedByteNames[i]] = update.updatedByteValues[i]; taskValuesChangeMask[update.updatedByteNames[i]] = changeMask; } for (int i = 0; i < update.updatedVector3ArrayNames.Count; i++) { taskVector3ArrayValues[update.updatedVector3ArrayNames[i]] = update.updatedVector3ArrayValues[i]; taskValuesChangeMask[update.updatedVector3ArrayNames[i]] = changeMask; } for (int i = 0; i < update.updatedBoolArrayNames.Count; i++) { taskBoolArrayValues[update.updatedBoolArrayNames[i]] = update.updatedBoolArrayValues[i]; taskValuesChangeMask[update.updatedBoolArrayNames[i]] = changeMask; } for (int i = 0; i < update.updatedStringArrayNames.Count; i++) { taskStringArrayValues[update.updatedStringArrayNames[i]] = update.updatedStringArrayValues[i]; taskValuesChangeMask[update.updatedStringArrayNames[i]] = changeMask; } }
public TaskUpdateBundled GetUpdateBundled() { // Bundled approach. TaskUpdateBundled msg = new TaskUpdateBundled(); msg.pointID = PointID; string[] intNames = taskIntValues.Keys.ToArray(); foreach (string intName in intNames) { if (taskValuesChangeMask[intName] || allModified) { msg.updatedIntNames.Add(intName); taskValuesChangeMask[intName] = false; int intValue; if (taskIntValues.TryGetValue(intName, out intValue)) { msg.updatedIntValues.Add(intValue); } } } string[] floatNames = taskFloatValues.Keys.ToArray(); foreach (string floatName in floatNames) { if (taskValuesChangeMask[floatName] || allModified) { msg.updatedFloatNames.Add(floatName); taskValuesChangeMask[floatName] = false; float floatValue; if (taskFloatValues.TryGetValue(floatName, out floatValue)) { msg.updatedFloatValues.Add(floatValue); } } } string[] quaternionNames = taskQuaternionValues.Keys.ToArray(); foreach (string quaternionName in quaternionNames) { if (taskValuesChangeMask[quaternionName] || allModified) { msg.updatedQuaternionNames.Add(quaternionName); taskValuesChangeMask[quaternionName] = false; Quaternion quaternionValue; if (taskQuaternionValues.TryGetValue(quaternionName, out quaternionValue)) { msg.updatedQuaternionValues.Add(quaternionValue); } } } string[] vector3Names = taskVector3Values.Keys.ToArray(); foreach (string vector3Name in vector3Names) { if (taskValuesChangeMask[vector3Name] || allModified) { msg.updatedVector3Names.Add(vector3Name); taskValuesChangeMask[vector3Name] = false; Vector3 vector3Value; if (taskVector3Values.TryGetValue(vector3Name, out vector3Value)) { msg.updatedVector3Values.Add(vector3Value); } } } string[] stringNames = taskStringValues.Keys.ToArray(); foreach (string stringName in stringNames) { if (taskValuesChangeMask[stringName] || allModified) { msg.updatedStringNames.Add(stringName); taskValuesChangeMask[stringName] = false; string stringValue; if (taskStringValues.TryGetValue(stringName, out stringValue)) { msg.updatedStringValues.Add(stringValue); } } } string[] ushortNames = taskUshortValues.Keys.ToArray(); foreach (string ushortName in ushortNames) { if (taskValuesChangeMask[ushortName] || allModified) { msg.updatedUshortNames.Add(ushortName); taskValuesChangeMask[ushortName] = false; ushort[] ushortValue; if (taskUshortValues.TryGetValue(ushortName, out ushortValue)) { msg.updatedUshortValues.Add(ushortValue); } } } string[] byteNames = taskByteValues.Keys.ToArray(); foreach (string byteName in byteNames) { if (taskValuesChangeMask[byteName] || allModified) { msg.updatedByteNames.Add(byteName); taskValuesChangeMask[byteName] = false; byte[] byteValue; if (taskByteValues.TryGetValue(byteName, out byteValue)) { msg.updatedByteValues.Add(byteValue); } } } string[] vector3ArrayNames = taskVector3ArrayValues.Keys.ToArray(); foreach (string vector3ArrayName in vector3ArrayNames) { if (taskValuesChangeMask[vector3ArrayName] || allModified) { msg.updatedVector3ArrayNames.Add(vector3ArrayName); taskValuesChangeMask[vector3ArrayName] = false; Vector3[] vector3ArrayValue; if (taskVector3ArrayValues.TryGetValue(vector3ArrayName, out vector3ArrayValue)) { msg.updatedVector3ArrayValues.Add(vector3ArrayValue); } } } string[] boolArrayNames = taskBoolArrayValues.Keys.ToArray(); foreach (string boolArrayName in boolArrayNames) { if (taskValuesChangeMask[boolArrayName] || allModified) { msg.updatedBoolArrayNames.Add(boolArrayName); taskValuesChangeMask[boolArrayName] = false; bool[] boolArrayValue; if (taskBoolArrayValues.TryGetValue(boolArrayName, out boolArrayValue)) { msg.updatedBoolArrayValues.Add(boolArrayValue); } } } string[] stringArrayNames = taskStringArrayValues.Keys.ToArray(); foreach (string stringArrayName in stringArrayNames) { if (taskValuesChangeMask[stringArrayName] || allModified) { msg.updatedStringArrayNames.Add(stringArrayName); taskValuesChangeMask[stringArrayName] = false; string[] stringArrayValue; if (taskStringArrayValues.TryGetValue(stringArrayName, out stringArrayValue)) { msg.updatedStringArrayValues.Add(stringArrayValue); } } } allModified = false; return(msg); }