From 84f6ca74349522981c153800bca83faef022cab3 Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Fri, 1 May 2020 02:27:47 -0400 Subject: [PATCH] Client entity deletion --- client/scripts/entities/Player.gd | 4 ++-- client/scripts/network/NetworkManager.gd | 2 ++ client/scripts/systems/WorldManager.gd | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/scripts/entities/Player.gd b/client/scripts/entities/Player.gd index 3c993cf..933fede 100644 --- a/client/scripts/entities/Player.gd +++ b/client/scripts/entities/Player.gd @@ -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")): diff --git a/client/scripts/network/NetworkManager.gd b/client/scripts/network/NetworkManager.gd index c7d5713..1f462fc 100644 --- a/client/scripts/network/NetworkManager.gd +++ b/client/scripts/network/NetworkManager.gd @@ -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 diff --git a/client/scripts/systems/WorldManager.gd b/client/scripts/systems/WorldManager.gd index f93bd41..05569ed 100644 --- a/client/scripts/systems/WorldManager.gd +++ b/client/scripts/systems/WorldManager.gd @@ -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() +