private bool moveItem(IMyInventory src, IMyInventory tgt, MyInventoryItem item, MyFixedPoint amt) { bool ret = false; IMyRefinery prod1 = src as IMyRefinery; IMyRefinery prod2 = tgt as IMyRefinery; if (prod1 != null) { prod1.UseConveyorSystem = true; } if (prod2 != null) { prod2.UseConveyorSystem = true; } if (src.TransferItemTo(tgt, item, amt)) { //show("Moved "+amt+" of "+item.Type.SubtypeId+" from "+src.Owner.Name+" to "+tgt.Owner.Name); ret = true; } else { //show("Could not move "+item.Type.SubtypeId+" from "+src.Owner.Name+" to "+tgt.Owner.Name); ret = false; } if (prod1 != null) { prod1.UseConveyorSystem = false; } if (prod2 != null) { prod2.UseConveyorSystem = false; } return(ret); }
private void addToCache(MyInventoryItem item, IMyCargoContainer box) { ItemProfile prof = new ItemProfile(item); //show("Caching "+prof.ToString()+" in "+box.CustomName); List <IMyCargoContainer> li = null; sourceCache.TryGetValue(prof, out li); if (li == null) { li = new List <IMyCargoContainer>(); } li.Add(box); sourceCache[prof] = li; int has = 0; allItems.TryGetValue(prof, out has); int amt = item.Amount.ToIntSafe(); has += amt; allItems[prof] = has; totalItems += amt; }
public bool match(MyInventoryItem item) { return(strip(item.Type.TypeId) == itemType && strip(item.Type.SubtypeId) == itemSubType); }
internal ItemProfile(MyInventoryItem item) : this(item.Type.TypeId, item.Type.SubtypeId) { }
internal FoundItem(MyInventoryItem inv, IMyInventory src) { item = inv; source = src; }
private bool moveItem(IMyInventory src, IMyInventory tgt, MyInventoryItem item) { return(moveItem(src, tgt, item, item.Amount)); }