public bool CraftPartRecipe(PartRecipe toCraft) { bool hasAll = true; foreach (Item itm in toCraft.parts) { if (!parts.ContainsKey(ARareItemSwapJPANs.ItemToTag(itm))) { return(false); } if ((long)parts[ARareItemSwapJPANs.ItemToTag(itm)] < itm.stack) { hasAll = false; } } if (hasAll) { foreach (Item itm in toCraft.parts) { decreasePart(ARareItemSwapJPANs.ItemToTag(itm), itm.stack); } return(true); } return(false); }
public bool maxPart(Item itm) { string tag = ARareItemSwapJPANs.ItemToTag(itm); if (ARareItemSwapJPANs.tokenList.Contains(tag)) { parts[tag] = Int64.MaxValue; return(true); } return(false); }
public override bool ShiftClickSlot(Item[] inventory, int context, int slot) { if (PartExchangeUI.visible && inventory != null && inventory[slot] != null && !inventory[slot].IsAir) { if (ARareItemSwapJPANs.tokenList.Contains(ARareItemSwapJPANs.ItemToTag(inventory[slot]))) { this.addPart(inventory[slot]); inventory[slot].TurnToAir(); return(true); } if (PartRecipes.ContainsAsResult(inventory[slot])) { List <PartRecipe> target = PartRecipes.recipesByResult[ARareItemSwapJPANs.ItemToTag(inventory[slot])]; for (int i = 0; i < target.Count; i++) { if (target[i].irreversible || !target[i].isAvailable() || target[i].result.stack > inventory[slot].stack) { target.RemoveAt(i); i--; } } if (target.Count > 0) { PartRecipe pr = target[0]; int min = pr.result.stack; for (int i = 1; i < target.Count; i++) { if (min > target[i].result.stack) { min = target[i].result.stack; pr = target[i]; } } int stack; int cnt = 0; do { stack = inventory[slot].stack; pr.refund(this, ref inventory[slot]); cnt++; }while (inventory[slot].stack > 0 && stack != inventory[slot].stack); } if (inventory[slot].stack <= 0) { inventory[slot].TurnToAir(); } } return(true); } return(false); }
public bool CanCraftRecipe(PartRecipe toCraft) { foreach (Item itm in toCraft.parts) { if (!parts.ContainsKey(ARareItemSwapJPANs.ItemToTag(itm))) { return(false); } if ((long)parts[ARareItemSwapJPANs.ItemToTag(itm)] < itm.stack) { return(false); } } return(true); }
public bool addPart(Item itm) { string tag = ARareItemSwapJPANs.ItemToTag(itm); if (ARareItemSwapJPANs.tokenList.Contains(tag)) { if (!parts.ContainsKey(tag)) { parts[tag] = (long)(itm.stack); } else { parts[tag] = (long)(parts[tag]) + itm.stack; } itm.stack = 0; if ((long)(parts[tag]) < 0) { parts[tag] = Int64.MaxValue; } return(true); } return(false); }