예제 #1
0
 public override TaskStatus OnUpdate()
 {
     // Send the event and return success
     if (argument1 == null || argument1.IsNone)
     {
         behaviorTree.SendEvent(eventName.Value);
     }
     else
     {
         if (argument2 == null || argument2.IsNone)
         {
             behaviorTree.SendEvent <object>(eventName.Value, argument1.GetValue());
         }
         else
         {
             if (argument3 == null || argument3.IsNone)
             {
                 behaviorTree.SendEvent <object, object>(eventName.Value, argument1.GetValue(), argument2.GetValue());
             }
             else
             {
                 behaviorTree.SendEvent <object, object, object>(eventName.Value, argument1.GetValue(), argument2.GetValue(), argument3.GetValue());
             }
         }
     }
     return(TaskStatus.Success);
 }
예제 #2
0
 private object[] buildParamsArray()
 {
     object[] paramsArray;
     if (isValid(arg3))
     {
         paramsArray    = new object[4];
         paramsArray[3] = arg3.GetValue();
         paramsArray[2] = arg2.GetValue();
         paramsArray[1] = arg1.GetValue();
         paramsArray[0] = arg0.GetValue();
     }
     else if (isValid(arg2))
     {
         paramsArray    = new object[3];
         paramsArray[2] = arg2.GetValue();
         paramsArray[1] = arg1.GetValue();
         paramsArray[0] = arg0.GetValue();
     }
     else if (isValid(arg1))
     {
         paramsArray    = new object[2];
         paramsArray[1] = arg1.GetValue();
         paramsArray[0] = arg0.GetValue();
     }
     else if (isValid(arg0))
     {
         paramsArray    = new object[1];
         paramsArray[0] = arg0.GetValue();
     }
     else
     {
         return(null);
     }
     return(paramsArray);
 }
예제 #3
0
        public override TaskStatus OnUpdate()
        {
            if (compareValue == null)
            {
                Debug.LogWarning("Unable to compare field - compare value is null");
                return(TaskStatus.Failure);
            }

            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to compare the property");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(TaskUtility.GetTypeWithinAssembly(componentName.Value));

            if (component == null)
            {
                Debug.LogWarning("Unable to compare the property with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var property      = component.GetType().GetProperty(propertyName.Value);
            var propertyValue = property.GetValue(component, null);

            if (propertyValue == null && compareValue.GetValue() == null)
            {
                return(TaskStatus.Success);
            }

            return(propertyValue.Equals(compareValue.GetValue()) ? TaskStatus.Success : TaskStatus.Failure);
        }
예제 #4
0
        public override TaskStatus OnUpdate()
        {
            if (compareValue == null)
            {
                Debug.LogWarning("Unable to compare field - compare value is null");
                return(TaskStatus.Failure);
            }

            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to compare field");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(componentName.Value);

            if (component == null)
            {
                Debug.LogWarning("Unable to compare the field with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var field      = component.GetType().GetField(fieldName.Value);
            var fieldValue = field.GetValue(component);

            if (fieldValue == null && compareValue.GetValue() == null)
            {
                return(TaskStatus.Success);
            }

            return(fieldValue.Equals(compareValue.GetValue()) ? TaskStatus.Success : TaskStatus.Failure);
        }
        public override TaskStatus OnUpdate()
        {
            foreach (GameObject go in storedGameObjectList.Value)
            {
                var behaviorTrees = GetDefaultGameObject(go).GetComponents <BehaviorTree>();
                if (behaviorTrees.Length == 1)
                {
                    behaviorTree = behaviorTrees[0];
                }
                else if (behaviorTrees.Length > 1)
                {
                    for (int i = 0; i < behaviorTrees.Length; ++i)
                    {
                        if (behaviorTrees[i].Group == group.Value)
                        {
                            behaviorTree = behaviorTrees[i];
                            break;
                        }
                    }
                    // If the group can't be found then use the first behavior tree
                    if (behaviorTree == null)
                    {
                        behaviorTree = behaviorTrees[0];
                    }
                }

                // Send the event and return success
                if (argument1 == null || argument1.IsNone)
                {
                    behaviorTree.SendEvent(eventName.Value);
                }
                else
                {
                    if (argument2 == null || argument2.IsNone)
                    {
                        behaviorTree.SendEvent <object>(eventName.Value, argument1.GetValue());
                    }
                    else
                    {
                        if (argument3 == null || argument3.IsNone)
                        {
                            behaviorTree.SendEvent <object, object>(eventName.Value, argument1.GetValue(), argument2.GetValue());
                        }
                        else
                        {
                            behaviorTree.SendEvent <object, object, object>(eventName.Value, argument1.GetValue(), argument2.GetValue(), argument3.GetValue());
                        }
                    }
                }
            }
            return(TaskStatus.Success);
        }
예제 #6
0
        public override TaskStatus OnUpdate()
        {
            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to invoke method");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to invoke - type is null");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to invoke method with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var            parameterList     = new List <object>();
            var            parameterTypeList = new List <Type>();
            SharedVariable sharedVariable    = null;

            for (int i = 0; i < 4; ++i)
            {
                var parameterField = GetType().GetField("parameter" + (i + 1));
                if ((sharedVariable = parameterField.GetValue(this) as SharedVariable) != null)
                {
                    parameterList.Add(sharedVariable.GetValue());
                    parameterTypeList.Add(sharedVariable.GetType().GetProperty("Value").PropertyType);
                }
                else
                {
                    break;
                }
            }
            // If you are receiving a compiler error on the Windows Store platform see this topic:
            // http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=46
            var methodInfo = component.GetType().GetMethod(methodName.Value, parameterTypeList.ToArray());

            if (methodInfo == null)
            {
                Debug.LogWarning("Unable to invoke method " + methodName.Value + " on component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var result = methodInfo.Invoke(component, parameterList.ToArray());

            if (storeResult != null)
            {
                storeResult.SetValue(result);
            }

            return(TaskStatus.Success);
        }
예제 #7
0
        public override TaskStatus OnUpdate()
        {
            if (propertyValue == null)
            {
                Debug.LogWarning("Unable to get field - field value is null");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to set property - type is null");
                return(TaskStatus.Failure);
            }

            var component = GetDefaultGameObject(targetGameObject.Value).GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to set the property with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            // If you are receiving a compiler error on the Windows Store platform see this topic:
            // https://www.opsive.com/support/documentation/behavior-designer/installation/
            var property = component.GetType().GetProperty(propertyName.Value);

            property.SetValue(component, propertyValue.GetValue(), null);

            return(TaskStatus.Success);
        }
예제 #8
0
        public override TaskStatus OnUpdate()
        {
            if (fieldValue == null)
            {
                Debug.LogWarning("Unable to get field - field value is null");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to set field - type is null");
                return(TaskStatus.Failure);
            }

            var component = GetDefaultGameObject(targetGameObject.Value).GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to set the field with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            // If you are receiving a compiler error on the Windows Store platform see this topic:
            // http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=46
            var field = component.GetType().GetField(fieldName.Value);

            field.SetValue(component, fieldValue.GetValue());

            return(TaskStatus.Success);
        }
예제 #9
0
    public static Example.BehaviorVariable ExportSharedVariable(SharedVariable variable)
    {
        var value = new Example.BehaviorVariable();

        value.Name = variable.Name;

        var v = variable.GetValue();
        var t = v.GetType();

        if (t == typeof(int))
        {
            value.IntValue  = (int)v;
            value.valueType = Example.BehaviorVariable.ValueType.INTEGER;
        }
        else if (t == typeof(bool))
        {
            value.BoolValue = (bool)v;
            value.valueType = Example.BehaviorVariable.ValueType.BOOLEAN;
        }
        else if (t == typeof(float))
        {
            value.FloatValue = (float)v;
            value.valueType  = Example.BehaviorVariable.ValueType.FLOAT;
        }
        else
        {
            Debug.LogErrorFormat("Variable Type {0} not support", t);
        }

        return(value);
    }
예제 #10
0
        public override TaskStatus OnUpdate()
        {
            if (sharedValue == null)
            {
                return(TaskStatus.Inactive);
            }

            var value = sharedValue.GetValue();

            if (value is int)
            {
                return(CheckCondition((int)value, compareValue.IntValue) ? TaskStatus.Success : TaskStatus.Failure);
            }
            else if (value is float)
            {
                return(CheckCondition((float)value, compareValue.FloatValue) ? TaskStatus.Success : TaskStatus.Failure);
            }
            else if (value is bool)
            {
                return(CheckCondition((bool)value)? TaskStatus.Success : TaskStatus.Failure);
            }
            else if (value is string)
            {
                return(CheckCondition((string)value, compareValue.StrValue) ? TaskStatus.Success : TaskStatus.Failure);
            }
            else
            {
                Debug.LogErrorFormat("comparetype {0} not support", sharedValue);
            }

            return(TaskStatus.Inactive);
        }
예제 #11
0
        public override TaskStatus OnUpdate()
        {
            if (fieldValue == null)
            {
                Debug.LogWarning("Unable to get field - field value is null");
                return(TaskStatus.Failure);
            }

            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to set field");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(TaskUtility.GetTypeWithinAssembly(componentName.Value));

            if (component == null)
            {
                Debug.LogWarning("Unable to set the field with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var field = component.GetType().GetField(fieldName.Value);

            field.SetValue(component, fieldValue.GetValue());

            return(TaskStatus.Success);
        }
예제 #12
0
        public override TaskStatus OnUpdate()
        {
            targetGameObject.Value = gameObject;// 临时使用
            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to invoke method");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to invoke - type is null");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to invoke method with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var            parameterList     = new List <object>();
            var            parameterTypeList = new List <Type>();
            SharedVariable sharedVariable    = null;

            for (int i = 0; i < 4; ++i)
            {
                var parameterField = GetType().GetField("parameter" + (i + 1));
                if ((sharedVariable = parameterField.GetValue(this) as SharedVariable) != null)
                {
                    parameterList.Add(sharedVariable.GetValue());
                    parameterTypeList.Add(sharedVariable.GetType().GetProperty("Value").PropertyType);
                }
                else
                {
                    break;
                }
            }
            var methodInfo = component.GetType().GetMethod(methodName.Value, parameterTypeList.ToArray());

            if (methodInfo == null)
            {
                Debug.LogWarning("Unable to invoke method " + methodName.Value + " on component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var result = methodInfo.Invoke(component, parameterList.ToArray());

            if (storeResult != null)
            {
                storeResult.SetValue(result);
            }

            return(TaskStatus.Success);
        }
        public override TaskStatus OnUpdate()
        {
            if (compareValue == null)
            {
                Debug.LogWarning("Unable to compare field - compare value is null");
                return(TaskStatus.Failure);
            }

            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to compare the property");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to compare property - type is null");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to compare the property with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            // If you are receiving a compiler error on the Windows Store platform see this topic:
            // http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=46
            var property      = component.GetType().GetProperty(propertyName.Value);
            var propertyValue = property.GetValue(component, null);

            if (propertyValue == null && compareValue.GetValue() == null)
            {
                return(TaskStatus.Success);
            }

            return(propertyValue.Equals(compareValue.GetValue()) ? TaskStatus.Success : TaskStatus.Failure);
        }
예제 #14
0
        private void DoSync()
        {
            FsmVariable    variable       = this.Root.GetVariable(variableName.Value);
            SharedVariable sharedVariable = behaviorTree.GetVariable(variableName.Value);

            if (direction == Direction.FromBehaviourTree)
            {
                variable.SetValue(sharedVariable.GetValue());
            }
            else
            {
                sharedVariable.SetValue(variable.GetValue());
            }
        }
        public override TaskStatus OnUpdate()
        {
            if (compareValue == null)
            {
                Debug.LogWarning("Unable to compare field - compare value is null");
                return(TaskStatus.Failure);
            }

            var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);

            if (type == null)
            {
                Debug.LogWarning("Unable to compare field - type is null");
                return(TaskStatus.Failure);
            }

            var component = GetDefaultGameObject(targetGameObject.Value).GetComponent(type);

            if (component == null)
            {
                Debug.LogWarning("Unable to compare the field with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            // If you are receiving a compiler error on the Windows Store platform see this topic:
            // https://www.opsive.com/support/documentation/behavior-designer/installation/
            var field      = component.GetType().GetField(fieldName.Value);
            var fieldValue = field.GetValue(component);

            if (fieldValue == null && compareValue.GetValue() == null)
            {
                return(TaskStatus.Success);
            }

            return(fieldValue.Equals(compareValue.GetValue()) ? TaskStatus.Success : TaskStatus.Failure);
        }
예제 #16
0
 // Token: 0x0600017B RID: 379 RVA: 0x0000D0CC File Offset: 0x0000B2CC
 private static void CheckField(Task task, bool projectLevelBehavior, ref List <ErrorDetails> errorDetails, FieldInfo field, int index, object value)
 {
     if (value == null)
     {
         return;
     }
     if (TaskUtility.HasAttribute(field, typeof(RequiredFieldAttribute)) && !ErrorCheck.IsRequiredFieldValid(field.FieldType, value))
     {
         ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.RequiredField, task, index, field.Name);
     }
     if (typeof(SharedVariable).IsAssignableFrom(field.FieldType))
     {
         SharedVariable sharedVariable = value as SharedVariable;
         if (sharedVariable != null)
         {
             if (sharedVariable.IsShared && string.IsNullOrEmpty(sharedVariable.Name) && !TaskUtility.HasAttribute(field, typeof(SharedRequiredAttribute)))
             {
                 ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.SharedVariable, task, index, field.Name);
             }
             object value2 = sharedVariable.GetValue();
             if (!EditorApplication.isPlaying && projectLevelBehavior && !sharedVariable.IsShared && value2 is Object && AssetDatabase.GetAssetPath(value2 as Object).Length <= 0)
             {
                 ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.InvalidTaskReference, task, index, field.Name);
             }
         }
     }
     else if (value is Object)
     {
         bool flag = AssetDatabase.GetAssetPath(value as Object).Length > 0;
         if (!EditorApplication.isPlaying && !flag)
         {
             ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.InvalidTaskReference, task, index, field.Name);
         }
     }
     else if (!typeof(Delegate).IsAssignableFrom(field.FieldType) && (field.FieldType.IsClass || (field.FieldType.IsValueType && !field.FieldType.IsPrimitive)))
     {
         FieldInfo[] allFields = TaskUtility.GetAllFields(field.FieldType);
         for (int i = 0; i < allFields.Length; i++)
         {
             ErrorCheck.CheckField(task, projectLevelBehavior, ref errorDetails, allFields[i], index, allFields[i].GetValue(value));
         }
     }
 }
예제 #17
0
        public override TaskStatus OnUpdate()
        {
            if (targetGameObject == null || targetGameObject.Value == null)
            {
                Debug.LogWarning("Unable to set property");
                return(TaskStatus.Failure);
            }

            var component = targetGameObject.Value.GetComponent(TaskUtility.GetTypeWithinAssembly(componentName.Value));

            if (component == null)
            {
                Debug.LogWarning("Unable to set the property with component " + componentName.Value);
                return(TaskStatus.Failure);
            }

            var property = component.GetType().GetProperty(propertyName.Value);

            property.SetValue(component, propertyValue.GetValue(), null);

            return(TaskStatus.Success);
        }
        public void SetVariable(SharedVariable sharedVariable)
        {
            if (sharedVariable == null)
            {
                return;
            }
            CheckSerialization();

            if (variables == null)
            {
                variables = new List <SharedVariable>();
            }
            else if (sharedVariableIndex == null)
            {
                UpdateVariablesIndex();
            }
            int index;

            if (sharedVariableIndex != null && sharedVariableIndex.TryGetValue(sharedVariable.GUID, out index))
            {
                SharedVariable sharedVariable2 = variables[index];
                if (!sharedVariable2.GetType().Equals(typeof(SharedVariable)) && !sharedVariable2.GetType().Equals(sharedVariable.GetType()))
                {
                    Debug.LogError(string.Format("Error: Unable to set SharedVariable {0} - the variable type {1} does not match the existing type {2}", sharedVariable.GUID, sharedVariable2.GetType(), sharedVariable.GetType()));
                }
                else
                {
                    sharedVariable2.SetValue(sharedVariable.GetValue());
                }
            }
            else
            {
                variables.Add(sharedVariable);
                UpdateVariablesIndex();
            }
        }
예제 #19
0
 public static void DrawSharedVariableValue(SharedVariable sharedVariable, int width)
 {
     if (sharedVariable == null)
     {
         return;
     }
     try
     {
         switch (sharedVariable.ValueType)
         {
             case SharedVariableTypes.Int:
                 sharedVariable.SetValue(EditorGUILayout.IntField((int)sharedVariable.GetValue(), new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Float:
                 sharedVariable.SetValue(EditorGUILayout.FloatField((float)sharedVariable.GetValue(), new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Bool:
                 sharedVariable.SetValue(EditorGUILayout.Toggle((bool)sharedVariable.GetValue(), EditorStyles.toggle, new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.String:
                 sharedVariable.SetValue(EditorGUILayout.TextField((string)sharedVariable.GetValue(), new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Vector2:
                 sharedVariable.SetValue(VariableInspector.Vector2Field((Vector2)sharedVariable.GetValue()));
                 break;
             case SharedVariableTypes.Vector3:
                 sharedVariable.SetValue(VariableInspector.Vector3Field((Vector3)sharedVariable.GetValue()));
                 break;
             case SharedVariableTypes.Vector4:
                 sharedVariable.SetValue(VariableInspector.Vector4Field((Vector4)sharedVariable.GetValue()));
                 break;
             case SharedVariableTypes.Quaternion:
                 {
                     Vector4 vector = VariableInspector.QuaternionToVector4((Quaternion)sharedVariable.GetValue());
                     Vector4 vector2 = VariableInspector.Vector4Field(vector);
                     if (vector != vector2)
                     {
                         sharedVariable.SetValue(new Quaternion(vector2.x, vector2.y, vector2.z, vector2.w));
                     }
                     break;
                 }
             case SharedVariableTypes.Color:
                 sharedVariable.SetValue(EditorGUILayout.ColorField((Color)sharedVariable.GetValue(), new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Rect:
                 sharedVariable.SetValue(EditorGUILayout.RectField((Rect)sharedVariable.GetValue(), new GUILayoutOption[0]));
                 break;
             case SharedVariableTypes.GameObject:
                 sharedVariable.SetValue(EditorGUILayout.ObjectField((GameObject)sharedVariable.GetValue(), typeof(GameObject), true, new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Transform:
                 sharedVariable.SetValue(EditorGUILayout.ObjectField((Transform)sharedVariable.GetValue(), typeof(Transform), true, new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
             case SharedVariableTypes.Object:
                 sharedVariable.SetValue(EditorGUILayout.ObjectField((UnityEngine.Object)sharedVariable.GetValue(), typeof(UnityEngine.Object), true, new GUILayoutOption[]
                 {
                     GUILayout.Width((float)width)
                 }));
                 break;
         }
     }
     catch (Exception)
     {
     }
 }
        public override void OnGUI(GUIContent label)
        {
            SharedVariable variable      = Value as SharedVariable;
            IVariableOwner variableOwner = variable.VariableOwner;

            if (variableOwner == null)
            {
                EditorGUILayout.HelpBox("没有VariableOwner", MessageType.Error); return;
            }
            //EditorGUILayout.HelpBox("ReferenceType:" + variable.GUID, MessageType.Info);
            //if (variableOwner.GetVariable(variable.GUID) == null)
            //    variableOwner.SetVariable(variable.Clone() as SharedVariable);
            EditorGUI.BeginChangeCheck();
            object value = EditorGUILayoutExtension.DrawField(label, variable.GetValueType(), variable.GetValue());

            if (EditorGUI.EndChangeCheck())
            {
                variable.SetValue(value);
                EditorUtility.SetDirty(variableOwner.Self());
            }
        }
    private static object LoadField(FieldSerializationData fieldSerializationData, Dictionary <int, int> fieldIndexMap, Type fieldType, string fieldName, int hashPrefix, IVariableSource variableSource, object obj = null, FieldInfo fieldInfo = null)
    {
        int num;

        if (BinaryDeserialization.shaHashSerialization)
        {
            num = hashPrefix + (BinaryDeserialization.StringHash(fieldType.Name.ToString()) + BinaryDeserialization.StringHash(fieldName));
        }
        else
        {
            num = hashPrefix + (fieldType.Name.GetHashCode() + fieldName.GetHashCode());
        }
        int num2;

        if (fieldIndexMap.TryGetValue(num, out num2))
        {
            object obj2 = null;
            if (typeof(IList).IsAssignableFrom(fieldType))
            {
                int num3 = BinaryDeserialization.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
                if (fieldType.IsArray)
                {
                    Type elementType = fieldType.GetElementType();
                    if (elementType == null)
                    {
                        return(null);
                    }
                    Array array = Array.CreateInstance(elementType, num3);
                    for (int i = 0; i < num3; i++)
                    {
                        object obj3 = BinaryDeserialization.LoadField(fieldSerializationData, fieldIndexMap, elementType, i.ToString(), num / ((!BinaryDeserialization.updatedSerialization) ? 1 : (i + 1)), 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 < num3; j++)
                    {
                        object obj4 = BinaryDeserialization.LoadField(fieldSerializationData, fieldIndexMap, type2, j.ToString(), num / ((!BinaryDeserialization.updatedSerialization) ? 1 : (j + 1)), 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 text = BinaryDeserialization.BytesToString(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2], BinaryDeserialization.GetFieldSize(fieldSerializationData, num2));
                    if (!string.IsNullOrEmpty(text))
                    {
                        Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(text);
                        if (typeWithinAssembly != null)
                        {
                            obj2 = TaskUtility.CreateInstance(typeWithinAssembly);
                            BinaryDeserialization.LoadFields(fieldSerializationData, fieldIndexMap, obj2, num, variableSource);
                        }
                    }
                }
                else
                {
                    if (BinaryDeserialization.taskIDs == null)
                    {
                        BinaryDeserialization.taskIDs = new Dictionary <BinaryDeserialization.ObjectFieldMap, List <int> >(new BinaryDeserialization.ObjectFieldMapComparer());
                    }
                    int item = BinaryDeserialization.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
                    BinaryDeserialization.ObjectFieldMap key = new BinaryDeserialization.ObjectFieldMap(obj, fieldInfo);
                    if (BinaryDeserialization.taskIDs.ContainsKey(key))
                    {
                        BinaryDeserialization.taskIDs[key].Add(item);
                    }
                    else
                    {
                        List <int> list2 = new List <int>();
                        list2.Add(item);
                        BinaryDeserialization.taskIDs.Add(key, list2);
                    }
                }
            }
            else if (typeof(SharedVariable).IsAssignableFrom(fieldType))
            {
                obj2 = BinaryDeserialization.BytesToSharedVariable(fieldSerializationData, fieldIndexMap, fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2], variableSource, true, num);
            }
            else if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType))
            {
                int index = BinaryDeserialization.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
                obj2 = BinaryDeserialization.IndexToUnityObject(index, fieldSerializationData);
            }
            else if (fieldType.Equals(typeof(int)) || fieldType.IsEnum)
            {
                obj2 = BinaryDeserialization.BytesToInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(uint)))
            {
                obj2 = BinaryDeserialization.BytesToUInt(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(float)))
            {
                obj2 = BinaryDeserialization.BytesToFloat(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(double)))
            {
                obj2 = BinaryDeserialization.BytesToDouble(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(long)))
            {
                obj2 = BinaryDeserialization.BytesToLong(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(bool)))
            {
                obj2 = BinaryDeserialization.BytesToBool(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(string)))
            {
                obj2 = BinaryDeserialization.BytesToString(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2], BinaryDeserialization.GetFieldSize(fieldSerializationData, num2));
            }
            else if (fieldType.Equals(typeof(byte)))
            {
                obj2 = BinaryDeserialization.BytesToByte(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Vector2)))
            {
                obj2 = BinaryDeserialization.BytesToVector2(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Vector3)))
            {
                obj2 = BinaryDeserialization.BytesToVector3(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Vector4)))
            {
                obj2 = BinaryDeserialization.BytesToVector4(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Quaternion)))
            {
                obj2 = BinaryDeserialization.BytesToQuaternion(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Color)))
            {
                obj2 = BinaryDeserialization.BytesToColor(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Rect)))
            {
                obj2 = BinaryDeserialization.BytesToRect(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(Matrix4x4)))
            {
                obj2 = BinaryDeserialization.BytesToMatrix4x4(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(AnimationCurve)))
            {
                obj2 = BinaryDeserialization.BytesToAnimationCurve(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.Equals(typeof(LayerMask)))
            {
                obj2 = BinaryDeserialization.BytesToLayerMask(fieldSerializationData.byteDataArray, fieldSerializationData.dataPosition[num2]);
            }
            else if (fieldType.IsClass || (fieldType.IsValueType && !fieldType.IsPrimitive))
            {
                obj2 = TaskUtility.CreateInstance(fieldType);
                BinaryDeserialization.LoadFields(fieldSerializationData, fieldIndexMap, obj2, num, variableSource);
                return(obj2);
            }
            return(obj2);
        }
        if (fieldType.IsAbstract)
        {
            return(null);
        }
        if (typeof(SharedVariable).IsAssignableFrom(fieldType))
        {
            SharedVariable sharedVariable  = TaskUtility.CreateInstance(fieldType) as SharedVariable;
            SharedVariable sharedVariable2 = fieldInfo.GetValue(obj) as SharedVariable;
            if (sharedVariable2 != null)
            {
                sharedVariable.SetValue(sharedVariable2.GetValue());
            }
            return(sharedVariable);
        }
        return(null);
    }