Table of Contents

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 fails
  • 1 != 1.0 — int vs float always fails
  • true != 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

requiredProperties Dictionary<string, object>
allowEmptyCells bool

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

bool

Id

Unique identifier for the rule.

public string Id { get; }

Property Value

string

Name

Human-readable name for the rule.

public string Name { get; }

Property Value

string

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

Dictionary<string, object>

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

tileData CoreTileData

The tile data to validate.

errorMessage string

Set 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

configuration IGridConfiguration

The grid configuration.

gridPosition CoreVector2I

The grid position to validate.

placementData PlacementData

The data of the item being placed.

Returns

ValidationResult

A ValidationResult indicating success or failure.