Ejemplo n.º 1
0
        private bool CheckGameAttributes(ref List <MelonGameAttribute> gameAttributes)
        {
            gameAttributes = new List <MelonGameAttribute>();
            MelonGameAttribute[] gameatt = MelonUtils.PullAttributesFromAssembly <MelonGameAttribute>(Assembly);
            if ((gameatt != null) && (gameatt.Length > 0))
            {
                gameAttributes.AddRange(gameatt);
            }

            // Legacy Support
            MelonModGameAttribute[] legacymodgameAttributes = MelonUtils.PullAttributesFromAssembly <MelonModGameAttribute>(Assembly);
            if ((legacymodgameAttributes != null) && (legacymodgameAttributes.Length > 0))
            {
                foreach (MelonModGameAttribute legacyatt in legacymodgameAttributes)
                {
                    gameAttributes.Add(legacyatt.Convert());
                }
            }
            MelonPluginGameAttribute[] legacyplugingameAttributes = MelonUtils.PullAttributesFromAssembly <MelonPluginGameAttribute>(Assembly);
            if ((legacyplugingameAttributes != null) && (legacyplugingameAttributes.Length > 0))
            {
                foreach (MelonPluginGameAttribute legacyatt in legacyplugingameAttributes)
                {
                    gameAttributes.Add(legacyatt.Convert());
                }
            }

            if (!MelonUtils.CurrentGameAttribute.Universal && (gameAttributes.Count > 0))
            {
                bool is_compatible = false;
                for (int i = 0; i < gameAttributes.Count; i++)
                {
                    MelonGameAttribute melonGameAttribute = gameAttributes[i];
                    if (melonGameAttribute == null)
                    {
                        continue;
                    }
                    if (melonGameAttribute.Universal || MelonUtils.CurrentGameAttribute.IsCompatible(melonGameAttribute))
                    {
                        is_compatible = true;
                        break;
                    }
                }
                if (!is_compatible)
                {
                    MelonLogger.Error($"Incompatible Game for {(is_plugin ? "Plugin" : "Mod")}: {FilePath}");
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool CheckGameVersionAttribute()
        {
            if (!is_plugin) // Temporarily Skip this Check for Plugins
            {
                return(true);
            }

            List <MelonGameVersionAttribute> gameVersionAttributes = MelonUtils.PullAttributesFromAssembly <MelonGameVersionAttribute>(Assembly).ToList();

            if (gameVersionAttributes.Count <= 0)
            {
                return(true);
            }

            string game_version  = GameVersionHandler.Version;
            bool   is_compatible = false;

            for (int i = 0; i < gameVersionAttributes.Count; i++)
            {
                MelonGameVersionAttribute melonGameVersionAttribute = gameVersionAttributes[i];
                if (melonGameVersionAttribute == null)
                {
                    continue;
                }

                if (melonGameVersionAttribute.Universal ||
                    game_version.Equals(melonGameVersionAttribute.Version))
                {
                    is_compatible = true;
                    break;
                }
            }
            if (!is_compatible)
            {
                //MelonLogger.Error($"Incompatible Game Version for {(is_plugin ? "Plugin" : "Mod")}: {FilePath}");
                MelonLogger.Error($"Incompatible Game Version for Mod: {FilePath}");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private bool CheckProcessAttributes()
        {
            List <MelonProcessAttribute> processAttributes = MelonUtils.PullAttributesFromAssembly <MelonProcessAttribute>(Assembly).ToList();

            if (processAttributes.Count <= 0)
            {
                return(true);
            }

            string current_exe_path        = Process.GetCurrentProcess().MainModule.FileName;
            string current_exe_name        = Path.GetFileName(current_exe_path);
            string current_exe_name_no_ext = Path.GetFileNameWithoutExtension(current_exe_path);

            bool is_compatible = false;

            for (int i = 0; i < processAttributes.Count; i++)
            {
                MelonProcessAttribute melonProcessAttribute = processAttributes[i];
                if (melonProcessAttribute == null)
                {
                    continue;
                }

                if (melonProcessAttribute.Universal ||
                    current_exe_name.Equals(melonProcessAttribute.EXE_Name) ||
                    current_exe_name_no_ext.Equals(melonProcessAttribute.EXE_Name))
                {
                    is_compatible = true;
                    break;
                }
            }
            if (!is_compatible)
            {
                MelonLogger.Error($"Incompatible Process Executable for {(is_plugin ? "Plugin" : "Mod")}: {FilePath}");
                return(false);
            }

            return(true);
        }