public bool TryStartCarry(Thing item) { if (pawn.Dead || pawn.Downed) { Log.Error(string.Concat("Dead/downed pawn ", pawn, " tried to start carry item.")); return(false); } if (innerContainer.TryAdd(item)) { item.def.soundPickup.PlayOneShot(new TargetInfo(item.Position, pawn.Map)); return(true); } return(false); }
public void TryAddItemNotForSale(Thing item) { if (innerContainer.TryAdd(item, canMergeWithExistingStacks: false)) { itemsNotForSale.Add(item); } }
public int TryTransferToContainer(Thing item, ThingOwner otherContainer, int count, out Thing resultingTransferredItem, bool canMergeWithExistingStacks = true) { if (!this.Contains(item)) { Log.Error(string.Concat(new object[] { "Can't transfer item ", item, " because it's not here. owner=", this.owner.ToStringSafe <IThingHolder>() }), false); resultingTransferredItem = null; return(0); } if (otherContainer == this && count > 0) { resultingTransferredItem = item; return(item.stackCount); } if (!otherContainer.CanAcceptAnyOf(item, canMergeWithExistingStacks)) { resultingTransferredItem = null; return(0); } if (count <= 0) { resultingTransferredItem = null; return(0); } if (this.owner is Map || otherContainer.owner is Map) { Log.Warning("Can't transfer items to or from Maps directly. They must be spawned or despawned manually. Use TryAdd(item.SplitOff(count))", false); resultingTransferredItem = null; return(0); } int num = Mathf.Min(item.stackCount, count); Thing thing = item.SplitOff(num); if (this.Contains(thing)) { this.Remove(thing); } bool flag = otherContainer.TryAdd(thing, canMergeWithExistingStacks); if (flag) { resultingTransferredItem = thing; return(thing.stackCount); } resultingTransferredItem = null; if (!otherContainer.Contains(thing) && thing.stackCount > 0 && !thing.Destroyed) { int result = num - thing.stackCount; if (item != thing) { item.TryAbsorbStack(thing, false); } else { this.TryAdd(thing, false); } return(result); } return(thing.stackCount); }