/* InventoryCountDefs * If the ThingDef is minifiable, search the container for how many minified objects are contained. * fallback to TotalStackCountOfDef for non-minifiable things. */ private int InventoryCountDefs(ThingContainer container, ThingDef def) { int count = 0; if (def.Minifiable) { count = container.Count(t => t.GetInnerIfMinified().def == def); } else { count = container.TotalStackCountOfDef(def); } return(count); }
public virtual void BoardOn(Pawn pawn) { if (mountableComp.IsMounted && (storage.Count(x => x is Pawn) >= maxNumBoarding || //No Space (Faction != null && Faction != pawn.Faction))) //Not your vehicle { return; } if (pawn.Faction == Faction.OfPlayer && (pawn.needs.food.CurCategory == HungerCategory.Starving || pawn.needs.rest.CurCategory == RestCategory.Exhausted)) { Messages.Message(pawn.LabelCap + "cannot board on " + LabelCap + ": " + pawn.LabelCap + "is starving or exhausted", MessageSound.RejectInput); return; } Job jobNew = new Job(HaulJobDefOf.StandBy, mountableComp.Driver.Position, 4800); mountableComp.Driver.jobs.StartJob(jobNew, JobCondition.Incompletable); storage.TryAdd(pawn); pawn.holder = GetContainer(); pawn.holder.owner = this; pawn.jobs.StartJob(new Job(JobDefOf.WaitCombat)); }