Esempio n. 1
0
        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;
                     * }
                     */
                }
            }
        }
Esempio n. 2
0
 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);
 }