/// <summary> /// Initializes a new instance of the <see cref="QModPatchAttributeBase" /> class. /// </summary> /// <param name="patchOrder">The patch order.</param> /// <param name="secretPasword">The secret pasword.</param> /// <exception cref="FatalPatchingException">This modder has not read the documentation and should not be using prepatch/postpatch functions.</exception> internal QModPatchAttributeBase(PatchingOrder patchOrder, string secretPasword) : this(patchOrder) { if (string.IsNullOrEmpty(secretPasword)) { throw new FatalPatchingException("This modder has not read the documentation and should not be using prepatch/postpatch functions."); } _secretPasword = secretPasword; }
internal void InitializeMods(List<QMod> modsToInitialize, PatchingOrder order) { foreach (QMod mod in modsToInitialize) { if (mod.Status != ModStatus.Success) continue; if (mod.IsLoaded) continue; if ((mod.SupportedGame & currentGame) == QModGame.None) { mod.PatchMethods.Clear(); // Do not attempt any other patch methods mod.Status = ModStatus.CurrentGameNotSupported; continue; } if(!mod.NitroxCompat && NitroxCheck.IsRunning) { mod.PatchMethods.Clear(); // Do not attempt any other patch methods mod.Status = ModStatus.NitroxIncompatible; continue; } if (!mod.PatchMethods.TryGetValue(order, out QModPatchMethod patchMethod)) continue; // Nothing to patch at this stage if (patchMethod.IsPatched) { mod.Status = ModStatus.DuplicatePatchAttemptDetected; continue; } Logger.Debug($"Starting patch method for mod \"{mod.Id}\" at {order}"); if (!patchMethod.TryInvoke()) { mod.PatchMethods.Clear(); // Do not attempt any other patch methods mod.Status = ModStatus.PatchMethodFailed; continue; } Logger.Debug($"Completed patch method for mod \"{mod.Id}\" at {order}"); } }
/// <summary> /// Initializes a new instance of the <see cref="QModPatchAttributeBase"/> class. /// </summary> /// <param name="patchOrder">The patch order.</param> internal QModPatchAttributeBase(PatchingOrder patchOrder) { this.PatchOrder = patchOrder; }
internal QModPatchMethod(MethodInfo method, QMod qmod, PatchingOrder order) { this.Method = method; this.Origin = qmod; this.Order = order; }