CellTileBuffer

ldtk.rules.CellTileBuffer (Class)
Implements: AutoTileSink

Cell indexed tile store for runtime use, supporting partial recomputes: the tiles of any cell can be cleared and rewritten in place (RuleEngine.computeRect). Records live in a reusable pool of STRIDE ints, chained per cell; the capacity is kept between computes and nothing is allocated once the pool has reached its peak size. Record layout: ruleIndex (index in the evaluation order), tid, flips, x, y, srcX, srcY, alpha*4096, next record (-1 = end).

Static Members

STRIDE: Int

Instance Members

records: Array<Int>

cellCount: Int

Number of cells of the layer (set by reset)


tileCount: Int

rulesCount: Int

Number of rules declared by the last setRules


reset(cellCount: Int): Void

Size the store for a layer of cellCount cells and empty it

Name Type
cellCount Int

setRules(rulesEvalOrder: Array<RuleDef>): Bool

Declare the rules of the next compute (evaluation order). Must be called before beginRule. Returns TRUE if the rule list differs from the previous one: the stored rule indexes are then stale and the store must be fully recomputed.

Name Type
rulesEvalOrder Array<RuleDef>
Returns
Bool

beginRule(ruleUid: Int): Void
Name Type
ruleUid Int

add(coordId: Int, x: Int, y: Int, srcX: Int, srcY: Int, tid: Int, flips: Int, a: Float): Void
Name Type
coordId Int
x Int
y Int
srcX Int
srcY Int
tid Int
flips Int
a Float

clearCell(coordId: Int): Void

Remove the tiles of a cell (the records go back to the free list)

Name Type
coordId Int

clearRect(left: Int, top: Int, right: Int, bottom: Int, w: Int): Void

Remove the tiles of every cell of a rectangle (inclusive bounds)

Name Type
left Int
top Int
right Int
bottom Int
w Int

writeDisplayOrder(out: Array<Int>): Int

Write every tile in display order (rules from the last evaluated to the first, cells in ascending order, tiles of a cell in production order) as 7 ints per tile: tid, flips, x, y, srcX, srcY, alpha*4096. This is the autoLayerTiles layout and the exact order produced by RuleEngine.flatten in the editor. out is reused and resized; returns the number of ints written.

Name Type
out Array<Int>
Returns
Int

cellHead(coordId: Int): Int

First record of a cell, or -1

Name Type
coordId Int
Returns
Int

recordNext(i: Int): Int

Record following i, or -1

Name Type
i Int
Returns
Int

new(): Void

Private Members



countByRule: haxe.ds.Vector<Int>

ruleIndexByUid: Map

freeHead: Int

used: Int

curRuleIndex: Int