mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-05-07 05:51:36 +02:00
Make the teleporter work with the dungeon even when it's noit loaded, also fixed and enablen mob spawning in the dungeon.
This commit is contained in:
parent
e95f5ac67e
commit
7b5712a996
@ -41,4 +41,5 @@ func teleport():
|
|||||||
if (p.get_body().transform.origin - transform.origin).length() > use_range:
|
if (p.get_body().transform.origin - transform.origin).length() > use_range:
|
||||||
return
|
return
|
||||||
|
|
||||||
p.get_body().transform.origin = teleport_to
|
p.get_body().teleport(teleport_to)
|
||||||
|
# p.get_body().transform.origin = teleport_to
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
[sub_resource type="CubeMesh" id=1]
|
[sub_resource type="CubeMesh" id=1]
|
||||||
size = Vector3( 1, 1, 1 )
|
size = Vector3( 1, 1, 1 )
|
||||||
|
|
||||||
[sub_resource type="SpatialMaterial" id=3]
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
flags_vertex_lighting = true
|
flags_vertex_lighting = true
|
||||||
albedo_color = Color( 0.494118, 0.494118, 0.494118, 1 )
|
albedo_color = Color( 0.494118, 0.494118, 0.494118, 1 )
|
||||||
albedo_texture = ExtResource( 2 )
|
albedo_texture = ExtResource( 2 )
|
||||||
|
|
||||||
[sub_resource type="BoxShape" id=2]
|
[sub_resource type="BoxShape" id=3]
|
||||||
extents = Vector3( 0.5, 0.5, 0.5 )
|
extents = Vector3( 0.5, 0.5, 0.5 )
|
||||||
|
|
||||||
[node name="DungeonTeleporter" type="StaticBody"]
|
[node name="DungeonTeleporter" type="StaticBody"]
|
||||||
@ -20,7 +20,7 @@ default_albedo = Color( 0.521569, 0.521569, 0.521569, 1 )
|
|||||||
|
|
||||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
mesh = SubResource( 1 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = SubResource( 3 )
|
material/0 = SubResource( 2 )
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 3 )
|
||||||
|
@ -121,7 +121,7 @@ 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.size_x, chunk.size_y, chunk.size_z))
|
var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z), Vector3(chunk.size_x, chunk.size_y, chunk.size_z))
|
||||||
|
|
||||||
if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin):
|
if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin):
|
||||||
inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, (posy + 2) * 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)
|
call_deferred("spawn_teleporter_scene", dung_entrance_scene, entrance_position, chunk, inner_entrance_position)
|
||||||
|
|
||||||
if !aabb.intersects(chunk_aabb):
|
if !aabb.intersects(chunk_aabb):
|
||||||
@ -198,10 +198,13 @@ func _generate_chunk(chunk, spawn_mobs):
|
|||||||
zz = 0
|
zz = 0
|
||||||
|
|
||||||
if spawn_mobs:
|
if spawn_mobs:
|
||||||
|
var chunk_world_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))
|
||||||
|
|
||||||
for enemy in enemy_data:
|
for enemy in enemy_data:
|
||||||
var bp = enemy[0]
|
var bp = enemy[0]
|
||||||
var pos : Vector3 = Vector3(bp.x * chunk.voxel_scale, floor_pos, bp.y * chunk.voxel_scale)
|
var pos : Vector3 = Vector3(bp.x * chunk.voxel_scale, (posy + 4) * chunk.voxel_scale, bp.y * chunk.voxel_scale)
|
||||||
|
|
||||||
|
if chunk_world_aabb.has_point(pos):
|
||||||
ESS.entity_spawner.spawn_mob(enemy[1], enemy[2], pos)
|
ESS.entity_spawner.spawn_mob(enemy[1], enemy[2], pos)
|
||||||
# entities.app
|
# entities.app
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=11]
|
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=11]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
posy = -50
|
posy = -45
|
||||||
sizex = 40
|
sizex = 40
|
||||||
sizey = 3
|
sizey = 3
|
||||||
sizez = 40
|
sizez = 40
|
||||||
@ -22,7 +22,7 @@ level_room_count = 9
|
|||||||
min_room_dimension = 5
|
min_room_dimension = 5
|
||||||
max_room_dimension = 8
|
max_room_dimension = 8
|
||||||
enemy_count = 14
|
enemy_count = 14
|
||||||
spawn_mobs = false
|
spawn_mobs = true
|
||||||
dung_floor = ExtResource( 7 )
|
dung_floor = ExtResource( 7 )
|
||||||
dung_ceiling = ExtResource( 4 )
|
dung_ceiling = ExtResource( 4 )
|
||||||
dung_wall_xp = ExtResource( 5 )
|
dung_wall_xp = ExtResource( 5 )
|
||||||
|
@ -385,7 +385,7 @@ func process_movement_mob(delta : float) -> void:
|
|||||||
if vel.length_squared() < 0.12:
|
if vel.length_squared() < 0.12:
|
||||||
sleep = true
|
sleep = true
|
||||||
|
|
||||||
if translation.y < -50.0:
|
if translation.y < -200.0:
|
||||||
print("killed mob with fall damage")
|
print("killed mob with fall damage")
|
||||||
var sdi : SpellDamageInfo = SpellDamageInfo.new()
|
var sdi : SpellDamageInfo = SpellDamageInfo.new()
|
||||||
sdi.damage_source_type = SpellDamageInfo.DAMAGE_SOURCE_UNKNOWN
|
sdi.damage_source_type = SpellDamageInfo.DAMAGE_SOURCE_UNKNOWN
|
||||||
@ -653,3 +653,7 @@ func set_max_visible_distance(var value : float) -> void:
|
|||||||
|
|
||||||
max_visible_distance = value
|
max_visible_distance = value
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -56,7 +56,7 @@ func generate():
|
|||||||
if level_generator != null:
|
if level_generator != null:
|
||||||
level_generator.setup(self, 80, false, library)
|
level_generator.setup(self, 80, false, library)
|
||||||
|
|
||||||
spawn()
|
spawn(0, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
@ -174,14 +174,14 @@ func _create_chunk(x : int, y : int, z : int, pchunk : VoxelChunk) -> VoxelChunk
|
|||||||
# print("added " + str(Vector3(x, y, z)))
|
# print("added " + str(Vector3(x, y, z)))
|
||||||
return ._create_chunk(x, y, z, chunk)
|
return ._create_chunk(x, y, z, chunk)
|
||||||
|
|
||||||
func spawn() -> void:
|
func spawn(start_x : int, start_y : int, start_z : int) -> void:
|
||||||
if not Engine.editor_hint:
|
if not Engine.editor_hint:
|
||||||
_max_frame_chunk_build_temp = max_frame_chunk_build_steps
|
_max_frame_chunk_build_temp = max_frame_chunk_build_steps
|
||||||
max_frame_chunk_build_steps = 0
|
max_frame_chunk_build_steps = 0
|
||||||
|
|
||||||
for x in range(-chunk_spawn_range, chunk_spawn_range):
|
for x in range(-chunk_spawn_range + start_x, chunk_spawn_range + start_x):
|
||||||
for z in range(-chunk_spawn_range, chunk_spawn_range):
|
for z in range(-chunk_spawn_range + start_z, chunk_spawn_range + start_z):
|
||||||
for y in range(-1, 2):
|
for y in range(-1 + start_y, 2 + start_y):
|
||||||
create_chunk(x, y, z)
|
create_chunk(x, y, z)
|
||||||
|
|
||||||
# add_prop(Transform().translated(Vector3(0, 2, 0)), test_prop)
|
# add_prop(Transform().translated(Vector3(0, 2, 0)), test_prop)
|
||||||
@ -197,7 +197,7 @@ func set_editor_generate(value : bool) -> void:
|
|||||||
library.refresh_rects()
|
library.refresh_rects()
|
||||||
|
|
||||||
level_generator.setup(self, current_seed, false, library)
|
level_generator.setup(self, current_seed, false, library)
|
||||||
spawn()
|
spawn(0, 0, 0)
|
||||||
# else:
|
# else:
|
||||||
# spawned = false
|
# spawned = false
|
||||||
# clear()
|
# clear()
|
||||||
@ -226,7 +226,7 @@ func setup_client_seed(pseed : int) -> void:
|
|||||||
if level_generator != null:
|
if level_generator != null:
|
||||||
level_generator.setup(self, pseed, false, library)
|
level_generator.setup(self, pseed, false, library)
|
||||||
|
|
||||||
spawn()
|
spawn(0, 0, 0)
|
||||||
|
|
||||||
func load_character(file_name : String) -> void:
|
func load_character(file_name : String) -> void:
|
||||||
_player_file_name = file_name
|
_player_file_name = file_name
|
||||||
@ -241,7 +241,7 @@ func load_character(file_name : String) -> void:
|
|||||||
if level_generator != null:
|
if level_generator != null:
|
||||||
level_generator.setup(self, _player.sseed, true, library)
|
level_generator.setup(self, _player.sseed, true, library)
|
||||||
|
|
||||||
spawn()
|
spawn(0, 0, 0)
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user