Removed parent_positions from WorldGenBaseResources, and also removed the setup() method. I'ts better this way, as they are resources, and now they can be reused (even though the gui itself doesn't support it). Spawning code is also simpler.

This commit is contained in:
Relintai 2022-08-04 20:05:19 +02:00
parent 345aa62ed4
commit ffe566b0ac
7 changed files with 2 additions and 30 deletions

View File

@ -52,7 +52,6 @@ func edit(object):
if object is WorldGenWorld: if object is WorldGenWorld:
var wgw : WorldGenWorld = object as WorldGenWorld var wgw : WorldGenWorld = object as WorldGenWorld
wgw.setup()
editor_scene.set_wgworld(wgw) editor_scene.set_wgworld(wgw)
func make_visible(visible): func make_visible(visible):

View File

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

View File

@ -5,19 +5,6 @@ class_name WorldGenBaseResource
export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100) export(Rect2) var rect : Rect2 = Rect2(0, 0, 100, 100)
export(bool) var locked : bool = false 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: func get_rect() -> Rect2:
return rect return rect
@ -32,16 +19,6 @@ func set_locked(r : bool) -> void:
locked = r locked = r
emit_changed() 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: func get_content() -> Array:
return Array() return Array()

View File

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

View File

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

View File

@ -35,7 +35,6 @@ func setup(world : TerrainWorld, level_seed : int, spawn_mobs : bool, library: T
_library = library _library = library
if world_gen_world != null: if world_gen_world != null:
world_gen_world.setup()
world_gen_world.setup_terra_library(_library, _level_seed) world_gen_world.setup_terra_library(_library, _level_seed)
_library.refresh_rects() _library.refresh_rects()

View File

@ -23,14 +23,14 @@ vendor = ExtResource( 8 )
[sub_resource type="Resource" id=4] [sub_resource type="Resource" id=4]
resource_name = "DungeonSpawner" resource_name = "DungeonSpawner"
script = ExtResource( 11 ) script = ExtResource( 11 )
rect = Rect2( 10.4375, 4.76562, 0.734375, 0.734375 ) rect = Rect2( 9.96875, 4.07812, 2.26562, 1.79688 )
locked = false locked = false
dungeon_teleporter = ExtResource( 4 ) dungeon_teleporter = ExtResource( 4 )
[sub_resource type="Resource" id=5] [sub_resource type="Resource" id=5]
resource_name = "DungeonSpawner2" resource_name = "DungeonSpawner2"
script = ExtResource( 11 ) script = ExtResource( 11 )
rect = Rect2( 13.689, 6.71965, 1.30323, 1.0916 ) rect = Rect2( 13.439, 6.6259, 3.11573, 2.0916 )
locked = false locked = false
dungeon_teleporter = ExtResource( 4 ) dungeon_teleporter = ExtResource( 4 )