public Item GetItem(CONTAINER_TYPE container, int itemID) { switch (container) { case CONTAINER_TYPE.INVENTORY: foreach (byte i in this.inv.Keys) { Item item = this.inv[i]; if (item.id != itemID) { continue; } return(item); } return(null); case CONTAINER_TYPE.STORAGE: foreach (byte i in this.storage.Keys) { Item item = this.storage[i]; if (item.id != itemID) { continue; } return(item); } return(null); default: return(null); } }
public DeleteItemResult DeleteItem(CONTAINER_TYPE container, int itemID, byte amount, out byte index, out byte newAmount) { newAmount = 0; index = 0; foreach (byte i in this.inv.Keys) { Item item = null; if (container == CONTAINER_TYPE.INVENTORY) { item = this.inv[i]; } if (container == CONTAINER_TYPE.STORAGE) { item = this.storage[i]; } if (item.id != itemID) { continue; } if (item.stack < amount) { return(DeleteItemResult.ERROR); } index = i; if (item.stack == amount) { switch (container) { case CONTAINER_TYPE.INVENTORY: this.inv.Remove(index); break; case CONTAINER_TYPE.STORAGE: this.storage.Remove(index); break; } return(DeleteItemResult.ALL_DELETED); } else { item.stack -= amount; newAmount = item.stack; return(DeleteItemResult.NOT_ALL_DELETED); } } return(DeleteItemResult.ERROR); }
public Item GetItem(CONTAINER_TYPE container, byte index) { switch (container) { case CONTAINER_TYPE.INVENTORY: if (!this.inv.ContainsKey(index)) { return(null); } return(this.inv[index]); case CONTAINER_TYPE.STORAGE: if (!this.storage.ContainsKey(index)) { return(null); } return(this.storage[index]); default: return(null); } }
public DeleteItemResult DeleteItem(CONTAINER_TYPE container, byte index, int itemID, byte amount, out byte newAmount) { newAmount = 0; Item item = this.GetItem(container, index); if (item == null) { return(DeleteItemResult.ERROR); } if (item.id != itemID) { return(DeleteItemResult.WRONG_ITEMID); } if (item.stack < amount) { return(DeleteItemResult.ERROR); } if (item.stack == amount) { switch (container) { case CONTAINER_TYPE.INVENTORY: this.inv.Remove(index); break; case CONTAINER_TYPE.STORAGE: this.storage.Remove(index); break; } return(DeleteItemResult.ALL_DELETED); } else { item.stack -= amount; newAmount = item.stack; return(DeleteItemResult.NOT_ALL_DELETED); } }
public void SetContainer(CONTAINER_TYPE type) { this.PutByte((byte)type, 4); }
public void SetContainer(CONTAINER_TYPE container) { this.PutByte((byte)container, 9); }
public void SetContainer(CONTAINER_TYPE container) { this.PutByte((byte)container, 4); }
public Item GetItem(CONTAINER_TYPE container, int itemID) { switch (container) { case CONTAINER_TYPE.INVENTORY: foreach (byte i in this.inv.Keys) { Item item = this.inv[i]; if (item.id != itemID) continue; return item; } return null; case CONTAINER_TYPE.STORAGE: foreach (byte i in this.storage.Keys) { Item item = this.storage[i]; if (item.id != itemID) continue; return item; } return null; default: return null; } }
public Item GetItem(CONTAINER_TYPE container, byte index) { switch (container) { case CONTAINER_TYPE.INVENTORY: if (!this.inv.ContainsKey(index)) return null; return this.inv[index]; case CONTAINER_TYPE.STORAGE : if (!this.storage.ContainsKey(index)) return null; return this.storage[index]; default: return null; } }
public DeleteItemResult DeleteItem(CONTAINER_TYPE container, int itemID, byte amount,out byte index, out byte newAmount) { newAmount = 0; index = 0; foreach (byte i in this.inv.Keys) { Item item = null; if (container == CONTAINER_TYPE.INVENTORY) item = this.inv[i]; if (container == CONTAINER_TYPE.STORAGE) item = this.storage[i]; if (item.id != itemID) continue; if (item.stack < amount) return DeleteItemResult.ERROR; index = i; if (item.stack == amount) { switch (container) { case CONTAINER_TYPE.INVENTORY: this.inv.Remove(index); break; case CONTAINER_TYPE.STORAGE: this.storage.Remove(index); break; } return DeleteItemResult.ALL_DELETED; } else { item.stack -= amount; newAmount = item.stack; return DeleteItemResult.NOT_ALL_DELETED; } } return DeleteItemResult.ERROR; }
public DeleteItemResult DeleteItem(CONTAINER_TYPE container, byte index, int itemID, byte amount, out byte newAmount) { newAmount = 0; Item item = this.GetItem(container, index); if (item == null) return DeleteItemResult.ERROR; if (item.id != itemID) return DeleteItemResult.WRONG_ITEMID; if (item.stack < amount) return DeleteItemResult.ERROR; if (item.stack == amount) { switch (container) { case CONTAINER_TYPE.INVENTORY: this.inv.Remove(index); break; case CONTAINER_TYPE.STORAGE : this.storage.Remove(index); break; } return DeleteItemResult.ALL_DELETED; } else { item.stack -= amount; newAmount = item.stack; return DeleteItemResult.NOT_ALL_DELETED; } }