mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Updated the modules, and added a few test scripts/scenes for terraman.
This commit is contained in:
parent
b921802e06
commit
13fff7b64c
2
HEADS
2
HEADS
@ -1 +1 @@
|
||||
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "595a74ca79578ca882e3f9f71fbcc6bd3c5c1818"}, "world_generator": {"master": "d12ab222a2387e20164b3e7c6236983223ca88ef"}, "entity_spell_system": {"master": "3bbe1138973bafe57638e569e87d28b6e0a0eb46"}, "ui_extensions": {"master": "f1ae14c1be0750f65c77ecaad037dbe1cfb28269"}, "voxelman": {"master": "9253cc53c6fbbd78b5e4268eb498ef55b4dd0181"}, "texture_packer": {"master": "c712c4b30839400ba22e5a6b01f2a20fd9b311fa"}, "fastnoise": {"master": "d447fd5364e9ab5a6b14184483eab23cd3fe820b"}, "mesh_data_resource": {"master": "2cb2d2e558e00e55c8995b19d59e3b7c654b5210"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "f4bc70c94e5042c2f8bc91b89bd5d476274f79cc"}, "mesh_utils": {"master": "9bd800489580680d4b778d78cc7b2449092caefd"}, "broken_seals_module": {"master": "4d8de70db8e48b283beb0b0537649e7e4f1b19e7"}, "thread_pool": {"master": "da4e049da09cb726a00f1edb1df935a2e8475902"}, "terraman": {"master": "603581f6e0401393c387fe8cf43239958d764d81"}}
|
||||
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "d91c1a60a4fdae76b33dff1df0736b1b5f52def9"}, "world_generator": {"master": "d12ab222a2387e20164b3e7c6236983223ca88ef"}, "entity_spell_system": {"master": "3bbe1138973bafe57638e569e87d28b6e0a0eb46"}, "ui_extensions": {"master": "f1ae14c1be0750f65c77ecaad037dbe1cfb28269"}, "voxelman": {"master": "9253cc53c6fbbd78b5e4268eb498ef55b4dd0181"}, "texture_packer": {"master": "c712c4b30839400ba22e5a6b01f2a20fd9b311fa"}, "fastnoise": {"master": "d447fd5364e9ab5a6b14184483eab23cd3fe820b"}, "mesh_data_resource": {"master": "2cb2d2e558e00e55c8995b19d59e3b7c654b5210"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "f4bc70c94e5042c2f8bc91b89bd5d476274f79cc"}, "mesh_utils": {"master": "9bd800489580680d4b778d78cc7b2449092caefd"}, "broken_seals_module": {"master": "4d8de70db8e48b283beb0b0537649e7e4f1b19e7"}, "thread_pool": {"master": "da4e049da09cb726a00f1edb1df935a2e8475902"}, "terraman": {"master": "149734433987b2f87a0a2b045e5295ec1ff6af22"}}
|
346
game/tw/TerraWorldBlocky.gd
Normal file
346
game/tw/TerraWorldBlocky.gd
Normal file
@ -0,0 +1,346 @@
|
||||
tool
|
||||
extends TerraWorldBlocky
|
||||
|
||||
# Copyright Péter Magyar relintai@gmail.com
|
||||
# MIT License, might be merged into the Voxelman engine module
|
||||
|
||||
# Copyright (c) 2019-2021 Péter Magyar
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
export(Array, MeshDataResource) var meshes : Array
|
||||
|
||||
export(bool) var editor_generate : bool = false setget set_editor_generate, get_editor_generate
|
||||
export(bool) var show_loading_screen : bool = true
|
||||
export(bool) var generate_on_ready : bool = false
|
||||
|
||||
export(int) var spawn_height : int = 5
|
||||
|
||||
export(bool) var use_global_chunk_settings : bool = true
|
||||
|
||||
export(PropData) var test_prop : PropData
|
||||
|
||||
var mob_level : int = 1
|
||||
|
||||
var initial_generation : bool = true
|
||||
|
||||
var spawned : bool = false
|
||||
|
||||
var _editor_generate : bool
|
||||
|
||||
var _player_file_name : String
|
||||
var _player : Entity
|
||||
|
||||
const VIS_UPDATE_INTERVAL = 5
|
||||
var vis_update : float = 0
|
||||
var _max_frame_chunk_build_temp : int
|
||||
|
||||
var rc : int = 0
|
||||
|
||||
func _enter_tree():
|
||||
if !Engine.is_editor_hint() && use_global_chunk_settings:
|
||||
Settings.connect("setting_changed", self, "on_setting_changed")
|
||||
Settings.connect("settings_loaded", self, "on_settings_loaded")
|
||||
|
||||
if Settings.loaded:
|
||||
on_settings_loaded()
|
||||
|
||||
if generate_on_ready and not Engine.is_editor_hint():
|
||||
# call_deferred("generate")
|
||||
generate()
|
||||
|
||||
func on_setting_changed(section, key, value):
|
||||
if section == "game":
|
||||
if key == "chunk_spawn_range":
|
||||
chunk_spawn_range = value
|
||||
|
||||
if key == "chunk_lod_falloff":
|
||||
chunk_lod_falloff = value
|
||||
|
||||
|
||||
func on_settings_loaded():
|
||||
chunk_spawn_range = Settings.get_value("game", "chunk_spawn_range")
|
||||
chunk_lod_falloff = Settings.get_value("game", "chunk_lod_falloff")
|
||||
|
||||
vis_update += VIS_UPDATE_INTERVAL
|
||||
|
||||
func generate():
|
||||
#if level_generator != null:
|
||||
# level_generator.setup(self, 80, false, library)
|
||||
|
||||
spawn(0, 0)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if initial_generation:
|
||||
return
|
||||
|
||||
if _player == null:
|
||||
set_process(false)
|
||||
return
|
||||
|
||||
vis_update += delta
|
||||
|
||||
if vis_update >= VIS_UPDATE_INTERVAL:
|
||||
vis_update = 0
|
||||
|
||||
var ppos : Vector3 = _player.get_body_3d().transform.origin
|
||||
|
||||
var cpos : Vector3 = ppos
|
||||
var ppx : int = int(cpos.x / (chunk_size_x * voxel_scale))
|
||||
var ppz : int = int(cpos.z / (chunk_size_z * voxel_scale))
|
||||
|
||||
cpos.x = ppx
|
||||
cpos.y = 0
|
||||
cpos.z = ppz
|
||||
|
||||
var count : int = chunk_get_count()
|
||||
var i : int = 0
|
||||
while i < count:
|
||||
var c : TerraChunk = chunk_get_index(i)
|
||||
|
||||
var l : float = (Vector2(cpos.x, cpos.z) - Vector2(c.position_x, c.position_z)).length()
|
||||
|
||||
if l > chunk_spawn_range + 3:
|
||||
# print("despawn " + str(Vector3(c.position_x, c.position_y, c.position_z)))
|
||||
chunk_remove_index(i)
|
||||
i -= 1
|
||||
count -= 1
|
||||
# else:
|
||||
# var dx : int = abs(ppx - c.position_x)
|
||||
# var dy : int = abs(ppy - c.position_y)
|
||||
# var dz : int = abs(ppz - c.position_z)
|
||||
#
|
||||
# var mr : int = max(max(dx, dy), dz)
|
||||
#
|
||||
# if mr <= 1:
|
||||
# c.current_lod_level = 0
|
||||
# elif mr == 2:
|
||||
# c.current_lod_level = 1
|
||||
# elif mr == 3:# or mr == 4:
|
||||
# c.current_lod_level = 2
|
||||
# else:
|
||||
# c.current_lod_level = 3
|
||||
|
||||
i += 1
|
||||
|
||||
|
||||
for x in range(int(cpos.x) - chunk_spawn_range, chunk_spawn_range + int(cpos.x)):
|
||||
for z in range(int(cpos.z) - chunk_spawn_range, chunk_spawn_range + int(cpos.z)):
|
||||
|
||||
var l : float = (Vector2(cpos.x, cpos.z) - Vector2(x, z)).length()
|
||||
|
||||
if l > chunk_spawn_range:
|
||||
continue
|
||||
|
||||
for y in range(-1 + cpos.y, spawn_height + cpos.y):
|
||||
if not chunk_has(x, z):
|
||||
# print("spawn " + str(Vector3(x, y, z)))
|
||||
chunk_create(x, z)
|
||||
|
||||
update_lods()
|
||||
|
||||
#func _process(delta : float) -> void:
|
||||
# if not generation_queue.empty():
|
||||
# var chunk : TerraChunk = generation_queue.front()
|
||||
|
||||
# refresh_chunk_lod_level_data(chunk)
|
||||
|
||||
# level_generator.generate_chunk(chunk)
|
||||
|
||||
# generation_queue.remove(0)
|
||||
#
|
||||
# if generation_queue.empty():
|
||||
# emit_signal("generation_finished")
|
||||
# initial_generation = false
|
||||
#
|
||||
# if show_loading_screen and not Engine.editor_hint:
|
||||
# get_node("..").hide_loading_screen()
|
||||
|
||||
func _generation_finished():
|
||||
if not Engine.editor_hint:
|
||||
max_frame_chunk_build_steps = _max_frame_chunk_build_temp
|
||||
|
||||
initial_generation = false
|
||||
|
||||
# for i in range(get_chunk_count()):
|
||||
# get_chunk_index(i).draw_debug_voxels(555555)
|
||||
|
||||
if show_loading_screen and not Engine.editor_hint:
|
||||
get_node("..").hide_loading_screen()
|
||||
|
||||
#TODO hack, do this properly
|
||||
if _player:
|
||||
_player.set_physics_process(true)
|
||||
|
||||
func get_chunk_lod_level(x : int, z : int, default : int) -> int:
|
||||
# var key : String = str(x) + "," + str(y) + "," + str(z)
|
||||
|
||||
var ch : TerraChunk = chunk_get(x, z)
|
||||
|
||||
if ch == null:
|
||||
return default
|
||||
|
||||
return ch.lod_size
|
||||
|
||||
func _create_chunk(x : int, z : int, pchunk : TerraChunk) -> TerraChunk:
|
||||
if !pchunk:
|
||||
pchunk = TerraChunkBlocky.new()
|
||||
|
||||
if pchunk.job_get_count() == 0:
|
||||
var tj : TerraTerrarinJob = TerraTerrarinJob.new()
|
||||
var lj : TerraLightJob = TerraLightJob.new()
|
||||
var pj : TerraPropJob = TerraPropJob.new()
|
||||
|
||||
var prop_mesher = TerraMesherBlocky.new()
|
||||
prop_mesher.base_light_value = 0.45
|
||||
prop_mesher.ao_strength = 0.2
|
||||
prop_mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
|
||||
prop_mesher.voxel_scale = voxel_scale
|
||||
prop_mesher.build_flags = build_flags
|
||||
prop_mesher.texture_scale = 3
|
||||
|
||||
pj.set_prop_mesher(prop_mesher);
|
||||
|
||||
var mesher : TerraMesherBlocky = TerraMesherBlocky.new()
|
||||
mesher.base_light_value = 0.45
|
||||
mesher.ao_strength = 0.2
|
||||
mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
|
||||
mesher.voxel_scale = voxel_scale
|
||||
mesher.build_flags = build_flags
|
||||
mesher.texture_scale = 3
|
||||
mesher.channel_index_type = TerraChunkDefault.DEFAULT_CHANNEL_TYPE
|
||||
mesher.channel_index_isolevel = TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL
|
||||
tj.add_mesher(mesher)
|
||||
|
||||
var cmesher : TerraMesherBlocky = TerraMesherBlocky.new()
|
||||
cmesher.texture_scale = 3
|
||||
cmesher.base_light_value = 0.45
|
||||
cmesher.ao_strength = 0.2
|
||||
cmesher.voxel_scale = voxel_scale
|
||||
cmesher.build_flags = build_flags
|
||||
|
||||
if cmesher.build_flags & TerraChunkDefault.BUILD_FLAG_USE_LIGHTING != 0:
|
||||
cmesher.build_flags = cmesher.build_flags ^ TerraChunkDefault.BUILD_FLAG_USE_LIGHTING
|
||||
|
||||
cmesher.always_add_colors = true
|
||||
|
||||
# cmesher.channel_index_type = TerraChunkDefault.DEFAULT_CHANNEL_TYPE
|
||||
cmesher.channel_index_type = TerraChunkDefault.DEFAULT_CHANNEL_ALT_TYPE
|
||||
tj.add_mesher(cmesher)
|
||||
|
||||
pchunk.job_add(lj)
|
||||
pchunk.job_add(tj)
|
||||
pchunk.job_add(pj)
|
||||
|
||||
return ._create_chunk(x, z, pchunk)
|
||||
|
||||
func spawn(start_x : int, start_z : int) -> void:
|
||||
if not Engine.editor_hint:
|
||||
_max_frame_chunk_build_temp = max_frame_chunk_build_steps
|
||||
max_frame_chunk_build_steps = 0
|
||||
|
||||
var spv : Vector2 = Vector2(start_x, start_z)
|
||||
|
||||
for x in range(start_x - chunk_spawn_range, chunk_spawn_range + start_x):
|
||||
for z in range(start_z - chunk_spawn_range, chunk_spawn_range + start_z):
|
||||
|
||||
var l : float = (spv - Vector2(x, z)).length()
|
||||
|
||||
if l > chunk_spawn_range:
|
||||
continue
|
||||
|
||||
chunk_create(x, z)
|
||||
|
||||
# add_prop(Transform().translated(Vector3(0, 2, 0)), test_prop)
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
func get_editor_generate() -> bool:
|
||||
return _editor_generate
|
||||
|
||||
func set_editor_generate(value : bool) -> void:
|
||||
if value:
|
||||
library.refresh_rects()
|
||||
|
||||
#level_generator.setup(self, current_seed, false, library)
|
||||
spawn(0, 0)
|
||||
# else:
|
||||
# spawned = false
|
||||
# clear()
|
||||
|
||||
_editor_generate = value
|
||||
|
||||
func create_light(x : int, y : int, z : int, size : int, color : Color) -> void:
|
||||
var chunkx : int = int(x / chunk_size_x)
|
||||
var chunkz : int = int(z / chunk_size_z)
|
||||
|
||||
var light : TerraLight = TerraLight.new()
|
||||
light.color = color
|
||||
light.size = size
|
||||
light.set_world_position(x, 20, z)
|
||||
|
||||
light_add(light)
|
||||
|
||||
|
||||
func setup_client_seed(pseed : int) -> void:
|
||||
# _player_file_name = ""
|
||||
# _player = null
|
||||
|
||||
Server.sset_seed(pseed)
|
||||
|
||||
#if level_generator != null:
|
||||
#level_generator.setup(self, pseed, false, library)
|
||||
|
||||
spawn(0, 0)
|
||||
|
||||
func load_character(file_name : String) -> void:
|
||||
_player_file_name = file_name
|
||||
_player = ESS.entity_spawner.load_player(file_name, Vector3(5, 30, 5), 1) as Entity
|
||||
#TODO hack, do this properly
|
||||
_player.set_physics_process(false)
|
||||
|
||||
mob_level = _player.clevel
|
||||
|
||||
set_player(_player.get_body())
|
||||
|
||||
Server.sset_seed(_player.sseed)
|
||||
|
||||
#if level_generator != null:
|
||||
# level_generator.setup(self, _player.sseed, true, library)
|
||||
|
||||
spawn(0, 0)
|
||||
|
||||
set_process(true)
|
||||
|
||||
func needs_loading_screen() -> bool:
|
||||
return show_loading_screen
|
||||
|
||||
func save() -> void:
|
||||
if _player == null or _player_file_name == "":
|
||||
return
|
||||
|
||||
ESS.entity_spawner.save_player(_player, _player_file_name)
|
||||
|
||||
func get_mob_level() -> int:
|
||||
return mob_level
|
||||
|
||||
func set_mob_level(level : int) -> void:
|
||||
mob_level = level
|
15
game/tw/TerraWorldBlocky.tscn
Normal file
15
game/tw/TerraWorldBlocky.tscn
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://tw/new_terramanlibrarymerger.tres" type="TerramanLibraryMerger" id=1]
|
||||
[ext_resource path="res://tw/TerraWorldBlocky.gd" type="Script" id=2]
|
||||
[ext_resource path="res://tw/new_terramanlevelgenerator.tres" type="TerramanLevelGenerator" id=3]
|
||||
|
||||
[node name="TerraWorldBlocky" type="TerraWorldBlocky"]
|
||||
editable = true
|
||||
library = ExtResource( 1 )
|
||||
level_generator = ExtResource( 3 )
|
||||
voxel_scale = 2.0
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||
transform = Transform( -0.839321, 0.447369, -0.30887, 0.215012, 0.795005, 0.567219, 0.49931, 0.409668, -0.763454, -40.7817, 19.7414, -39.9584 )
|
13
game/tw/new_terramanlevelgenerator.gd
Normal file
13
game/tw/new_terramanlevelgenerator.gd
Normal file
@ -0,0 +1,13 @@
|
||||
tool
|
||||
extends TerramanLevelGenerator
|
||||
|
||||
|
||||
func _generate_chunk(chunk: TerraChunk) -> void:
|
||||
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
|
||||
var s : OpenSimplexNoise = OpenSimplexNoise.new()
|
||||
|
||||
for x in range(chunk.data_size_x):
|
||||
for z in range(chunk.data_size_z):
|
||||
chunk.set_voxel(s.get_noise_2d(x, z) * 10.0, x, z, TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
6
game/tw/new_terramanlevelgenerator.tres
Normal file
6
game/tw/new_terramanlevelgenerator.tres
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_resource type="TerramanLevelGenerator" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://tw/new_terramanlevelgenerator.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
8
game/tw/new_terramanlevelgeneratorflat.tres
Normal file
8
game/tw/new_terramanlevelgeneratorflat.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="TerramanLevelGeneratorFlat" format=2]
|
||||
|
||||
[resource]
|
||||
floor_position = 10
|
||||
channel_map = {
|
||||
0: 1,
|
||||
1: 10
|
||||
}
|
33
game/tw/new_terramanlibrarymerger.tres
Normal file
33
game/tw/new_terramanlibrarymerger.tres
Normal file
@ -0,0 +1,33 @@
|
||||
[gd_resource type="TerramanLibraryMerger" load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/grass_mossy_albedo.png" type="Texture" id=1]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_1_albedo.png" type="Texture" id=2]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/dirt_albedo.png" type="Texture" id=3]
|
||||
[ext_resource path="res://modules/core/materials/7_standard_material_notex.tres" type="Material" id=4]
|
||||
[ext_resource path="res://modules/core/materials/5_standard_material_nouv2.tres" type="Material" id=5]
|
||||
[ext_resource path="res://modules/core/materials/1_standard_material.tres" type="Material" id=6]
|
||||
|
||||
[sub_resource type="TerraSurfaceMerger" id=1]
|
||||
texture_top = ExtResource( 1 )
|
||||
texture_bottom = ExtResource( 1 )
|
||||
texture_side = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="TerraSurfaceMerger" id=2]
|
||||
texture_top = ExtResource( 3 )
|
||||
texture_bottom = ExtResource( 3 )
|
||||
texture_side = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="TerraSurfaceMerger" id=3]
|
||||
texture_top = ExtResource( 3 )
|
||||
texture_bottom = ExtResource( 1 )
|
||||
texture_side = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="TerraSurfaceMerger" id=4]
|
||||
texture_top = ExtResource( 2 )
|
||||
texture_bottom = ExtResource( 2 )
|
||||
texture_side = ExtResource( 2 )
|
||||
|
||||
[resource]
|
||||
materials = [ ExtResource( 6 ), ExtResource( 5 ), ExtResource( 4 ), ExtResource( 4 ) ]
|
||||
texture_flags = 1
|
||||
voxel_surfaces = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ]
|
Loading…
Reference in New Issue
Block a user