mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-02-01 14:37:01 +01:00
Now trees will spawn on grass. Currently it's done with nodes/mesh instances for testing. It actually looks a lot better that I anticipated, so I'll soon port it to use terraman's prop system (Which also needs to have material caches implemented).
This commit is contained in:
parent
c7938caaa8
commit
254fb23d98
@ -1,6 +1,8 @@
|
||||
[gd_resource type="Biome" load_steps=2 format=2]
|
||||
[gd_resource type="Biome" load_steps=3 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/biomes/simple_biome/low_poly_rpg_item_collection_3/t1.tscn" type="PackedScene" id=2]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
tree = ExtResource( 2 )
|
||||
|
@ -1,8 +1,10 @@
|
||||
[gd_resource type="Biome" load_steps=3 format=2]
|
||||
[gd_resource type="Biome" load_steps=4 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.tscn" type="PackedScene" id=3]
|
||||
|
||||
[resource]
|
||||
buildings = [ ExtResource( 2 ) ]
|
||||
script = ExtResource( 1 )
|
||||
tree = ExtResource( 3 )
|
||||
|
@ -21,6 +21,8 @@ extends Biome
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
export(PackedScene) var tree : PackedScene
|
||||
|
||||
var terrarin_gen : BiomeTerrarinGenerator = BiomeTerrarinGenerator.new()
|
||||
|
||||
var voxel_scale : float = -1
|
||||
@ -32,6 +34,11 @@ func _setup():
|
||||
var d : Building = get_building(i)
|
||||
d.setup()
|
||||
|
||||
func _instance(p_seed, p_instance):
|
||||
p_instance.tree = tree
|
||||
|
||||
return ._instance(p_seed, p_instance)
|
||||
|
||||
func _generate_terra_chunk(chunk, spawn_mobs):
|
||||
if voxel_scale < 0:
|
||||
voxel_scale = chunk.voxel_scale
|
||||
@ -93,3 +100,18 @@ func gen_terra_chunk(chunk: TerraChunk) -> void:
|
||||
chunk.set_voxel(2, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|
||||
elif val > 90:
|
||||
chunk.set_voxel(4, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|
||||
else:
|
||||
#Todo use the prop system for this
|
||||
if randf() > 0.992:
|
||||
var t = tree.instance()
|
||||
|
||||
var spat : Spatial = t as Spatial
|
||||
|
||||
spat.rotate(Vector3(0, 1, 0), randf() * PI)
|
||||
spat.rotate(Vector3(1, 0, 0), randf() * 0.2 - 0.1)
|
||||
spat.rotate(Vector3(0, 0, 1), randf() * 0.2 - 0.1)
|
||||
spat.transform = spat.transform.scaled(Vector3(0.9 + 0.8 - randf(), 0.9 + 0.8 - randf(), 0.9 + 0.8 - randf()))
|
||||
spat.transform.origin = Vector3((x + chunk.position_x * chunk.size_x) * chunk.voxel_scale, ((val - 2) / 255.0) * chunk.world_height * chunk.voxel_scale, (z + chunk.position_z * chunk.size_z) * chunk.voxel_scale)
|
||||
|
||||
chunk.voxel_world.call_deferred("add_child", spat)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user