Client entity deletion

This commit is contained in:
Layla 2020-05-01 02:27:47 -04:00
parent 9a6ba77e72
commit 84f6ca7434
No known key found for this signature in database
GPG Key ID: A494D9357BA1BE31
3 changed files with 14 additions and 3 deletions

View File

@ -11,9 +11,9 @@ func _process(delta):
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
if(Input.is_action_just_pressed("ui_down")):
movePos.y = movePos.y + 1
if(Input.is_action_just_pressed("ui_right")):
movePos.x = movePos.x + 1
if(Input.is_action_just_pressed("ui_left")):

View File

@ -1,6 +1,8 @@
extends Node
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
signal disconnection

View File

@ -10,7 +10,10 @@ func _on_world_update():
var data = $"/root/NetworkManager".world_data.split('\n')
for tileUpdate in data:
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(',')
if ':' in tile_data[2]:
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.")
if entity:
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()