public bool AnyActiveDeepScannersOnMap() { foreach (Building item in map.listerBuildings.allBuildingsColonist) { CompDeepScanner compDeepScanner = item.TryGetComp <CompDeepScanner>(); if (compDeepScanner != null && compDeepScanner.ShouldShowDeepResourceOverlay()) { return(true); } } return(false); }
public void DeepResourcesOnGUI() { Thing singleSelectedThing = Find.Selector.SingleSelectedThing; if (singleSelectedThing != null) { CompDeepScanner compDeepScanner = singleSelectedThing.TryGetComp <CompDeepScanner>(); CompDeepDrill compDeepDrill = singleSelectedThing.TryGetComp <CompDeepDrill>(); if ((compDeepScanner != null || compDeepDrill != null) && AnyActiveDeepScannersOnMap()) { RenderMouseAttachments(); } } }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) { if (Find.CurrentMap is Map map && map.GetComponent <BetharianDeposits>() is BetharianDeposits betharianDeposits && BetharianDefOf.BetharianScanning.IsFinished) { List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count; i++) { Building thing2 = allBuildingsColonist[i]; CompDeepScanner compDeepScanner = thing2.TryGetComp <CompDeepScanner>(); if (compDeepScanner != null) { CompPowerTrader compPowerTrader = thing2.TryGetComp <CompPowerTrader>(); if (compPowerTrader == null || compPowerTrader.PowerOn) { betharianDeposits.MarkForDraw(); break; } } } } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { if (map.GetComponent <BetharianDeposits>() is BetharianDeposits betharianDeposits && BetharianDefOf.BetharianScanning.IsFinished) { List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count; i++) { Building thing2 = allBuildingsColonist[i]; CompDeepScanner compDeepScanner = thing2.TryGetComp <CompDeepScanner>(); if (compDeepScanner != null) { CompPowerTrader compPowerTrader = thing2.TryGetComp <CompPowerTrader>(); if (compPowerTrader == null || compPowerTrader.PowerOn) { //Check Betharian stone coverage. CellRect occupiedRect = GenAdj.OccupiedRect(loc, rot, checkingDef.Size); int area = occupiedRect.Width * occupiedRect.Height; int coveredArea = 0; foreach (IntVec3 cell in occupiedRect) { if (betharianDeposits.grid.StrengthAt(cell) > 0) { coveredArea++; } } if (coveredArea >= area) { return(AcceptanceReport.WasAccepted); } break; } } } } return(AcceptanceReport.WasRejected); }
//public override void PostDrawExtraSelectionOverlays() public static bool Prefix(CompDeepScanner __instance) { //no need to check powerComp.PowerOn, just draw what was previously scanned. __instance.parent.Map.deepResourceGrid.MarkForDraw(); return(false); }