Beispiel #1
0
        public static int HarmonyComparison(PluginInfo p1, PluginInfo p2)
        {
            var savedOrder1 = p1.GetLoadOrder();
            var savedOrder2 = p2.GetLoadOrder();

            // orderless harmony comes first
            if (!p1.HasLoadOrder() && p1.IsHarmonyMod())
            {
                return(-1);
            }
            if (!p2.HasLoadOrder() && p2.IsHarmonyMod())
            {
                return(+1);
            }

            if (!p1.HasLoadOrder() && !p2.HasLoadOrder())
            {
                // if neither have saved order,
                {
                    // 1st: harmony mod
                    // 2nd: harmony 2
                    // 3rd: harmony 1
                    // 4th: no harmony
                    var o1 = GetHarmonyOrder(p1);
                    var o2 = GetHarmonyOrder(p2);
                    if (o1 != o2)
                    {
                        return(o1 - o2);
                    }
                }
                {
Beispiel #2
0
        public static int OldComparison(PluginInfo p1, PluginInfo p2)
        {
            var savedOrder1 = p1.GetLoadOrder();
            var savedOrder2 = p2.GetLoadOrder();

            // orderless harmony comes first
            if (!p1.HasLoadOrder() && p1.IsHarmonyMod())
            {
                return(-1);
            }
            if (!p2.HasLoadOrder() && p2.IsHarmonyMod())
            {
                return(+1);
            }

            // if neither have order, use string comparison
            // then built-in first, workshop second, local last
            // otherwise use string comparison
            if (!p1.HasLoadOrder() && !p2.HasLoadOrder())
            {
                int order(PluginInfo _p) =>
                _p.isBuiltin ? 0 :
                (_p.publishedFileID != PublishedFileId.invalid ? 1 : 2);

                if (order(p1) != order(p2))
                {
                    return(order(p1) - order(p2));
                }
                return(p1.name.CompareTo(p2.name));
            }

            // use assigned or default values
            return(savedOrder1 - savedOrder2);
        }
Beispiel #3
0
 /// <returns>
 /// harmony mod : 2.0.1.0+
 /// harmony 2 : 2.0.0.0
 /// harmony 1 : 1.*
 /// no harmony : 0
 /// </returns>
 public static int GetHarmonyOrder(PluginInfo p)
 {
     if (p.IsHarmonyMod())
     {
         return(0);
     }
     foreach (var asm in p.GetAssemblies())
     {
         var name = asm.GetName().Name;
         if (name == "CitiesHarmony.API")
         {
             return(1);
         }
         if (name == "0Harmony")
         {
             return(2);
         }
     }
     return(3);
 }