Spawn mobs into the dungeons.

This commit is contained in:
Relintai 2021-08-28 00:55:59 +02:00
parent 12e7618cd3
commit 6b36577aa3
11 changed files with 39 additions and 0 deletions

View File

@ -155,5 +155,13 @@ func spawn_dungeon(chunk: TerraChunk) -> void:
var dt : Spatial = dungeon_teleporter.instance()
chunk.voxel_world.add_child(dt)
dt.owner_chunk = chunk
var level : int = 2
if chunk.get_voxel_world().has_method("get_mob_level"):
level = chunk.get_voxel_world().get_mob_level()
dt.min_level = level - 1
dt.max_level = level + 1
dt.transform = Transform(Basis().scaled(Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)), Vector3(x, vwh, z))

View File

@ -7,6 +7,9 @@ export(float) var use_range : float = 5
export(PackedScene) var dungeon : PackedScene
export(PackedScene) var dungeon_back_teleporter : PackedScene
var min_level : int = 1
var max_level : int = 2
var owner_chunk : TerraChunk = null
var _dungeon : Spatial = null
var _dungeon_back_teleporter : Spatial = null
@ -69,6 +72,8 @@ func teleport():
var t : Transform = global_transform
t = t.translated(Vector3(0, -500, 0))
_dungeon.transform = t
_dungeon.min_level = min_level
_dungeon.max_level = max_level
get_parent().add_child(_dungeon)
teleport_to = t.xform(Vector3())

View File

@ -6,6 +6,11 @@ export(PropData) var start_room : PropData
export(Array, PropData) var rooms : Array
export(PropData) var plug : PropData
export(bool) var generate : bool setget set_generate, get_generate
export(bool) var spawn_mobs : bool = true
export(int) var min_level : int = 1
export(int) var max_level : int = 2
#todo calc aabbs and store in PropData during prop conversion
var room_hulls : Dictionary
@ -162,6 +167,19 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
current_aabbs.push_back(ctfab)
if spawn_mobs && level > 0 && ctfab.size() > 0:
if randi() % 3 == 0:
var v2 : Vector2 = ctfab[0]
for i in range(1, ctfab.size()):
v2 = v2.linear_interpolate(ctfab[i], 0.5)
var gt : Transform = global_transform
var scale : Vector3 = gt.basis.get_scale()
v2 *= Vector2(scale.x, scale.z)
ESS.entity_spawner.spawn_mob(0, min_level + (randi() % (max_level - min_level)), Vector3(v2.x, gt.origin.y, v2.y))
#if Engine.editor_hint and debug:
# sr.owner = get_tree().edited_scene_root

View File

@ -39,6 +39,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 6
data = ExtResource( 5 )
collision = false
[sub_resource type="PropDataTiledWall" id=7]
transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 )

View File

@ -71,6 +71,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 6
data = ExtResource( 10 )
collision = false
[node name="wallzp" type="Spatial" parent="."]

View File

@ -27,6 +27,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 10
data = ExtResource( 3 )
collision = false
[sub_resource type="PropDataTiledWall" id=5]
transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 )

View File

@ -33,6 +33,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 10
data = ExtResource( 10 )
collision = false
[node name="wallzp" type="Spatial" parent="."]

View File

@ -27,6 +27,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 16
data = ExtResource( 3 )
collision = false
[sub_resource type="PropDataTiledWall" id=5]
transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 )

View File

@ -33,6 +33,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 16
data = ExtResource( 10 )
collision = false
[node name="wallzp" type="Spatial" parent="."]

View File

@ -15,6 +15,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 6
data = ExtResource( 3 )
collision = false
[sub_resource type="PropDataTiledWall" id=3]
transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 )

View File

@ -21,6 +21,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
width = 5
heigth = 6
data = ExtResource( 10 )
collision = false
[node name="wallzp" type="Spatial" parent="."]