/// <summary> /// Do patching and checks various parameters of the game. /// </summary> public static void CheckAll() { LanguageWorkerPatcher.DoPatching(); LoadedLanguage active = LanguageDatabase.activeLanguage; LanguageWorkerPatcher.LogMessage("Active: " + active.FriendlyNameEnglish + " (" + active.folderName + ") " + active.Worker.GetType()); foreach (LoadedLanguage l in LanguageDatabase.AllLoadedLanguages) { if (LanguageWorkerPatcher.IsTargetLanguage(l.FriendlyNameEnglish)) { LanguageWorkerPatcher.LogMessage("Other: " + l.FriendlyNameEnglish + " (" + l.folderName + ") " + l.info.languageWorkerClass); } } }
static void Postfix(GrammarRequest __result) { #if DEBUG LanguageWorkerPatcher.LogMessage("--InspectionPatch called..."); LanguageWorkerPatcher.LogMessage("result: " + __result); foreach (Rule r in __result.Rules) { LanguageWorkerPatcher.LogMessage(r.ToString()); } LanguageWorkerPatcher.LogMessage("constants: " + __result.Constants); if (__result.Constants != null) { foreach (var c in __result.Constants) { LanguageWorkerPatcher.LogMessage(c.Key + "=" + c.Value); } } #endif }
static bool RulesForDefPrefix(ref IEnumerable <Rule> __result, string prefix, Def def) { // if the current language is not the target, do nothing if (!LanguageWorkerPatcher.IsTargetLanguage(LanguageDatabase.activeLanguage.FriendlyNameEnglish)) { return(true); } // Rewrite the method entirely since it is short enough __result = LanguageWorker_Spanish.FixRulesForDef(prefix, def); #if DEBUG LanguageWorkerPatcher.LogMessage("--RulesForDefPrefix called..."); LanguageWorkerPatcher.LogMessage("result: " + __result); foreach (Rule r in __result) { LanguageWorkerPatcher.LogMessage(r.ToString()); } #endif // DO NOT CONTINUE to the original GrammarUtility.RulesforPawn return(false); }
static bool GetWorkerPrefix(LoadedLanguage __instance, ref LanguageWorker ___workerInt) { // if the current language is not the target, do nothing if (!LanguageWorkerPatcher.IsTargetLanguage(__instance.FriendlyNameEnglish)) { return(true); } Type myType = typeof(RimWorld_LanguageWorker_Spanish.LanguageWorker_Spanish); if (__instance.info.languageWorkerClass != myType) { // overwrite all target language worker class __instance.info.languageWorkerClass = myType; if (___workerInt != null && ___workerInt.GetType() != myType) { ___workerInt = (LanguageWorker_Spanish)Activator.CreateInstance(myType); } } // continue to original method return(true); }