Public repository for MUR pre alpha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  1. extends BaseInventory
  2. var view:Spatial
  3. var preview:Spatial
  4. func _ready():
  5. view = get_node("view")
  6. preview = get_node("preview")
  7. var hud_track = get_node("../hud/inventory/track_container/track")
  8. hud_track.get_texture().set_viewport_path_in_scene(str(get_path()) + "/viewport")
  9. connect("item_changed",self,"_on_item_changed")
  10. connect("item_changed",preview,"_on_inventory_item_changed")
  11. func _physics_process(delta):
  12. if is_network_master():
  13. if player != null:
  14. if not player.is_out && player.is_in_group("first"):
  15. get_node("../hud/inventory").show()
  16. if item == null:
  17. set_item()
  18. if preview.item:
  19. preview.item.show()
  20. if Input.is_action_just_pressed("controls_add_road"):
  21. route.rpc("add_road", roads[type][index], player.get_index())
  22. if Input.is_action_just_pressed("controls_prev_road_type"):
  23. type -= 1
  24. if type < 0:
  25. type = roads.size() -1
  26. index = 0
  27. set_item()
  28. if Input.is_action_just_pressed("controls_next_road_type"):
  29. type += 1
  30. if type > roads.size() - 1:
  31. type = 0
  32. index = 0
  33. set_item()
  34. if Input.is_action_just_pressed("controls_prev_road_variant"):
  35. index -= 1
  36. if index < 0:
  37. index = roads[type].size() -1
  38. set_item()
  39. if Input.is_action_just_pressed("controls_next_road_variant"):
  40. index += 1
  41. if index > roads[type].size() - 1:
  42. index = 0
  43. set_item()
  44. else:
  45. get_node("../hud/inventory").hide()
  46. if preview.item:
  47. preview.item.hide()
  48. func _on_item_changed(road_identifier, player):
  49. if is_network_master():
  50. if view.get_child_count() > 0:
  51. view.remove_child(view.get_child(0))
  52. view.add_child(item)
  53. get_node("../hud/inventory/track_container/type").set_text(tr(road_identifier))