static public void Postfix(CompPowerTrader __instance)
 {
     if (__instance.parent.def == ReplimatDef.ReplimatHopper)
     {
         ReplimatMod.repHopperCache.Add(__instance.parent, __instance);
         ReplimatUtility.UpdateRepHopperGrid(__instance);
     }
 }
 static public void Prefix(ThingWithComps __instance)
 {
     if (ReplimatMod.repHopperCache.TryGetValue(__instance, out CompPowerTrader comp))
     {
         comp.powerOnInt = false;
         ReplimatUtility.UpdateRepHopperGrid(comp);
         ReplimatMod.repHopperCache.Remove(__instance);
     }
 }
        static bool Prefix(ref Thing foodSource, ref ThingDef __result)
        {
            if (foodSource is Building_ReplimatTerminal && ReplimatMod.BestFoodSourceOnMap)
            {
                __result = ReplimatUtility.PickMeal(ReplimatMod.eater, ReplimatMod.getter);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        static void Postfix()
        {
            if (++tick == 600)             // 10 seconds
            {
                tick = 0;
                foreach (var repHopper in ReplimatMod.repHopperCache)
                {
                    if (repHopper.Key.Map == null)
                    {
                        ReplimatMod.repHopperCache.Remove(repHopper.Key);
                        break;
                    }

                    ReplimatUtility.UpdateRepHopperGrid(repHopper.Value);
                }
            }
        }
        private static bool RepDel(Building_ReplimatTerminal t)
        {
            if (
                !ReplimatMod.allowDispenserFull ||
                !(ReplimatMod.getter.RaceProps.ToolUser && ReplimatMod.getter.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) ||
                t.Faction != ReplimatMod.getter.Faction && t.Faction != ReplimatMod.getter.HostFaction ||
                !ReplimatMod.allowForbidden && t.IsForbidden(ReplimatMod.getter) ||
                !t.powerComp.PowerOn ||
                !t.InteractionCell.Standable(t.Map) ||
                !FoodUtility.IsFoodSourceOnMapSociallyProper(t, ReplimatMod.getter, ReplimatMod.eater, ReplimatMod.allowSociallyImproper) ||
                ReplimatMod.getter.IsWildMan() ||
                ReplimatUtility.PickMeal(ReplimatMod.eater, ReplimatMod.getter) == null ||
                !t.HasStockFor(ReplimatUtility.PickMeal(ReplimatMod.eater, ReplimatMod.getter)) ||
                !ReplimatMod.getter.Map.reachability.CanReachNonLocal(ReplimatMod.getter.Position, new TargetInfo(t.InteractionCell, t.Map),
                                                                      PathEndMode.OnCell, TraverseParms.For(ReplimatMod.getter, Danger.Some)))
            {
                return(false);
            }

            return(true);
        }