From 6fb1f1ca9b39dde6c3edec8d4701eb611e17a20e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 5 Sep 2020 22:38:24 +0200 Subject: [PATCH] Implement and use the voxelman blocky style dungeon. Work on proper player pacement into it (will be fixed later). Also update voxelman to get the ensure_channel_allocated method. --- HEADS | 2 +- .../planets/test_planet/biomes/2_tdungb.tres | 7 ++-- .../test_planet/dungeons/vman_dungeon.gd | 11 +++++- .../test_planet/dungeons/vman_dungeon.tres | 7 +++- game/player/Body.gd | 37 ++++++++++++------- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/HEADS b/HEADS index 52153402..246cc62f 100644 --- a/HEADS +++ b/HEADS @@ -1 +1 @@ -{"engine": {"3.2": "36b746d90393299b81ecb991f4aa94a8d742fd11", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "0ddd4908fd3af76a50b2ddd0b112236bebed57f7"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "eea83093525be78a24ce8183cc6a931fed323f55"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}} \ No newline at end of file +{"engine": {"3.2": "36b746d90393299b81ecb991f4aa94a8d742fd11", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "0ddd4908fd3af76a50b2ddd0b112236bebed57f7"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "6f8e54879bcab6c628c761b545f6df4cd7534a07"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}} \ No newline at end of file diff --git a/game/modules/planets/test_planet/biomes/2_tdungb.tres b/game/modules/planets/test_planet/biomes/2_tdungb.tres index 5c3ee3f8..a79010d8 100644 --- a/game/modules/planets/test_planet/biomes/2_tdungb.tres +++ b/game/modules/planets/test_planet/biomes/2_tdungb.tres @@ -1,9 +1,8 @@ -[gd_resource type="Biome" load_steps=4 format=2] +[gd_resource type="Biome" load_steps=3 format=2] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1] -[ext_resource path="res://modules/planets/test_planet/dungeons/dungeon.tres" type="Dungeon" id=2] -[ext_resource path="res://modules/planets/test_planet/dungeons/dungeon_l2.tres" type="Dungeon" id=3] +[ext_resource path="res://modules/planets/test_planet/dungeons/vman_dungeon.tres" type="Dungeon" id=2] [resource] -dungeons = [ ExtResource( 2 ), ExtResource( 3 ) ] +dungeons = [ ExtResource( 2 ) ] script = ExtResource( 1 ) diff --git a/game/modules/planets/test_planet/dungeons/vman_dungeon.gd b/game/modules/planets/test_planet/dungeons/vman_dungeon.gd index 92d6080c..57eb3444 100644 --- a/game/modules/planets/test_planet/dungeons/vman_dungeon.gd +++ b/game/modules/planets/test_planet/dungeons/vman_dungeon.gd @@ -26,6 +26,8 @@ export(int) var min_room_dimension : int = 5 export(int) var max_room_dimension : int = 8 export(int) var enemy_count : int = 14 +export(int) var fill_tile : int = 1 + export(bool) var spawn_mobs : bool = false export(Texture) var wall_texture : Texture @@ -59,6 +61,8 @@ func _instance(p_seed, p_instance): p_instance.max_room_dimension = max_room_dimension p_instance.enemy_count = enemy_count + p_instance.fill_tile = fill_tile + p_instance.spawn_mobs = spawn_mobs p_instance.dung_entrance_mdr = dung_entrance_mdr @@ -96,11 +100,13 @@ func _generate_chunk(chunk, spawn_mobs): var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale), Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)) if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin): - inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, (posy + 4) * chunk.voxel_scale + 0.3, player_inner_entrance_position_z * chunk.voxel_scale) + inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, ((posy + 4) * chunk.voxel_scale) + 0.3, player_inner_entrance_position_z * chunk.voxel_scale) call_deferred("spawn_teleporter_scene", dung_entrance_scene, entrance_position, chunk, inner_entrance_position) if !aabb.intersects(chunk_aabb): return + + chunk.ensure_channel_allocated(VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE, 1) var px : int = chunk.position_x * chunk.size_x - posx var pz : int = chunk.position_z * chunk.size_z - posz @@ -167,7 +173,8 @@ func _generate_chunk(chunk, spawn_mobs): func add_wall(chunk : VoxelChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture): for y in range(floor_pos, ceiling_pos): - chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall, tex) + chunk.set_voxel(0, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE) +# chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall, tex) func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : VoxelChunk, teleports_to : Vector3): var s = scene.instance() diff --git a/game/modules/planets/test_planet/dungeons/vman_dungeon.tres b/game/modules/planets/test_planet/dungeons/vman_dungeon.tres index 4c46a061..86614cf1 100644 --- a/game/modules/planets/test_planet/dungeons/vman_dungeon.tres +++ b/game/modules/planets/test_planet/dungeons/vman_dungeon.tres @@ -1,9 +1,10 @@ -[gd_resource type="Dungeon" load_steps=2 format=2] +[gd_resource type="Dungeon" load_steps=3 format=2] [ext_resource path="res://modules/planets/test_planet/dungeons/vman_dungeon.gd" type="Script" id=1] +[ext_resource path="res://modules/planets/test_planet/dungeons/dung_teleporter.tscn" type="PackedScene" id=2] [resource] -posy = -79 +posy = -45 sizex = 40 sizey = 3 sizez = 40 @@ -12,4 +13,6 @@ level_room_count = 9 min_room_dimension = 5 max_room_dimension = 8 enemy_count = 14 +fill_tile = 1 spawn_mobs = false +dung_entrance_scene = ExtResource( 2 ) diff --git a/game/player/Body.gd b/game/player/Body.gd index a84376df..ba1bf0d3 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -92,6 +92,7 @@ var character_skeleton : CharacterSkeleton3D var visibility_update_timer : float = 0 var placed : bool = false +var just_place : bool = false #var los : bool = false @@ -181,20 +182,27 @@ func _physics_process(delta : float) -> void: return if not placed: - if world != null: - if not world.is_position_walkable(transform.origin): - return - - var space : PhysicsDirectSpaceState = get_world().direct_space_state - - var res : Dictionary = space.intersect_ray(transform.origin + Vector3(0, 100, 0), transform.origin + Vector3(0, -100, 0), [ self ]) - - if not res.empty(): - var pos : Vector3 = res["position"] - transform.origin = pos + Vector3(0, 0.2, 0) + if just_place: + if world.is_position_walkable(transform.origin): placed = true - - return + return + else: + return + else: + if world != null: + if not world.is_position_walkable(transform.origin): + return + + var space : PhysicsDirectSpaceState = get_world().direct_space_state + + var res : Dictionary = space.intersect_ray(transform.origin + Vector3(0, 100, 0), transform.origin + Vector3(0, -100, 0), [ self ]) + + if not res.empty(): + var pos : Vector3 = res["position"] + transform.origin = pos + Vector3(0, 0.2, 0) + placed = true + + return if entity.c_is_controlled: process_input(delta) @@ -676,3 +684,6 @@ func teleport(teleport_to : Vector3): world.spawn(teleport_to.x / world.chunk_size_x / world.voxel_scale, teleport_to.y/ world.chunk_size_y / world.voxel_scale, teleport_to.z/ world.chunk_size_z / world.voxel_scale) transform.origin = teleport_to placed = false +# just_place = true + +