/// @param char
/// @param x
/// @param y

var _c = argument[0];
var _xx = argument[1];
var _yy = argument[2];

var _tile = layer_tilemap_get_id("Tiles");
var _offset = 4;

var _xxr = _xx * BLOCK_WIDTH + BLOCK_WIDTH/2;
var _yyr = (_yy+_offset) * BLOCK_HEIGHT + BLOCK_HEIGHT/2;

switch(_c) {
case ".":
	if (irandom(30) == 0) {
		tilemap_set(_tile, 4+irandom(3), _xx, _yy+_offset);
	}
	break;
case "O":
	if (instance_exists(obj_portal))
		break;
	instance_create_layer(_xxr, _yyr, "Enemies", obj_portal);
	tilemap_set(global.road_tile, ROAD_TYPE.ROAD, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "T":
	if (instance_exists(obj_tower))
		break;
	instance_create_layer(
		_xxr - BLOCK_WIDTH/2,
		_yyr - BLOCK_HEIGHT/2,
		"Turrets",
		obj_tower
	);
	break;
case "r":
	tilemap_set(global.road_tile, ROAD_TYPE.RR, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "u":
	tilemap_set(global.road_tile, ROAD_TYPE.RU, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "l":
	tilemap_set(global.road_tile, ROAD_TYPE.RL, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "d":
	tilemap_set(global.road_tile, ROAD_TYPE.RD, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "b":
	tilemap_set(global.road_tile, ROAD_TYPE.ROAD, _xx, _yy+_offset);
	tilemap_set(_tile, 8+irandom(3), _xx, _yy+_offset);
	break;
case "+":
	tilemap_set(global.road_tile, ROAD_TYPE.PLACE, _xx, _yy+_offset);
	tilemap_set(_tile, 12, _xx, _yy+_offset);
	break;
}