public static bool Prefix(ref bool __result, ResearchProjectDef __instance) { if (__instance.HasModExtension <CompleteTechLevelPrereq>()) { //Log.Message("Technology Blueprints :: PrerequisitesCompleted HasModExtension " + __instance); List <ResearchProjectDef> unfinishedProjects = DefDatabase <ResearchProjectDef> .AllDefsListForReading .FindAll((ResearchProjectDef x) => x.techLevel == __instance.GetModExtension <CompleteTechLevelPrereq>().techLevel && !x.HasModExtension <CompleteTechLevelPrereq>() && !x.IsFinished); if (unfinishedProjects.NullOrEmpty()) { __result = true; return(false); } else { //Log.Message("Technology Blueprints :: unfinished techs = " + unfinishedProjects.Join(null, ", ")); __result = false; return(false); } } return(true); }
public static void Postfix(ResearchProjectDef __instance, ref bool __result) { if (__instance.HasModExtension <AnyPrerequisiteResearchExtension>()) { AnyPrerequisiteResearchExtension ext = __instance.GetModExtensionFast <AnyPrerequisiteResearchExtension>(); if (!ext.RequiredResearch.NullOrEmpty()) { if (ext.AnyRequiredResearchCompleted) { List <ResearchProjectDef> reqs = new List <ResearchProjectDef>(); if (!__instance.prerequisites.NullOrEmpty()) { reqs.AddRange(__instance.prerequisites); } if (!__instance.hiddenPrerequisites.NullOrEmpty()) { reqs.AddRange(__instance.hiddenPrerequisites); } if (!reqs.NullOrEmpty()) { __result = __result || !reqs.Any(x => !x.IsFinished && !ext.RequiredResearch.Contains(x)); } } /* * else * { * __result = false; * } */ } } }
public static bool Prefix(ref bool __result, object __instance) { ResearchProjectDef research = AccessTools.Field(__instance.GetType(), "Research").GetValue(__instance) as ResearchProjectDef; bool hasExtension = research.HasModExtension <CompleteTechLevelPrereq>(); if (hasExtension) { //Log.Message("Technology Blueprints Rsearch Pal/Tree patch :: " + research + ", divert to PrerequisitesCompleted patch"); __result = research.PrerequisitesCompleted; return(false); } return(true); }
public static bool Prefix(MainTabWindow_Research __instance, ResearchProjectDef project, Rect rect, ref float __result) { if (project.HasModExtension <AnyPrerequisiteResearchExtension>()) { AnyPrerequisiteResearchExtension ext = project.GetModExtensionFast <AnyPrerequisiteResearchExtension>(); if (project.prerequisites.NullOrEmpty <ResearchProjectDef>() && ext.RequiredResearch.NullOrEmpty()) { return(true); } float xMin = rect.xMin; float yMin = rect.yMin; Widgets.LabelCacheHeight(ref rect, "ResearchPrerequisites".Translate() + ":", true, false); rect.yMin += rect.height; rect.xMin += 6f; for (int i = 0; i < project.prerequisites.Count; i++) { SetPrerequisiteStatusColor(project.prerequisites[i].IsFinished, project); Widgets.LabelCacheHeight(ref rect, project.prerequisites[i].LabelCap, true, false); rect.yMin += rect.height; } GUI.color = Color.white; Widgets.LabelCacheHeight(ref rect, "and ONE of the following" + ":", true, false); rect.yMin += rect.height; rect.xMin += 6f; if (ext.RequiredResearch != null) { for (int j = 0; j < ext.RequiredResearch.Count; j++) { SetPrerequisiteStatusColor(ext.RequiredResearch[j].IsFinished, project); Widgets.LabelCacheHeight(ref rect, ext.RequiredResearch[j].LabelCap, true, false); rect.yMin += rect.height; } } GUI.color = Color.white; rect.xMin = xMin; __result = rect.yMin - yMin; return(false); } return(true); }