Beispiel #1
0
        // Token: 0x06000411 RID: 1041 RVA: 0x00018CDC File Offset: 0x00016EDC
        public static void Postfix(Building_ResearchBench bench, bool ignoreResearchBenchPowerStatus,
                                   ResearchProjectDef __instance, ref bool __result)
        {
            if (__result)
            {
                return;
            }

            if (__instance.requiredResearchBuilding != ThingDef.Named("HiTechResearchBench"))
            {
                return;
            }

            var researchExtension = bench.def.GetModExtension <DefModExt_HighTechResearchBench>();

            if (researchExtension == null)
            {
                return;
            }

            if (!researchExtension.IsHighTechResearchBench)
            {
                return;
            }

            if (!ignoreResearchBenchPowerStatus)
            {
                var comp = bench.GetComp <CompPowerTrader>();
                if (comp != null && !comp.PowerOn)
                {
                    return;
                }
            }

            if (!__instance.requiredResearchFacilities.NullOrEmpty())
            {
                var affectedByFacilities = bench.TryGetComp <CompAffectedByFacilities>();
                if (affectedByFacilities == null)
                {
                    return;
                }

                var linkedFacilitiesListForReading = affectedByFacilities.LinkedFacilitiesListForReading;
                int j;
                int i;
                for (i = 0; i < __instance.requiredResearchFacilities.Count; i = j + 1)
                {
                    if (linkedFacilitiesListForReading.Find(x =>
                                                            x.def == __instance.requiredResearchFacilities[i] &&
                                                            affectedByFacilities.IsFacilityActive(x)) == null)
                    {
                        return;
                    }

                    j = i;
                }
            }

            __result = true;
        }
Beispiel #2
0
 public bool CanBeResearchedAt(Building_ResearchBench bench, bool ignoreResearchBenchPowerStatus)
 {
     if (this.requiredResearchBuilding != null && bench.def != this.requiredResearchBuilding)
     {
         return(false);
     }
     if (!ignoreResearchBenchPowerStatus)
     {
         CompPowerTrader comp = bench.GetComp <CompPowerTrader>();
         if (comp != null && !comp.PowerOn)
         {
             return(false);
         }
     }
     if (!this.requiredResearchFacilities.NullOrEmpty <ThingDef>())
     {
         CompAffectedByFacilities affectedByFacilities = bench.TryGetComp <CompAffectedByFacilities>();
         if (affectedByFacilities == null)
         {
             return(false);
         }
         List <Thing> linkedFacilitiesListForReading = affectedByFacilities.LinkedFacilitiesListForReading;
         int          i;
         for (i = 0; i < this.requiredResearchFacilities.Count; i++)
         {
             if (linkedFacilitiesListForReading.Find((Thing x) => x.def == this.requiredResearchFacilities[i] && affectedByFacilities.IsFacilityActive(x)) == null)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Beispiel #3
0
        public static bool CanBeResearchedAt_Prefix(ref bool __result, ResearchProjectDef __instance, Building_ResearchBench bench, bool ignoreResearchBenchPowerStatus)
        {
            //不是幽能工作台不处理
            if (bench.def != Resources.ThingDefs.VoidEnergyResearchBench)
            {
                return(true);
            }
            //只允许幽能研究台研究幽能科技
            if (__instance.requiredResearchBuilding != null && bench.def != __instance.requiredResearchBuilding)
            {
                __result = false;
                return(false);
            }
            Comp.VoidNetPort comp = bench.GetComp <Comp.VoidNetPort>();
            if (comp != null && !comp.PowerOn)
            {
                __result = false;
                return(false);
            }

            if (!__instance.requiredResearchFacilities.NullOrEmpty())
            {
                CompAffectedByFacilities affectedByFacilities = bench.TryGetComp <CompAffectedByFacilities>();
                if (affectedByFacilities == null)
                {
                    __result = false;
                    return(false);
                }
                List <Thing> linkedFacilitiesListForReading = affectedByFacilities.LinkedFacilitiesListForReading;
                foreach (ThingDef item in __instance.requiredResearchFacilities)
                {
                    if (linkedFacilitiesListForReading.Find((Thing x) => x.def == item && affectedByFacilities.IsFacilityActive(x)) == null)
                    {
                        __result = false;
                        return(false);
                    }
                }
            }
            __result = true;
            return(false);
        }
Beispiel #4
0
 public static void Postfix(ResearchProjectDef __instance, Building_ResearchBench bench, bool ignoreResearchBenchPowerStatus, ref bool __result)
 {
     if (!__result)
     {
         if ((__instance.requiredResearchBuilding == AdeptusThingDefOf.HiTechResearchBench && bench.def.defName.Contains("HiTechResearchBench")) || (__instance.requiredResearchBuilding == AdeptusThingDefOf.SimpleResearchBench && bench.def.defName.Contains("ResearchBench")))
         {
             if (raceTableFor(bench, __instance))
             {
                 if (!ignoreResearchBenchPowerStatus)
                 {
                     CompPowerTrader comp = bench.TryGetCompFast <CompPowerTrader>();
                     if (comp != null && !comp.PowerOn)
                     {
                         return;
                     }
                 }
                 if (!__instance.requiredResearchFacilities.NullOrEmpty())
                 {
                     CompAffectedByFacilities affectedByFacilities = bench.TryGetComp <CompAffectedByFacilities>();
                     if (affectedByFacilities == null)
                     {
                         return;
                     }
                     List <Thing> linkedFacilitiesListForReading = affectedByFacilities.LinkedFacilitiesListForReading;
                     int          i;
                     for (i = 0; i < __instance.requiredResearchFacilities.Count; i++)
                     {
                         if (linkedFacilitiesListForReading.Find((Thing x) => x.def == __instance.requiredResearchFacilities[i] && affectedByFacilities.IsFacilityActive(x)) == null)
                         {
                             return;
                         }
                     }
                 }
                 __result = true;
             }
         }
     }
 }