Client entity deletion
This commit is contained in:
		@ -11,9 +11,9 @@ func _process(delta):
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if(Input.is_action_just_pressed("ui_up")):
 | 
						if(Input.is_action_just_pressed("ui_up")):
 | 
				
			||||||
		movePos.y = movePos.y + 1
 | 
					 | 
				
			||||||
	if(Input.is_action_just_pressed("ui_down")):
 | 
					 | 
				
			||||||
		movePos.y = movePos.y - 1
 | 
							movePos.y = movePos.y - 1
 | 
				
			||||||
 | 
						if(Input.is_action_just_pressed("ui_down")):
 | 
				
			||||||
 | 
							movePos.y = movePos.y + 1
 | 
				
			||||||
	if(Input.is_action_just_pressed("ui_right")):
 | 
						if(Input.is_action_just_pressed("ui_right")):
 | 
				
			||||||
		movePos.x = movePos.x + 1
 | 
							movePos.x = movePos.x + 1
 | 
				
			||||||
	if(Input.is_action_just_pressed("ui_left")):
 | 
						if(Input.is_action_just_pressed("ui_left")):
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
extends Node
 | 
					extends Node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const SERVER_HOST : String = "192.168.1.34"
 | 
					const SERVER_HOST : String = "192.168.1.34"
 | 
				
			||||||
 | 
					#const SERVER_HOST : String = "stage.dt.cloudsumu.com"
 | 
				
			||||||
 | 
					#const SERVER_HOST : String = "dt-in-Publi-1S7VAU6QPEQHR-51ac8fd89ed249aa.elb.us-east-1.amazonaws.com"
 | 
				
			||||||
const SERVER_PORT : int = 7777
 | 
					const SERVER_PORT : int = 7777
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signal disconnection
 | 
					signal disconnection
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,10 @@ func _on_world_update():
 | 
				
			|||||||
	var data = $"/root/NetworkManager".world_data.split('\n')
 | 
						var data = $"/root/NetworkManager".world_data.split('\n')
 | 
				
			||||||
	for tileUpdate in data:
 | 
						for tileUpdate in data:
 | 
				
			||||||
		if len(tileUpdate) > 3:
 | 
							if len(tileUpdate) > 3:
 | 
				
			||||||
			if ',' in tileUpdate:
 | 
								if "delete," in tileUpdate:
 | 
				
			||||||
 | 
									var delete_data = tileUpdate.substr(len("delete,")).split(':')
 | 
				
			||||||
 | 
									delete_entity(delete_data[1],delete_data[0])
 | 
				
			||||||
 | 
								elif ',' in tileUpdate:
 | 
				
			||||||
				var tile_data = tileUpdate.split(',')
 | 
									var tile_data = tileUpdate.split(',')
 | 
				
			||||||
				if ':' in tile_data[2]:
 | 
									if ':' in tile_data[2]:
 | 
				
			||||||
					var pos : Vector2 = $Tiles.map_to_world(Vector2(int(tile_data[0]), int(tile_data[1])))
 | 
										var pos : Vector2 = $Tiles.map_to_world(Vector2(int(tile_data[0]), int(tile_data[1])))
 | 
				
			||||||
@ -47,3 +50,9 @@ func update_entity(entity_id : String, pos : Vector2, type : String):
 | 
				
			|||||||
			display_error("Trying to load entity of type: " + type + ", but failed.")
 | 
								display_error("Trying to load entity of type: " + type + ", but failed.")
 | 
				
			||||||
	if entity:
 | 
						if entity:
 | 
				
			||||||
		entity.position = pos
 | 
							entity.position = pos
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					func delete_entity(entity_id : String, type : String):
 | 
				
			||||||
 | 
						var entity : Node2D = get_node_or_null( str(type + "-" + entity_id))
 | 
				
			||||||
 | 
						if entity:
 | 
				
			||||||
 | 
							entity.queue_free()
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user