public Tile PushContent(Directions direction) { Tile tile = getTileInDirection(direction); if (!tile.IsMoveableTile()) { return(null); } if (!tile.IsOccupied()) { tile.Entity = Entity; Entity = null; return(tile); } if (tile.IsEntityNotPushable()) { INotPushable entity = (INotPushable)tile.Entity; entity.Update(); return(null); } else if (tile.IsEntityAPlayer()) { Player player = (Player)tile.Entity; Tile newTile = tile.PushContent(direction); if (newTile == null) { return(null); } player.Tile = newTile; tile.Entity = Entity; Entity = null; return(tile); } else if (tile.IsEntityPushable()) { IPushable entity = (IPushable)tile.Entity; if (IsEntityPushable()) { return(null); } if (tile.PushContent(direction) == null) { return(null); } entity.Update(tile.getTileInDirection(direction)); tile.Entity = Entity; Entity = null; return(tile); } return(null); }