Beispiel #1
0
 public AMMod(ModContentPack content) : base(content)
 {
     this.settings         = GetSettings <AMSettings>();
     SettingsHelper.latest = this.settings;
     AMMod.Instance        = this;
     AMSettings.Instance   = base.GetSettings <AMSettings>();
 }
Beispiel #2
0
        public AMAMod(ModContentPack content) : base(content)
        {
            Instance = this;
            settings = GetSettings <AMSettings>();
            harmony.PatchAll(Assembly.GetExecutingAssembly());
            HarmonyPatches.PatchPawnsArrivalModeWorker(harmony);
            if (AdeptusIntergrationUtility.enabled_ResearchPal)
            {
                //    harmony.Patch(AccessTools.Method(GenTypes.GetTypeInAnyAssembly("ResearchPal.Tree", "ResearchPal"), "DrawEquipmentAimingPostFix", null, null), new HarmonyMethod(typeof(AM_ResearchProjectDef_get_PrerequisitesCompleted_CommonTech_ResearchPal_Patch), "Postfix", null));
            }
            showArmouryIntergrationMenu = !Patches.NullOrEmpty() || (AdeptusIntergrationUtility.enabled_AlienRaces && Dev);
            if (!Patches.NullOrEmpty())
            {
                IntergrationOptions = (int)Mathf.Round((Patches.Count / 2) + 0.25f);
                var allPatches = content.Patches as List <PatchOperation>;
                foreach (var patch in Patches)
                {
                    if (patch.optional)
                    {
                        if (settings.PatchDisabled[patch] == false)
                        {
                            if (Prefs.DevMode)
                            {
                                Log.Message("RemoveAll XML Patch: " + patch.label);
                            }
                            allPatches.RemoveAll(p => p.sourceFile.EndsWith(patch.file));
                        }
                        else
                        {
                            if (Prefs.DevMode)
                            {
                                Log.Message("Running XML Patch: " + patch.label);
                            }
                        }
                    }
                }
            }

            if (AdeptusIntergrationUtility.enabled_rooloDualWield)
            {
                string     tname  = "DualWield.Ext_Pawn";
                string     nspace = "DualWield";
                string     mname  = "TryStartOffHandAttack";
                MethodInfo target = AccessTools.Method(GenTypes.GetTypeInAnyAssembly(tname, nspace), mname, null, null);
                if (target == null)
                {
                    Log.Warning("Target: " + tname + "." + mname + " Not found");
                }
                else
                {
                    Type       t      = typeof(Ext_Pawn_TryStartOffHandAttack_DualWield_Patch);
                    string     pmname = "Prefix";
                    MethodInfo patch  = t.GetMethod(pmname);
                    if (patch == null)
                    {
                        Log.Warning("Patch is null " + t.Name.ToString() + "." + pmname);
                    }
                    else
                    {
                        // JobDriver_AttackStatic
                        if (harmony.Patch(target, new HarmonyMethod(patch)) == null)
                        {
                            Log.Warning("AdeptusMechanicus.ModName".Translate() + ": " + tname + " Patch Failed to apply");
                        }
                    }
                }
            }

            listing_Main = new Listing_StandardExpanding();
            if (Prefs.DevMode)
            {
                Log.Message(string.Format("Adeptus Mecanicus: Armoury: successfully completed {0} harmony patches.", harmony.GetPatchedMethods().Select(new Func <MethodBase, Patches>(Harmony.GetPatchInfo)).SelectMany((Patches p) => p.Prefixes.Concat(p.Postfixes).Concat(p.Transpilers)).Count((Patch p) => p.owner.Contains(harmony.Id))));
            }
        }