ArrayRuleSource

ldtk.rules.ArrayRuleSource (Class)
Implements: RuleSource

RuleSource over a flat IntGrid array (same layout as the intGridCsv JSON field: row major, 0 = empty). Keeps per-area value counters so that the engine prefilter can skip irrelevant rules, exactly like the LDtk editor does. IntGrid groups are counted under their rule value (groupUid+1)*1000.

Static Members

makeGroupTable(values: Array<AnonStruct>): haxe.ds.Vector<Int>

Build a value to group table from a list of (value, groupUid) pairs

Name Type
values Array
Returns
haxe.ds.Vector<Int>

Instance Members

intGrid: Array<Int>

cWid: Int

cHei: Int

getWidth(): Int
Returns
Int

getHeight(): Int
Returns
Int

getIntGrid(cx: Int, cy: Int): Int
Name Type
cx Int
cy Int
Returns
Int

getGroupUidOfValue(v: Int): Int
Name Type
v Int
Returns
Int

containsIntGridValueOrGroup(v: Int): Bool
Name Type
v Int
Returns
Bool

hasIntGridValueInArea(v: Int, cx: Int, cy: Int): Bool
Name Type
v Int
cx Int
cy Int
Returns
Bool

setIntGrid(cx: Int, cy: Int, v: Int): Void

Change a cell value and keep the prefilter counters up to date

Name Type
cx Int
cy Int
v Int

recount(): Void

Recount everything from the current intGrid content (existing counters are reused, not reallocated)


recountRect(cx: Int, cy: Int, wid: Int, hei: Int): Void

Recount only the areas intersecting a rectangle of cells. Use it after the shared intGrid array was modified directly (not through setIntGrid) in that rectangle.

Name Type
cx Int
cy Int
wid Int
hei Int

new(intGrid: Array<Int>, cWid: Int, cHei: Int, valueGroupUids: haxe.ds.Vector<Int>): Void
Name Type
intGrid Array<Int>
cWid Int
cHei Int
valueGroupUids haxe.ds.Vector<Int>

Private Members

valueGroupUids: haxe.ds.Vector<Int>

valueGroupUids[value] = group uid of the IntGrid value, or -1 (index 0 unused)


areaCols: Int

areaRows: Int

areaCounts: Map

layerCounts: Map

recountArea(ax: Int, ay: Int): Void
Name Type
ax Int
ay Int

imin(a: Int, b: Int): Int
Name Type
a Int
b Int
Returns
Int

imax(a: Int, b: Int): Int
Name Type
a Int
b Int
Returns
Int

changeCount(v: Int, cx: Int, cy: Int, delta: Int): Void
Name Type
v Int
cx Int
cy Int
delta Int

changeSingleCount(v: Int, cx: Int, cy: Int, delta: Int): Void
Name Type
v Int
cx Int
cy Int
delta Int

addLayerCount(v: Int, delta: Int): Void
Name Type
v Int
delta Int