aboutsummaryrefslogtreecommitdiff
path: root/client/scripts/map.gd
blob: 64d1572336a62bb1be86a03e580e3e66723ad308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
extends Node3D

func _ready():
	Multiplayer.connect("update_map", update)

func update(pos, tile_name, neighbors):
	var instance: Floor
	match tile_name:
		"trash":
			instance = Trash.new()
		"tomato-crate":
			instance = CounterBase.new()
		"cuttingboard":
			instance = CounterBase.new()
		"counter":
			instance = CounterBase.new()
		"flour-crate":
			instance = CounterBase.new()
		"oven":
			instance = CounterBase.new()
		"raw-steak-crate":
			instance = CounterBase.new()
		"pan":
			instance = CounterBase.new()
		"watercooler":
			instance = CounterBase.new()
		"sink":
			instance = CounterBase.new()
		"dirty-plate-crate":
			instance = CounterBase.new()
		"wall":
			instance = Wall.new()
		"chair":
			instance = Chair.new()
		"table":
			instance = Table.new()
		"floor":
			instance = Floor.new()
		"window":
			instance = Wall.new()
		"door":
			instance = Wall.new()
		_:
			instance = Floor.new()
		
	var node_name = str(pos)
	
	if has_node(node_name):
		queue_free_rename(get_node(node_name))
	
	instance.setup(node_name, neighbors)
	instance.position = Vector3(pos[0], 0, pos[1])
	add_child(instance)

func queue_free_rename(node: Node) -> void:
	node.name += "_queued_free"
	node.queue_free()