From 21e1f3af230d1f28d1559611081205fd21f66e3a Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 21 Apr 2021 10:49:49 +0200 Subject: [PATCH] Don't generate lods in the menu. --- game/menu/Menu.tscn | 34 ++-- game/menu/MenuWorld.gd | 361 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 378 insertions(+), 17 deletions(-) create mode 100644 game/menu/MenuWorld.gd diff --git a/game/menu/Menu.tscn b/game/menu/Menu.tscn index 29f7bc4d..c309e4cd 100644 --- a/game/menu/Menu.tscn +++ b/game/menu/Menu.tscn @@ -15,13 +15,13 @@ [ext_resource path="res://scenes/DisconnectButton.gd" type="Script" id=13] [ext_resource path="res://scenes/ConnectServerButton.gd" type="Script" id=14] [ext_resource path="res://scenes/HostGameButton.gd" type="Script" id=15] -[ext_resource path="res://tw/TerraWorldBlocky.gd" type="Script" id=16] +[ext_resource path="res://menu/MenuWorld.gd" type="Script" id=16] [ext_resource path="res://tw/new_terramanlibrarymerger.tres" type="TerramanLibraryMerger" id=17] [ext_resource path="res://tw/new_terramanlevelgenerator.tres" type="TerramanLevelGenerator" id=18] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19] [ext_resource path="res://ui/about/About.tscn" type="PackedScene" id=20] -[sub_resource type="TerraChunkBlocky" id=3] +[sub_resource type="TerraChunkBlocky" id=1] resource_name = "Chunk[-2,0]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -51.2, 0, 0 ) position_x = -2 @@ -38,7 +38,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 112, 73, 74, 74, 75, 75, 75, 76, 1, 0, 17, 77, 1, 0, 32, 78, 74, 15, 0, 48, 77, 77, 78, 1, 0, 161, 79, 79, 79, 79, 80, 80, 75, 75, 76, 77, 12, 0, 144, 80, 80, 80, 80, 81, 81, 81, 82, 83, 17, 0, 0, 15, 0, 0, 13, 0, 98, 82, 82, 83, 83, 84, 85, 17, 0, 1, 16, 0, 112, 83, 83, 84, 84, 85, 86, 87, 18, 0, 21, 80, 32, 0, 97, 85, 86, 87, 88, 77, 78, 51, 0, 5, 34, 0, 32, 88, 90, 18, 0, 0, 17, 0, 1, 67, 0, 121, 86, 87, 88, 89, 91, 78, 79, 18, 0, 50, 89, 90, 92, 53, 0, 1, 72, 0, 0, 36, 0, 51, 89, 91, 93, 18, 0, 2, 73, 0, 1, 18, 0, 3, 140, 0, 0, 20, 0, 2, 18, 0, 17, 94, 172, 0, 1, 175, 0, 0, 55, 0, 53, 87, 89, 92, 18, 0, 0, 148, 0, 2, 18, 0, 1, 33, 0, 1, 2, 0, 129, 81, 82, 83, 85, 87, 90, 92, 95, 13, 0, 16, 80, 245, 0, 9, 18, 0, 2, 7, 1, 22, 81, 36, 0, 0, 17, 0, 160, 79, 79, 80, 81, 83, 85, 87, 90, 92, 95 ) -[sub_resource type="TerraChunkBlocky" id=4] +[sub_resource type="TerraChunkBlocky" id=2] resource_name = "Chunk[-1,-1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -25.6, 0, -25.6 ) position_x = -1 @@ -56,7 +56,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 1, 1, 0, 202, 19, 4, 1, 0, 1, 229, 0, 3, 12, 0, 5, 2, 0, 21, 1, 10, 0, 15, 2, 0, 39, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 242, 3, 51, 51, 51, 52, 52, 53, 53, 54, 55, 56, 56, 57, 58, 58, 59, 59, 59, 59, 18, 0, 52, 54, 54, 55, 17, 0, 21, 59, 35, 0, 33, 57, 57, 34, 0, 39, 59, 59, 52, 0, 0, 15, 0, 50, 59, 59, 59, 69, 0, 0, 52, 0, 145, 59, 59, 60, 60, 60, 60, 59, 59, 53, 68, 0, 5, 17, 0, 66, 60, 60, 59, 54, 33, 0, 80, 58, 59, 60, 60, 61, 1, 0, 65, 60, 60, 56, 56, 84, 0, 64, 60, 60, 61, 62, 1, 0, 48, 61, 61, 60, 31, 0, 97, 59, 60, 61, 61, 62, 63, 1, 0, 49, 62, 62, 61, 46, 0, 160, 62, 63, 63, 64, 64, 65, 65, 65, 64, 64, 20, 0, 16, 62, 15, 0, 177, 65, 65, 66, 66, 67, 67, 66, 66, 66, 65, 64, 28, 0, 240, 1, 66, 66, 67, 68, 68, 69, 69, 69, 68, 68, 67, 67, 66, 65, 67, 67, 14, 0, 48, 70, 70, 71, 1, 0, 81, 70, 69, 69, 68, 67, 13, 0, 209, 72, 72, 73, 73, 74, 74, 74, 73, 73, 72, 71, 70, 69, 13, 0, 49, 75, 75, 76, 1, 0, 80, 75, 74, 73, 72, 71, 13, 0, 65, 77, 77, 78, 79, 1, 0, 209, 78, 77, 76, 75, 74, 77, 78, 78, 79, 80, 80, 81, 82, 1, 0, 81, 81, 80, 79, 78, 77, 14, 0, 208, 83, 84, 85, 85, 85, 85, 85, 85, 84, 83, 82, 81, 80 ) -[sub_resource type="TerraChunkBlocky" id=5] +[sub_resource type="TerraChunkBlocky" id=3] resource_name = "Chunk[-1,0]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -25.6, 0, 0 ) position_x = -1 @@ -73,7 +73,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 129, 77, 78, 78, 79, 80, 80, 81, 82, 1, 0, 81, 81, 80, 79, 78, 77, 14, 0, 49, 83, 84, 85, 1, 0, 240, 8, 84, 83, 82, 81, 80, 82, 83, 83, 84, 85, 86, 87, 87, 88, 88, 88, 88, 87, 87, 86, 85, 84, 82, 15, 0, 209, 88, 89, 89, 90, 91, 91, 91, 91, 90, 90, 89, 88, 87, 16, 0, 240, 1, 90, 91, 92, 93, 93, 94, 94, 94, 93, 93, 92, 91, 90, 88, 87, 88, 16, 0, 242, 53, 94, 95, 96, 96, 97, 97, 96, 95, 95, 94, 93, 91, 88, 90, 91, 93, 94, 95, 97, 98, 98, 99, 99, 99, 99, 98, 97, 96, 95, 94, 89, 91, 93, 94, 96, 97, 99, 100, 101, 101, 102, 102, 101, 101, 100, 99, 98, 97, 90, 92, 94, 95, 97, 99, 100, 102, 103, 104, 104, 104, 104, 103, 103, 102, 101, 100, 91, 93, 17, 0, 241, 42, 105, 105, 106, 106, 106, 106, 105, 105, 104, 103, 91, 93, 95, 98, 100, 102, 103, 105, 106, 107, 108, 108, 108, 108, 107, 107, 106, 106, 91, 94, 96, 98, 101, 103, 105, 106, 108, 109, 109, 110, 110, 110, 109, 109, 109, 108, 92, 94, 97, 99, 101, 104, 106, 107, 109, 110, 111, 1, 0, 240, 14, 110, 110, 92, 94, 97, 100, 102, 104, 106, 108, 110, 111, 112, 112, 113, 113, 112, 112, 112, 112, 92, 95, 97, 100, 103, 105, 107, 109, 110, 17, 0, 1, 2, 0, 49, 92, 95, 98, 18, 0, 66, 111, 112, 113, 114, 1, 0, 127, 92, 95, 98, 101, 103, 106, 108, 18, 0, 3, 112, 113, 114, 114, 114, 114, 114, 114 ) -[sub_resource type="TerraChunkBlocky" id=6] +[sub_resource type="TerraChunkBlocky" id=4] resource_name = "Chunk[-1,1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -25.6, 0, 25.6 ) position_x = -1 @@ -91,7 +91,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 194, 92, 95, 98, 101, 103, 106, 108, 109, 111, 112, 113, 114, 1, 0, 7, 18, 0, 3, 19, 0, 1, 18, 0, 114, 105, 107, 109, 111, 112, 112, 113, 20, 0, 146, 92, 95, 98, 100, 103, 105, 107, 109, 110, 19, 0, 48, 113, 113, 113, 18, 0, 112, 102, 105, 106, 108, 109, 110, 111, 1, 0, 242, 0, 112, 112, 112, 92, 95, 97, 100, 102, 104, 106, 107, 108, 109, 109, 110, 1, 0, 179, 92, 95, 97, 99, 101, 103, 104, 106, 107, 107, 108, 1, 0, 179, 92, 94, 96, 98, 100, 102, 103, 104, 105, 105, 106, 1, 0, 179, 92, 94, 96, 97, 99, 100, 101, 102, 103, 103, 104, 1, 0, 148, 92, 94, 95, 97, 98, 99, 100, 100, 101, 1, 0, 150, 102, 92, 93, 95, 96, 97, 98, 98, 99, 1, 0, 113, 92, 93, 94, 95, 96, 96, 97, 1, 0, 32, 96, 96, 10, 0, 82, 92, 93, 93, 94, 95, 1, 0, 17, 94, 1, 0, 32, 95, 92, 19, 0, 116, 94, 94, 94, 93, 93, 93, 92, 1, 0, 16, 93, 1, 0, 97, 92, 92, 91, 91, 91, 90, 1, 0, 18, 92, 29, 0, 112, 91, 91, 90, 89, 89, 89, 88, 1, 0, 3, 33, 0, 177, 90, 90, 89, 88, 88, 87, 87, 87, 86, 87, 87, 18, 0, 1, 17, 0, 128, 87, 87, 86, 86, 85, 85, 85, 85 ) -[sub_resource type="TerraChunkBlocky" id=7] +[sub_resource type="TerraChunkBlocky" id=5] resource_name = "Chunk[0,-2]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -51.2 ) position_z = -2 @@ -108,7 +108,7 @@ channel_count = 10 data_channel = PoolByteArray( 27, 1, 1, 0, 43, 4, 4, 17, 0, 15, 18, 0, 0, 29, 1, 36, 0, 15, 2, 0, 230, 80, 1, 1, 1, 1, 1 ) isolevel_channel = PoolByteArray( 240, 3, 51, 52, 52, 53, 53, 54, 55, 56, 57, 59, 60, 62, 64, 66, 67, 69, 71, 72, 16, 0, 0, 17, 0, 16, 58, 18, 0, 80, 65, 67, 68, 70, 71, 16, 0, 34, 55, 56, 18, 0, 16, 63, 37, 0, 49, 70, 54, 55, 17, 0, 176, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 69, 16, 0, 0, 17, 0, 33, 58, 59, 19, 0, 96, 64, 66, 67, 56, 56, 57, 1, 0, 21, 58, 19, 0, 16, 65, 15, 0, 1, 2, 0, 5, 20, 0, 1, 11, 0, 1, 19, 0, 0, 10, 0, 80, 59, 59, 60, 62, 58, 1, 0, 0, 15, 0, 18, 56, 80, 0, 32, 59, 60, 17, 0, 17, 58, 16, 0, 2, 117, 0, 37, 58, 59, 18, 0, 17, 55, 1, 0, 16, 56, 118, 0, 2, 36, 0, 65, 55, 55, 54, 54, 173, 0, 145, 57, 59, 59, 59, 58, 58, 57, 56, 56, 17, 0, 1, 208, 0, 10, 18, 0, 0, 55, 0, 11, 18, 0, 0, 91, 0, 4, 54, 0, 17, 55, 34, 0, 9, 18, 0, 4, 126, 0, 2, 54, 0, 192, 57, 56, 56, 56, 56, 56, 56, 57, 58, 58, 59, 60 ) -[sub_resource type="TerraChunkBlocky" id=8] +[sub_resource type="TerraChunkBlocky" id=6] resource_name = "Chunk[0,-1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -25.6 ) position_z = -1 @@ -125,7 +125,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 1, 1, 0, 159, 28, 4, 179, 0, 28, 4, 18, 0, 28, 4, 18, 0, 16, 4, 1, 0, 8, 55, 0, 0, 16, 0, 0, 2, 0, 5, 20, 0, 0, 13, 0, 15, 2, 0, 32, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 144, 59, 59, 59, 58, 58, 57, 56, 56, 55, 1, 0, 82, 56, 56, 57, 58, 59, 18, 0, 33, 57, 56, 1, 0, 87, 57, 58, 58, 59, 60, 18, 0, 115, 57, 57, 58, 59, 60, 61, 62, 18, 0, 0, 2, 0, 0, 33, 0, 53, 61, 62, 63, 18, 0, 3, 16, 0, 48, 64, 65, 60, 90, 0, 1, 2, 0, 1, 33, 0, 68, 64, 65, 66, 60, 19, 0, 4, 17, 0, 32, 67, 61, 19, 0, 0, 2, 0, 3, 34, 0, 51, 67, 68, 62, 19, 0, 5, 17, 0, 134, 69, 63, 62, 61, 61, 60, 60, 60, 17, 0, 132, 70, 64, 63, 62, 62, 61, 61, 61, 51, 0, 178, 69, 70, 70, 66, 65, 64, 63, 63, 63, 62, 63, 68, 0, 144, 69, 70, 70, 71, 68, 67, 66, 65, 64, 1, 0, 4, 17, 0, 96, 71, 70, 69, 68, 67, 66, 1, 0, 18, 67, 34, 0, 128, 72, 72, 72, 71, 70, 69, 69, 68, 1, 0, 225, 69, 69, 70, 71, 71, 72, 72, 73, 75, 74, 73, 72, 71, 70, 1, 0, 224, 71, 71, 72, 73, 73, 73, 73, 78, 77, 75, 74, 73, 73, 72, 1, 0, 240, 10, 73, 73, 74, 74, 75, 75, 75, 81, 80, 78, 77, 76, 75, 75, 74, 74, 74, 74, 75, 75, 76, 76, 76, 76, 76 ) -[sub_resource type="TerraChunkBlocky" id=9] +[sub_resource type="TerraChunkBlocky" id=7] resource_name = "Chunk[0,0]" size_x = 16 size_z = 16 @@ -140,7 +140,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 112, 78, 77, 75, 74, 73, 73, 72, 1, 0, 240, 1, 73, 73, 74, 74, 75, 75, 75, 81, 80, 78, 77, 76, 75, 75, 74, 74, 14, 0, 16, 76, 1, 0, 114, 84, 82, 81, 80, 79, 78, 77, 1, 0, 16, 78, 1, 0, 242, 15, 87, 85, 84, 83, 82, 81, 80, 80, 80, 79, 79, 80, 80, 80, 80, 81, 81, 80, 90, 88, 87, 86, 85, 84, 83, 83, 83, 82, 82, 83, 1, 0, 134, 93, 91, 90, 89, 88, 87, 87, 86, 1, 0, 134, 95, 94, 93, 92, 91, 91, 90, 89, 1, 0, 117, 98, 97, 96, 95, 95, 94, 93, 1, 0, 165, 92, 92, 101, 100, 99, 99, 98, 97, 97, 96, 1, 0, 132, 95, 104, 103, 102, 102, 101, 101, 100, 1, 0, 165, 99, 99, 99, 106, 106, 105, 104, 104, 104, 103, 1, 0, 149, 102, 102, 109, 108, 108, 107, 107, 107, 106, 1, 0, 104, 105, 105, 110, 110, 110, 109, 1, 0, 148, 108, 108, 112, 112, 112, 111, 111, 111, 112, 1, 0, 66, 111, 111, 110, 113, 1, 0, 19, 114, 1, 0, 50, 113, 113, 112, 10, 0, 65, 115, 115, 115, 116, 1, 0, 32, 115, 115, 17, 0, 2, 15, 0, 17, 117, 1, 0, 49, 116, 116, 116, 18, 0, 2, 17, 0, 112, 118, 118, 118, 118, 117, 117, 117 ) -[sub_resource type="TerraChunkBlocky" id=10] +[sub_resource type="TerraChunkBlocky" id=8] resource_name = "Chunk[0,1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 25.6 ) position_z = 1 @@ -157,7 +157,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 161, 114, 114, 114, 115, 115, 115, 116, 116, 116, 117, 1, 0, 49, 116, 116, 116, 18, 0, 2, 17, 0, 131, 118, 118, 118, 118, 117, 117, 117, 114, 19, 0, 2, 17, 0, 0, 2, 0, 48, 113, 113, 113, 56, 0, 0, 19, 0, 16, 117, 16, 0, 106, 118, 118, 112, 112, 112, 112, 20, 0, 71, 110, 110, 111, 111, 20, 0, 177, 118, 118, 118, 108, 108, 109, 109, 110, 110, 111, 112, 61, 0, 192, 116, 116, 117, 118, 118, 106, 106, 107, 107, 108, 108, 109, 42, 0, 242, 0, 113, 114, 115, 115, 116, 117, 118, 104, 104, 104, 105, 106, 106, 107, 108, 41, 0, 176, 114, 115, 116, 117, 101, 102, 102, 103, 103, 104, 105, 42, 0, 0, 60, 0, 129, 114, 116, 117, 99, 99, 100, 100, 101, 21, 0, 0, 40, 0, 160, 112, 113, 115, 116, 97, 97, 97, 98, 99, 99, 21, 0, 240, 5, 105, 106, 107, 109, 111, 112, 114, 115, 94, 95, 95, 96, 96, 97, 98, 99, 100, 101, 103, 104, 19, 0, 177, 113, 114, 92, 92, 93, 94, 94, 95, 96, 97, 98, 19, 0, 240, 3, 108, 110, 112, 113, 90, 90, 91, 91, 92, 93, 94, 95, 97, 98, 99, 101, 103, 105, 56, 0, 208, 88, 88, 89, 90, 90, 91, 92, 94, 95, 96, 98, 100, 101, 37, 0, 160, 111, 87, 87, 87, 88, 89, 90, 91, 92, 93, 19, 0, 144, 102, 104, 107, 109, 110, 85, 85, 86, 86, 20, 0, 160, 92, 93, 95, 97, 99, 101, 103, 106, 108, 109 ) -[sub_resource type="TerraChunkBlocky" id=11] +[sub_resource type="TerraChunkBlocky" id=9] resource_name = "Chunk[1,-1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 25.6, 0, -25.6 ) position_x = 1 @@ -175,7 +175,7 @@ channel_count = 10 data_channel = PoolByteArray( 21, 1, 1, 0, 19, 4, 1, 0, 5, 17, 0, 19, 1, 17, 0, 15, 18, 0, 9, 4, 35, 0, 5, 36, 0, 5, 17, 0, 4, 18, 0, 6, 17, 0, 2, 18, 0, 7, 16, 0, 2, 108, 0, 0, 8, 0, 6, 2, 0, 12, 16, 0, 37, 4, 4, 135, 0, 15, 2, 0, 129, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 242, 6, 58, 59, 60, 61, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 73, 74, 74, 74, 59, 60, 62, 17, 0, 17, 69, 18, 0, 68, 73, 74, 74, 61, 17, 0, 3, 18, 0, 35, 73, 73, 17, 0, 16, 68, 17, 0, 16, 72, 17, 0, 48, 73, 64, 65, 68, 0, 68, 69, 69, 70, 71, 18, 0, 58, 65, 66, 67, 17, 0, 18, 72, 50, 0, 1, 34, 0, 2, 53, 0, 17, 72, 33, 0, 7, 18, 0, 48, 72, 72, 68, 16, 0, 48, 70, 71, 71, 71, 0, 2, 2, 0, 0, 17, 0, 0, 16, 0, 5, 19, 0, 21, 71, 16, 0, 5, 2, 0, 1, 49, 0, 48, 71, 71, 70, 1, 0, 0, 9, 0, 4, 2, 0, 0, 16, 0, 1, 2, 0, 3, 61, 0, 8, 19, 0, 48, 70, 70, 72, 113, 0, 8, 18, 0, 17, 71, 203, 0, 7, 19, 0, 113, 71, 71, 75, 75, 75, 74, 74, 39, 0, 4, 119, 0, 66, 76, 76, 76, 76, 20, 0, 128, 72, 71, 71, 71, 71, 72, 72, 72 ) -[sub_resource type="TerraChunkBlocky" id=12] +[sub_resource type="TerraChunkBlocky" id=10] resource_name = "Chunk[1,0]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 25.6, 0, 0 ) position_x = 1 @@ -192,7 +192,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 224, 75, 75, 75, 74, 74, 73, 72, 72, 71, 71, 71, 70, 70, 71, 1, 0, 66, 76, 76, 76, 76, 20, 0, 0, 21, 0, 145, 71, 72, 72, 72, 78, 78, 78, 77, 77, 20, 0, 1, 1, 0, 192, 72, 72, 72, 81, 80, 80, 80, 79, 78, 77, 76, 76, 62, 0, 176, 74, 74, 74, 73, 73, 83, 83, 83, 82, 81, 81, 21, 0, 16, 77, 64, 0, 130, 75, 75, 74, 86, 86, 85, 85, 84, 21, 0, 33, 79, 78, 44, 0, 128, 89, 89, 88, 88, 87, 86, 85, 84, 43, 0, 0, 64, 0, 129, 78, 77, 92, 92, 92, 91, 90, 89, 21, 0, 0, 43, 0, 133, 80, 79, 79, 96, 95, 95, 94, 93, 21, 0, 149, 83, 82, 81, 80, 99, 99, 98, 97, 96, 21, 0, 0, 20, 0, 68, 102, 102, 101, 100, 21, 0, 163, 90, 89, 88, 86, 85, 84, 105, 105, 104, 103, 21, 0, 1, 20, 0, 98, 87, 86, 108, 108, 107, 106, 21, 0, 180, 98, 97, 95, 94, 92, 91, 90, 88, 111, 110, 109, 20, 0, 163, 99, 98, 96, 95, 93, 92, 90, 113, 112, 111, 21, 0, 210, 103, 102, 100, 99, 97, 95, 94, 93, 115, 114, 113, 113, 112, 20, 0, 33, 104, 103, 39, 0, 82, 116, 116, 115, 114, 114, 20, 0, 48, 106, 105, 103, 78, 0, 97, 117, 117, 116, 116, 115, 115, 20, 0, 112, 108, 107, 105, 103, 102, 100, 99 ) -[sub_resource type="TerraChunkBlocky" id=13] +[sub_resource type="TerraChunkBlocky" id=11] resource_name = "Chunk[1,1]" transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 25.6, 0, 25.6 ) position_x = 1 @@ -210,7 +210,7 @@ channel_count = 10 data_channel = PoolByteArray( 31, 4, 1, 0, 255, 44, 80, 4, 4, 4, 4, 4 ) isolevel_channel = PoolByteArray( 241, 9, 116, 116, 115, 114, 114, 113, 112, 111, 110, 109, 108, 106, 105, 103, 101, 100, 98, 97, 117, 117, 116, 116, 115, 115, 20, 0, 216, 108, 107, 105, 103, 102, 100, 99, 118, 118, 117, 117, 117, 116, 19, 0, 16, 118, 1, 0, 0, 40, 0, 64, 114, 113, 111, 110, 57, 0, 80, 102, 118, 118, 119, 119, 40, 0, 81, 116, 115, 114, 112, 111, 76, 0, 0, 18, 0, 1, 20, 0, 146, 116, 115, 113, 112, 110, 109, 107, 106, 104, 18, 0, 16, 119, 18, 0, 134, 114, 113, 111, 109, 108, 107, 105, 117, 19, 0, 18, 114, 37, 0, 33, 116, 117, 55, 0, 1, 37, 0, 0, 18, 0, 51, 108, 106, 116, 37, 0, 1, 55, 0, 0, 92, 0, 35, 107, 115, 37, 0, 5, 18, 0, 32, 106, 114, 19, 0, 16, 118, 129, 0, 2, 54, 0, 113, 107, 106, 113, 114, 116, 117, 117, 165, 0, 2, 164, 0, 112, 107, 106, 112, 113, 115, 116, 117, 1, 0, 5, 163, 0, 101, 111, 112, 114, 115, 116, 116, 199, 0, 96, 107, 105, 104, 110, 111, 113, 19, 0, 1, 255, 0, 0, 70, 0, 129, 104, 103, 109, 110, 112, 113, 114, 115, 36, 1, 0, 17, 0, 240, 6, 105, 103, 102, 108, 109, 111, 112, 113, 113, 114, 113, 112, 112, 110, 109, 108, 106, 105, 103, 102, 100 ) -[sub_resource type="ProceduralSky" id=1] +[sub_resource type="ProceduralSky" id=12] sky_top_color = Color( 0.447059, 0.780392, 0.854902, 1 ) sky_horizon_color = Color( 0.27451, 0.278431, 0.207843, 1 ) sky_curve = 0.263535 @@ -227,9 +227,9 @@ sun_angle_max = 23.15 sun_energy = 9.29 texture_size = 0 -[sub_resource type="Environment" id=2] +[sub_resource type="Environment" id=13] background_mode = 2 -background_sky = SubResource( 1 ) +background_sky = SubResource( 12 ) ambient_light_color = Color( 0.870588, 0.870588, 0.870588, 1 ) ambient_light_energy = 1.24 ambient_light_sky_contribution = 0.09 @@ -764,7 +764,7 @@ library = ExtResource( 17 ) level_generator = ExtResource( 18 ) voxel_scale = 1.6 chunk_spawn_range = 2 -chunks = [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ] +chunks = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ] build_flags = 254 chunk_lod_falloff = 0 num_lods = 0 @@ -773,7 +773,7 @@ show_loading_screen = false generate_on_ready = true [node name="WorldEnvironment" type="WorldEnvironment" parent="World"] -environment = SubResource( 2 ) +environment = SubResource( 13 ) __meta__ = { "_editor_description_": "" } diff --git a/game/menu/MenuWorld.gd b/game/menu/MenuWorld.gd new file mode 100644 index 00000000..d2d21373 --- /dev/null +++ b/game/menu/MenuWorld.gd @@ -0,0 +1,361 @@ +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 + +export(int) var test_lod : int = 0 setget set_test_lod + +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 + elif key == "chunk_lod_falloff": + chunk_lod_falloff = value + elif key == "chunk_lod_first_falloff": + chunk_lod_first_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") + chunk_lod_first_falloff = Settings.get_value("game", "chunk_lod_first_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(Vector2(x, 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(): + 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 +# mesher.lod_index = 3 + tj.set_mesher(mesher) + + var s : TerraMesherJobStep = TerraMesherJobStep.new() + s.job_type = TerraMesherJobStep.TYPE_NORMAL + tj.add_jobs_step(s) + +# s = TerraMesherJobStep.new() +# s.job_type = TerraMesherJobStep.TYPE_NORMAL_LOD +# s.lod_index = 1 +# tj.add_jobs_step(s) +# +# s = TerraMesherJobStep.new() +# s.job_type = TerraMesherJobStep.TYPE_NORMAL_LOD +# s.lod_index = 2 +# tj.add_jobs_step(s) +# +# s = TerraMesherJobStep.new() +# s.job_type = TerraMesherJobStep.TYPE_MERGE_VERTS +# tj.add_jobs_step(s) +# +# s = TerraMesherJobStep.new() +# s.job_type = TerraMesherJobStep.TYPE_BAKE_TEXTURE +# tj.add_jobs_step(s) + + + 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: + + 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 + +func set_test_lod(val : int) -> void: + test_lod = val + + for i in range(chunk_get_count()): + var c : TerraChunkDefault = chunk_get_index(i) + + c.current_lod_level = test_lod + +