예제 #1
0
        public override void Init(IScriptExportManager manager)
        {
            m_template = manager.RetrieveType(Type.ElementType);

            int argumentCount = MonoUtils.GetGenericArgumentCount(Type);

            m_arguments = new ScriptExportType[argumentCount];
            for (int i = Type.GenericArguments.Count - argumentCount, j = 0; i < Type.GenericArguments.Count; i++, j++)
            {
                TypeReference argument = Type.GenericArguments[i];
                m_arguments[j] = manager.RetrieveType(argument);
            }

            if (Type.DeclaringType != null)
            {
                if (Type.DeclaringType.HasGenericParameters)
                {
                    IEnumerable <TypeReference> nestArguments = Type.GenericArguments.Take(Type.GenericArguments.Count - argumentCount);
                    GenericInstanceType         nestInstance  = MonoUtils.CreateGenericInstance(Type.DeclaringType, nestArguments);
                    m_nest = manager.RetrieveType(nestInstance);
                }
                else
                {
                    m_nest = manager.RetrieveType(Type.DeclaringType);
                }
            }
        }
예제 #2
0
        internal static TypeReference GetElementType(TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            if (type.IsGenericParameter)
            {
                GenericParameter parameter = (GenericParameter)type;
                type = arguments[parameter];
            }
            if (type.IsGenericInstance)
            {
                GenericInstanceType genericInstance = (GenericInstanceType)type;
                if (MonoUtils.HasGenericParameters(genericInstance))
                {
                    type = MonoUtils.ReplaceGenericParameters(genericInstance, arguments);
                }
            }

            if (type.IsArray)
            {
                type = type.GetElementType();
                return(GetElementType(type, arguments));
            }
            if (IsList(type))
            {
                GenericInstanceType generic = (GenericInstanceType)type;
                type = generic.GenericArguments[0];
                return(GetElementType(type, arguments));
            }

            return(type);
        }
예제 #3
0
        IEnumerator SaveFilesData()
        {
            Debug.Log("Saving...");
            var objsModel = GameManager.Instance.objsScene;
            var models    = new List <Model.Model>();

            objsModel.ForEach(x =>
            {
                models.Add(new Model.Model(x));
            });
            var newScene = new SceneModel()
            {
                Models = models
            };
            var now             = DateTime.Now;
            var fileName        = "save_" + now.Year + now.Month + now.Day + now.Hour + now.Millisecond;
            var jsonFormatScene = new SceneData(newScene);
            var json            = MonoUtils.ConvertToJsonData(jsonFormatScene);

            Debug.Log("Saving... Dir: " + _dirPath + @"/" + fileName + ".json");

            //write string to file
            System.IO.File.WriteAllText(_dirPath + @"/" + fileName + ".json", json);

            GameEvents.OnFilesOpFinished();
            yield return(null);
        }
예제 #4
0
        private static IScriptStructure CreateBase(MonoManager manager, TypeDefinition type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            if (MonoType.IsPrime(type.BaseType))
            {
                return(null);
            }

            if (type.BaseType.IsGenericInstance)
            {
                Dictionary <GenericParameter, TypeReference> templateArguments = new Dictionary <GenericParameter, TypeReference>();
                GenericInstanceType instance = (GenericInstanceType)type.BaseType;
                TypeDefinition      template = instance.ElementType.Resolve();
                for (int i = 0; i < instance.GenericArguments.Count; i++)
                {
                    GenericParameter parameter = template.GenericParameters[i];
                    TypeReference    argument  = instance.GenericArguments[i];
                    if (argument.ContainsGenericParameter)
                    {
                        argument = MonoUtils.ResolveGenericParameter(argument, arguments);
                    }
                    templateArguments.Add(parameter, argument);
                }

                return(new MonoStructure(manager, template, templateArguments));
            }

            TypeDefinition definition = type.BaseType.Resolve();

            return(new MonoStructure(manager, definition));
        }
예제 #5
0
        private IEnumerator GetNetworkFiles()
        {
            //todo: change to UnityWebRequest
            var www = new WWW(Settings.UrlDownloadData);

            yield return(www);

            var jsonData = "";

            if (string.IsNullOrEmpty(www.error))
            {
                jsonData = System.Text.Encoding.UTF8.GetString(www.bytes, 3, www.bytes.Length - 3);  // Skip thr first 3 bytes (i.e. the UTF8 BOM)
                // JSONObject works now
                var objDownloadData = MonoUtils.ConvertToObjDownloadData(jsonData);

                objDownloadData.Name = "Network Scene";
                GameEvents.OnDownloadDataFinished(objDownloadData);
            }
            else
            {
                GameEvents.ErrorMessage(www.error);
            }

            GameEvents.OnFilesOpFinished();
        }
예제 #6
0
        /// <summary>
        /// Try to set the tileset. Might return false if an error ocurred.
        /// </summary>
        /// <param name="newTileset">The tileset to be set.</param>
        /// <returns>Wheter the tileset was set or an error ocurred.</returns>
        public bool TrySetTileset(Tileset newTileset)
        {
            if (this.loadedTexture != null)
            {
                this.loadedTexture.Dispose();
            }

            if (newTileset == null)
            {
                dtc.tex         = null;
                htt.highlighted = null;
                return(true);
            }

            // try and load the texture.
            if (MonoUtils.TryLoadTextureFromAbsolutePath(GraphicsDevice, newTileset.imagePath, out Texture2D loadedTexture) == false)
            {
                dtc.tex = null;
                return(false);
            }

            this.loadedTexture = loadedTexture;

            dtc.tex = loadedTexture;
            mcc.Set(this, loadedTexture.Width, loadedTexture.Height);
            ((HighlitingTilesetTile)htt).Set(newTileset, loadedTexture.Width, loadedTexture.Height);

            mcc.Clamp();

            // Reset the camera
            Stage.Camera.Zoom = 1;
            Stage.Camera.CenterOn(new Vector2(loadedTexture.Width, loadedTexture.Height));

            return(true);
        }
예제 #7
0
 public static string GetNestedName(TypeReference type, string typeName)
 {
     if (type.IsGenericParameter)
     {
         return(typeName);
     }
     if (type.IsNested)
     {
         string declaringName;
         if (type.IsGenericInstance)
         {
             GenericInstanceType generic           = (GenericInstanceType)type;
             int argumentCount                     = MonoUtils.GetGenericArgumentCount(generic);
             List <TypeReference> genericArguments = new List <TypeReference>(generic.GenericArguments.Count - argumentCount);
             for (int i = 0; i < generic.GenericArguments.Count - argumentCount; i++)
             {
                 genericArguments.Add(generic.GenericArguments[i]);
             }
             declaringName = GetNestedGenericName(type.DeclaringType, genericArguments);
         }
         else if (type.HasGenericParameters)
         {
             List <TypeReference> genericArguments = new List <TypeReference>(type.GenericParameters);
             declaringName = GetNestedGenericName(type.DeclaringType, genericArguments);
         }
         else
         {
             declaringName = GetNestedName(type.DeclaringType);
         }
         return($"{declaringName}.{typeName}");
     }
     return(typeName);
 }
예제 #8
0
        private static string GetGenericName(TypeReference genericType, IReadOnlyList <TypeReference> genericArguments)
        {
            string name          = genericType.Name;
            int    argumentCount = MonoUtils.GetGenericParameterCount(genericType);

            if (argumentCount == 0)
            {
                // nested class/enum (of generic class) is generic instance but it doesn't has '`' symbol in its name
                return(name);
            }

            int           index = name.IndexOf('`');
            StringBuilder sb    = new StringBuilder(genericType.Name, 0, index, 50 + index);

            sb.Append('<');
            for (int i = genericArguments.Count - argumentCount; i < genericArguments.Count; i++)
            {
                TypeReference arg          = genericArguments[i];
                string        argumentName = GetArgumentName(arg);
                sb.Append(argumentName);
                if (i < genericArguments.Count - 1)
                {
                    sb.Append(", ");
                }
            }
            sb.Append('>');
            return(sb.ToString());
        }
예제 #9
0
        private static SerializableType GetBaseType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            TypeDefinition definition = type.Resolve();

            if (IsObject(definition.BaseType))
            {
                return(null);
            }

            if (definition.BaseType.IsGenericInstance)
            {
                Dictionary <GenericParameter, TypeReference> templateArguments = new Dictionary <GenericParameter, TypeReference>();
                GenericInstanceType instance = (GenericInstanceType)definition.BaseType;
                TypeDefinition      template = instance.ElementType.Resolve();
                for (int i = 0; i < instance.GenericArguments.Count; i++)
                {
                    GenericParameter parameter = template.GenericParameters[i];
                    TypeReference    argument  = instance.GenericArguments[i];
                    if (argument.ContainsGenericParameter)
                    {
                        argument = MonoUtils.ResolveGenericParameter(argument, arguments);
                    }
                    templateArguments.Add(parameter, argument);
                }
                return(manager.GetSerializableType(instance, templateArguments));
            }
            else
            {
                TypeDefinition baseDefinition = definition.BaseType.Resolve();
                return(manager.GetSerializableType(baseDefinition, s_emptyArguments));
            }
        }
예제 #10
0
        private static void Main(string[] args)
        {
            MonoLogger.Setup();

            MonoUtils.EnsurePdb2MdbCallWorks();

            using (var server = new MonoDebugServer())
            {
                server.StartAnnouncing();
                server.Start();

                server.WaitForExit();
            }
        }
예제 #11
0
        private static void Main(string[] args)
        {
            Console.WriteLine($"MonoRemoteDebugger.Server v{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}");

            MonoLogger.Setup();

            MonoUtils.EnsurePdb2MdbCallWorks();

            using (var server = new MonoDebugServer())
            {
                server.StartAnnouncing();
                server.Start();

                server.WaitForExit();
            }
        }
예제 #12
0
        internal MonoType(MonoManager manager, MonoTypeContext context) :
            base(context.Type.Namespace, ToPrimitiveType(context.Type), MonoUtils.GetName(context.Type))
        {
            if (context.Type.ContainsGenericParameter)
            {
                throw new ArgumentException(nameof(context));
            }
            if (IsSerializableArray(context.Type))
            {
                throw new ArgumentException(nameof(context));
            }

            manager.AddSerializableType(context.Type, this);
            Base   = GetBaseType(manager, context);
            Fields = CreateFields(manager, context);
        }
예제 #13
0
        private static TypeReference GetSerializedElementType(TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            TypeReference resolvedType = type.ContainsGenericParameter ? MonoUtils.ResolveGenericParameter(type, arguments) : type;

            if (resolvedType.IsArray)
            {
                ArrayType array = (ArrayType)resolvedType;
                return(array.ElementType);
            }
            if (MonoType.IsList(resolvedType))
            {
                GenericInstanceType generic = (GenericInstanceType)resolvedType;
                return(generic.GenericArguments[0]);
            }

            return(resolvedType);
        }
예제 #14
0
        internal MonoType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
            base(type.Namespace, ToPrimitiveType(type), MonoUtils.GetName(type))
        {
            if (type.IsGenericParameter)
            {
                throw new ArgumentException(nameof(type));
            }
            if (MonoField.IsSerializableArray(type))
            {
                throw new ArgumentException(nameof(type));
            }

            string uniqueName = GetUniqueName(type);

            manager.AssemblyManager.AddSerializableType(uniqueName, this);
            Base   = GetBaseType(manager, type, arguments);
            Fields = CreateFields(manager, type, arguments);
        }
예제 #15
0
        /// <summary>
        /// Tries to add a tileset to the map drawer. Can fail if the texture is missing.
        /// </summary>
        /// <param name="tileset">The tileset that should be added.</param>
        /// <param name="error">An error if any occured.</param>
        /// <returns>Wheter the tileset was added or not.</returns>
        public bool TryAddTileset(Tileset tileset, out string error)
        {
            // If the tileset already exists, remove it first. This is done because the tileset might have updated
            // its texture.
            if (loadedTextures.ContainsKey(tileset) == true)
            {
                RemoveTileset(tileset);
            }

            if (MonoUtils.TryLoadTextureFromAbsolutePath(Stage.GraphicsDevice, tileset.imagePath, out Texture2D tex) == false)
            {
                error = "Could not find the image for the tileset " + tileset.name;
                return(false);
            }

            loadedTextures.Add(tileset, tex);
            error = null;
            return(true);
        }
예제 #16
0
    public void Update()
    {
        //Create a raycast and returns the distance between the origin and the collide point
        _ins[0] = MonoUtils.GetDistance(leftSensor.position, leftSensor.forward);
        _ins[1] = MonoUtils.GetDistance(rightSensor.position, rightSensor.forward);

        //Returns the percentage of the sensor between the minimalDistance and the maximalDistance,
        //if less than the minimal returns 0, it greater that the maximal returns 1, the idea is give
        //the neural net values between 0 and 1, is the only way it works
        _ins[0] = MathUtils.Range(0, 5, _ins[0]);
        _ins[1] = MathUtils.Range(0, 5, _ins[1]);

        //Check the neural net return value
        neuralNet.Calculate(_ins, out _outs);

        //Get the only value that in this case the neural net return
        //Check the MonoNeuralNet script in the gameobject IA in the
        //gameObject car and see where it specifies one
        float val = _outs[0];

        //Turns base in the the direction that the neural net says
        if (val < 0.2f)
        {
            transform.Rotate(0, (1 - MathUtils.Range(0, 0.2f, val)) *  -100 * Time.deltaTime, 0);
        }
        else if (val > 0.8f)
        {
            transform.Rotate(0, MathUtils.Range(0.8f, 1, val) * 100 * Time.deltaTime, 0);
        }

        /* USE THIS IF YOU WANT A NON SMOOTH TURN
         *
         * if (val < 0.2f)
         *  transform.Rotate(0, -100 * Time.deltaTime, 0);
         * else if (val > 0.8f)
         *  transform.Rotate(0, 100 * Time.deltaTime, 0);
         *
         */

        //Constant move forward
        transform.Translate(0, 0, 0.2f);
    }
예제 #17
0
        private static string GetNestedGenericName(TypeReference type, List <TypeReference> genericArguments)
        {
            string name = type.Name;

            if (type.HasGenericParameters)
            {
                name = GetGenericTypeName(type, genericArguments);
                int argumentCount = MonoUtils.GetGenericParameterCount(type);
                genericArguments.RemoveRange(genericArguments.Count - argumentCount, argumentCount);
            }
            if (type.IsNested)
            {
                string declaringName = GetNestedGenericName(type.DeclaringType, genericArguments);
                return($"{declaringName}.{name}");
            }
            else
            {
                return(name);
            }
        }
예제 #18
0
        IEnumerator LoadFilesData()
        {
            var info     = new DirectoryInfo(_dirPath);
            var fileInfo = info.GetFiles();

            foreach (var file in fileInfo)
            {
                if (!file.FullName.Contains(".json"))
                {
                    continue;
                }
                Debug.Log(file.FullName);
                var data            = File.ReadAllText(file.FullName);
                var objDownloadData = MonoUtils.ConvertToObjDownloadData(data);
                objDownloadData.Name = file.Name;
                GameEvents.OnDownloadDataFinished(objDownloadData);
            }
            yield return(null);

            GameEvents.OnFilesOpFinished();
        }
예제 #19
0
        /// <summary>
        /// Called when [UI loaded].
        /// </summary>
        /// <param name="objs">The objs.</param>
        private void OnceUILoaded(params object[] objs)
        {
            if (objs.Length == 0)
            {
                return;
            }

            if (!isUILoaded)
            {
                // FIX: This is called any time when the object is selected... So Gif will be loaded all the times that this object is reselected
                // Debug.Log("Loading gif UI (property drawer)!");

                // Fixed: If any exception occurs this will not continue executing
                isUILoaded = true;

                SerializedProperty property = objs[0] as SerializedProperty;
                string             path     = (string)objs[1];
                UniGif.GifFile     gif      = objs[2] as UniGif.GifFile;

                if (gif != null && gif.IsInitFlag == false)
                {
                    var mono = MonoUtils.FindExecutingInEditModeMonoBehaviour();
                    gif.Init(Path.GetFileNameWithoutExtension(path), mono, this);
                }

                isFoldout = property.isExpanded;
                validPath = CheckValidGif(path);

                if (validPath)
                {
                    if (gif == null)
                    {
                        Debug.LogException(new ArgumentNullException(nameof(gif), "Null gif passed!"));
                    }
                    gif?.UpdateFromPath(path, this);
                }
            }
        }
예제 #20
0
        public static string GetName(TypeReference type)
        {
            if (MonoType.IsCPrimitive(type))
            {
                return(MonoUtils.ToCPrimitiveString(type.Name));
            }

            if (type.IsGenericInstance)
            {
                GenericInstanceType generic = (GenericInstanceType)type;
                return(GetGenericInstanceName(generic));
            }
            else if (type.HasGenericParameters)
            {
                return(GetGenericTypeName(type));
            }
            else if (type.IsArray)
            {
                ArrayType array = (ArrayType)type;
                return(GetName(array.ElementType) + $"[{new string(',', array.Dimensions.Count - 1)}]");
            }
            return(type.Name);
        }
예제 #21
0
    public void Update()
    {
        //Create a raycast and returns the distance between the origin and the collide point
        _ins[0] = MonoUtils.GetDistance(leftSensor.position, leftSensor.forward);
        _ins[1] = MonoUtils.GetDistance(rightSensor.position, rightSensor.forward);

        //Returns the percentage of the sensor between the minimalDistance and the maximalDistance,
        //if less than the minimal returns 0, it greater that the maximal returns
        _ins[0] = MathUtils.Range(minimalDistance, maximalDistance, _ins[0]);
        _ins[1] = MathUtils.Range(minimalDistance, maximalDistance, _ins[1]);

        //If the sensors reaches 0, that means that the neural net doesnt return the correct value,
        //so we need to train in every hit so the next time wont fail, also relocates to the initial
        //position and stops the current update to prevent undesired behaviours
        if (_ins[0] == 0)
        {
            for (int i = 0; i < trainLoops; i++)
            {
                neuralNet.Train(_ins, new float[] { 1f });
            }

            transform.position = startPos;
            transform.rotation = startRot;
            return;
        }
        else if (_ins [1] == 0)
        {
            for (int i = 0; i < trainLoops; i++)
            {
                neuralNet.Train(_ins, new float[] { 0f });
            }

            transform.position = startPos;
            transform.rotation = startRot;
            return;
        }


        //Check the neural net return value
        neuralNet.Calculate(_ins, out _outs);


        //Get the only value that in this case the neural net return
        //Check the MonoNeuralNet script in the gameobject IA in the
        //gameObject car and see where it specifies one
        float val = _outs[0];

        //Turns base in the the direction that the neural net says
        if (val < 0.3f)
        {
            transform.Rotate(0, (1 - MathUtils.Range(0, 0.2f, val)) * -100 * Time.deltaTime, 0);
        }
        else if (val > 0.7f)
        {
            transform.Rotate(0, MathUtils.Range(0.8f, 1, val) * 100 * Time.deltaTime, 0);
        }

        /* USE THIS IF YOU WANT A NON SMOOTH TURN
         *
         * if (val < 0.2f)
         * transform.Rotate(0, -100 * Time.deltaTime, 0);
         * else if (val > 0.8f)
         * transform.Rotate(0, 100 * Time.deltaTime, 0);
         *
         */

        //Constant move forward
        transform.Translate(0, 0, 0.2f);
    }
예제 #22
0
    void DestructionHandler()
    {
        AudioClip clip = destructionSounds[Random.Range(0, destructionSounds.Length)];

        MonoUtils.PlayAudioClip(clip, transform.position, volume);
    }
예제 #23
0
        private static bool IsSerializableArray(TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            TypeReference resolvedType = type.ContainsGenericParameter ? MonoUtils.ResolveGenericParameter(type, arguments) : type;

            return(IsSerializableArray(resolvedType));
        }
예제 #24
0
        private IReadOnlyList <ScriptExportMethod> CreateMethods(IScriptExportManager manager)
        {
            if (Definition == null || Definition.BaseType == null || Definition.BaseType.Module == null)
            {
                return(Array.Empty <ScriptExportMethod>());
            }

            // we need to export only such properties that are declared as asbtract inside builin assemblies
            // and not overridden anywhere except current type
            List <MethodDefinition> overrides = new List <MethodDefinition>();

            foreach (MethodDefinition method in Definition.Methods)
            {
                if (method.IsVirtual && method.IsReuseSlot && !method.IsGetter && !method.IsSetter)
                {
                    overrides.Add(method);
                }
            }

            List <ScriptExportMethod> methods    = new List <ScriptExportMethod>();
            MonoTypeContext           context    = new MonoTypeContext(Definition);
            TypeDefinition            definition = Definition;

            while (true)
            {
                if (overrides.Count == 0)
                {
                    break;
                }
                if (definition.BaseType == null || definition.BaseType.Module == null)
                {
                    break;
                }

                context    = context.GetBase();
                definition = context.Type.Resolve();
                if (definition == null)
                {
                    break;
                }

                string module    = GetModuleName(definition);
                bool   isBuiltIn = ScriptExportManager.IsBuiltinLibrary(module);
                IReadOnlyDictionary <GenericParameter, TypeReference> arguments = context.GetContextArguments();
                // definition is a Template for GenericInstance, so we must recreate context
                MonoTypeContext definitionContext = new MonoTypeContext(definition, arguments);
                foreach (MethodDefinition method in definition.Methods)
                {
                    if (method.IsVirtual && (method.IsNewSlot || method.IsReuseSlot))
                    {
                        for (int i = 0; i < overrides.Count; i++)
                        {
                            MethodDefinition @override = overrides[i];
                            if (MonoUtils.AreSame(@override, definitionContext, method))
                            {
                                if (isBuiltIn && method.IsAbstract)
                                {
                                    ScriptExportMethod exportMethod = manager.RetrieveMethod(@override);
                                    methods.Add(exportMethod);
                                }

                                overrides.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
            }
            return(methods.ToArray());
        }
예제 #25
0
 private void Awake()
 {
     instance = this;
 }
예제 #26
0
        public static bool IsFieldTypeSerializable(MonoSerializableScope scope)
        {
            TypeReference fieldType = scope.FieldType;

            // if it's generic parameter then get its real type
            if (fieldType.IsGenericParameter)
            {
                GenericParameter parameter = (GenericParameter)fieldType;
                fieldType = scope.Arguments[parameter];
            }

            if (fieldType.IsArray)
            {
                ArrayType array = (ArrayType)fieldType;
                // one dimention array only
                if (!array.IsVector)
                {
                    return(false);
                }

                // if it's generic parameter then get its real type
                TypeReference elementType = array.ElementType;
                if (elementType.IsGenericParameter)
                {
                    GenericParameter parameter = (GenericParameter)elementType;
                    elementType = scope.Arguments[parameter];
                }

                // array of arrays isn't serializable
                if (elementType.IsArray)
                {
                    return(false);
                }
                // array of generics isn't serializable
                if (MonoType.IsSerializableGeneric(elementType))
                {
                    return(false);
                }
                // check if array element is serializable
                MonoSerializableScope elementScope = new MonoSerializableScope(scope.DeclaringType, elementType, true, scope.Arguments);
                return(IsFieldTypeSerializable(elementScope));
            }

            if (MonoType.IsList(fieldType))
            {
                // list is serialized same way as array, so check its argument
                GenericInstanceType list        = (GenericInstanceType)fieldType;
                TypeReference       listElement = list.GenericArguments[0];

                // if it's generic parameter then get its real type
                if (listElement.IsGenericParameter)
                {
                    GenericParameter parameter = (GenericParameter)listElement;
                    listElement = scope.Arguments[parameter];
                }

                // list of arrays isn't serializable
                if (listElement.IsArray)
                {
                    return(false);
                }
                // list of buildin generics isn't serializable
                if (MonoType.IsBuiltinGeneric(listElement))
                {
                    return(false);
                }
                // check if list element is serializable
                MonoSerializableScope elementScope = new MonoSerializableScope(scope.DeclaringType, listElement, true, scope.Arguments);
                return(IsFieldTypeSerializable(elementScope));
            }

            if (MonoUtils.IsSerializablePrimitive(fieldType))
            {
                return(true);
            }
            if (MonoType.IsString(fieldType))
            {
                return(true);
            }
            if (MonoType.IsEngineStruct(fieldType))
            {
                return(true);
            }
            if (MonoType.IsEnginePointer(fieldType))
            {
                return(true);
            }

            if (MonoType.IsObject(fieldType))
            {
                return(false);
            }
            if (fieldType.IsGenericInstance)
            {
                return(MonoType.IsSerializableGeneric(fieldType));
            }
            if (IsRecursive(scope.DeclaringType, fieldType))
            {
                return(scope.IsArrayElement);
            }

            TypeDefinition definition = fieldType.Resolve();

            if (definition.IsInterface)
            {
                return(false);
            }
            if (definition.IsAbstract)
            {
                return(false);
            }
            if (MonoType.IsCompilerGenerated(definition))
            {
                return(false);
            }
            if (definition.IsSerializable)
            {
                return(true);
            }
            if (definition.IsEnum)
            {
                return(true);
            }

            return(false);
        }