Started working on a layered world. It's not used yet. And will probably not get used for a while.

This commit is contained in:
Relintai 2022-03-05 14:23:39 +01:00
parent f50a687e27
commit 95101dcf2d
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,25 @@
tool
extends Viewport
export(bool) var enabled : bool = false setget set_enabled, get_enabled
var terrain : Node2D
var _enabled : bool
func _ready():
terrain = $World
set_enabled(enabled)
func get_enabled() -> bool:
return _enabled
func set_enabled(val) -> void:
_enabled = val
if _enabled:
render_target_clear_mode = Viewport.CLEAR_MODE_ALWAYS
render_target_update_mode = Viewport.UPDATE_ALWAYS
else:
render_target_clear_mode = Viewport.CLEAR_MODE_NEVER
render_target_update_mode = Viewport.UPDATE_DISABLED

View File

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/layered_world/Layer.gd" type="Script" id=1]
[ext_resource path="res://scenes/terra_2d_world/Terrain2DWorldBlocky.tscn" type="PackedScene" id=3]
[node name="Layer" type="Viewport"]
size = Vector2( 100, 100 )
own_world = true
disable_3d = true
usage = 0
render_target_clear_mode = 1
render_target_update_mode = 0
audio_listener_enable_2d = true
script = ExtResource( 1 )
[node name="World" parent="." instance=ExtResource( 3 )]

View File

@ -0,0 +1,36 @@
tool
extends Node2D
var _player_file_name : String
var _player : Entity
func _ready():
pass # Replace with function body.
func load_character(file_name: String) -> void:
_player_file_name = file_name
#This is where things start to break due to preceision
#var world_pos : Vector2 = Vector2(5000000, 5000000) # In world coords: (0, 4500000), chunk coords: (9765, 9765)
var world_pos : Vector2 = Vector2(0, 0)
var tm : Vector2 = mesh_transform_terrain.xform(world_pos)
_player = ESS.entity_spawner.load_player(file_name, tm, 1) as Entity
#TODO hack, do this properly
# _player.set_physics_process(false)
Server.sset_seed(_player.sseed)
spawn(world_pos.x / (cell_size_x * chunk_size_x), world_pos.y / (cell_size_y * chunk_size_x))
#if spawn_mobs:
# generate()
func save() -> void:
if _player == null or _player_file_name == "":
return
ESS.entity_spawner.save_player(_player, _player_file_name)

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/layered_world/Layered_world.gd" type="Script" id=1]
[ext_resource path="res://scenes/layered_world/Layer.tscn" type="PackedScene" id=2]
[node name="World" type="Node2D"]
script = ExtResource( 1 )
[node name="Overworld" parent="." instance=ExtResource( 2 )]
[node name="DungeonLayer1" parent="." instance=ExtResource( 2 )]