RuleDef
ldtk.rules.RuleDef (Class)
All the data of an auto-layer rule needed to compute tiles, plus the pure pattern helpers.
The LDtk editor extends this class; other consumers (games, tools) build instances with fromJson.
Pattern cell encoding: see RuleConst.
Static Members
readTileMode(v: Dynamic): Anonymous
readCheckerMode(v: Dynamic): Anonymous
Read every field from JSON into an existing rule (tolerant to missing fields and legacy formats)
Instance Members
First condition of each cell (0 = ignored). Row major, cx + cy*size.
Extra conditions of each cell. Invariant: patternAlt[i].length>0 implies pattern[i]!=0
tileMode: Anonymous
checker: Anonymous
IntGrid values (or group rule values) that must exist for this rule to possibly match. Derived by updateUsedValues().
Recompute explicitlyRequiredValues. Must be called after any pattern change. Only single-condition cells are hard requirements.
Set a cell to a single condition (any extra condition of this cell is discarded)
All the conditions of a cell (first one from pattern, then the extra ones), or an empty array. Allocates: not for hot paths.
hasAnyMultiConditionCell(): Bool
Replace all the conditions of a cell. Zeros are removed, duplicates are removed, and if both +v and -v are present only the last one is kept.
A cell matches if (it has no required value, or the cell value is one of the required values) AND (the cell value is none of the forbidden values).
Change the pattern size, keeping the existing cells centered
Shrink the pattern while its borders are empty
hasAnyPositionOffset(): Bool
hasRandomTileFlip(): Bool
hasAnyRandomVariation(): Bool
Any random variation of the rendered tile (position offset or flip). For UI purpose.
hasAnyRandomFeature(): Bool
TRUE if this rule uses any random feature (chance, perlin, tile pick, offsets, flips)
Random chance test, shared by the 4 flip variants of a cell
Perlin filtering test
Modulo and checker tests
Prefilter: FALSE if a required value is absent from the whole source layer
Prefilter: FALSE if a required value is absent from the areas covered by the pattern around given coord
The tile rect to render at given coord (a reference into tileRectsIds, do not modify)
Random render flip bits (bit0=X, bit1=Y) for given coord, based on tileRandomFlipX/Y
| Name |
Type |
Default |
uid |
Int |
|
size |
Int |
3 |
Private Members
Compare all the conditions of 2 cells (order insensitive)