// Token: 0x0600011E RID: 286 RVA: 0x0000B200 File Offset: 0x00009400 private static SharedVariable BytesToSharedVariable(FieldSerializationData fieldSerializationData, Dictionary <string, int> fieldIndexMap, byte[] bytes, int dataPosition, IVariableSource variableSource, bool fromField, string namePrefix) { SharedVariable sharedVariable = null; string text = (string)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(string), namePrefix + "Type", null, null, null); if (string.IsNullOrEmpty(text)) { return(null); } string name = (string)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(string), namePrefix + "Name", null, null, null); bool flag = Convert.ToBoolean(BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(bool), namePrefix + "IsShared", null, null, null)); bool flag2 = Convert.ToBoolean(BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(bool), namePrefix + "IsGlobal", null, null, null)); if (flag && fromField) { if (!flag2) { sharedVariable = variableSource.GetVariable(name); } else { if (BinaryDeserializationDeprecated.globalVariables == null) { BinaryDeserializationDeprecated.globalVariables = GlobalVariables.Instance; } if (BinaryDeserializationDeprecated.globalVariables != null) { sharedVariable = BinaryDeserializationDeprecated.globalVariables.GetVariable(name); } } } Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(text); if (typeWithinAssembly == null) { return(null); } bool flag3 = true; if (sharedVariable == null || !(flag3 = sharedVariable.GetType().Equals(typeWithinAssembly))) { sharedVariable = (TaskUtility.CreateInstance(typeWithinAssembly) as SharedVariable); sharedVariable.Name = name; sharedVariable.IsShared = flag; sharedVariable.IsGlobal = flag2; sharedVariable.NetworkSync = Convert.ToBoolean(BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(bool), namePrefix + "NetworkSync", null, null, null)); if (!flag2) { sharedVariable.PropertyMapping = (string)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(string), namePrefix + "PropertyMapping", null, null, null); sharedVariable.PropertyMappingOwner = (GameObject)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(GameObject), namePrefix + "PropertyMappingOwner", null, null, null); sharedVariable.InitializePropertyMapping(variableSource as BehaviorSource); } if (!flag3) { sharedVariable.IsShared = true; } BinaryDeserializationDeprecated.LoadFields(fieldSerializationData, fieldIndexMap, sharedVariable, namePrefix, variableSource); } return(sharedVariable); }
// Token: 0x06000108 RID: 264 RVA: 0x0000A360 File Offset: 0x00008560 private static void LoadNodeData(FieldSerializationData fieldSerializationData, Dictionary <string, int> fieldIndexMap, Task task) { NodeData nodeData = new NodeData(); nodeData.Offset = (Vector2)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(Vector2), "NodeDataOffset", null, null, null); nodeData.Comment = (string)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(string), "NodeDataComment", null, null, null); nodeData.IsBreakpoint = (bool)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(bool), "NodeDataIsBreakpoint", null, null, null); nodeData.Collapsed = (bool)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(bool), "NodeDataCollapsed", null, null, null); object obj = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(int), "NodeDataColorIndex", null, null, null); if (obj != null) { nodeData.ColorIndex = (int)obj; } obj = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, typeof(List <string>), "NodeDataWatchedFields", null, null, null); if (obj != null) { nodeData.WatchedFieldNames = new List <string>(); nodeData.WatchedFields = new List <FieldInfo>(); IList list = obj as IList; for (int i = 0; i < list.Count; i++) { FieldInfo field = task.GetType().GetField((string)list[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { nodeData.WatchedFieldNames.Add(field.Name); nodeData.WatchedFields.Add(field); } } } task.NodeData = nodeData; }
// Token: 0x0600011C RID: 284 RVA: 0x0000B1A8 File Offset: 0x000093A8 private static LayerMask BytesToLayerMask(byte[] bytes, int dataPosition) { LayerMask result = default(LayerMask); result.value = BinaryDeserializationDeprecated.BytesToInt(bytes, dataPosition); return(result); }
// Token: 0x060000E6 RID: 230 RVA: 0x00008320 File Offset: 0x00006520 public static void Load(GlobalVariables globalVariables, string version) { if (globalVariables == null) { return; } if (string.IsNullOrEmpty(version)) { BinaryDeserializationDeprecated.Load(globalVariables); return; } globalVariables.Variables = null; FieldSerializationData fieldSerializationData; if (globalVariables.VariableData == null || (fieldSerializationData = globalVariables.VariableData.fieldSerializationData).byteData == null || fieldSerializationData.byteData.Count == 0) { return; } if (fieldSerializationData.typeName.Count > 0) { BinaryDeserializationDeprecated.Load(globalVariables); return; } VariableSerializationData variableData = globalVariables.VariableData; fieldSerializationData.byteDataArray = fieldSerializationData.byteData.ToArray(); BinaryDeserialization.updatedSerialization = (globalVariables.Version.CompareTo("1.5.7") >= 0); if (variableData.variableStartIndex != null) { List <SharedVariable> list = new List <SharedVariable>(); Dictionary <int, int> dictionary = ObjectPool.Get <Dictionary <int, int> >(); for (int i = 0; i < variableData.variableStartIndex.Count; i++) { int num = variableData.variableStartIndex[i]; int num2; if (i + 1 < variableData.variableStartIndex.Count) { num2 = variableData.variableStartIndex[i + 1]; } else { num2 = fieldSerializationData.startIndex.Count; } dictionary.Clear(); for (int j = num; j < num2; j++) { dictionary.Add(fieldSerializationData.fieldNameHash[j], fieldSerializationData.startIndex[j]); } SharedVariable sharedVariable = BinaryDeserialization.BytesToSharedVariable(fieldSerializationData, dictionary, fieldSerializationData.byteDataArray, variableData.variableStartIndex[i], globalVariables, false, 0); if (sharedVariable != null) { list.Add(sharedVariable); } } ObjectPool.Return <Dictionary <int, int> >(dictionary); globalVariables.Variables = list; } }
// Token: 0x06000109 RID: 265 RVA: 0x0000A4CC File Offset: 0x000086CC private static void LoadFields(FieldSerializationData fieldSerializationData, Dictionary <string, int> fieldIndexMap, object obj, string namePrefix, IVariableSource variableSource) { FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType()); for (int i = 0; i < allFields.Length; i++) { if (!TaskUtility.HasAttribute(allFields[i], typeof(NonSerializedAttribute)) && ((!allFields[i].IsPrivate && !allFields[i].IsFamily) || TaskUtility.HasAttribute(allFields[i], typeof(SerializeField))) && (!(obj is ParentTask) || !allFields[i].Name.Equals("children"))) { object obj2 = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, allFields[i].FieldType, namePrefix + allFields[i].Name, variableSource, obj, allFields[i]); if (obj2 != null && !object.ReferenceEquals(obj2, null) && !obj2.Equals(null)) { allFields[i].SetValue(obj, obj2); } } } }
public static void Load(TaskSerializationData taskData, BehaviorSource behaviorSource) { if (taskData != null && string.IsNullOrEmpty(taskData.Version)) { BinaryDeserializationDeprecated.Load(taskData, behaviorSource); return; } behaviorSource.EntryTask = null; behaviorSource.RootTask = null; behaviorSource.DetachedTasks = null; behaviorSource.Variables = null; FieldSerializationData fieldSerializationData; if (taskData == null || (fieldSerializationData = taskData.fieldSerializationData).byteData == null || fieldSerializationData.byteData.Count == 0) { return; } fieldSerializationData.byteDataArray = fieldSerializationData.byteData.ToArray(); BinaryDeserialization.taskIDs = null; BinaryDeserialization.updatedSerialization = (taskData.Version.CompareTo("1.5.7") >= 0); if (BinaryDeserialization.updatedSerialization) { BinaryDeserialization.shaHashSerialization = (taskData.Version.CompareTo("1.5.9") >= 0); } if (taskData.variableStartIndex != null) { List <SharedVariable> list = new List <SharedVariable>(); Dictionary <int, int> dictionary = ObjectPool.Get <Dictionary <int, int> >(); for (int i = 0; i < taskData.variableStartIndex.Count; i++) { int num = taskData.variableStartIndex[i]; int num2; if (i + 1 < taskData.variableStartIndex.Count) { num2 = taskData.variableStartIndex[i + 1]; } else if (taskData.startIndex != null && taskData.startIndex.Count > 0) { num2 = taskData.startIndex[0]; } else { num2 = fieldSerializationData.startIndex.Count; } dictionary.Clear(); for (int j = num; j < num2; j++) { dictionary.Add(fieldSerializationData.fieldNameHash[j], fieldSerializationData.startIndex[j]); } SharedVariable sharedVariable = BinaryDeserialization.BytesToSharedVariable(fieldSerializationData, dictionary, fieldSerializationData.byteDataArray, taskData.variableStartIndex[i], behaviorSource, false, 0); if (sharedVariable != null) { list.Add(sharedVariable); } } ObjectPool.Return <Dictionary <int, int> >(dictionary); behaviorSource.Variables = list; } List <Task> list2 = new List <Task>(); if (taskData.types != null) { for (int k = 0; k < taskData.types.Count; k++) { BinaryDeserialization.LoadTask(taskData, fieldSerializationData, ref list2, ref behaviorSource); } } if (taskData.parentIndex.Count != list2.Count) { Debug.LogError("Deserialization Error: parent index count does not match task list count"); return; } for (int l = 0; l < taskData.parentIndex.Count; l++) { if (taskData.parentIndex[l] == -1) { if (behaviorSource.EntryTask == null) { behaviorSource.EntryTask = list2[l]; } else { if (behaviorSource.DetachedTasks == null) { behaviorSource.DetachedTasks = new List <Task>(); } behaviorSource.DetachedTasks.Add(list2[l]); } } else if (taskData.parentIndex[l] == 0) { behaviorSource.RootTask = list2[l]; } else if (taskData.parentIndex[l] != -1) { ParentTask parentTask = list2[taskData.parentIndex[l]] as ParentTask; if (parentTask != null) { int index = (parentTask.Children != null) ? parentTask.Children.Count : 0; parentTask.AddChild(list2[l], index); } } } if (BinaryDeserialization.taskIDs != null) { foreach (BinaryDeserialization.ObjectFieldMap current in BinaryDeserialization.taskIDs.Keys) { List <int> list3 = BinaryDeserialization.taskIDs[current]; Type fieldType = current.fieldInfo.FieldType; if (typeof(IList).IsAssignableFrom(fieldType)) { if (fieldType.IsArray) { Type elementType = fieldType.GetElementType(); Array array = Array.CreateInstance(elementType, list3.Count); for (int m = 0; m < array.Length; m++) { array.SetValue(list2[list3[m]], m); } current.fieldInfo.SetValue(current.obj, array); } else { Type type = fieldType.GetGenericArguments()[0]; IList list4 = TaskUtility.CreateInstance(typeof(List <>).MakeGenericType(new Type[] { type })) as IList; for (int n = 0; n < list3.Count; n++) { list4.Add(list2[list3[n]]); } current.fieldInfo.SetValue(current.obj, list4); } } else { current.fieldInfo.SetValue(current.obj, list2[list3[0]]); } } } }
// Token: 0x0600010A RID: 266 RVA: 0x0000A5B4 File Offset: 0x000087B4 private static object LoadField(FieldSerializationData fieldSerializationData, Dictionary <string, int> fieldIndexMap, Type fieldType, string fieldName, IVariableSource variableSource, object obj = null, FieldInfo fieldInfo = null) { string text = fieldType.Name + fieldName; int num; if (fieldIndexMap.TryGetValue(text, out num)) { object obj2 = null; if (typeof(IList).IsAssignableFrom(fieldType)) { int num2 = BinaryDeserializationDeprecated.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); if (fieldType.IsArray) { Type elementType = fieldType.GetElementType(); if (elementType == null) { return(null); } Array array = Array.CreateInstance(elementType, num2); for (int i = 0; i < num2; i++) { object obj3 = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, elementType, text + i, variableSource, obj, fieldInfo); array.SetValue((!object.ReferenceEquals(obj3, null) && !obj3.Equals(null)) ? obj3 : null, i); } obj2 = array; } else { Type type = fieldType; while (!type.IsGenericType) { type = type.BaseType; } Type type2 = type.GetGenericArguments()[0]; IList list; if (fieldType.IsGenericType) { list = (TaskUtility.CreateInstance(typeof(List <>).MakeGenericType(new Type[] { type2 })) as IList); } else { list = (TaskUtility.CreateInstance(fieldType) as IList); } for (int j = 0; j < num2; j++) { object obj4 = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, fieldIndexMap, type2, text + j, variableSource, obj, fieldInfo); list.Add((!object.ReferenceEquals(obj4, null) && !obj4.Equals(null)) ? obj4 : null); } obj2 = list; } } else if (typeof(Task).IsAssignableFrom(fieldType)) { if (fieldInfo != null && TaskUtility.HasAttribute(fieldInfo, typeof(InspectTaskAttribute))) { string text2 = BinaryDeserializationDeprecated.BytesToString(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num], BinaryDeserializationDeprecated.GetFieldSize(fieldSerializationData, num)); if (!string.IsNullOrEmpty(text2)) { Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(text2); if (typeWithinAssembly != null) { obj2 = TaskUtility.CreateInstance(typeWithinAssembly); BinaryDeserializationDeprecated.LoadFields(fieldSerializationData, fieldIndexMap, obj2, text, variableSource); } } } else { if (BinaryDeserializationDeprecated.taskIDs == null) { BinaryDeserializationDeprecated.taskIDs = new Dictionary <BinaryDeserializationDeprecated.ObjectFieldMap, List <int> >(new BinaryDeserializationDeprecated.ObjectFieldMapComparer()); } int item = BinaryDeserializationDeprecated.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); BinaryDeserializationDeprecated.ObjectFieldMap key = new BinaryDeserializationDeprecated.ObjectFieldMap(obj, fieldInfo); if (BinaryDeserializationDeprecated.taskIDs.ContainsKey(key)) { BinaryDeserializationDeprecated.taskIDs[key].Add(item); } else { List <int> list2 = new List <int>(); list2.Add(item); BinaryDeserializationDeprecated.taskIDs.Add(key, list2); } } } else if (typeof(SharedVariable).IsAssignableFrom(fieldType)) { obj2 = BinaryDeserializationDeprecated.BytesToSharedVariable(fieldSerializationData, fieldIndexMap, fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num], variableSource, true, text); } else if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType)) { int index = BinaryDeserializationDeprecated.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); obj2 = BinaryDeserializationDeprecated.IndexToUnityObject(index, fieldSerializationData); } else if (fieldType.Equals(typeof(int)) || fieldType.IsEnum) { obj2 = BinaryDeserializationDeprecated.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(uint))) { obj2 = BinaryDeserializationDeprecated.BytesToUInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(float))) { obj2 = BinaryDeserializationDeprecated.BytesToFloat(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(double))) { obj2 = BinaryDeserializationDeprecated.BytesToDouble(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(long))) { obj2 = BinaryDeserializationDeprecated.BytesToLong(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(bool))) { obj2 = BinaryDeserializationDeprecated.BytesToBool(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(string))) { obj2 = BinaryDeserializationDeprecated.BytesToString(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num], BinaryDeserializationDeprecated.GetFieldSize(fieldSerializationData, num)); } else if (fieldType.Equals(typeof(byte))) { obj2 = BinaryDeserializationDeprecated.BytesToByte(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Vector2))) { obj2 = BinaryDeserializationDeprecated.BytesToVector2(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Vector3))) { obj2 = BinaryDeserializationDeprecated.BytesToVector3(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Vector4))) { obj2 = BinaryDeserializationDeprecated.BytesToVector4(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Quaternion))) { obj2 = BinaryDeserializationDeprecated.BytesToQuaternion(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Color))) { obj2 = BinaryDeserializationDeprecated.BytesToColor(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Rect))) { obj2 = BinaryDeserializationDeprecated.BytesToRect(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(Matrix4x4))) { obj2 = BinaryDeserializationDeprecated.BytesToMatrix4x4(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(AnimationCurve))) { obj2 = BinaryDeserializationDeprecated.BytesToAnimationCurve(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.Equals(typeof(LayerMask))) { obj2 = BinaryDeserializationDeprecated.BytesToLayerMask(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num]); } else if (fieldType.IsClass || (fieldType.IsValueType && !fieldType.IsPrimitive)) { obj2 = TaskUtility.CreateInstance(fieldType); BinaryDeserializationDeprecated.LoadFields(fieldSerializationData, fieldIndexMap, obj2, text, variableSource); return(obj2); } return(obj2); } if (fieldType.IsAbstract) { return(null); } if (typeof(SharedVariable).IsAssignableFrom(fieldType)) { return(TaskUtility.CreateInstance(fieldType)); } return(null); }
// Token: 0x06000107 RID: 263 RVA: 0x0000A06C File Offset: 0x0000826C private static void LoadTask(TaskSerializationData taskSerializationData, FieldSerializationData fieldSerializationData, ref List <Task> taskList, ref BehaviorSource behaviorSource) { int count = taskList.Count; Type type = TaskUtility.GetTypeWithinAssembly(taskSerializationData.types[count]); if (type == null) { bool flag = false; for (int i = 0; i < taskSerializationData.parentIndex.Count; i++) { if (count == taskSerializationData.parentIndex[i]) { flag = true; break; } } if (flag) { type = typeof(UnknownParentTask); } else { type = typeof(UnknownTask); } } Task task = TaskUtility.CreateInstance(type) as Task; task.Owner = (behaviorSource.Owner.GetObject() as Behavior); taskList.Add(task); int num = taskSerializationData.startIndex[count]; int num2; if (count + 1 < taskSerializationData.startIndex.Count) { num2 = taskSerializationData.startIndex[count + 1]; } else { num2 = fieldSerializationData.startIndex.Count; } Dictionary <string, int> dictionary = ObjectPool.Get <Dictionary <string, int> >(); dictionary.Clear(); for (int j = num; j < num2; j++) { if (!dictionary.ContainsKey(fieldSerializationData.typeName[j])) { dictionary.Add(fieldSerializationData.typeName[j], fieldSerializationData.startIndex[j]); } } task.ID = (int)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, dictionary, typeof(int), "ID", null, null, null); task.FriendlyName = (string)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, dictionary, typeof(string), "FriendlyName", null, null, null); task.IsInstant = (bool)BinaryDeserializationDeprecated.LoadField(fieldSerializationData, dictionary, typeof(bool), "IsInstant", null, null, null); object obj; if ((obj = BinaryDeserializationDeprecated.LoadField(fieldSerializationData, dictionary, typeof(bool), "Disabled", null, null, null)) != null) { task.Disabled = (bool)obj; } BinaryDeserializationDeprecated.LoadNodeData(fieldSerializationData, dictionary, taskList[count]); 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); } } BinaryDeserializationDeprecated.LoadFields(fieldSerializationData, dictionary, taskList[count], string.Empty, behaviorSource); ObjectPool.Return <Dictionary <string, int> >(dictionary); }
// Token: 0x06000104 RID: 260 RVA: 0x00009A48 File Offset: 0x00007C48 public static void Load(BehaviorSource behaviorSource) { BinaryDeserializationDeprecated.Load(behaviorSource.TaskData, behaviorSource); }