// Token: 0x06000159 RID: 345 RVA: 0x0000C0A0 File Offset: 0x0000A2A0 public static Task DeserializeTask(BehaviorSource behaviorSource, Dictionary <string, object> dict, ref Dictionary <int, Task> IDtoTask, List <UnityEngine.Object> unityObjects) { Task task = null; try { Type type = TaskUtility.GetTypeWithinAssembly(dict["Type"] as string); if (type == null) { if (dict.ContainsKey("Children")) { type = typeof(UnknownParentTask); } else { type = typeof(UnknownTask); } } task = (TaskUtility.CreateInstance(type) as Task); if (task is UnknownTask) { UnknownTask unknownTask = task as UnknownTask; unknownTask.JSONSerialization = MiniJSON.Serialize(dict); } } catch (Exception) { } if (task == null) { return(null); } task.Owner = (behaviorSource.Owner.GetObject() as Behavior); task.ID = Convert.ToInt32(dict["ID"]); object obj; if (dict.TryGetValue("Name", out obj)) { task.FriendlyName = (string)obj; } if (dict.TryGetValue("Instant", out obj)) { task.IsInstant = Convert.ToBoolean(obj); } if (dict.TryGetValue("Disabled", out obj)) { task.Disabled = Convert.ToBoolean(obj); } IDtoTask.Add(task.ID, task); task.NodeData = JSONDeserialization.DeserializeNodeData(dict["NodeData"] as Dictionary <string, object>, task); if (task.GetType().Equals(typeof(UnknownTask)) || task.GetType().Equals(typeof(UnknownParentTask))) { if (!task.FriendlyName.Contains("Unknown ")) { task.FriendlyName = string.Format("Unknown {0}", task.FriendlyName); } task.NodeData.Comment = "Unknown Task. Right click and Replace to locate new task."; } JSONDeserialization.DeserializeObject(task, task, dict, behaviorSource, unityObjects); if (task is ParentTask && dict.TryGetValue("Children", out obj)) { ParentTask parentTask = task as ParentTask; if (parentTask != null) { foreach (object obj2 in (obj as IEnumerable)) { Dictionary <string, object> dict2 = (Dictionary <string, object>)obj2; Task child = JSONDeserialization.DeserializeTask(behaviorSource, dict2, ref IDtoTask, unityObjects); int index = (parentTask.Children != null) ? parentTask.Children.Count : 0; parentTask.AddChild(child, index); } } } return(task); }
// Token: 0x06000156 RID: 342 RVA: 0x0000BBB0 File Offset: 0x00009DB0 public static void Load(TaskSerializationData taskData, BehaviorSource behaviorSource) { if (taskData != null && string.IsNullOrEmpty(taskData.Version)) { JSONDeserializationDeprecated.Load(taskData, behaviorSource); return; } behaviorSource.EntryTask = null; behaviorSource.RootTask = null; behaviorSource.DetachedTasks = null; behaviorSource.Variables = null; Dictionary <string, object> dictionary; if (!JSONDeserialization.serializationCache.TryGetValue(taskData.JSONSerialization.GetHashCode(), out dictionary)) { dictionary = (MiniJSON.Deserialize(taskData.JSONSerialization) as Dictionary <string, object>); JSONDeserialization.serializationCache.Add(taskData.JSONSerialization.GetHashCode(), dictionary); } if (dictionary == null) { Debug.Log("Failed to deserialize"); return; } JSONDeserialization.taskIDs = new Dictionary <JSONDeserialization.TaskField, List <int> >(); JSONDeserialization.updatedSerialization = (taskData.Version.CompareTo("1.5.7") >= 0); Dictionary <int, Task> dictionary2 = new Dictionary <int, Task>(); JSONDeserialization.DeserializeVariables(behaviorSource, dictionary, taskData.fieldSerializationData.unityObjects); if (dictionary.ContainsKey("EntryTask")) { behaviorSource.EntryTask = JSONDeserialization.DeserializeTask(behaviorSource, dictionary["EntryTask"] as Dictionary <string, object>, ref dictionary2, taskData.fieldSerializationData.unityObjects); } if (dictionary.ContainsKey("RootTask")) { behaviorSource.RootTask = JSONDeserialization.DeserializeTask(behaviorSource, dictionary["RootTask"] as Dictionary <string, object>, ref dictionary2, taskData.fieldSerializationData.unityObjects); } if (dictionary.ContainsKey("DetachedTasks")) { List <Task> list = new List <Task>(); foreach (object obj in (dictionary["DetachedTasks"] as IEnumerable)) { Dictionary <string, object> dict = (Dictionary <string, object>)obj; list.Add(JSONDeserialization.DeserializeTask(behaviorSource, dict, ref dictionary2, taskData.fieldSerializationData.unityObjects)); } behaviorSource.DetachedTasks = list; } if (JSONDeserialization.taskIDs != null && JSONDeserialization.taskIDs.Count > 0) { foreach (JSONDeserialization.TaskField key in JSONDeserialization.taskIDs.Keys) { List <int> list2 = JSONDeserialization.taskIDs[key]; Type fieldType = key.fieldInfo.FieldType; if (key.fieldInfo.FieldType.IsArray) { int num = 0; for (int i = 0; i < list2.Count; i++) { Task task = dictionary2[list2[i]]; if (task.GetType().Equals(fieldType.GetElementType()) || task.GetType().IsSubclassOf(fieldType.GetElementType())) { num++; } } Array array = Array.CreateInstance(fieldType.GetElementType(), num); int num2 = 0; for (int j = 0; j < list2.Count; j++) { Task task2 = dictionary2[list2[j]]; if (task2.GetType().Equals(fieldType.GetElementType()) || task2.GetType().IsSubclassOf(fieldType.GetElementType())) { array.SetValue(task2, num2); num2++; } } key.fieldInfo.SetValue(key.task, array); } else { Task task3 = dictionary2[list2[0]]; if (task3.GetType().Equals(key.fieldInfo.FieldType) || task3.GetType().IsSubclassOf(key.fieldInfo.FieldType)) { key.fieldInfo.SetValue(key.task, task3); } } } JSONDeserialization.taskIDs = null; } }