summaryrefslogtreecommitdiff
path: root/scripts/World.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/World.gd')
-rw-r--r--scripts/World.gd51
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/World.gd b/scripts/World.gd
new file mode 100644
index 0000000..dd5b177
--- /dev/null
+++ b/scripts/World.gd
@@ -0,0 +1,51 @@
+extends Spatial
+
+
+var m = SpatialMaterial.new()
+var winddir = Vector3(1,0,0)
+onready var pathfinder = get_node("PLAYERS/Player2")
+var path = []
+var map_rid
+var client_id
+var player_char
+var players_info = {}
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ map_rid = NavigationServer.get_maps()
+ print(map_rid)
+ for rid in map_rid:
+ NavigationServer.map_set_edge_connection_margin(rid,1)
+ m.flags_unshaded = true
+ m.flags_use_point_size = true
+ m.albedo_color = Color.white
+
+remotesync func update_players_info(info):
+ players_info = info
+
+remote func _call_on_server(function, arguments):
+ print('Remote server call: ' + function)
+ $Server.call(function, arguments)
+
+func find_path(to):
+ pathfinder.nav.set_target_location(to)
+ var t_path = pathfinder.nav.get_next_location()
+ pathfinder.should_move = true
+ t_path = pathfinder.nav.get_nav_path()
+ print(to)
+ print(t_path)
+ draw_path(t_path)
+ pass
+
+func draw_path(path_array):
+ var im = get_node("Draw")
+ im.set_material_override(m)
+ im.clear()
+ im.begin(Mesh.PRIMITIVE_POINTS, null)
+ im.add_vertex(path_array[0])
+ im.add_vertex(path_array[path_array.size() - 1])
+ im.end()
+ im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
+ for x in path_array:
+ im.add_vertex(x)
+ im.end()