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); }
// 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; }
public bool GetTarget(IntVec3 pos, Rot4 rot, bool spawned = false) { Building_WorkTable new_my_workTable = (Building_WorkTable)(pos + rot.FacingCell).GetThingList(Map) .Where(t => t.def.category == ThingCategory.Building) .Where(t => t is Building_WorkTable) .Where(t => t.InteractionCell == this.Position).FirstOrDefault(); Building new_drilltypeBuilding = (Building)(pos + rot.FacingCell).GetThingList(Map) .Where(t => t.def.category == ThingCategory.Building) .Where(t => t is Building && t.TryGetComp <CompDeepDrill>() != null) .Where(t => t.InteractionCell == this.Position).FirstOrDefault(); Building_ResearchBench new_researchBench = (Building_ResearchBench)(pos + rot.FacingCell).GetThingList(Map) .Where(t => t.def.category == ThingCategory.Building) .Where(t => t is Building_ResearchBench) .Where(t => t.InteractionCell == this.Position).FirstOrDefault(); if (spawned && ((my_workTable != null && new_my_workTable == null) || (researchBench != null && new_researchBench == null) || (drilltypeBuilding != null && new_drilltypeBuilding == null))) { FreeTarget(); } my_workTable = new_my_workTable; drilltypeBuilding = new_drilltypeBuilding; researchBench = new_researchBench; if (spawned && ValidTarget) { ReserveTraget(); } return(ValidTarget); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { ResearchProjectDef currentProj = Find.ResearchManager.currentProj; if (currentProj == null) { return(false); } // --- new code --- if (!Find.ResearchManager.currentProj.HasModExtension <ForbiddenResearchExtension>() && t.def.defName == "Cults_OccultResearchBench") { return(false); } // --- -------- --- Building_ResearchBench building_ResearchBench = t as Building_ResearchBench; if (building_ResearchBench == null) { return(false); } if (!currentProj.CanBeResearchedAt(building_ResearchBench, ignoreResearchBenchPowerStatus: false)) { return(false); } if (!pawn.CanReserve(t, 1, -1, null, forced)) { return(false); } return(true); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_ResearchBench Desk = t as Building_ResearchBench; if (Desk != null && pawn.CanReserve(t, 1, -1, null, forced)) { CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>(); bool result = techComp.homework.Any(x => !x.IsFinished && x.CanBeResearchedAt(Desk, false) && !x.IsKnownBy(pawn) && x.RequisitesKnownBy(pawn)); return(result); } return(false); }
public static bool HasFacility(this Building_ResearchBench building, ThingDef facility) { CompAffectedByFacilities comp = building.GetComp <CompAffectedByFacilities>(); if (comp == null) { return(false); } if (comp.LinkedFacilitiesListForReading.Select(f => f.def).Contains(facility)) { return(true); } return(false); }
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>()) { ResearchProjectDef.< CanBeResearchedAt > c__AnonStorey2 <CanBeResearchedAt> c__AnonStorey = new ResearchProjectDef.< CanBeResearchedAt > c__AnonStorey2();
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; } } } }
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); }
private void ResolveNonOccultProjects() { //First, declare our variables. ResearchProjectDef currentProject = Find.ResearchManager.currentProj; Pawn interactingPawn = InteractingPawn; if (currentProject == null) { return; } if (interactingPawn == null) { return; } if (Find.World.GetComponent <WorldComponent_GlobalCultTracker>().cultResearch == null) { return; } //Are we using this for the correct project type? this.SetForbidden(false); if (IsThisCultistResearch(currentProject)) { return; } this.SetForbidden(true); //Uh oh. //Let's try and find another research station to research this at. Building_ResearchBench bench = null; foreach (Building bld in Map.listerBuildings.allBuildingsColonist) { if (bld != this && bld.def != this.def) { if (bld is Building_ResearchBench) { bench = bld as Building_ResearchBench; } } } //No building found? Cancel the research projects. if (bench == null) { CancelResearch("Cannot use the grimoire to research standard research projects."); return; } //We found a research bench! Can we send the researcher there? if (!currentProject.CanBeResearchedAt(bench, false)) { CancelResearch("Cannot research this project at the forbidden center."); } if (!interactingPawn.CanReach(bench, Verse.AI.PathEndMode.ClosestTouch, Danger.Deadly)) { CancelResearch("Cannot research this project at the forbidden center."); } if (!interactingPawn.CanReserve(bench)) //Map.reservationManager.IsReserved(bench, Faction.OfPlayer)) { this.SetForbidden(true); interactingPawn.jobs.EndCurrentJob(JobCondition.InterruptForced); return; } //Okay, assign a job over there instead of here. Job J = new Job(JobDefOf.Research, bench); Map.reservationManager.ReleaseAllClaimedBy(interactingPawn); interactingPawn.jobs.TryTakeOrderedJob(J); //interactingpawn.CurJob.EndCurrentJob(JobCondition.InterruptForced); }
static bool raceTableFor(Building_ResearchBench bench, ResearchProjectDef def) { string tag = "OG"; List <string> Tags = new List <string>(); List <string> split = def.defName.Split(new char[] { '_' }).ToList(); if (split.NullOrEmpty()) { return(bench.def.defName.StartsWith("OG") && bench.def.defName.EndsWith("_" + def.requiredResearchBuilding.defName)); } if (split.Count > 1) { string race = split[1]; switch (race) { case "Imperial": Tags.Add(tag + "I"); break; case "Astartes": Tags.Add(tag + "AA"); Tags.Add(tag + "I"); break; case "Mechanicus": Tags.Add(tag + "AM"); break; case "Militarum": Tags.Add(tag + "I"); break; case "Sororitas": Tags.Add(tag + "I"); Tags.Add(tag + "AS"); break; case "Eldar": Tags.Add(tag + "E"); break; case "DarkEldar": Tags.Add(tag + "DE"); break; case "Aeldari": Tags.Add(tag + "DE"); Tags.Add(tag + "E"); break; case "Tau": Tags.Add(tag + "T"); break; case "Kroot": Tags.Add(tag + "T"); Tags.Add(tag + "K"); break; case "Vespid": Tags.Add(tag + "T"); Tags.Add(tag + "V"); break; case "Ork": Tags.Add(tag + "O"); break; case "Necron": Tags.Add(tag + "N"); break; case "Tyranid": Tags.Add(tag + "TY"); break; default: return(bench.def.defName.StartsWith("OG") && bench.def.defName.EndsWith("_" + def.requiredResearchBuilding.defName)); } } else { Tags.Add(tag); } if (!Tags.NullOrEmpty()) { for (int i = 0; i < Tags.Count; i++) { if (bench.def.defName.StartsWith(Tags[i] + (split.Count > 1 ? "_":""))) { return(true); } } } return(false); }