public bool Remove(Thing item) { if (item is null) { return(false); } if (!ThingCache.TryGetValue(item.def, out Dictionary <Thing, float> things)) { return(false); } if (!things.TryGetValue(item, out float weight)) { return(false); } things.Remove(item); this.TotalWeight -= weight; this.Count--; RemoveFromNonFull(item); return(true); }
private void AddToThingCache(Thing thing, float unitWeight) { if (ThingCache.TryGetValue(thing.def, out Dictionary <Thing, float> things)) { things[thing] = thing.stackCount * unitWeight; } else { Dictionary <Thing, float> newCache = new Dictionary <Thing, float> { [thing] = thing.stackCount * unitWeight }; ThingCache[thing.def] = newCache; } }