public static void Listener(Pawn pawn, ref Job __result) { try { //Si android alors OK if (Utils.ExceptionAndroidCanReloadWithPowerList.Contains(pawn.def.defName)) { //Check si l'android utilise sa batterie le cas non echeant on arrete l'override ET on l'arret aussi si l'android dans une caravane !! CompAndroidState ca = pawn.TryGetComp <CompAndroidState>(); if (ca == null || !pawn.Spawned || !ca.UseBattery || pawn.Drafted) { return; } //SI recharge LWPN en cours valide alors on annule la recharge par nourrite ou elec traditionelle if (Utils.POWERPP_LOADED && ca.connectedLWPNActive && ca.connectedLWPN != null) { __result = null; return; } Building_Bed pod = null; //Check disponibilité d'un POD alimenté try { pod = Utils.getAvailableAndroidPodForCharging(pawn, pawn.def.defName == "M7Mech"); } catch (Exception) { } if (pod != null) { __result = new Job(DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(pod)); return; } //Log.Message("Android want EAT !!! "); //Recherche reload station disponible sur la map Building rsb = Utils.GCATPP.getFreeReloadStation(pawn.Map, pawn); if (rsb == null) { __result = null; //Log.Message("No ReloadStation found !!"); return; } //Obtention place disponible sur la RS CompReloadStation rs = rsb.TryGetComp <CompReloadStation>(); if (rs == null) { __result = null; //Log.Message("No Place available on ReloadStation"); return; } __result = new Job(DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(rs.getFreeReloadPlacePos(pawn)), new LocalTargetInfo(rsb)); } } catch (Exception e) { Log.Message("[ATPP] JobGiver_GetFood.TryGiveJob : " + e.Message + " - " + e.StackTrace); } }
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)); } }