public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }
            InventoryRecordKey inventoryRecordKey = o as InventoryRecordKey;

            return(inventoryRecordKey != null && this.ThingDef == inventoryRecordKey.ThingDef && this.StuffDef == inventoryRecordKey.StuffDef);
        }
Пример #2
0
        public void Add(InventoryRecordKey key, Thing thing)
        {
            List <EquippableThing> list = this[key];

            if (list == null)
            {
                list      = new List <EquippableThing>();
                this[key] = list;
            }
            list.Add(new EquippableThing(thing));
        }
Пример #3
0
        protected void Count(InventoryCount count)
        {
            InventoryRecordKey key       = count.key;
            ThingDef           thingDef  = key.ThingDef;
            ThingDef           thingDef2 = null;

            if (thingDef.building != null && thingDef.entityDefToBuild != null)
            {
                thingDef2 = key.ThingDef;
                thingDef  = (thingDef.entityDefToBuild as ThingDef);
                if (thingDef == null)
                {
                    return;
                }
            }
            InventoryRecord inventoryRecord;

            if (!this.allRecords.TryGetValue(key, out inventoryRecord))
            {
                return;
            }
            if (inventoryRecord.type == InventoryType.UNKNOWN)
            {
                return;
            }
            if (thingDef2 == null)
            {
                inventoryRecord.count           += count.count;
                inventoryRecord.compressedCount += count.deepStorageCount;
            }
            else
            {
                inventoryRecord.unfinishedCount += count.count;
            }
            if (thingDef.building == null && inventoryRecord.texture == null)
            {
                TextureColorPair textureColorPair = MaterialResolver.Resolve(thingDef);
                if (textureColorPair != null)
                {
                    inventoryRecord.texture = textureColorPair.texture;
                    inventoryRecord.color   = textureColorPair.color;
                }
            }
            Dictionary <InventoryRecordKey, InventoryRecord> dictionary = this.categorizedRecords[inventoryRecord.type];

            if (!dictionary.ContainsKey(key))
            {
                dictionary.Add(key, inventoryRecord);
            }
            if (count.deepStorageCount > 0)
            {
                this.state.compressedStorage = true;
            }
        }
Пример #4
0
 public List <EquippableThing> this[InventoryRecordKey key]
 {
     get
     {
         List <EquippableThing> result;
         if (this.thingLookup.TryGetValue(key, out result))
         {
             return(result);
         }
         return(null);
     }
     set
     {
         this.thingLookup.Add(key, value);
     }
 }
Пример #5
0
        protected void Count(Thing thing)
        {
            if (thing == null)
            {
                return;
            }
            InventoryRecord  inventoryRecord = null;
            bool             flag            = false;
            InventoryCounter inventoryCounter;

            if (this.thingCounters.TryGetValue(thing.def, out inventoryCounter))
            {
                inventoryRecord = inventoryCounter.CountThing(thing, this.allRecords, this.state, out flag);
            }
            if (inventoryRecord == null)
            {
                inventoryRecord = this.defaultInventoryCounter.CountThing(thing, this.allRecords, this.state, out flag);
            }
            if (inventoryRecord == null)
            {
                return;
            }
            if (flag)
            {
                this.equippableThings.Add(new InventoryRecordKey(inventoryRecord.thingDef, inventoryRecord.stuffDef), thing);
            }
            Dictionary <InventoryRecordKey, InventoryRecord> dictionary;

            if (this.categorizedRecords.TryGetValue(inventoryRecord.type, out dictionary))
            {
                InventoryRecordKey key = new InventoryRecordKey(inventoryRecord.thingDef, inventoryRecord.stuffDef);
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, inventoryRecord);
                }
            }
        }