/ MessageBus.gd
MessageBus.gd
1 extends Node 2 3 @onready var event_bus = get_node("/root/MainGame/EventBus") 4 5 @rpc("any_peer", "call_local", "reliable") 6 func request_build_floor(floor_type: String, grid_pos: Vector2i, player_id: int): 7 if not multiplayer.is_server(): return 8 tLogger.info("Request Build " + floor_type + " Floor by " + str(player_id) + " at " + str(grid_pos)) 9 10 event_bus.emit_request_place_floor(floor_type, grid_pos) 11 12 @rpc("any_peer", "call_local", "reliable") 13 func request_build_structure(type: String, grid_pos: Vector2i, player_id: int): 14 if not multiplayer.is_server(): return 15 tLogger.info("Request Build " + type + " Wall by " + str(player_id) + " at " + str(grid_pos)) 16 17 event_bus.emit_request_place_structure(type, grid_pos) 18 19 @rpc("any_peer", "call_local", "reliable") 20 func request_zone_growing(start_draw, end_draw): 21 if not multiplayer.is_server(): return 22 tLogger.info("request_zone_growing at " + str(start_draw) + " and at " + str(end_draw)) 23 event_bus.emit_request_zone_growing(start_draw, end_draw) 24 25 @rpc("authority", "call_remote", "reliable") 26 func sync_entire_tile_layer(grid_data: Dictionary): 27 if multiplayer.is_server(): return 28 var tile_data = grid_data 29 30 # Tell the local WorldRenderer to draw everything 31 for pos in tile_data: 32 event_bus.emit_tile_changed(tile_data[pos], pos) 33 34 @rpc("authority", "call_remote", "reliable") 35 func sync_entire_FilthLayer(grid_data: Dictionary): #not in use 36 pass 37 38 39 @rpc("authority", "call_remote", "reliable") 40 func sync_entire_item_layer(item_grid_data: Dictionary, item_amount_grid_data: Dictionary): 41 if multiplayer.is_server(): return 42 var item_data = item_grid_data 43 44 # Tell the local WorldRenderer to draw everything 45 for pos in item_data: 46 event_bus.emit_item_dropped(item_data[pos],item_amount_grid_data[pos], pos) 47 48 @rpc("authority", "call_remote", "reliable") 49 func sync_entire_pipe_layer(grid_data: Dictionary): #not in use 50 pass 51 @rpc("authority", "call_remote", "reliable") 52 func sync_entire_structure_layer(grid_data: Dictionary): 53 if multiplayer.is_server(): return 54 var data = grid_data 55 # Tell the local WorldRenderer to draw everything 56 for pos in data: 57 event_bus.emit_structure_changed(str(data[pos]), pos) 58 pass 59 @rpc("authority", "call_remote", "reliable") 60 func sync_entire_BluePrintLayer(grid_data: Dictionary): #not in use 61 pass 62 @rpc("authority", "call_remote", "reliable") 63 func sync_entire_EntityLayer(grid_data: Dictionary): #not in use 64 pass 65 @rpc("authority", "call_remote", "reliable") 66 func sync_entire_RoofLayer(grid_data: Dictionary): #not in use 67 pass 68 69 @rpc("authority", "call_remote", "reliable") 70 func sync_entire_object_layer(grid_data: Dictionary): #trying to get rid of this 71 if multiplayer.is_server(): return 72 var object_data = grid_data 73 # Tell the local WorldRenderer to draw everything 74 for pos in object_data: 75 event_bus.emit_object_changed(str(object_data[pos]), pos) 76 77 @rpc("authority", "call_local", "reliable") 78 func sync_tile_changed(type: String, pos: Vector2i): 79 event_bus.emit_tile_changed(type, pos) 80 81 @rpc("authority", "call_local", "reliable") 82 func sync_item_dropped(type: String, amount: int, pos: Vector2i): 83 event_bus.emit_item_dropped(type,amount, pos) 84 85 @rpc("authority", "call_local", "reliable") 86 func sync_object_changed(type: String, pos: Vector2i): 87 event_bus.emit_object_changed(type, pos) 88 89 @rpc("authority", "call_local", "reliable") 90 func sync_structure_changed(type: String, pos: Vector2i): 91 event_bus.emit_structure_changed(type, pos)