Added parent pos setup to the world generator resources.

This commit is contained in:
Relintai 2021-12-27 03:48:55 +01:00
parent a44e362e31
commit 82435d4c59
6 changed files with 29 additions and 22 deletions

View File

@ -50,7 +50,9 @@ func edit(object):
# make_bottom_panel_item_visible(editor_scene)
if object is WorldGenWorld:
editor_scene.set_wgworld(object as WorldGenWorld)
var wgw : WorldGenWorld = object as WorldGenWorld
wgw.setup()
editor_scene.set_wgworld(wgw)
func make_visible(visible):
if tool_button:

View File

@ -25,6 +25,7 @@ func create_content(item_name : String = "") -> void:
func add_content(entry : WorldGenBaseResource) -> void:
zones.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:

View File

@ -5,6 +5,19 @@ class_name WorldGenBaseResource
export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100)
export(bool) var locked : bool = false
var _parent_pos : Vector2 = Vector2()
func setup() -> void:
_setup()
for c in get_content():
if c:
c.set_parent_pos(_parent_pos + get_rect().position)
c.setup()
func _setup() -> void:
pass
func get_rect() -> Rect2:
return rect
@ -12,6 +25,16 @@ func set_rect(r : Rect2) -> void:
rect = r
emit_changed()
func get_parent_pos() -> Vector2:
return _parent_pos
func set_parent_pos(parent_pos : Vector2) -> void:
_parent_pos = parent_pos
for c in get_content():
if c:
c.set_parent_pos(_parent_pos + get_rect().position)
func get_content() -> Array:
return Array()

View File

@ -25,6 +25,7 @@ func add_content(entry : WorldGenBaseResource) -> void:
entry.set_rect(r)
continents.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:

View File

@ -25,6 +25,7 @@ func create_content(item_name : String = "") -> void:
func add_content(entry : WorldGenBaseResource) -> void:
subzones.append(entry)
entry.set_parent_pos(get_parent_pos() + get_rect().position)
emit_changed()
func remove_content_entry(entry : WorldGenBaseResource) -> void:

View File

@ -113,22 +113,17 @@ subzones = [ ]
resource_name = "wwww"
script = ExtResource( 2 )
rect = Rect2( 163, 35, 241, 158 )
locked = false
zones = [ SubResource( 8 ), SubResource( 13 ), SubResource( 24 ), SubResource( 26 ), SubResource( 32 ), SubResource( 35 ) ]
[sub_resource type="Resource" id=2]
resource_name = "efefef"
script = ExtResource( 2 )
rect = Rect2( 107, 271, 100, 49 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=3]
resource_name = "grgrg"
script = ExtResource( 2 )
rect = Rect2( 498, 185, 100, 100 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=9]
resource_name = "asd"
@ -148,7 +143,6 @@ subzones = [ ]
resource_name = "qwdasd"
script = ExtResource( 2 )
rect = Rect2( 522, 29, 63, 54 )
locked = false
zones = [ SubResource( 9 ), SubResource( 10 ) ]
[sub_resource type="Resource" id=11]
@ -162,7 +156,6 @@ subzones = [ ]
resource_name = "qwe"
script = ExtResource( 2 )
rect = Rect2( 473, 331, 100, 100 )
locked = false
zones = [ SubResource( 11 ) ]
[sub_resource type="GDScript" id=16]
@ -265,8 +258,6 @@ zones = [ SubResource( 11 ) ]
resource_name = "ggg"
script = ExtResource( 2 )
rect = Rect2( 26, 51, 100, 100 )
locked = false
zones = [ ]
[sub_resource type="GDScript" id=21]
script/source = "tool
@ -320,42 +311,30 @@ zones = [ ]
resource_name = "eeqqq"
script = ExtResource( 2 )
rect = Rect2( 256, 365, 100, 100 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=27]
resource_name = "asd"
script = ExtResource( 2 )
rect = Rect2( 337, 79, 100, 100 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=28]
resource_name = "asd"
script = ExtResource( 2 )
rect = Rect2( 244, 234, 100, 100 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=29]
script = ExtResource( 2 )
rect = Rect2( 377, 69, 284, 238 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=30]
resource_name = "tttttt"
script = ExtResource( 2 )
rect = Rect2( 188, 225, 233, 259 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=31]
resource_name = "ttttyuqtttt"
script = ExtResource( 2 )
rect = Rect2( 339, 76, 220, 170 )
locked = false
zones = [ ]
[sub_resource type="Resource" id=33]
resource_name = "qttt"