Skip to content

Commit

Permalink
fix: fix or disable some things to get Spatial_simple to run
Browse files Browse the repository at this point in the history
  • Loading branch information
Zireael07 committed Jan 27, 2022
1 parent 422435f commit d8cc2df
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 44 deletions.
47 changes: 26 additions & 21 deletions game/car/kinematics/kinematic_vehicle_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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")
Expand Down
32 changes: 18 additions & 14 deletions game/car/vehiclebody/vehicle_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
18 changes: 9 additions & 9 deletions game/dynamic_sky/scripts/scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit d8cc2df

Please sign in to comment.