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.

32 lines
933 B

  1. extends Spatial
  2. class_name Preview
  3. var player:Player
  4. var item:Road
  5. func _ready():
  6. gamestate.game.route.connect("road_added",self,"_on_route_road_added")
  7. func _on_route_road_added(road):
  8. if is_network_master() && item:
  9. var transform = road.get_global_transform();
  10. var curve = road.get_curve()
  11. transform = transform.translated(curve.get_point_position(curve.get_point_count() -1))
  12. if road.get_end_rotation().length() != 0:
  13. transform.basis = transform.basis.rotated(road.get_end_rotation().normalized(), road.get_end_rotation().length())
  14. item.set_global_transform(transform)
  15. func _on_inventory_item_changed(road_identifier, player):
  16. if is_network_master():
  17. if item:
  18. item.free()
  19. item = roads_factory.get_road_instance(road_identifier)
  20. item.set_preview(true)
  21. if player != null:
  22. item.set_color(player.get_player_color())
  23. add_child(item)
  24. _on_route_road_added(gamestate.game.route.get_last_road())