From d8cc2dfa3aa120c30f493223a86350837c65140d Mon Sep 17 00:00:00 2001 From: Zireael07 Date: Thu, 27 Jan 2022 14:17:24 +0100 Subject: [PATCH] fix: fix or disable some things to get Spatial_simple to run --- .../kinematics/kinematic_vehicle_player.gd | 47 ++++++++++--------- game/car/vehiclebody/vehicle_player.gd | 32 +++++++------ game/dynamic_sky/scripts/scene.gd | 18 +++---- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/game/car/kinematics/kinematic_vehicle_player.gd b/game/car/kinematics/kinematic_vehicle_player.gd index 793ae87..9dd17ea 100644 --- a/game/car/kinematics/kinematic_vehicle_player.gd +++ b/game/car/kinematics/kinematic_vehicle_player.gd @@ -100,23 +100,23 @@ func _ready(): # get map seed - map = get_parent().get_parent().get_node(^"map") + map = get_parent().get_parent().get_node("map") if map != null: hud.update_seed(map.get_node(^"triangulate/poisson").seed3) - var m = preload("res://hud/SubViewport.tscn") - minimap = m.instantiate() - minimap.set_name("Viewport_root") - add_child(minimap) - minimap.set_name("Viewport_root") - - m = preload("res://hud/MapView.tscn") - map_big = m.instantiate() - map_big.set_name("Map") - # share the world with the minimap - map_big.get_node(^"SubViewport").world_2d = get_node(^"Viewport_root/SubViewport").world_2d - add_child(map_big) - map_big.hide() +# var m = preload("res://hud/Viewport.tscn") +# minimap = m.instantiate() +# minimap.set_name("Viewport_root") +# add_child(minimap) +# minimap.set_name("Viewport_root") +# +# m = preload("res://hud/MapView.tscn") +# map_big = m.instantiate() +# map_big.set_name("Map") +# # share the world with the minimap +# map_big.get_node(^"SubViewport").world_2d = get_node(^"Viewport_root/SubViewport").world_2d +# add_child(map_big) +# map_big.hide() var msg = preload("res://hud/message_panel.tscn") @@ -151,12 +151,12 @@ func _ready(): # smoke color var snow_mat = load("res://assets/snow_smoke_mat.tres") var smoke_mat = load("res://assets/Smoke_mat.tres") - if get_parent().get_parent().get_node(^"Ground").snow: - get_node(^"Smoke").material_override = snow_mat - get_node(^"Smoke2").material_override = snow_mat - else: - get_node(^"Smoke").material_override = smoke_mat - get_node(^"Smoke2").material_override = smoke_mat +# if get_parent().get_parent().get_node(^"Ground").snow: +# get_node(^"Smoke").material_override = snow_mat +# get_node(^"Smoke2").material_override = snow_mat +# else: +# get_node(^"Smoke").material_override = smoke_mat +# get_node(^"Smoke2").material_override = smoke_mat func random_date(): # seed the rng @@ -602,7 +602,7 @@ func driving_on_road(): if abs(angle_inter) < 40: hud.update_nav_label("") - mark_road_discovered(disp_name) + #mark_road_discovered(disp_name) # else we're on a dirt ground else: if not was_dirt: @@ -619,6 +619,11 @@ func mark_road_discovered(disp_name): return var root = get_node(^"/root/Node3D") + # paranoia + if root == null: + return + # or !"discovered_roads" in root + if not root.discovered_roads.has(disp_name): root.discovered_roads[disp_name] = true print("Marked " + disp_name + " as discovered") diff --git a/game/car/vehiclebody/vehicle_player.gd b/game/car/vehiclebody/vehicle_player.gd index 86619bd..593ea7c 100644 --- a/game/car/vehiclebody/vehicle_player.gd +++ b/game/car/vehiclebody/vehicle_player.gd @@ -209,16 +209,16 @@ func _physics_process(delta): if count: timer += delta - if speed > 28: - count = false - if timer and timer > 0.0: - #var perc_str = str((timer/12.0)*100) + "% of 12s (1500 force)" - print("Reached 100 kph, timer: " + str(timer) + " " + str(perf_distance) + " m " + \ - #"acc: " + str(accel_from_time(timer)) + " m/s^2 " + \ - "acc: " + str(accel_from_data(timer, perf_distance)) + " m/s^2 " + \ - str(time_from_accel(accel_from_data(timer, perf_distance))) + " s") - # \n " + perc_str) - timer = 0.0 +# if speed > 28: +# count = false +# if timer and timer > 0.0: +# #var perc_str = str((timer/12.0)*100) + "% of 12s (1500 force)" +# print("Reached 100 kph, timer: " + str(timer) + " " + str(perf_distance) + " m " + \ +# #"acc: " + str(accel_from_time(timer)) + " m/s^2 " + \ +# "acc: " + str(accel_from_data(timer, perf_distance)) + " m/s^2 " + \ +# str(time_from_accel(accel_from_data(timer, perf_distance))) + " s") +# # \n " + perc_str) +# timer = 0.0 #else: # print("Reached 100") @@ -528,7 +528,7 @@ func _process(delta): # speed effects # less rain visible if going fast - if World_node.weather > 1: + if World_node != null and World_node.weather > 1: if speed > 20: get_node(^"RainParticles").amount = 128 get_node(^"RainParticles2").amount = 128 @@ -574,10 +574,10 @@ func _process(delta): get_node(^"RainParticles2").set_emitting(true) # skid marks - if speed < 5: + if speed < 5 and map != null: var pos = get_node(^"cambase/Camera3D").get_global_transform().origin var mark = skidmark.instantiate() - var wh_pos = get_node(^"wheel2") + var wh_pos = get_node("wheel2") var mark_pos = wh_pos.get_global_transform().origin - Vector3(0,0.3, 0) # tiny offset to make marks show on roads var lpos = map.to_local(mark_pos) mark.set_translation(lpos) @@ -640,7 +640,11 @@ func get_heading(): # returns radians #return player_rot var North = get_node(^"/root/Node3D/marker_North") - var rel_loc = (North.get_global_transform( * get_global_transform()).origin) + + if North == null: + return 0 + + var rel_loc = (North.get_global_transform() * get_global_transform().origin) #2D angle to target (local coords) var angle = atan2(rel_loc.x, rel_loc.z) #print("Heading: ", rad2deg(angle)) diff --git a/game/dynamic_sky/scripts/scene.gd b/game/dynamic_sky/scripts/scene.gd index bf9af55..ed677b5 100644 --- a/game/dynamic_sky/scripts/scene.gd +++ b/game/dynamic_sky/scripts/scene.gd @@ -64,12 +64,12 @@ var player func _ready(): # get real world date - var winter = OS.get_datetime(true) + var winter = Time.get_date_dict_from_system(true) #print(winter) - if winter.month == 12 and winter.day > 21 or winter.month < 3: - get_parent().get_node(^"Ground").snow = true - else: - get_parent().get_node(^"Ground").snow = false +# if winter.month == 12 and winter.day > 21 or winter.month < 3: +# get_parent().get_node(^"Ground").snow = true +# else: +# get_parent().get_node(^"Ground").snow = false time = start_time; prev_time = start_time; @@ -284,7 +284,7 @@ func set_colors(time): #sky.set_sky_top_color(sky_color) #sky.set_sky_horizon_color(horizon_color) #sky.set_ground_horizon_color(gr_horizon_color) - env.set_fog_color(horizon_color) + #env.set_fog_color(horizon_color) func set_clouds(time): if time >= 18.1 && time < 18.5: @@ -370,10 +370,10 @@ func rain(): func no_rain(): env.set_ssr_enabled(false) env.adjustment_enabled = false - env.fog_color = Color(0.5, 0.6, 0.7) + #env.fog_color = Color(0.5, 0.6, 0.7) - player.get_node(^"BODY/RainParticles").set_emitting(false) - player.get_node(^"BODY/RainParticles2").set_emitting(false) + player.get_node("BODY/RainParticles").set_emitting(false) + player.get_node("BODY/RainParticles2").set_emitting(false) if get_tree().get_nodes_in_group("roads").size() > 0: get_tree().get_nodes_in_group("roads")[0].no_rain()