public static bool PreFix(ref CompDeepDrill __instance, ref CompPowerTrader ___powerComp, ref float ___portionProgress, ref float ___portionYieldPct, ref int ___lastUsedTick, Pawn driller) { if (driller.CurJob == null) { return(true); } var wbJob = driller.CurJob; if (driller.CurJob.def.defName != "OperateWideBoy") { return(true); } var powerFactor = 1f; if (wbJob.targetA.HasThing) { var basePower = ___powerComp.Props.basePowerConsumption; if (basePower > 0f) { powerFactor = Math.Max(0f, -1f * (___powerComp.PowerOutput / basePower)); } } var statValue = driller.GetStatValue(StatDefOf.MiningSpeed) * powerFactor; ___portionProgress += statValue; ___portionYieldPct += statValue * driller.GetStatValue(StatDefOf.MiningYield) / (10000f / Find.Storyteller.difficulty.mineYieldFactor); ___lastUsedTick = Find.TickManager.TicksGame; if (wbJob.targetA.HasThing) { var compWideBoy = wbJob.targetA.Thing.TryGetComp <CompWideBoy>(); if (compWideBoy != null) { compWideBoy.lastDriller = driller.thingIDNumber; } } if (!(___portionProgress > 10000f / Find.Storyteller.difficulty.mineYieldFactor)) { return(false); } AccessTools.Method(typeof(CompDeepDrill), "TryProducePortion", new[] { typeof(float), typeof(Pawn) }).Invoke(__instance, new object[] { ___portionYieldPct, driller }); ___portionProgress = 0f; ___portionYieldPct = 0f; return(false); }
public static bool Prefix(CompDeepDrill __instance, ref bool __result) { if (!Analyzer.Settings.OptimizeDrills) { return(true); } __result = (__instance.powerComp == null || __instance.powerComp.PowerOn) && (__instance.parent.Map.Biome.hasBedrock || __instance.ValuableResourcesPresent()); 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 bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { public static bool Prefix(ref bool __result, Pawn pawn, Thing t, bool forced = false) { if (!Settings.Get().qualityMining || forced) { return(true); } CompDeepDrill comp = t.TryGetComp <CompDeepDrill>(); if (!comp?.ValuableResourcesPresent() ?? false) { return(true); } if (!WorkGiver_Miner_JobOnThing_Patch.IsGoodMiner(pawn, typeof(WorkGiver_DeepDrill))) { __result = false; return(false); } return(true); }
public static bool Prefix(ref ThingDef resDef, ref int countPresent, ref IntVec3 cell, CompDeepDrill __instance, bool __result) { if (__instance.parent.def.defName == "MrXuiryus_CoalDrill") { resDef = ThingDef.Named("MrXuiryus_Coal"); countPresent = 75; __result = true; return(false); } else if (__instance.parent.def.defName == "MrXuiryus_BrassDrill") { resDef = ThingDef.Named("MrXuiryus_Brass"); countPresent = 75; __result = true; return(false); } return(true); }
public static void Postfix(CompDeepDrill __instance) { Log.Message(__instance.ResourcesPresent() + ""); }
public static void Clear(CompDeepDrill ddComp) { Log.Message($"Removing Deep Drill {ddComp.parent.Position}"); NextDrillResourceComp.Get(ddComp.parent.Map).Remove(ddComp.parent.Position); }