new iteration
This commit is contained in:
parent
ec3b8ab884
commit
c6a94dba80
@ -214,8 +214,6 @@ function tryObjectEnterContainer(container, object)
|
|||||||
-- stop mini cards from forming decks
|
-- stop mini cards from forming decks
|
||||||
if object.hasTag("Minicard") and container.hasTag("Minicard") then
|
if object.hasTag("Minicard") and container.hasTag("Minicard") then
|
||||||
return false
|
return false
|
||||||
elseif object.type == "Card" then
|
|
||||||
finishCardMoving(object)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
playAreaApi.tryObjectEnterContainer(container, object)
|
playAreaApi.tryObjectEnterContainer(container, object)
|
||||||
@ -308,6 +306,12 @@ function onPlayerAction(player, action, targets)
|
|||||||
trash.putObject(target)
|
trash.putObject(target)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
elseif action == Player.Action.PickUp then
|
||||||
|
for _, target in ipairs(targets) do
|
||||||
|
if target.type == "Card" or target.type == "Deck" then
|
||||||
|
storeTokenTransform(target)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2847,15 +2851,8 @@ function moveCardWithTokens(params)
|
|||||||
local position = params.position
|
local position = params.position
|
||||||
local rotation = params.rotation
|
local rotation = params.rotation
|
||||||
|
|
||||||
-- store local position/rotation of tokens
|
if not cardTokens[card] then
|
||||||
cardTokens[card] = {}
|
storeTokenTransform(card)
|
||||||
local cardRot = card.getRotation()
|
|
||||||
for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do
|
|
||||||
if not token.locked then
|
|
||||||
cardTokens[card].token = token
|
|
||||||
cardTokens[card].localPos = card.positionToLocal(token.getPosition())
|
|
||||||
cardTokens[card].localRot = token.getRotation() - cardRot
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if position then
|
if position then
|
||||||
@ -2866,12 +2863,15 @@ function moveCardWithTokens(params)
|
|||||||
card.setRotationSmooth(rotation)
|
card.setRotationSmooth(rotation)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- wait for the card to finish moving
|
if #cardTokens[card] == 0 then return end
|
||||||
|
|
||||||
|
-- wait for the card to finish moving, update token position/rotation regularly
|
||||||
Wait.condition(
|
Wait.condition(
|
||||||
function() finishCardMoving(card) end,
|
function() cardTokens[card] = nil end,
|
||||||
function()
|
function()
|
||||||
if card ~= nil then
|
if card ~= nil and cardTokens[card] ~= nil and #cardTokens[card] ~= 0 then
|
||||||
return card.resting and card.isSmoothMoving()
|
updateTokenTransform(card)
|
||||||
|
return card.resting and not card.isSmoothMoving()
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -2879,16 +2879,27 @@ function moveCardWithTokens(params)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function finishCardMoving(card)
|
function storeTokenTransform(card)
|
||||||
if card == nil or cardTokens[card] == nil or #cardTokens[card] == 0 then return end
|
cardTokens[card] = {}
|
||||||
|
|
||||||
local cardRot = card.getRotation()
|
local cardRot = card.getRotation()
|
||||||
for _, tokenData in ipairs(cardTokens[card]) do
|
for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do
|
||||||
tokenData.token.setPosition(card.positionToWorld(tokenData.localPos))
|
if not token.locked then
|
||||||
tokenData.token.setRotation(cardRot + tokenData.localRot)
|
local tokenPos = token.getPosition() + Vector(0, 0.1, 0) -- small offset so tokens don't collide with card
|
||||||
|
token.setPosition(tokenPos)
|
||||||
|
table.insert(cardTokens[card], {
|
||||||
|
token = token,
|
||||||
|
localPos = card.positionToLocal(tokenPos),
|
||||||
|
localRot = token.getRotation() - cardRot
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
cardTokens[card] = nil
|
function updateTokenTransform(card)
|
||||||
|
for _, tokenData in ipairs(cardTokens[card] or {}) do
|
||||||
|
tokenData.token.setPosition(card.positionToWorld(tokenData.localPos))
|
||||||
|
tokenData.token.setRotation(card.getRotation() + tokenData.localRot)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- removes tokens from the provided card/deck
|
-- removes tokens from the provided card/deck
|
||||||
|
Loading…
Reference in New Issue
Block a user