public static void Listener(CompPowerTrader __instance, ref float ___powerOutputInt) { CompReloadStation rs = __instance.parent.TryGetComp <CompReloadStation>(); if (rs != null) { rs.refreshPowerConsumed(); } }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { FloatMenuOption failureReason = this.GetFailureReason(myPawn); if (failureReason != null) { yield return(failureReason); } else { yield return(new FloatMenuOption("ATPP_ForceReload".Translate(), delegate(){ CompReloadStation rs = this.TryGetComp <CompReloadStation>(); Job job = new Job(DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(rs.getFreeReloadPlacePos(myPawn)), new LocalTargetInfo(this)); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } }
public static void Listener(Pawn pawn, ref Job __result) { if (!pawn.IsAndroidTier()) { return; } if (Utils.ExceptionAndroidCanReloadWithPowerList.Contains(pawn.def.defName)) { CompAndroidState ca = pawn.GetComp <CompAndroidState>(); if (ca == null || !pawn.Spawned || !ca.UseBattery || pawn.Drafted) { return; } if (Utils.POWERPP_LOADED && ca.connectedLWPNActive && ca.connectedLWPN != null) { __result = null; return; } Building rsb = Utils.GCATPP.getFreeReloadStation(pawn.Map, pawn); if (rsb == null) { __result = null; return; } CompReloadStation rs = rsb.TryGetComp <CompReloadStation>(); if (rs == null) { __result = null; return; } __result = new Job( DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(rs.getFreeReloadPlacePos(pawn)), new LocalTargetInfo(rsb)); } }
private FloatMenuOption GetFailureReason(Pawn myPawn) { if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn)) { return(new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (base.Spawned && base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare)) { return(new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (!this.TryGetComp <CompPowerTrader>().PowerOn) { return(new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (!Utils.ExceptionAndroidList.Contains(myPawn.def.defName)) { return(new FloatMenuOption("ATPP_CanOnlyBeUsedByAndroid".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } CompAndroidState ca = myPawn.ATCompState; if (ca == null || !ca.UseBattery) { return(new FloatMenuOption("ATPP_CannotUseBecauseNotInBatteryMode".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } CompReloadStation rs = this.TryGetComp <CompReloadStation>(); int nb = rs.getNbAndroidReloading(true); if (nb >= 8) { return(new FloatMenuOption("ATPP_CannotUseEveryPlaceUsed".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(null); }