// A box is being Pushed to this field // If this field has a Moveable object on it, the object on this field Gets Pushed to the next field, in the same direction // If not, the object given as a parameter will be set onto this field and Gets reMoved from its previous field public void Push(Direction direction, Box box, double remStrength) { if (onThis != null) { if (neighbours.ContainsKey(direction)) { onThis.Pushed(box, neighbours[direction]); } else { onThis.Pushed(box, null); } if (onThis != null && ((remStrength - friction) > 0)) { enter = direction; remainedStrength = remStrength - friction; onThis.Accept(this); } } if (onThis == null) { onThis = box; box.SetField(this); neighbours[GetReverse()].RemoveMoveable(); if (feature != null) { feature.Interact(box); } } }
// Interacting with the Moveable object // Initiating the Visitor pattern public void Interact(Moveable Moveable) { Moveable.Accept(this); }