Cleanup client
This commit is contained in:
		@ -61,7 +61,7 @@ func join_world_async() -> Dictionary:
 | 
			
		||||
	for precense in match_join_result.presences:
 | 
			
		||||
		_precenses[precense.user_id] = precense
 | 
			
		||||
		
 | 
			
		||||
	print("Currently connected: %s" % _precenses.size())
 | 
			
		||||
	print("Joined matched with %s other players!" % _precenses.size())
 | 
			
		||||
 | 
			
		||||
	return _precenses
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,47 @@
 | 
			
		||||
extends Node
 | 
			
		||||
 | 
			
		||||
export(NodePath) var tilemapPath
 | 
			
		||||
 | 
			
		||||
# Declare member variables here. Examples:
 | 
			
		||||
# var a = 2
 | 
			
		||||
# var b = "text"
 | 
			
		||||
var tilemap : TileMap
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Called when the node enters the scene tree for the first time.
 | 
			
		||||
func _ready():
 | 
			
		||||
	
 | 
			
		||||
	# Setup tilemap
 | 
			
		||||
	tilemap = get_node(tilemapPath)
 | 
			
		||||
	tilemap.clear()
 | 
			
		||||
	
 | 
			
		||||
	# Setup connections and join wolrd
 | 
			
		||||
	ServerConnection.connect("tile_update", self, "on_tile_update")
 | 
			
		||||
	yield(ServerConnection.join_world_async(), "completed")
 | 
			
		||||
 | 
			
		||||
func on_tile_update(tile_data):
 | 
			
		||||
	print(tile_data)
 | 
			
		||||
func on_tile_update(tile_data, update_bitmask=true):
 | 
			
		||||
	print("Updating tilemap")
 | 
			
		||||
	
 | 
			
		||||
	var max_pos_x : int
 | 
			
		||||
	var min_pos_x : int
 | 
			
		||||
	var max_pos_y : int
 | 
			
		||||
	var min_pos_y : int
 | 
			
		||||
	
 | 
			
		||||
	for x in tile_data:
 | 
			
		||||
		
 | 
			
		||||
		# Find max & min x
 | 
			
		||||
		if not max_pos_x or max_pos_x > int(x):
 | 
			
		||||
			max_pos_x = int(x)
 | 
			
		||||
		if not min_pos_x or min_pos_x < int(x):
 | 
			
		||||
			min_pos_x = int(x)
 | 
			
		||||
		
 | 
			
		||||
		for y in tile_data[x]:
 | 
			
		||||
			
 | 
			
		||||
			# Find max & min y
 | 
			
		||||
			if not max_pos_y or max_pos_y > int(y):
 | 
			
		||||
				max_pos_y = int(y)
 | 
			
		||||
			if not min_pos_y or min_pos_y < int(y):
 | 
			
		||||
				min_pos_y = int(y)
 | 
			
		||||
			
 | 
			
		||||
			# Update tile data
 | 
			
		||||
			tilemap.set_cell(int(x),int(y), int(tile_data[x][y]), false, false, false, tilemap.get_cell_autotile_coord(int(x), int(y)))
 | 
			
		||||
	
 | 
			
		||||
	if update_bitmask:
 | 
			
		||||
		tilemap.update_bitmask_region(Vector2(min_pos_x, min_pos_y), Vector2(max_pos_x, max_pos_y))
 | 
			
		||||
 | 
			
		||||
	print("Update complete!")
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user