mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
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:
parent
f50a687e27
commit
95101dcf2d
25
game/scenes/layered_world/Layer.gd
Normal file
25
game/scenes/layered_world/Layer.gd
Normal 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
|
16
game/scenes/layered_world/Layer.tscn
Normal file
16
game/scenes/layered_world/Layer.tscn
Normal 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 )]
|
36
game/scenes/layered_world/Layered_world.gd
Normal file
36
game/scenes/layered_world/Layered_world.gd
Normal 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)
|
11
game/scenes/layered_world/Layered_world.tscn
Normal file
11
game/scenes/layered_world/Layered_world.tscn
Normal 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 )]
|
Loading…
Reference in New Issue
Block a user