Exemplo n.º 1
0
        // Token: 0x06000157 RID: 343 RVA: 0x0000BFA4 File Offset: 0x0000A1A4
        public static void Load(string serialization, GlobalVariables globalVariables, string version)
        {
            if (globalVariables == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(version))
            {
                JSONDeserializationDeprecated.Load(serialization, globalVariables);
                return;
            }
            Dictionary <string, object> dictionary = MiniJSON.Deserialize(serialization) as Dictionary <string, object>;

            if (dictionary == null)
            {
                Debug.Log("Failed to deserialize");
                return;
            }
            if (globalVariables.VariableData == null)
            {
                globalVariables.VariableData = new VariableSerializationData();
            }
            JSONDeserialization.updatedSerialization = (globalVariables.Version.CompareTo("1.5.7") >= 0);
            JSONDeserialization.DeserializeVariables(globalVariables, dictionary, globalVariables.VariableData.fieldSerializationData.unityObjects);
        }
        // Token: 0x0600016C RID: 364 RVA: 0x0000D680 File Offset: 0x0000B880
        public static void Load(string serialization, GlobalVariables globalVariables)
        {
            if (globalVariables == null)
            {
                return;
            }
            Dictionary <string, object> dictionary = MiniJSON.Deserialize(serialization) as Dictionary <string, object>;

            if (dictionary == null)
            {
                Debug.Log("Failed to deserialize");
                return;
            }
            if (globalVariables.VariableData == null)
            {
                globalVariables.VariableData = new VariableSerializationData();
            }
            JSONDeserializationDeprecated.DeserializeVariables(globalVariables, dictionary, globalVariables.VariableData.fieldSerializationData.unityObjects);
        }
        // Token: 0x0600016B RID: 363 RVA: 0x0000D2C4 File Offset: 0x0000B4C4
        public static void Load(TaskSerializationData taskData, BehaviorSource behaviorSource)
        {
            behaviorSource.EntryTask     = null;
            behaviorSource.RootTask      = null;
            behaviorSource.DetachedTasks = null;
            behaviorSource.Variables     = null;
            Dictionary <string, object> dictionary;

            if (!JSONDeserializationDeprecated.serializationCache.TryGetValue(taskData.JSONSerialization.GetHashCode(), out dictionary))
            {
                dictionary = (MiniJSON.Deserialize(taskData.JSONSerialization) as Dictionary <string, object>);
                JSONDeserializationDeprecated.serializationCache.Add(taskData.JSONSerialization.GetHashCode(), dictionary);
            }
            if (dictionary == null)
            {
                Debug.Log("Failed to deserialize");
                return;
            }
            JSONDeserializationDeprecated.taskIDs = new Dictionary <JSONDeserializationDeprecated.TaskField, List <int> >();
            Dictionary <int, Task> dictionary2 = new Dictionary <int, Task>();

            JSONDeserializationDeprecated.DeserializeVariables(behaviorSource, dictionary, taskData.fieldSerializationData.unityObjects);
            if (dictionary.ContainsKey("EntryTask"))
            {
                behaviorSource.EntryTask = JSONDeserializationDeprecated.DeserializeTask(behaviorSource, dictionary["EntryTask"] as Dictionary <string, object>, ref dictionary2, taskData.fieldSerializationData.unityObjects);
            }
            if (dictionary.ContainsKey("RootTask"))
            {
                behaviorSource.RootTask = JSONDeserializationDeprecated.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(JSONDeserializationDeprecated.DeserializeTask(behaviorSource, dict, ref dictionary2, taskData.fieldSerializationData.unityObjects));
                }
                behaviorSource.DetachedTasks = list;
            }
            if (JSONDeserializationDeprecated.taskIDs != null && JSONDeserializationDeprecated.taskIDs.Count > 0)
            {
                foreach (JSONDeserializationDeprecated.TaskField key in JSONDeserializationDeprecated.taskIDs.Keys)
                {
                    List <int> list2     = JSONDeserializationDeprecated.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);
                        }
                    }
                }
                JSONDeserializationDeprecated.taskIDs = null;
            }
        }