sort pieces T->B, L->R
This commit is contained in:
parent
193888cd2b
commit
1c9fc2de85
1 changed files with 10 additions and 4 deletions
14
board.gd
14
board.gd
|
|
@ -15,10 +15,16 @@ func top_left_aabb() -> AABB:
|
||||||
func bottom_right_aabb() -> AABB:
|
func bottom_right_aabb() -> AABB:
|
||||||
return AABB(position + Vector3(dims.x, 0, dims.y) + Vector3(1,0,2), Vector3.ONE*0.1)
|
return AABB(position + Vector3(dims.x, 0, dims.y) + Vector3(1,0,2), Vector3.ONE*0.1)
|
||||||
|
|
||||||
# todo: Array[Piece]
|
func pieces() -> Array[Piece]:
|
||||||
func pieces() -> Array:
|
var sorted: Array[Piece] = []
|
||||||
# todo: sort for consistency
|
for child in get_children():
|
||||||
return get_children()
|
if child is Piece:
|
||||||
|
sorted.push_back(child)
|
||||||
|
# important for consistency.
|
||||||
|
# everything involving pieces is done top to bottom, then left to right
|
||||||
|
# expensive? yes. wasteful? definitely. worth it? i think so.
|
||||||
|
sorted.sort_custom(func(a, b): return a.lpos.y < b.lpos.y or a.lpos.x < b.lpos.x)
|
||||||
|
return sorted
|
||||||
|
|
||||||
func pieces_at(pos: Vector2i) -> Array[Piece]:
|
func pieces_at(pos: Vector2i) -> Array[Piece]:
|
||||||
var out: Array[Piece] = []
|
var out: Array[Piece] = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue