diff --git a/.godot/editor/3DWorld.tscn-folding-5ee7dca069a2497be3bb28c4d56856bf.cfg b/.godot/editor/3DWorld.tscn-folding-5ee7dca069a2497be3bb28c4d56856bf.cfg index 0e30067..1c93dca 100644 --- a/.godot/editor/3DWorld.tscn-folding-5ee7dca069a2497be3bb28c4d56856bf.cfg +++ b/.godot/editor/3DWorld.tscn-folding-5ee7dca069a2497be3bb28c4d56856bf.cfg @@ -1,5 +1,5 @@ [folding] -node_unfolds=[NodePath("DirectionalLight3D"), PackedStringArray("Transform", "Light", "Shadow", "Directional Shadow"), NodePath("Highlighter"), PackedStringArray("Transform"), NodePath("WorldEnvironment"), PackedStringArray("camera_attributes", "environment"), NodePath("GridMap"), PackedStringArray("Cell"), NodePath("Ocean"), PackedStringArray("Collision"), NodePath("Ocean/CollisionShape3D"), PackedStringArray("shape")] +node_unfolds=[NodePath("DirectionalLight3D"), PackedStringArray("Transform", "Light", "Shadow", "Directional Shadow"), NodePath("Highlighter"), PackedStringArray("Transform"), NodePath("WorldEnvironment"), PackedStringArray("camera_attributes", "environment"), NodePath("Ocean"), PackedStringArray("Collision"), NodePath("Ocean/CollisionShape3D"), PackedStringArray("shape")] resource_unfolds=["res://scenes/3DWorld.tscn::CameraAttributesPractical_fwdfs", PackedStringArray("DOF Blur", "Auto Exposure"), "res://scenes/3DWorld.tscn::WorldBoundaryShape3D_iogdu", PackedStringArray("Resource")] nodes_folded=[] diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index 584c08e..a798bea 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -7,3 +7,5 @@ res://scenes/Water.tscn res://assets/blocs/blocs.tscn res://assets/water.gdshader res://scripts/Chunk.gd +res://scripts/Board.gd +res://scripts/Ground.gd diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 0f5a12e..732a238 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -16,7 +16,7 @@ scripts=["Vector2i", "res://scripts/Map_Cursor.gd", "res://scripts/Map.gd", "res [color_picker] -recent_presets=PackedColorArray(0.459595, 0.538874, 0.656934, 1, 0.221081, 0.275062, 0.358885, 1, 1.34766e-06, 0.853688, 0.994746, 1, 0, 0.803922, 0.937255, 1, 0.476347, 0.898661, 1, 1, 1, 0, 0, 1, 1, 0.945098, 0, 1, 0.780392, 1, 1, 1, 1, 1, 1, 1) +recent_presets=PackedColorArray(0.221081, 0.275062, 0.358885, 1, 1.34766e-06, 0.853688, 0.994746, 1, 0, 0.803922, 0.937255, 1, 0.476347, 0.898661, 1, 1, 1, 0, 0, 1, 1, 0.945098, 0, 1, 0.780392, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1) [dialog_bounds] diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index 2b86460..df212b1 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -21,7 +21,7 @@ state={ "folded_lines": Array[int]([]), "h_scroll_position": 0, "row": 15, -"scroll_position": 0.0, +"scroll_position": 78.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -87,11 +87,11 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 3, +"column": 41, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 20, -"scroll_position": 8.0, +"row": 31, +"scroll_position": 20.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -104,8 +104,8 @@ state={ "column": 45, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 100, -"scroll_position": 79.5, +"row": 101, +"scroll_position": 89.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -115,11 +115,11 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 29, +"column": 79, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 69, -"scroll_position": 69.0, +"row": 22, +"scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -145,9 +145,9 @@ state={ "breakpoints": PackedInt32Array(), "column": 80, "folded_lines": Array[int]([]), -"h_scroll_position": 540, +"h_scroll_position": 0, "row": 48, -"scroll_position": 27.0, +"scroll_position": 23.0, "selection": false, "syntax_highlighter": "GDScript" } diff --git a/.godot/shader_cache/SceneForwardClusteredShaderRD/c78728374d98d767dfb15a2ef7b0a55a33e98e82605a8224fb72b41a9816ce22/86f0e50dd1cced740ed4a7a2bd47dfa02bc882b2.cache b/.godot/shader_cache/SceneForwardClusteredShaderRD/c78728374d98d767dfb15a2ef7b0a55a33e98e82605a8224fb72b41a9816ce22/86f0e50dd1cced740ed4a7a2bd47dfa02bc882b2.cache new file mode 100644 index 0000000..f64c6ca Binary files /dev/null and b/.godot/shader_cache/SceneForwardClusteredShaderRD/c78728374d98d767dfb15a2ef7b0a55a33e98e82605a8224fb72b41a9816ce22/86f0e50dd1cced740ed4a7a2bd47dfa02bc882b2.cache differ diff --git a/assets/water.material b/assets/water.material index 0b4715c..2cbb68b 100644 Binary files a/assets/water.material and b/assets/water.material differ diff --git a/project.godot b/project.godot index 9c2f299..cf36680 100644 --- a/project.godot +++ b/project.godot @@ -21,7 +21,7 @@ Global="*res://scripts/Global.gd" [display] -window/stretch/mode="viewport" +window/stretch/mode="canvas_items" window/stretch/aspect="expand" [gui] diff --git a/scenes/3DWorld.tscn b/scenes/3DWorld.tscn index 7a16d66..9bc4276 100644 --- a/scenes/3DWorld.tscn +++ b/scenes/3DWorld.tscn @@ -40,12 +40,6 @@ texture = ExtResource("4_nyumm") environment = ExtResource("4_dycnn") camera_attributes = SubResource("CameraAttributesPractical_fwdfs") -[node name="GridMap" type="GridMap" parent="."] -cell_size = Vector3(1, 1, 1) -cell_center_x = false -cell_center_y = false -cell_center_z = false - [node name="Camera" parent="." instance=ExtResource("5_6daj8")] [node name="Ocean" type="StaticBody3D" parent="."] diff --git a/scripts/Board.gd b/scripts/Board.gd index de711c0..5ba048e 100644 --- a/scripts/Board.gd +++ b/scripts/Board.gd @@ -3,7 +3,6 @@ extends Node3D @onready var ground = $Ground @onready var camera =$Camera @onready var highlighter = $Highlighter -@onready var gridmap = $GridMap var highlight = {} var selection = {} @@ -21,14 +20,15 @@ func _process(delta): var entity = Global.world.add_entity(Vector2i(highlight.grid_position.x, highlight.grid_position.y)) if Input.is_action_just_pressed("main_command"): if selection.type == 1: - var path = Global.world.entities[selection.data.id].path_create(Global.world.get_real_coordinates(Vector2i(highlight.data.position.x, highlight.data.position.z))) + Global.world.entities[selection.data.id].path_create(Global.world.get_real_coordinates(Vector2i(round(highlight.data.position.x), round(highlight.data.position.z)))) Global.world.entities[selection.data.id].path_start() func _unhandled_input(event): if event is InputEventMouseMotion: highlight = get_highlight() if highlight.type == 0: highlighter.transparency = 0.0 - var sprite_position = Vector3(round(highlight.board_position.x), ceil(highlight.board_position.y), round(highlight.board_position.z)) + Vector3(0, 0.01, 0) +# var sprite_position = Vector3(round(highlight.board_position.x), ceil(highlight.board_position.y), round(highlight.board_position.z)) + Vector3(0, 0.01, 0) + var sprite_position = Vector3((highlight.board_position.x), (highlight.board_position.y), (highlight.board_position.z)) + Vector3(0, 0.05, 0) highlighter.position = sprite_position else: highlighter.transparency = 1.0 @@ -48,8 +48,10 @@ func get_highlight(): if raycast_result: var collider = raycast_result.collider if "Chunk" in raycast_result.collider.name or "Ocean" in raycast_result.collider.name: - var position = gridmap.local_to_map(raycast_result.position) -# var position = collider.get_used_cells()[raycast_result.shape] * Vector3i(collider.x, 1, collider.z) + var position = round(raycast_result.position) + position.y = Global.world.get_height(Vector2i(position.x, position.z)) + if "Ocean" in raycast_result.collider.name: + position.y += ground.WATER_HEIGHT result["type"] = 0 result["board_position"] = position result["grid_position"] = Global.world.get_real_coordinates(Vector2i(position.x, position.z)) diff --git a/scripts/Chunk.gd b/scripts/Chunk.gd index 7732285..8a87d84 100644 --- a/scripts/Chunk.gd +++ b/scripts/Chunk.gd @@ -2,18 +2,19 @@ extends GridMap class_name Chunk const Pawn = preload("res://scenes/Pawn.tscn") -const WATER_HEIGHT = 0.5 var location: Vector2i var size = 0 var should_remove = false +var water_height var chunks_array: Array -func _init(x: int, z: int, size: int, chunks_array: Array): +func _init(x: int, z: int, size: int, chunks_array: Array, water_height: float): self.location.x = x self.location.y = z self.size = size self.chunks_array = chunks_array + self.water_height = water_height mesh_library = load("res://assets/blocs/blocs.meshlib") cell_size = Vector3(1, 1, 1) cell_center_x = false @@ -98,7 +99,7 @@ func create_water(): var water = OceanTile.instantiate() water.mesh.size.x = size water.mesh.size.y = size - water.translate(Vector3(size/2, WATER_HEIGHT, size/2)) + water.translate(Vector3(size/2, water_height, size/2)) add_child(water) func is_inside_chunk(position: Vector2i) : diff --git a/scripts/Ground.gd b/scripts/Ground.gd index 4993d1b..850ae42 100644 --- a/scripts/Ground.gd +++ b/scripts/Ground.gd @@ -1,5 +1,7 @@ extends Node3D +const WATER_HEIGHT = 0.5 + var thread var displayed_chunks = {} var unready_chunks = {} @@ -18,7 +20,7 @@ func init_chunks(): chunks.append([]) for y in Global.world.height / Global.world.chunk_size: chunks[x].append([]) - chunks[x][y] = Chunk.new(x, y, Global.world.chunk_size, chunks) + chunks[x][y] = Chunk.new(x, y, Global.world.chunk_size, chunks, WATER_HEIGHT) chunks[x][y].set_name("Chunk") chunks[x][y]