public MaterialHolder takeMaterial(MaterialHolder holded, int grabCount) { if (materialHolded != null && (holded == null || holded.getMaterialId() == materialHolded.getMaterialId())) { int maxPossible = materialHolded.Substract(grabCount); MaterialId mid = materialHolded.getMaterialId(); if (maxPossible != grabCount) { materialHolded = null; } return(new MaterialHolder(mid, maxPossible)); } return(null); }
public bool getFromNeighbour() { if (neighbor != null) { MaterialHolder neighbourPresent = neighbor.takeMaterial(materialHolded, grabCount); addMaterial(neighbourPresent.getMaterialId(), neighbourPresent.getCount()); return(true); } return(false); }