Skip to content

Commit

Permalink
add a bit of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBond committed Nov 25, 2023
1 parent c5bd576 commit 30d6fcf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addons/wfc/nodes/generator_2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions addons/wfc/problems/2d/mappers/mapper_2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.
"""
Expand All @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions addons/wfc/problems/2d/preconditions/precondition_2d_base.gd
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 30d6fcf

Please sign in to comment.