private static bool RepDel(Building_ReplimatTerminal t) { if ( !allowDispenserFull || !(getter.RaceProps.ToolUser && getter.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) || t.Faction != getter.Faction && t.Faction != getter.HostFaction || !allowForbidden && t.IsForbidden(getter) || !t.powerComp.PowerOn || !t.InteractionCell.Standable(t.Map) || !FoodUtility.IsFoodSourceOnMapSociallyProper(t, getter, eater, allowSociallyImproper) || getter.IsWildMan() || ReplimatUtility.PickMeal(eater, getter) == null || !t.HasStockFor(ReplimatUtility.PickMeal(eater, getter)) || !getter.Map.reachability.CanReachNonLocal(getter.Position, new TargetInfo(t.InteractionCell, t.Map), PathEndMode.OnCell, TraverseParms.For(getter, Danger.Some))) { return(false); } return(true); }
public override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Thing> list = map.listerThings.ThingsOfDef(ReplimatDef.ReplimatTerminal); if (!list.Any()) { // If there are no Terminals or Animal Feeders, break out of execution early return(false); } Thing building_ReplimatTerminal = list.RandomElement(); Building_ReplimatTerminal currentTerminal = building_ReplimatTerminal as Building_ReplimatTerminal; ThingDef kibble = ThingDef.Named("Kibble"); int unitsOfKibble = 75 * 3; float volumeOfFeedstockToWaste = ReplimatUtility.convertMassToFeedstockVolume(unitsOfKibble * kibble.BaseMass); if (currentTerminal.HasEnoughFeedstockInHopperForIncident(volumeOfFeedstockToWaste)) { currentTerminal.powerComp.PowerNet.TryConsumeFeedstock(volumeOfFeedstockToWaste); Thing t = ThingMaker.MakeThing(kibble, null); t.stackCount = unitsOfKibble; GenPlace.TryPlaceThing(t, building_ReplimatTerminal.InteractionCell, map, ThingPlaceMode.Near); string letterLabel = "LetterLabelReplimatMalfunctionKibble".Translate(); string letterText = "LetterTextReplimatMalfunctionKibble".Translate(new object[] { currentTerminal.def.label }); Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NegativeEvent, new TargetInfo(building_ReplimatTerminal.Position, map, false), null); return(true); } return(false); }