public bool getFromNeighbour() { if (neighbor != null) { MaterialHolder neighbourPresent = neighbor.takeMaterial(materialHolded, grabCount); addMaterial(neighbourPresent.getMaterialId(), neighbourPresent.getCount()); return(true); } return(false); }
public bool addMaterial(MaterialId id, int count) { if (materialHolded == null) { materialHolded = new MaterialHolder(id, count); } else if (materialHolded.getMaterialId() == id) { materialHolded.Add(count); return(true); } return(false); }
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 Output(int ref_x, int ref_y, Output neighbor, direction faceDirection, List <MaterialId> materialsFilter, MaterialHolder materialHolded, putState state) { this.ref_x = ref_x; this.ref_y = ref_y; this.neighbor = neighbor; put = putDirection.output; this.faceDirection = faceDirection; this.materialsFilter = materialsFilter; this.materialHolded = materialHolded; this.state = state; }