diff options
| author | nokoe <nokoe@mailbox.org> | 2024-06-21 00:47:57 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:25:29 +0200 | 
| commit | b430895ea49ebeb0359a2d36164832303aaf757d (patch) | |
| tree | 651c4e1e0a9e22207607eba0c15da6c02374ead6 /client/scripts/tiles/counter.gd | |
| parent | 4f19a2cd91b099dc2e0d6c673d853befc7044340 (diff) | |
| download | hurrycurry-b430895ea49ebeb0359a2d36164832303aaf757d.tar hurrycurry-b430895ea49ebeb0359a2d36164832303aaf757d.tar.bz2 hurrycurry-b430895ea49ebeb0359a2d36164832303aaf757d.tar.zst | |
add door
Diffstat (limited to 'client/scripts/tiles/counter.gd')
| -rw-r--r-- | client/scripts/tiles/counter.gd | 63 | 
1 files changed, 63 insertions, 0 deletions
| diff --git a/client/scripts/tiles/counter.gd b/client/scripts/tiles/counter.gd new file mode 100644 index 00000000..d8b41804 --- /dev/null +++ b/client/scripts/tiles/counter.gd @@ -0,0 +1,63 @@ +class_name Counter +extends FullTile + +var counters = [ +	"counter", +	"pan", +	"sink", +	"oven", +] + +enum CounterKind { +	OUTER_CORNER, +	STRAIGHT, +	STRAIGHT_BACKSPLASH +} + +var kind: CounterKind = CounterKind.STRAIGHT + +func setup(rename: String, neighbors: Array): +	super.setup(rename, neighbors) +	var facing = 0 +	var edges = neighbors.duplicate() +	for i in range(4): +		var i_name = tile_name(edges[i]) +		if is_counter(i_name): +			edges[i] = "counter" +		else: +			edges[i] = tile_name(edges[i]) + +	var series: int = 0 +	var last_series: int = 0 +	var adj: Array = [] +	 +	for i in range(4): +		if edges[i] == "floor": +			last_series += 1 +			adj.append(i) +			if last_series > series: +				series = last_series +		else: +			last_series = 0 +	 +	var count = 4 - adj.size() + +	# we can neither find out whether it is an inner corner nor an outer corner +	# backsplash  +	if series == 1&&count == 3: +		facing = adj[0] % 4 +		 +		if edges[(adj[0] + 2) % 4] == "wall": +			kind = CounterKind.STRAIGHT_BACKSPLASH +		else: +			kind = CounterKind.STRAIGHT +	elif series == 2&&count == 2: +		facing = (adj[0] + 1) % 4 +		kind = CounterKind.OUTER_CORNER +	 +	turn_facing(facing) + +func is_counter(tile_name_t) -> bool: +	if tile_name_t == null: +		return false +	return name.ends_with("crate")||counters.has(name) | 
