Class TileDataCheckRuleCore
- Namespace
- MoonBark.GridPlacement.Core.Data.Placement
- Assembly
- MoonBark.GridPlacement.Core.dll
Pure C# placement rule that validates tile custom data properties.
Evaluates whether a tile's custom data layers match the expected values.
For example: verify a tile has growable == true before allowing crop placement.
This is the Core counterpart to MoonBark.GridPlacement.Godot.Placement.PlacementRules.TileDataCheckRuleDefinition (Godot-side). It contains no Godot dependencies and is fully testable in xunit.
Strict equality rules for comparison:
1 != true— int vs bool always fails1 != 1.0— int vs float always failstrue != false— same type, different value fails
public sealed class TileDataCheckRuleCore : IPlacementRule
- Inheritance
-
TileDataCheckRuleCore
- Implements
- Inherited Members
Constructors
TileDataCheckRuleCore()
Creates a rule with the given required properties.
public TileDataCheckRuleCore()
TileDataCheckRuleCore(Dictionary<string, object?>, bool)
Creates a rule with the given required properties.
public TileDataCheckRuleCore(Dictionary<string, object?> requiredProperties, bool allowEmptyCells = false)
Parameters
requiredPropertiesDictionary<string, object>allowEmptyCellsbool
Properties
AllowEmptyCells
Whether to skip tiles with no data (empty cell) as a pass. If false, empty cells fail the check.
public bool AllowEmptyCells { get; set; }
Property Value
Id
Unique identifier for the rule.
public string Id { get; }
Property Value
Name
Human-readable name for the rule.
public string Name { get; }
Property Value
RequiredProperties
Maps property name → expected value. Values are plain C# types: bool, int, float, string, etc.
public Dictionary<string, object?> RequiredProperties { get; set; }
Property Value
Methods
CheckTileData(CoreTileData, out string)
Validates tile data against this rule's requirements. Uses strict type equality — a type mismatch fails even if values would coerce.
public bool CheckTileData(CoreTileData tileData, out string errorMessage)
Parameters
tileDataCoreTileDataThe tile data to validate.
errorMessagestringSet to a description of the failure when returning false.
Returns
- bool
True if all properties match or cell is empty and AllowEmptyCells is true.
Validate(IGridConfiguration, CoreVector2I, PlacementData?)
Validates the placement against this rule.
public ValidationResult Validate(IGridConfiguration configuration, CoreVector2I gridPosition, PlacementData? placementData)
Parameters
configurationIGridConfigurationThe grid configuration.
gridPositionCoreVector2IThe grid position to validate.
placementDataPlacementDataThe data of the item being placed.
Returns
- ValidationResult
A ValidationResult indicating success or failure.