Loads of crap

This commit is contained in:
Dan Baker 2025-06-26 14:46:23 +01:00
parent b5bf7619e6
commit 1dc768ad27
725 changed files with 15096 additions and 191 deletions

View file

@ -0,0 +1,27 @@
class_name DebugHelperClass
extends Node
func _count_nodes_recursive(node: Node) -> int:
var count = 1 # Count current node
for child in node.get_children():
count += _count_nodes_recursive(child)
return count
func _count_nodes_by_type(node: Node, type_name: String) -> int:
var count = 0
if node.get_script() and node.get_script().get_global_name() == type_name:
count += 1
for child in node.get_children():
count += _count_nodes_by_type(child, type_name)
return count
func _count_nodes_by_name_pattern(node: Node, pattern: String) -> int:
var count = 0
if node.name.contains(pattern):
count += 1
for child in node.get_children():
count += _count_nodes_by_name_pattern(child, pattern)
return count

View file

@ -0,0 +1 @@
uid://cd4o4df64qlb7

View file

@ -9,3 +9,10 @@ extends Resource
@export var ground_compaction: float = 0.0
@export var water: float = 0
@export var moisture_level: float = 0.6
@export var trees: Array = []
func add_trees(qty: int) -> void:
for i in qty:
var tree = TreeDataResource.new()
trees.append(tree)

View file

@ -1,19 +1,9 @@
class_name MapDataClass
extends Node
var map_data: Array
var map_data: Array = Global.map_data
var cell_data: CellDataResource
func _init() -> void:
map_data.resize(500) # First resize the main array
for y in range(500):
map_data[y] = []
map_data[y].resize(500)
func _ready() -> void:
Log.pr('MapData class ready...')
func setup_cell_data(x, z, density, path = false, water = false):
var cell_data_res = CellDataResource.new()
@ -39,9 +29,5 @@ func get_map_data(x, z) -> CellDataResource:
if x < map_data.size() and x >= 0:
if z < map_data[x].size() and z >= 0:
return map_data[x][z]
else:
Log.pr("Z index out of bounds")
else:
Log.pr("X index out of bounds")
return CellDataResource.new()

View file

@ -0,0 +1,27 @@
class_name MapPopulationClass
extends Node
var map_data: Array = Global.map_data
## Generate the CellDataResource for a given cell
## Setup the X and Z
## If it's a path or water we do nothing else for now
## If it's anything else then we need to:
## Set grass density directly from the vegetation density
## Then do the following:
## Density < 0.5 - chance of spawning special stuff and nothing else
## Density > 0.6 - add trees, varying quantity from 0.6 to 1
## Density 0.1 to 0.6 - add bushes, varying quantity TBD
## Density 0.1 to 0.4 - add flowers, varying quantity TBD
static func generate_cell(x: int, z: int, density: float, path: bool = false, water: bool = false):
var cell_data = CellDataResource.new()
cell_data.x = x
cell_data.z = z
cell_data.vegetation_density = density
if not (path or water):
if density >= 0.6:
cell_data.add_trees(int(density * 10 / 3))
Global.map_data[x][z] = cell_data

View file

@ -0,0 +1 @@
uid://k0na6fmppqew

View file

@ -1 +0,0 @@
uid://b4fmlst8kv1px

View file

@ -2,8 +2,8 @@ class_name MapGenerationClass
extends Node
# Map settings
@export var map_width: int = 500
@export var map_height: int = 500
var map_width: int = Global.map_width
var map_height: int = Global.map_height
# Path generation settings
@export var num_horizontal_paths: int = 3
@ -38,20 +38,27 @@ var path_segments: Array = [] # Store all path segments for better branching
var path_id_counter: int = 0
func _ready():
pass
generate_map()
generate_paths()
generate_water_bodies()
generate_final_map_data()
#print_visual_map_to_console()
#if export_image:
# export_map_as_image()
func generate_final_map_data():
var objects_before = Performance.get_monitor(Performance.OBJECT_COUNT)
for y in range(map_height):
for x in range(map_width):
MapData.setup_cell_data(y, x, map_data[y][x], is_path_at(x, y), is_water_at(x, y))
MapPopulationClass.generate_cell(x, y, map_data[y][x], is_path_at(x, y), is_water_at(x, y))
# Check immediately after
await get_tree().process_frame
var objects_after = Performance.get_monitor(Performance.OBJECT_COUNT)
Log.pr("Objects created in generate_final_map_data: ", objects_after - objects_before)
func generate_map():
# Initialize noise

View file

@ -6,17 +6,14 @@ var _rng: RandomNumberGenerator = RandomNumberGenerator.new()
func _ready():
randomize()
print("Global RNG initialized with seed: ", _rng.seed)
# Set a specific seed for reproducible results
func set_seed(seed_value: int) -> void:
_rng.seed = seed_value
print("RNG seed set to: ", seed_value)
# Randomize the seed (for non-reproducible results)
func randomize() -> void:
_rng.randomize()
print("RNG seed randomized to: ", _rng.seed)
# Get the current seed value
func get_seed() -> int: