Merge pull request #187 from argonui/loc-snap-shadow

Bugfix for location lines
This commit is contained in:
Chr1Z 2023-01-13 22:34:22 +01:00 committed by GitHub
commit 5f0b2037db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,14 +136,20 @@ function onObjectPickUp(player, object)
local objType = object.name
if objType ~= "Card" and objType ~= "CardCustom" then return end
-- onCollisionExit fires first, so we have to check the card to see if it's a location we should
-- be tracking
-- onCollisionExit USUALLY fires first, so we have to check the card to see if it's a location we
-- should be tracking
if showLocationLinks() and isInPlayArea(object) and object.getGMNotes() ~= nil and object.getGMNotes() ~= "" then
local pickedUpGuid = object.getGUID()
local metadata = JSON.decode(object.getGMNotes())
if (metadata.type == "Location") then
-- onCollisionExit sometimes comes 1 frame after onObjectPickUp (rather than before it or in
-- the same frame). This causes a mismatch in the data between dragging the on-table, and
-- that one frame draws connectors on the card which then show up as shadows for snap points.
-- Waiting ensures we always do thing in the expected Exit->PickUp order
Wait.frames(function()
draggingGuids[pickedUpGuid] = metadata
rebuildConnectionList()
end, 2)
end
end
end
@ -356,7 +362,7 @@ function drawDraggingConnections()
-- Objects should reliably exist at this point, but since this can be called during onUpdate the
-- object checks are conservative just to make sure.
local origin = getObjectFromGUID(originGuid)
if draggingGuids[originGuid] and origin != nil then
if draggingGuids[originGuid] and origin ~= nil and targetGuids ~= nil then
ownedVectors[originGuid] = { }
for targetGuid, direction in pairs(targetGuids) do
local target = getObjectFromGUID(targetGuid)