public static FieldInfo[] GetPublicFields(Type t) { List <FieldInfo> list = new List <FieldInfo>(); BindingFlags flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public; TaskUtility.GetFields(t, ref list, (int)flags); return(list.ToArray()); }
public static T Get <T>() { if (ObjectPool.poolDictionary.ContainsKey(typeof(T))) { Stack <T> stack = ObjectPool.poolDictionary[typeof(T)] as Stack <T>; if (stack.Count > 0) { return(stack.Pop()); } } return((T)((object)TaskUtility.CreateInstance(typeof(T)))); }
// Token: 0x06000223 RID: 547 RVA: 0x0001026C File Offset: 0x0000E46C private static void GetFields(Type t, ref List <FieldInfo> fieldList, int flags) { if (t == null || t.Equals(typeof(ParentTask)) || t.Equals(typeof(Task)) || t.Equals(typeof(SharedVariable))) { return; } FieldInfo[] fields = t.GetFields((BindingFlags)flags); for (int i = 0; i < fields.Length; i++) { fieldList.Add(fields[i]); } TaskUtility.GetFields(t.BaseType, ref fieldList, flags); }
public void SetVariableValue(string name, object value) { SharedVariable variable = this.GetVariable(name); if (variable != null) { if (value is SharedVariable) { SharedVariable sharedVariable = value as SharedVariable; if (!string.IsNullOrEmpty(sharedVariable.PropertyMapping)) { variable.PropertyMapping = sharedVariable.PropertyMapping; variable.PropertyMappingOwner = sharedVariable.PropertyMappingOwner; variable.InitializePropertyMapping(this.mBehaviorSource); } else { variable.SetValue(sharedVariable.GetValue()); } } else { variable.SetValue(value); } variable.ValueChanged(); } else if (value is SharedVariable) { SharedVariable sharedVariable = value as SharedVariable; SharedVariable instance = TaskUtility.CreateInstance(sharedVariable.GetType()) as SharedVariable; instance.Name = sharedVariable.Name; instance.IsShared = sharedVariable.IsShared; instance.IsGlobal = sharedVariable.IsGlobal; if (!string.IsNullOrEmpty(sharedVariable.PropertyMapping)) { instance.PropertyMapping = sharedVariable.PropertyMapping; instance.PropertyMappingOwner = sharedVariable.PropertyMappingOwner; instance.InitializePropertyMapping(this.mBehaviorSource); } else { instance.SetValue(sharedVariable.GetValue()); } this.mBehaviorSource.SetVariable(name, instance); } else { Debug.LogError((object)("Error: No variable exists with name " + name)); } }
public static T Get <T>() { if (ObjectPool.poolDictionary.ContainsKey(typeof(T))) { List <T> list = ObjectPool.poolDictionary[typeof(T)] as List <T>; if (list.Count > 0) { T result = list[0]; list.RemoveAt(0); return(result); } } return((T)((object)TaskUtility.CreateInstance(typeof(T)))); }
// Token: 0x06000222 RID: 546 RVA: 0x00010218 File Offset: 0x0000E418 public static FieldInfo[] GetPublicFields(Type t) { FieldInfo[] array = null; if (!TaskUtility.publicFieldsLookup.TryGetValue(t, out array)) { List <FieldInfo> list = ObjectPool.Get <List <FieldInfo> >(); list.Clear(); BindingFlags flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public; TaskUtility.GetFields(t, ref list, (int)flags); array = list.ToArray(); ObjectPool.Return <List <FieldInfo> >(list); TaskUtility.publicFieldsLookup.Add(t, array); } return(array); }
private void SaveValue(Task task) { if (task == null) { return; } FieldInfo[] publicFields = TaskUtility.GetPublicFields(task.GetType()); Dictionary <string, object> dictionary = new Dictionary <string, object>(); int i = 0; while (i < publicFields.Length) { object value = publicFields[i].GetValue(task); if (!(value is SharedVariable)) { goto IL_5A; } SharedVariable sharedVariable = value as SharedVariable; if (!sharedVariable.IsGlobal && !sharedVariable.IsShared) { goto IL_5A; } IL_71: i++; continue; IL_5A: dictionary.Add(publicFields[i].Name, publicFields[i].GetValue(task)); goto IL_71; } this.defaultValues.Add(dictionary); if (task is ParentTask) { ParentTask parentTask = task as ParentTask; if (parentTask.Children != null) { for (int j = 0; j < parentTask.Children.Count; j++) { this.SaveValue(parentTask.Children[j]); } } } }
// Token: 0x06000253 RID: 595 RVA: 0x00010DE0 File Offset: 0x0000EFE0 public override void InitializePropertyMapping(BehaviorSource behaviorSource) { if (!Application.isPlaying || !(behaviorSource.Owner.GetObject() is Behavior)) { return; } if (!string.IsNullOrEmpty(base.PropertyMapping)) { string[] array = base.PropertyMapping.Split(new char[] { '/' }); GameObject gameObject; if (!object.Equals(base.PropertyMappingOwner, null)) { gameObject = base.PropertyMappingOwner; } else { gameObject = (behaviorSource.Owner.GetObject() as Behavior).gameObject; } Component component = gameObject.GetComponent(TaskUtility.GetTypeWithinAssembly(array[0])); Type type = component.GetType(); PropertyInfo property = type.GetProperty(array[1]); if (property != null) { MethodInfo methodInfo = property.GetGetMethod(); if (methodInfo != null) { this.mGetter = (Func <T>)Delegate.CreateDelegate(typeof(Func <T>), component, methodInfo); } methodInfo = property.GetSetMethod(); if (methodInfo != null) { this.mSetter = (Action <T>)Delegate.CreateDelegate(typeof(Action <T>), component, methodInfo); } } } }
private void SaveValue(Task task) { if (task == null) { return; } FieldInfo[] publicFields = TaskUtility.GetPublicFields(task.GetType()); Dictionary <string, object> dictionary = new Dictionary <string, object>(); for (int index = 0; index < publicFields.Length; ++index) { object obj = publicFields[index].GetValue((object)task); if (obj is SharedVariable) { SharedVariable sharedVariable = obj as SharedVariable; if (sharedVariable.IsGlobal || sharedVariable.IsShared) { continue; } } dictionary.Add(publicFields[index].Name, publicFields[index].GetValue((object)task)); } this.defaultValues.Add(task, dictionary); if (!(task is ParentTask)) { return; } ParentTask parentTask = task as ParentTask; if (parentTask.Children == null) { return; } for (int index = 0; index < parentTask.Children.Count; ++index) { this.SaveValue(parentTask.Children[index]); } }
// Token: 0x06000172 RID: 370 RVA: 0x0000E170 File Offset: 0x0000C370 private static object ValueToObject(Task task, Type type, object obj, IVariableSource variableSource, List <UnityEngine.Object> unityObjects) { if (type.Equals(typeof(SharedVariable)) || type.IsSubclassOf(typeof(SharedVariable))) { SharedVariable sharedVariable = JSONDeserializationDeprecated.DeserializeSharedVariable(obj as Dictionary <string, object>, variableSource, false, unityObjects); if (sharedVariable == null) { sharedVariable = (TaskUtility.CreateInstance(type) as SharedVariable); } return(sharedVariable); } if (type.Equals(typeof(UnityEngine.Object)) || type.IsSubclassOf(typeof(UnityEngine.Object))) { return(JSONDeserializationDeprecated.IndexToUnityObject(Convert.ToInt32(obj), unityObjects)); } if (!type.IsPrimitive) { if (!type.Equals(typeof(string))) { goto IL_C5; } } try { return(Convert.ChangeType(obj, type)); } catch (Exception) { return(null); } IL_C5: if (type.IsSubclassOf(typeof(Enum))) { try { return(Enum.Parse(type, (string)obj)); } catch (Exception) { return(null); } } if (type.Equals(typeof(Vector2))) { return(JSONDeserializationDeprecated.StringToVector2((string)obj)); } if (type.Equals(typeof(Vector3))) { return(JSONDeserializationDeprecated.StringToVector3((string)obj)); } if (type.Equals(typeof(Vector4))) { return(JSONDeserializationDeprecated.StringToVector4((string)obj)); } if (type.Equals(typeof(Quaternion))) { return(JSONDeserializationDeprecated.StringToQuaternion((string)obj)); } if (type.Equals(typeof(Matrix4x4))) { return(JSONDeserializationDeprecated.StringToMatrix4x4((string)obj)); } if (type.Equals(typeof(Color))) { return(JSONDeserializationDeprecated.StringToColor((string)obj)); } if (type.Equals(typeof(Rect))) { return(JSONDeserializationDeprecated.StringToRect((string)obj)); } if (type.Equals(typeof(LayerMask))) { return(JSONDeserializationDeprecated.ValueToLayerMask(Convert.ToInt32(obj))); } if (type.Equals(typeof(AnimationCurve))) { return(JSONDeserializationDeprecated.ValueToAnimationCurve((Dictionary <string, object>)obj)); } object obj2 = TaskUtility.CreateInstance(type); JSONDeserializationDeprecated.DeserializeObject(task, obj2, obj as Dictionary <string, object>, variableSource, unityObjects); return(obj2); }
// Token: 0x06000171 RID: 369 RVA: 0x0000DD50 File Offset: 0x0000BF50 private static void DeserializeObject(Task task, object obj, Dictionary <string, object> dict, IVariableSource variableSource, List <UnityEngine.Object> unityObjects) { if (dict == null) { return; } FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType()); for (int i = 0; i < allFields.Length; i++) { object obj2; if (dict.TryGetValue(allFields[i].FieldType + "," + allFields[i].Name, out obj2) || dict.TryGetValue(allFields[i].Name, out obj2)) { if (typeof(IList).IsAssignableFrom(allFields[i].FieldType)) { IList list = obj2 as IList; if (list != null) { Type type; if (allFields[i].FieldType.IsArray) { type = allFields[i].FieldType.GetElementType(); } else { Type type2 = allFields[i].FieldType; while (!type2.IsGenericType) { type2 = type2.BaseType; } type = type2.GetGenericArguments()[0]; } bool flag = type.Equals(typeof(Task)) || type.IsSubclassOf(typeof(Task)); if (flag) { if (JSONDeserializationDeprecated.taskIDs != null) { List <int> list2 = new List <int>(); for (int j = 0; j < list.Count; j++) { list2.Add(Convert.ToInt32(list[j])); } JSONDeserializationDeprecated.taskIDs.Add(new JSONDeserializationDeprecated.TaskField(task, allFields[i]), list2); } } else if (allFields[i].FieldType.IsArray) { Array array = Array.CreateInstance(type, list.Count); for (int k = 0; k < list.Count; k++) { array.SetValue(JSONDeserializationDeprecated.ValueToObject(task, type, list[k], variableSource, unityObjects), k); } allFields[i].SetValue(obj, array); } else { IList list3; if (allFields[i].FieldType.IsGenericType) { list3 = (TaskUtility.CreateInstance(typeof(List <>).MakeGenericType(new Type[] { type })) as IList); } else { list3 = (TaskUtility.CreateInstance(allFields[i].FieldType) as IList); } for (int l = 0; l < list.Count; l++) { list3.Add(JSONDeserializationDeprecated.ValueToObject(task, type, list[l], variableSource, unityObjects)); } allFields[i].SetValue(obj, list3); } } } else { Type fieldType = allFields[i].FieldType; if (fieldType.Equals(typeof(Task)) || fieldType.IsSubclassOf(typeof(Task))) { if (TaskUtility.HasAttribute(allFields[i], typeof(InspectTaskAttribute))) { Dictionary <string, object> dictionary = obj2 as Dictionary <string, object>; Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(dictionary["ObjectType"] as string); if (typeWithinAssembly != null) { Task task2 = TaskUtility.CreateInstance(typeWithinAssembly) as Task; JSONDeserializationDeprecated.DeserializeObject(task2, task2, dictionary, variableSource, unityObjects); allFields[i].SetValue(task, task2); } } else if (JSONDeserializationDeprecated.taskIDs != null) { List <int> list4 = new List <int>(); list4.Add(Convert.ToInt32(obj2)); JSONDeserializationDeprecated.taskIDs.Add(new JSONDeserializationDeprecated.TaskField(task, allFields[i]), list4); } } else { allFields[i].SetValue(obj, JSONDeserializationDeprecated.ValueToObject(task, fieldType, obj2, variableSource, unityObjects)); } } } else if (typeof(SharedVariable).IsAssignableFrom(allFields[i].FieldType) && !allFields[i].FieldType.IsAbstract) { if (dict.TryGetValue(allFields[i].FieldType + "," + allFields[i].Name, out obj2)) { SharedVariable sharedVariable = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable; sharedVariable.SetValue(JSONDeserializationDeprecated.ValueToObject(task, allFields[i].FieldType, obj2, variableSource, unityObjects)); allFields[i].SetValue(obj, sharedVariable); } else { SharedVariable value = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable; allFields[i].SetValue(obj, value); } } } }
// Token: 0x06000170 RID: 368 RVA: 0x0000DB70 File Offset: 0x0000BD70 private static SharedVariable DeserializeSharedVariable(Dictionary <string, object> dict, IVariableSource variableSource, bool fromSource, List <UnityEngine.Object> unityObjects) { if (dict == null) { return(null); } SharedVariable sharedVariable = null; object obj; if (!fromSource && variableSource != null && dict.TryGetValue("Name", out obj)) { object value; dict.TryGetValue("IsGlobal", out value); if (!dict.TryGetValue("IsGlobal", out value) || !Convert.ToBoolean(value)) { sharedVariable = variableSource.GetVariable(obj as string); } else { if (JSONDeserializationDeprecated.globalVariables == null) { JSONDeserializationDeprecated.globalVariables = GlobalVariables.Instance; } if (JSONDeserializationDeprecated.globalVariables != null) { sharedVariable = JSONDeserializationDeprecated.globalVariables.GetVariable(obj as string); } } } Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(dict["Type"] as string); if (typeWithinAssembly == null) { return(null); } bool flag = true; if (sharedVariable == null || !(flag = sharedVariable.GetType().Equals(typeWithinAssembly))) { sharedVariable = (TaskUtility.CreateInstance(typeWithinAssembly) as SharedVariable); sharedVariable.Name = (dict["Name"] as string); object obj2; if (dict.TryGetValue("IsShared", out obj2)) { sharedVariable.IsShared = Convert.ToBoolean(obj2); } if (dict.TryGetValue("IsGlobal", out obj2)) { sharedVariable.IsGlobal = Convert.ToBoolean(obj2); } if (dict.TryGetValue("NetworkSync", out obj2)) { sharedVariable.NetworkSync = Convert.ToBoolean(obj2); } if (!sharedVariable.IsGlobal && dict.TryGetValue("PropertyMapping", out obj2)) { sharedVariable.PropertyMapping = (obj2 as string); if (dict.TryGetValue("PropertyMappingOwner", out obj2)) { sharedVariable.PropertyMappingOwner = (JSONDeserializationDeprecated.IndexToUnityObject(Convert.ToInt32(obj2), unityObjects) as GameObject); } sharedVariable.InitializePropertyMapping(variableSource as BehaviorSource); } if (!flag) { sharedVariable.IsShared = true; } JSONDeserializationDeprecated.DeserializeObject(null, sharedVariable, dict, variableSource, unityObjects); } return(sharedVariable); }
// Token: 0x0600016E RID: 366 RVA: 0x0000D74C File Offset: 0x0000B94C 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["ObjectType"] as string); if (type == null) { if (dict.ContainsKey("Children")) { type = typeof(UnknownParentTask); } else { type = typeof(UnknownTask); } } task = (TaskUtility.CreateInstance(type) as Task); } 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 = JSONDeserializationDeprecated.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); } if (!task.NodeData.Comment.Contains("Loaded from an unknown type. Was a task renamed or deleted?")) { task.NodeData.Comment = string.Format("Loaded from an unknown type. Was a task renamed or deleted?{0}", (!task.NodeData.Comment.Equals(string.Empty)) ? string.Format("\0{0}", task.NodeData.Comment) : string.Empty); } } JSONDeserializationDeprecated.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 = JSONDeserializationDeprecated.DeserializeTask(behaviorSource, dict2, ref IDtoTask, unityObjects); int index = (parentTask.Children != null) ? parentTask.Children.Count : 0; parentTask.AddChild(child, index); } } } return(task); }
public GenericVariable() { this.value = (Activator.CreateInstance(TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.SharedString")) as SharedVariable); }
public void Awake() { for (int i = this.synchronizedVariables.Count - 1; i > -1; i--) { VariableSynchronizer.SynchronizedVariable synchronizedVariable = this.synchronizedVariables[i]; if (synchronizedVariable.global) { synchronizedVariable.sharedVariable = GlobalVariables.Instance.GetVariable(synchronizedVariable.variableName); } else { synchronizedVariable.sharedVariable = synchronizedVariable.behavior.GetVariable(synchronizedVariable.variableName); } string text = string.Empty; if (synchronizedVariable.sharedVariable == null) { text = "the SharedVariable can't be found"; } else { switch (synchronizedVariable.synchronizationType) { case VariableSynchronizer.SynchronizationType.BehaviorDesigner: { Behavior behavior = synchronizedVariable.targetComponent as Behavior; if (behavior == null) { text = "the target component is not of type Behavior Tree"; } else { if (synchronizedVariable.targetGlobal) { synchronizedVariable.targetSharedVariable = GlobalVariables.Instance.GetVariable(synchronizedVariable.targetName); } else { synchronizedVariable.targetSharedVariable = behavior.GetVariable(synchronizedVariable.targetName); } if (synchronizedVariable.targetSharedVariable == null) { text = "the target SharedVariable cannot be found"; } } break; } case VariableSynchronizer.SynchronizationType.Property: { PropertyInfo property = synchronizedVariable.targetComponent.GetType().GetProperty(synchronizedVariable.targetName); if (property == null) { text = "the property " + synchronizedVariable.targetName + " doesn't exist"; } else if (synchronizedVariable.setVariable) { MethodInfo getMethod = property.GetGetMethod(); if (getMethod == null) { text = "the property has no get method"; } else { synchronizedVariable.getDelegate = VariableSynchronizer.CreateGetDelegate(synchronizedVariable.targetComponent, getMethod); } } else { MethodInfo setMethod = property.GetSetMethod(); if (setMethod == null) { text = "the property has no set method"; } else { synchronizedVariable.setDelegate = VariableSynchronizer.CreateSetDelegate(synchronizedVariable.targetComponent, setMethod); } } break; } case VariableSynchronizer.SynchronizationType.Animator: synchronizedVariable.animator = (synchronizedVariable.targetComponent as Animator); if (synchronizedVariable.animator == null) { text = "the component is not of type Animator"; } else { synchronizedVariable.targetID = Animator.StringToHash(synchronizedVariable.targetName); Type propertyType = synchronizedVariable.sharedVariable.GetType().GetProperty("Value").PropertyType; if (propertyType.Equals(typeof(bool))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Bool; } else if (propertyType.Equals(typeof(float))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Float; } else if (propertyType.Equals(typeof(int))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Integer; } else { text = "there is no animator parameter type that can synchronize with " + propertyType; } } break; case VariableSynchronizer.SynchronizationType.PlayMaker: { Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.VariableSynchronizer_PlayMaker"); if (typeWithinAssembly != null) { MethodInfo method = typeWithinAssembly.GetMethod("Start"); if (method != null) { int num = (int)method.Invoke(null, new object[] { synchronizedVariable }); if (num == 1) { text = "the PlayMaker NamedVariable cannot be found"; } else if (num == 2) { text = "the Behavior Designer SharedVariable is not the same type as the PlayMaker NamedVariable"; } else { MethodInfo method2 = typeWithinAssembly.GetMethod("Tick"); if (method2 != null) { synchronizedVariable.thirdPartyTick = (Action <VariableSynchronizer.SynchronizedVariable>)Delegate.CreateDelegate(typeof(Action <VariableSynchronizer.SynchronizedVariable>), method2); } } } } else { text = "has the PlayMaker classes been imported?"; } break; } case VariableSynchronizer.SynchronizationType.uFrame: { Type typeWithinAssembly2 = TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.VariableSynchronizer_uFrame"); if (typeWithinAssembly2 != null) { MethodInfo method3 = typeWithinAssembly2.GetMethod("Start"); if (method3 != null) { int num2 = (int)method3.Invoke(null, new object[] { synchronizedVariable }); if (num2 == 1) { text = "the uFrame property cannot be found"; } else if (num2 == 2) { text = "the Behavior Designer SharedVariable is not the same type as the uFrame property"; } else { MethodInfo method4 = typeWithinAssembly2.GetMethod("Tick"); if (method4 != null) { synchronizedVariable.thirdPartyTick = (Action <VariableSynchronizer.SynchronizedVariable>)Delegate.CreateDelegate(typeof(Action <VariableSynchronizer.SynchronizedVariable>), method4); } } } } else { text = "has the uFrame classes been imported?"; } break; } } } if (!string.IsNullOrEmpty(text)) { UnityEngine.Debug.LogError(string.Format("Unable to synchronize {0}: {1}", synchronizedVariable.sharedVariable.Name, text)); this.synchronizedVariables.RemoveAt(i); } } if (this.synchronizedVariables.Count == 0) { base.enabled = (false); return; } this.UpdateIntervalChanged(); }
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"], CultureInfo.InvariantCulture); object obj; if (dict.TryGetValue("Name", out obj)) { task.FriendlyName = (string)obj; } if (dict.TryGetValue("Instant", out obj)) { task.IsInstant = Convert.ToBoolean(obj, CultureInfo.InvariantCulture); } if (dict.TryGetValue("Disabled", out obj)) { task.Disabled = Convert.ToBoolean(obj, CultureInfo.InvariantCulture); } 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 (Dictionary <string, object> dict2 in (obj as IEnumerable)) { Task child = JSONDeserialization.DeserializeTask(behaviorSource, dict2, ref IDtoTask, unityObjects); int index = (parentTask.Children != null) ? parentTask.Children.Count : 0; parentTask.AddChild(child, index); } } } return(task); }