Skip to content

Commit

Permalink
fixed a bug where barehand digging 'box' would not align as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
curioustorvald committed Feb 9, 2022
1 parent 4612493 commit e69cb58
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,18 @@ object PickaxeCore {
) = mouseInInteractableRangeTools(actor, item) {
// un-round the mx
val ww = INGAME.world.width
val hpww = ww * TILE_SIZE / 2
val apos = actor.centrePosPoint
val mx = if (apos.x < 0.0 && mx >= ww / 2) mx - ww
else if (apos.x > 0.0 && mx < ww / 2) mx + ww
val mx = if (apos.x - mx * TILE_SIZE< -hpww) mx - ww
else if (apos.x - mx * TILE_SIZE >= hpww) mx + ww
else mx
val wmx = mx * TILE_SIZED
val wmy = my * TILE_SIZED

var xoff = -(mw / 2) // implicit flooring
var yoff = -(mh / 2) // implicit flooring
// if mw or mh is even number, make it closer toward the actor
if (mw % 2 == 0 && apos.x > wmx) xoff += 1
if (mh % 2 == 0 && apos.y > wmy) yoff += 1

if (mw % 2 == 0 && apos.x > mx * TILE_SIZE) xoff += 1
if (mh % 2 == 0 && apos.y > my * TILE_SIZE) yoff += 1
var usageStatus = false

for (oy in 0 until mh) for (ox in 0 until mw) {
Expand Down

0 comments on commit e69cb58

Please sign in to comment.