mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Now dungeons and teleporters get spawned in the world. They use placeholder graphics for now.
This commit is contained in:
parent
4b5f6253db
commit
9a8d658643
@ -1,12 +1,14 @@
|
||||
[gd_resource type="Biome" load_steps=5 format=2]
|
||||
[gd_resource type="Biome" load_steps=6 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/villages/village.tres" type="Building" id=2]
|
||||
[ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t1.tres" type="PropData" id=3]
|
||||
[ext_resource path="res://modules/planets/test_planet/biomes/simple_biome/low_poly_rpg_item_collection_3/t2.tres" type="PropData" id=4]
|
||||
[ext_resource path="res://modules/planets/test_planet/dungeons/dung_teleporter.tscn" type="PackedScene" id=5]
|
||||
|
||||
[resource]
|
||||
buildings = [ ExtResource( 2 ) ]
|
||||
script = ExtResource( 1 )
|
||||
dungeon_teleporter = ExtResource( 5 )
|
||||
prop_tree = ExtResource( 3 )
|
||||
prop_tree2 = ExtResource( 4 )
|
||||
|
@ -22,6 +22,7 @@ extends Biome
|
||||
# SOFTWARE.
|
||||
|
||||
export(PackedScene) var tree : PackedScene
|
||||
export(PackedScene) var dungeon_teleporter : PackedScene
|
||||
export(PropData) var prop_tree : PropData
|
||||
export(PropData) var prop_tree2 : PropData
|
||||
|
||||
@ -40,6 +41,7 @@ func _instance(p_seed, p_instance):
|
||||
p_instance.tree = tree
|
||||
p_instance.prop_tree = prop_tree
|
||||
p_instance.prop_tree2 = prop_tree2
|
||||
p_instance.dungeon_teleporter = dungeon_teleporter
|
||||
|
||||
return ._instance(p_seed, p_instance)
|
||||
|
||||
@ -47,21 +49,28 @@ func _generate_terra_chunk(chunk, spawn_mobs):
|
||||
if voxel_scale < 0:
|
||||
voxel_scale = chunk.voxel_scale
|
||||
|
||||
#todo generate this properly
|
||||
var entrance_position : Vector3 = Vector3(7, 5, 7)
|
||||
|
||||
for i in range(get_building_count()):
|
||||
var d : Building = get_building(i)
|
||||
|
||||
if d.has_method("has_entrance_position"):
|
||||
d.entrance_position.origin = entrance_position
|
||||
|
||||
entrance_position = d.next_level_teleporter_position_data_space
|
||||
entrance_position *= voxel_scale
|
||||
# #todo generate this properly
|
||||
# var entrance_position : Vector3 = Vector3(7, 5, 7)
|
||||
#
|
||||
# for i in range(get_building_count()):
|
||||
# var d : Building = get_building(i)
|
||||
#
|
||||
# if d.has_method("has_entrance_position"):
|
||||
# d.entrance_position.origin = entrance_position
|
||||
#
|
||||
# entrance_position = d.next_level_teleporter_position_data_space
|
||||
# entrance_position *= voxel_scale
|
||||
|
||||
#terrarin_gen.generate_simple_terrarin(chunk, spawn_mobs)
|
||||
gen_terra_chunk(chunk)
|
||||
|
||||
if chunk.position_x == 0 && chunk.position_z == 0:
|
||||
#test
|
||||
spawn_dungeon(chunk)
|
||||
else:
|
||||
if randi() % 10 == 0:
|
||||
spawn_dungeon(chunk)
|
||||
|
||||
for i in range(get_building_count()):
|
||||
get_building(i).generate_terra_chunk(chunk, spawn_mobs)
|
||||
|
||||
@ -135,3 +144,15 @@ func gen_terra_chunk(chunk: TerraChunk) -> void:
|
||||
# else:
|
||||
# chunk.voxel_world.prop_add(tr, prop_tree2)
|
||||
|
||||
|
||||
func spawn_dungeon(chunk: TerraChunk) -> void:
|
||||
var x : float = chunk.position_x * chunk.voxel_scale * chunk.size_x
|
||||
var z : float = chunk.position_z * chunk.voxel_scale * chunk.size_z
|
||||
|
||||
var vh : int = chunk.get_voxel(6, 6, TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
var vwh : float = chunk.get_voxel_scale() * chunk.get_world_height() * (vh / 256.0)
|
||||
|
||||
var dt : Spatial = dungeon_teleporter.instance()
|
||||
chunk.voxel_world.add_child(dt)
|
||||
dt.transform = Transform(Basis().scaled(Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)), Vector3(x, vwh, z))
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
extends StaticBody
|
||||
|
||||
export(Color) var default_albedo : Color = Color(0.494118, 0.494118, 0.494118)
|
||||
export(Color) var hover_albedo : Color = Color(0.65098, 0.65098, 0.65098)
|
||||
export(float) var use_range : float = 5
|
||||
|
||||
var _dungeon : Spatial = null
|
||||
|
||||
var teleport_to : Vector3 = Vector3()
|
||||
|
||||
func _ready():
|
||||
connect("mouse_entered", self, "on_mouse_entered")
|
||||
connect("mouse_exited", self, "on_mouse_exited")
|
||||
|
||||
var mat = $MeshInstance.get_surface_material(0)
|
||||
mat.albedo_color = default_albedo
|
||||
|
||||
func on_mouse_entered():
|
||||
var mat = $MeshInstance.get_surface_material(0)
|
||||
mat.albedo_color = hover_albedo
|
||||
|
||||
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
|
||||
|
||||
func on_mouse_exited():
|
||||
var mat = $MeshInstance.get_surface_material(0)
|
||||
mat.albedo_color = default_albedo
|
||||
|
||||
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
|
||||
|
||||
#func _enter_tree():
|
||||
# if get_parent().has_method("get_voxel_scale"):
|
||||
#
|
||||
|
||||
func _exit_tree():
|
||||
if _dungeon:
|
||||
_dungeon.queue_free()
|
||||
|
||||
func _input_event(camera: Object, event: InputEvent, click_position: Vector3, click_normal: Vector3, shape_idx: int):
|
||||
if event is InputEventMouseButton && !event.pressed:
|
||||
teleport()
|
||||
|
||||
if event is InputEventScreenTouch && !event.pressed:
|
||||
teleport()
|
||||
|
||||
func teleport():
|
||||
var world = get_node("..")
|
||||
|
||||
if world && world._player:
|
||||
var p : Entity = world._player
|
||||
|
||||
if (p.get_body().transform.origin - transform.origin).length() > use_range:
|
||||
return
|
||||
|
||||
if _dungeon:
|
||||
#turn it off
|
||||
_dungeon.hide()
|
||||
|
||||
#turn back on world
|
||||
|
||||
p.get_body().teleport(teleport_to)
|
||||
# p.get_body().transform.origin = teleport_to
|
@ -0,0 +1,25 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://modules/planets/test_planet/dungeons/dung_back_teleporter.gd" type="Script" id=1]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/test_brick_albedo.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CubeMesh" id=1]
|
||||
size = Vector3( 1, 1, 1 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=2]
|
||||
flags_vertex_lighting = true
|
||||
albedo_color = Color( 0.494118, 0.494118, 0.494118, 1 )
|
||||
albedo_texture = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="BoxShape" id=3]
|
||||
extents = Vector3( 0.5, 0.5, 0.5 )
|
||||
|
||||
[node name="DungeonBackTeleporter" type="StaticBody"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
shape = SubResource( 3 )
|
@ -2,7 +2,13 @@ extends StaticBody
|
||||
|
||||
export(Color) var default_albedo : Color = Color(0.494118, 0.494118, 0.494118)
|
||||
export(Color) var hover_albedo : Color = Color(0.65098, 0.65098, 0.65098)
|
||||
export(float) var use_range : float = 3
|
||||
export(float) var use_range : float = 5
|
||||
|
||||
export(PackedScene) var dungeon : PackedScene
|
||||
export(PackedScene) var dungeon_back_teleporter : PackedScene
|
||||
|
||||
var _dungeon : Spatial = null
|
||||
var _dungeon_back_teleporter : Spatial = null
|
||||
|
||||
var teleport_to : Vector3 = Vector3()
|
||||
|
||||
@ -25,6 +31,17 @@ func on_mouse_exited():
|
||||
|
||||
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
|
||||
|
||||
#func _enter_tree():
|
||||
# if get_parent().has_method("get_voxel_scale"):
|
||||
#
|
||||
|
||||
func _exit_tree():
|
||||
if _dungeon:
|
||||
_dungeon.queue_free()
|
||||
|
||||
if _dungeon_back_teleporter:
|
||||
_dungeon_back_teleporter.queue_free()
|
||||
|
||||
func _input_event(camera: Object, event: InputEvent, click_position: Vector3, click_normal: Vector3, shape_idx: int):
|
||||
if event is InputEventMouseButton && !event.pressed:
|
||||
teleport()
|
||||
@ -41,5 +58,28 @@ func teleport():
|
||||
if (p.get_body().transform.origin - transform.origin).length() > use_range:
|
||||
return
|
||||
|
||||
if !_dungeon:
|
||||
_dungeon = dungeon.instance() as Spatial
|
||||
var t : Transform = global_transform
|
||||
t = t.translated(Vector3(0, -500, 0))
|
||||
_dungeon.transform = t
|
||||
get_parent().add_child(_dungeon)
|
||||
|
||||
teleport_to = t.xform(Vector3())
|
||||
#todo add this into the dungeon and just query
|
||||
teleport_to -= Vector3(-5, -1, 5)
|
||||
|
||||
_dungeon_back_teleporter = dungeon_back_teleporter.instance() as Spatial
|
||||
var tdb : Transform = global_transform
|
||||
tdb = tdb.translated(Vector3(0, -500, 0))
|
||||
tdb = tdb.translated(Vector3(1, 0.5, -1))
|
||||
_dungeon_back_teleporter.transform = tdb
|
||||
_dungeon_back_teleporter.teleport_to = global_transform.xform(Vector3())
|
||||
get_parent().add_child(_dungeon_back_teleporter)
|
||||
|
||||
#turn off world
|
||||
#turn on dungeon
|
||||
_dungeon.show()
|
||||
|
||||
p.get_body().teleport(teleport_to)
|
||||
# p.get_body().transform.origin = teleport_to
|
||||
|
@ -1,7 +1,9 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://modules/planets/test_planet/dungeons/dung_teleporter.gd" type="Script" id=1]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/test_brick_albedo.png" type="Texture" id=2]
|
||||
[ext_resource path="res://test_dungeon/Dungeon.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://modules/planets/test_planet/dungeons/dung_back_teleporter.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CubeMesh" id=1]
|
||||
size = Vector3( 1, 1, 1 )
|
||||
@ -17,6 +19,8 @@ extents = Vector3( 0.5, 0.5, 0.5 )
|
||||
[node name="DungeonTeleporter" type="StaticBody"]
|
||||
script = ExtResource( 1 )
|
||||
default_albedo = Color( 0.521569, 0.521569, 0.521569, 1 )
|
||||
dungeon = ExtResource( 3 )
|
||||
dungeon_back_teleporter = ExtResource( 4 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
|
@ -815,7 +815,7 @@ func set_max_visible_distance(var value : float) -> void:
|
||||
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)
|
||||
world.spawn(teleport_to.x / world.chunk_size_x / world.voxel_scale, teleport_to.z/ world.chunk_size_z / world.voxel_scale)
|
||||
transform.origin = teleport_to
|
||||
placed = false
|
||||
# just_place = true
|
||||
|
@ -126,6 +126,7 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
|
||||
if level > 4:
|
||||
var plugi : PropInstanceMerger = PropInstanceMerger.new()
|
||||
plugi.prop_data = plug
|
||||
plugi.first_lod_distance_squared = 4000
|
||||
add_child(plugi)
|
||||
plugi.transform = room_lworld_transform
|
||||
|
||||
@ -145,6 +146,7 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
|
||||
|
||||
var sr : PropInstanceMerger = PropInstanceMerger.new()
|
||||
sr.prop_data = room
|
||||
sr.first_lod_distance_squared = 4000
|
||||
add_child(sr)
|
||||
sr.transform = room_lworld_transform
|
||||
|
||||
|
@ -37,6 +37,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636
|
||||
width = 5
|
||||
heigth = 6
|
||||
data = ExtResource( 1 )
|
||||
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 )
|
||||
|
@ -43,6 +43,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="."]
|
||||
|
||||
|
@ -65,4 +65,4 @@ texture = ExtResource( 4 )
|
||||
[resource]
|
||||
props = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ]
|
||||
is_room = true
|
||||
room_bounds = PoolVector3Array( 5.01, -0.01, -6.01, 5.01, -0.01, 0.00999975, 5.01, 3.01, 0.00999975, 5.01, 3.01, -6.01, -0.0100001, -0.01, -6.01, -0.0100001, 3.01, -6.01, -0.0100001, -0.01, 0.00999975, -0.0100001, 0.745, 0.00999975, -0.0100001, 3.01, 0.00999975, 0.826667, 3.01, 0.00999975, 0.826667, 0.745, 0.00999975 )
|
||||
room_bounds = PoolVector3Array( 3.01, 0.745, -1.74541, 3.01, -0.01, -1.74541, 3.01, -0.01, 0.00999999, 3.01, 2.255, -0.867703, 1.99, -0.01, -1.74541, 1.99, -0.01, 0.00999999, 1.99, 0.745, -1.74541, 1.99, 3.01, -0.867703, 3.01, 3.01, -0.867703, 3.01, 3.01, 0.00999999, 2.5, 3.01, 0.00999999, 1.99, 3.01, 0.00999999 )
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://tw/new_terramanlibrarymergerpcm.tres" type="TerramanLibraryMergerPCM" id=1]
|
||||
[ext_resource path="res://tw/TerraWorldBlocky.gd" type="Script" id=2]
|
||||
@ -6,7 +6,6 @@
|
||||
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=4]
|
||||
[ext_resource path="res://test_props/MeshDataInstance.tres" type="PropData" id=5]
|
||||
[ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="Planet" id=6]
|
||||
[ext_resource path="res://test_dungeon/Dungeon.tscn" type="PackedScene" id=7]
|
||||
|
||||
[sub_resource type="TerramanLevelGenerator" id=1]
|
||||
script = ExtResource( 3 )
|
||||
@ -80,6 +79,3 @@ light_energy = 0.87
|
||||
light_specular = 0.65
|
||||
shadow_bias = 0.07
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Dungeon" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 99, 0 )
|
||||
|
Loading…
Reference in New Issue
Block a user