Access global map data directly

This commit is contained in:
Dan Baker 2025-06-26 15:14:40 +01:00
parent 1dc768ad27
commit e7337bede6
5 changed files with 11 additions and 222 deletions

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=17 format=3 uid="uid://bwcevwwphdvq"]
[gd_scene load_steps=16 format=3 uid="uid://bwcevwwphdvq"]
[ext_resource type="Script" uid="uid://bq7hia2dit80y" path="res://Entities/GroundTile/ground_tile.gd" id="1_uwxqs"]
[ext_resource type="PackedScene" uid="uid://ckesk3bs6g7tt" path="res://Stages/Test3D/assets/fish.glb" id="2_h4g11"]
[ext_resource type="ArrayMesh" uid="uid://duj6747nq4qsk" path="res://Stages/Test3D/assets/stylizedGrassMeshes/grass.res" id="3_8mhad"]
[ext_resource type="Script" uid="uid://cacp8ncwuofuj" path="res://Entities/GroundTile/scripts/grass.gd" id="3_224hx"]
[ext_resource type="Material" uid="uid://b1miqvl8lus75" path="res://Stages/Test3D/GrassMaterialOverride.tres" id="3_f37ob"]
@ -58,10 +57,6 @@ mesh = SubResource("PlaneMesh_oqd8f")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource("BoxShape3D_h4g11")
[node name="fish2" parent="." instance=ExtResource("2_h4g11")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00713956, 0, 0.0313604)
visible = false
[node name="Grass" type="Node3D" parent="."]
script = ExtResource("3_224hx")

View file

@ -1,6 +1,7 @@
# GroundTile.gd
class_name GroundTile
extends Node3D
@onready var debug_text: Label = $DebugText/DebugTextViewport/DebugTextLabel
@onready var tree_spawner = $Trees
@onready var grass_spawner = $Grass
@ -39,4 +40,4 @@ func spawn_content():
grass_spawner.spawn_grass_for_cell(cell_info)
func update_text_label() -> void:
debug_text.text = str(cell_info.vegetation_density)
debug_text.text = str(cell_info.vegetation_density)

View file

@ -1,7 +1,6 @@
class_name MapDataClass
extends Node
var map_data: Array = Global.map_data
var cell_data: CellDataResource
func setup_cell_data(x, z, density, path = false, water = false):
@ -23,11 +22,11 @@ func setup_cell_data(x, z, density, path = false, water = false):
cell_data_res.water = 100
cell_data_res.moisture_level = 100
map_data[x][z] = cell_data_res
Global.map_data[x][z] = cell_data_res
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]
if x < Global.map_data.size() and x >= 0:
if z < Global.map_data[x].size() and z >= 0:
return Global.map_data[x][z]
return CellDataResource.new()
return null

File diff suppressed because one or more lines are too long

View file

@ -94,7 +94,7 @@ func load_chunk_async(chunk_pos: Vector2i) -> void:
start_z + (z * tile_size)
)
chunk_node.add_child(tile_instance)
tiles_created += 1
tiles_this_frame += 1