From 30d6fcfc812bb40341ebd0c675189ec503f8c719 Mon Sep 17 00:00:00 2001 From: "A.Bond" Date: Sat, 25 Nov 2023 19:35:05 +0600 Subject: [PATCH] add a bit of docs --- addons/wfc/nodes/generator_2d.gd | 2 +- addons/wfc/problems/2d/mappers/mapper_2d.gd | 6 +++--- .../2d/preconditions/precondition_2d_base.gd | 6 ++++++ .../precondition_2d_base_settings.gd | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/addons/wfc/nodes/generator_2d.gd b/addons/wfc/nodes/generator_2d.gd index cb002d6..0171f35 100644 --- a/addons/wfc/nodes/generator_2d.gd +++ b/addons/wfc/nodes/generator_2d.gd @@ -93,7 +93,7 @@ func _create_precondition(problem_settings: WFC2DProblem.WFC2DProblemSettings, m parameters.target_node = map parameters.problem_settings = problem_settings - parameters.base_node = self + parameters.generator_node = self return settings.create_precondition(parameters) diff --git a/addons/wfc/problems/2d/mappers/mapper_2d.gd b/addons/wfc/problems/2d/mappers/mapper_2d.gd index 35f0422..b92964d 100644 --- a/addons/wfc/problems/2d/mappers/mapper_2d.gd +++ b/addons/wfc/problems/2d/mappers/mapper_2d.gd @@ -14,7 +14,7 @@ func get_used_rect(_map: Node) -> Rect2i: func read_cell(_map: Node, _coords: Vector2i) -> int: """ Read cell from map and return a mapped code. - + Returns a negative value if cell is empty or mapping for the cell is missing. """ @warning_ignore("assert_always_false") @@ -24,7 +24,7 @@ func read_cell(_map: Node, _coords: Vector2i) -> int: func read_tile_meta(_tile: int, _meta_name: String) -> Array: """ Read metadata attribute values associated with given cell type. - + May return array of multiple values if cell type consists of multiple objects having metadata. E.g. combinations of different tiles in multi-layer tilemap. """ @@ -35,7 +35,7 @@ func read_tile_meta(_tile: int, _meta_name: String) -> Array: func write_cell(_map: Node, _coords: Vector2i, _code: int): """ Write a cell to map. - + code should be inside acceptable range for mapped codes. """ @warning_ignore("assert_always_false") diff --git a/addons/wfc/problems/2d/preconditions/precondition_2d_base.gd b/addons/wfc/problems/2d/preconditions/precondition_2d_base.gd index c81c424..82a7345 100644 --- a/addons/wfc/problems/2d/preconditions/precondition_2d_base.gd +++ b/addons/wfc/problems/2d/preconditions/precondition_2d_base.gd @@ -1,6 +1,12 @@ class_name WFC2DPrecondition extends RefCounted +""" +Sets initial conditions (by deciding what tiles can be placed in what cells) for 2D WFC generation. + +Instances should be created by WFC2DPrecondition2DNullSettings subclasses. +""" + func prepare(): """ May calculate data necessary for this precondition. diff --git a/addons/wfc/problems/2d/preconditions/precondition_2d_base_settings.gd b/addons/wfc/problems/2d/preconditions/precondition_2d_base_settings.gd index 045b7cb..9c859a3 100644 --- a/addons/wfc/problems/2d/preconditions/precondition_2d_base_settings.gd +++ b/addons/wfc/problems/2d/preconditions/precondition_2d_base_settings.gd @@ -1,10 +1,27 @@ extends Resource class_name WFC2DPrecondition2DNullSettings +""" +Contains serializable settings for creation of a WFC2DPrecondition. + +This base class creates an empty precondition that does not limit acontent of any cells. +For custom precondition classes a corresponding WFC2DPrecondition2DNullSettings subclasses should exist. + +This class is named WFC2DPrecondition2DNullSettings, not WFC2DPrecondition2DSettings to make it clearer to +node inspector users that it will create a "null" (empty, default) precondition. +If GdScript supported interfaces or abstract classes then there would be an interface/abstract class +IWFC2DPrecondition2DSettings and WFC2DPrecondition2DNullSettings extending/implementing it along with +other concreate classes. +But with GdScript all other precondition settings classes should extend WFC2DPrecondition2DNullSettings. +""" + class CreationParameters: var problem_settings: WFC2DProblem.WFC2DProblemSettings var target_node: Node - var base_node: Node + var generator_node: WFC2DGenerator func create_precondition(parameters: CreationParameters) -> WFC2DPrecondition: + """ + Instantiates a precondition using settings from this object. + """ return WFC2DPrecondition.new()