diff --git a/game/addons/world_generator/plugin.gd b/game/addons/world_generator/plugin.gd index 76c019f8..1d80a917 100644 --- a/game/addons/world_generator/plugin.gd +++ b/game/addons/world_generator/plugin.gd @@ -1,10 +1,11 @@ tool extends EditorPlugin -var WorldGenWorld = preload("res://addons/world_generator/resources/world_gen_world.gd") -var Continent = preload("res://addons/world_generator/resources/continent.gd") -var Zone = preload("res://addons/world_generator/resources/zone.gd") -var SubZone = preload("res://addons/world_generator/resources/subzone.gd") +var SWorldGenBaseResource = preload("res://addons/world_generator/resources/world_gen_base_resource.gd") +var SWorldGenWorld = preload("res://addons/world_generator/resources/world_gen_world.gd") +var SContinent = preload("res://addons/world_generator/resources/continent.gd") +var SZone = preload("res://addons/world_generator/resources/zone.gd") +var SSubZone = preload("res://addons/world_generator/resources/subzone.gd") var editor_packed_scene = preload("res://addons/world_generator/ui/MainScreen.tscn") var editor_scene = null @@ -12,10 +13,13 @@ var editor_scene = null var tool_button : ToolButton = null func _enter_tree(): - add_custom_type("WorldGenWorld", "Resource", WorldGenWorld, null) - add_custom_type("Continent", "Resource", Continent, null) - add_custom_type("Zone", "Resource", Zone, null) - add_custom_type("SubZone", "Resource", SubZone, null) + add_custom_type("WorldGenBaseResource", "Resource", SWorldGenBaseResource, null) + #Don't change the base to "WorldGenBaseResource" else it will complain about a non-existant class + #Also it works perfectly like this + add_custom_type("WorldGenWorld", "Resource", SWorldGenWorld, null) + add_custom_type("Continent", "Resource", SContinent, null) + add_custom_type("Zone", "Resource", SZone, null) + add_custom_type("SubZone", "Resource", SSubZone, null) editor_scene = editor_packed_scene.instance() @@ -23,6 +27,7 @@ func _enter_tree(): tool_button.hide() func _exit_tree(): + remove_custom_type("WorldGenBaseResource") remove_custom_type("WorldGenWorld") remove_custom_type("Continent") remove_custom_type("Zone") diff --git a/game/addons/world_generator/resources/continent.gd b/game/addons/world_generator/resources/continent.gd index f5611db8..1f93e201 100644 --- a/game/addons/world_generator/resources/continent.gd +++ b/game/addons/world_generator/resources/continent.gd @@ -1,6 +1,14 @@ tool -extends Resource +extends "res://addons/world_generator/resources/world_gen_base_resource.gd" class_name Continent -export(Rect2) var rect : Rect2 -export(Array) var data : Array +export(Array) var zones : Array + +func get_content() -> Array: + return zones + +func set_content(arr : Array) -> void: + zones = arr + +func setup_property_inspector(inspector) -> void: + .setup_property_inspector(inspector) diff --git a/game/addons/world_generator/resources/subzone.gd b/game/addons/world_generator/resources/subzone.gd index 233ad5dc..416682a4 100644 --- a/game/addons/world_generator/resources/subzone.gd +++ b/game/addons/world_generator/resources/subzone.gd @@ -1,5 +1,7 @@ tool -extends Resource +extends "res://addons/world_generator/resources/world_gen_base_resource.gd" class_name SubZone -export(Rect2) var rect : Rect2 +func setup_property_inspector(inspector) -> void: + .setup_property_inspector(inspector) + diff --git a/game/addons/world_generator/resources/world_gen_base_resource.gd b/game/addons/world_generator/resources/world_gen_base_resource.gd new file mode 100644 index 00000000..4443b571 --- /dev/null +++ b/game/addons/world_generator/resources/world_gen_base_resource.gd @@ -0,0 +1,14 @@ +tool +extends Resource +class_name WorldGenBaseResource + +export(Rect2) var rect : Rect2 = Rect2(0, 0, 1, 1) + +func get_content() -> Array: + return Array() + +func set_content(arr : Array) -> void: + pass + +func setup_property_inspector(inspector) -> void: + inspector.add_slot_line_edit("get_name", "set_name", "Name") diff --git a/game/addons/world_generator/resources/world_gen_world.gd b/game/addons/world_generator/resources/world_gen_world.gd index 6110c446..96fc4761 100644 --- a/game/addons/world_generator/resources/world_gen_world.gd +++ b/game/addons/world_generator/resources/world_gen_world.gd @@ -1,5 +1,15 @@ tool -extends Resource +extends "res://addons/world_generator/resources/world_gen_base_resource.gd" class_name WorldGenWorld -export(Array) var data : Array +export(Array) var continents : Array + +func get_content() -> Array: + return continents + +func set_content(arr : Array) -> void: + continents = arr + +func setup_property_inspector(inspector) -> void: + .setup_property_inspector(inspector) + diff --git a/game/addons/world_generator/resources/zone.gd b/game/addons/world_generator/resources/zone.gd index f6f51a8b..4ff93bf5 100644 --- a/game/addons/world_generator/resources/zone.gd +++ b/game/addons/world_generator/resources/zone.gd @@ -1,6 +1,14 @@ tool -extends Resource +extends "res://addons/world_generator/resources/world_gen_base_resource.gd" class_name Zone -export(Rect2) var rect : Rect2 -export(Array) var data : Array +export(Array) var subzones : Array + +func get_content() -> Array: + return subzones + +func set_content(arr : Array) -> void: + subzones = arr + +func setup_property_inspector(inspector) -> void: + .setup_property_inspector(inspector) diff --git a/game/addons/world_generator/test/test_world.tres b/game/addons/world_generator/test/test_world.tres index e8c4236b..fb1844a7 100644 --- a/game/addons/world_generator/test/test_world.tres +++ b/game/addons/world_generator/test/test_world.tres @@ -3,4 +3,7 @@ [ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1] [resource] +resource_name = "asdasdss" script = ExtResource( 1 ) +rect = Rect2( 0, 0, 1, 1 ) +continents = [ ]