remove train radar
This commit is contained in:
@@ -18,6 +18,7 @@ const LAMPPOST_WIRE_STEPS_PER_FRAME: int = 1
|
||||
@export_group("Lamppost")
|
||||
@export var lamppost_wire_material: ShaderMaterial
|
||||
@export_range(0.01, 1.0) var wire_thickness: float = 0.05
|
||||
@export var lamppost_dist_factor: int = 10
|
||||
|
||||
var board: Dictionary = {}
|
||||
var last_pos_train: Vector2i = Vector2i(999999, 999999)
|
||||
@@ -100,7 +101,7 @@ func _destroy_and_regenrate_world() -> void:
|
||||
if rail_path != null and rail_path.train_instance != null:
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var current_pos = Vector2i(roundi(train_pos.x / chunk_size), roundi(train_pos.z / chunk_size))
|
||||
_refresh_world_work(current_pos)
|
||||
_refresh_world(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
@@ -110,7 +111,6 @@ func _process(_delta: float) -> void:
|
||||
|
||||
if pending_radar_update:
|
||||
pending_radar_update = false
|
||||
_train_radar()
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if rail_path == null or rail_path.train_instance == null: return
|
||||
@@ -122,7 +122,7 @@ func _physics_process(_delta: float) -> void:
|
||||
|
||||
if current_pos != last_pos_train:
|
||||
last_pos_train = current_pos
|
||||
_refresh_world_work(current_pos)
|
||||
_refresh_world(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
@@ -216,7 +216,7 @@ func _clear_pending_world_work() -> void:
|
||||
pending_wire_lookup.clear()
|
||||
pending_radar_update = false
|
||||
|
||||
func _refresh_world_work(center: Vector2i) -> void:
|
||||
func _refresh_world(center: Vector2i) -> void:
|
||||
_rebuild_generation_queue(center)
|
||||
_rebuild_cleanup_queue(center)
|
||||
|
||||
@@ -516,32 +516,6 @@ func _needed_heights(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if board.has(near_pos) and board[near_pos].has("heights"):
|
||||
return board[near_pos]["heights"][side_needed]
|
||||
return -1
|
||||
|
||||
func _train_radar() -> void:
|
||||
if rail_path == null or rail_path.curve == null or rail_path.train_instance == null: return
|
||||
|
||||
if manual_biome != null:
|
||||
return
|
||||
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var grid_x = roundi(train_pos.x / chunk_size)
|
||||
var grid_z = roundi(train_pos.z / chunk_size)
|
||||
var current_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(grid_x, grid_z))
|
||||
|
||||
var current_progress = rail_path.train_progress
|
||||
var total_length = rail_path.curve.get_baked_length()
|
||||
|
||||
for step in range(1, 31):
|
||||
var next_progress = wrapf(current_progress + (step * chunk_size), 0.0, total_length)
|
||||
var next_local_pos = rail_path.curve.sample_baked(next_progress, true)
|
||||
var next_global_pos = rail_path.to_global(next_local_pos)
|
||||
|
||||
var f_x = roundi(next_global_pos.x / chunk_size)
|
||||
var f_z = roundi(next_global_pos.z / chunk_size)
|
||||
var future_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(f_x, f_z))
|
||||
|
||||
if future_biome != current_biome:
|
||||
break
|
||||
|
||||
func _get_lampposts(info_node: Node, side: String) -> Array[Node3D]:
|
||||
var lampposts: Array[Node3D] = []
|
||||
@@ -576,7 +550,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
var p_sx_your_best = null; var p_dx_your_best = null
|
||||
var best_closest_to_root = null
|
||||
var best_distance = 999999.0
|
||||
var ray_research = 3
|
||||
var ray_research = 6
|
||||
|
||||
for x in range(-ray_research, ray_research + 1):
|
||||
for z in range(-ray_research, ray_research + 1):
|
||||
@@ -644,7 +618,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
p_sx_your_best = closest_sx[i_t]
|
||||
p_dx_your_best = closest_dx[i_t]
|
||||
|
||||
var max_dist = chunk_size * 8.0
|
||||
var max_dist = chunk_size * lamppost_dist_factor
|
||||
|
||||
if best_closest_to_root != null and best_distance < max_dist:
|
||||
var dist_streight = p_sx_my_best.global_position.distance_to(p_sx_your_best.global_position) + p_dx_my_best.global_position.distance_to(p_dx_your_best.global_position)
|
||||
@@ -662,6 +636,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
if not wire_connections.has(closest_id): wire_connections[closest_id] = 0
|
||||
wire_connections[closest_id] += 1
|
||||
|
||||
#draw lamppost
|
||||
func _draw_parable(p1: Vector3, p2: Vector3, parent: Node3D) -> void:
|
||||
var segments = 15
|
||||
var lowering = 1.5
|
||||
|
||||
Reference in New Issue
Block a user