// Token: 0x0600015D RID: 349 RVA: 0x0000CB28 File Offset: 0x0000AD28 private static object ValueToObject(Task task, Type type, object obj, IVariableSource variableSource, List <UnityEngine.Object> unityObjects) { if (typeof(SharedVariable).IsAssignableFrom(type)) { SharedVariable sharedVariable = JSONDeserialization.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(JSONDeserialization.IndexToUnityObject(Convert.ToInt32(obj), unityObjects)); } if (!type.IsPrimitive) { if (!type.Equals(typeof(string))) { goto IL_B0; } } try { return(Convert.ChangeType(obj, type)); } catch (Exception) { return(null); } IL_B0: if (type.IsSubclassOf(typeof(Enum))) { try { return(Enum.Parse(type, (string)obj)); } catch (Exception) { return(null); } } if (type.Equals(typeof(Vector2))) { return(JSONDeserialization.StringToVector2((string)obj)); } if (type.Equals(typeof(Vector3))) { return(JSONDeserialization.StringToVector3((string)obj)); } if (type.Equals(typeof(Vector4))) { return(JSONDeserialization.StringToVector4((string)obj)); } if (type.Equals(typeof(Quaternion))) { return(JSONDeserialization.StringToQuaternion((string)obj)); } if (type.Equals(typeof(Matrix4x4))) { return(JSONDeserialization.StringToMatrix4x4((string)obj)); } if (type.Equals(typeof(Color))) { return(JSONDeserialization.StringToColor((string)obj)); } if (type.Equals(typeof(Rect))) { return(JSONDeserialization.StringToRect((string)obj)); } if (type.Equals(typeof(LayerMask))) { return(JSONDeserialization.ValueToLayerMask(Convert.ToInt32(obj))); } if (type.Equals(typeof(AnimationCurve))) { return(JSONDeserialization.ValueToAnimationCurve((Dictionary <string, object>)obj)); } object obj2 = TaskUtility.CreateInstance(type); JSONDeserialization.DeserializeObject(task, obj2, obj as Dictionary <string, object>, variableSource, unityObjects); return(obj2); }
// Token: 0x0600015B RID: 347 RVA: 0x0000C490 File Offset: 0x0000A690 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 (JSONDeserialization.globalVariables == null) { JSONDeserialization.globalVariables = GlobalVariables.Instance; } if (JSONDeserialization.globalVariables != null) { sharedVariable = JSONDeserialization.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 = (JSONDeserialization.IndexToUnityObject(Convert.ToInt32(obj2), unityObjects) as GameObject); } sharedVariable.InitializePropertyMapping(variableSource as BehaviorSource); } if (!flag) { sharedVariable.IsShared = true; } JSONDeserialization.DeserializeObject(null, sharedVariable, dict, variableSource, unityObjects); } return(sharedVariable); }