tokens spawn on card
This commit is contained in:
parent
e33f3d9d9e
commit
abc291fd5c
@ -2050,6 +2050,7 @@ function TokenManager.spawnTokenGroup(params)
|
||||
local tokenCount = params.tokenCount
|
||||
local shiftDown = params.shiftDown
|
||||
local subType = params.subType
|
||||
local temporary = params.temporary
|
||||
|
||||
if tokenType == "damage" or tokenType == "horror" then
|
||||
TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)
|
||||
@ -2058,7 +2059,7 @@ function TokenManager.spawnTokenGroup(params)
|
||||
elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "custom" and tokenCount == 0 then
|
||||
TokenManager.spawnResourceCounterToken(card, tokenCount)
|
||||
else
|
||||
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)
|
||||
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType, temporary)
|
||||
end
|
||||
end
|
||||
|
||||
@ -2089,7 +2090,8 @@ end
|
||||
---@param tokenCount number How many tokens to spawn
|
||||
---@param shiftDown? number An offset for the z-value of this group of tokens
|
||||
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource or action tokens
|
||||
function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)
|
||||
---@param temporary? boolean If present adds the temporary tag to an action token
|
||||
function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType, temporary)
|
||||
if tokenCount < 1 then return end
|
||||
|
||||
local offsets = {}
|
||||
@ -2124,6 +2126,7 @@ function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown
|
||||
end
|
||||
|
||||
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
||||
log(temporary)
|
||||
local callbackName = nil
|
||||
local callbackParams = nil
|
||||
local stateID = stateTable[string.lower(subType or "")]
|
||||
@ -2134,7 +2137,11 @@ function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown
|
||||
local matColor = playermatApi.getMatColorByPosition(card.getPosition())
|
||||
local activeInvestigatorData = playermatApi.getActiveInvestigatorData(matColor)
|
||||
callbackName = "updateUniversalActionAbilityToken"
|
||||
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class }
|
||||
if temporary then
|
||||
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class, addTag = "Temporary" }
|
||||
else
|
||||
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class}
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, tokenCount do
|
||||
|
@ -70,7 +70,8 @@ do
|
||||
-- spawned state object rather than spawning multiple tokens
|
||||
---@param shiftDown? number An offset for the z-value of this group of tokens
|
||||
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens
|
||||
function TokenManagerApi.spawnTokenGroup(card, tokenType, tokenCount, shiftDown, subType)
|
||||
---@param temporary? boolean If present adds the temporary tag to an action token
|
||||
function TokenManagerApi.spawnTokenGroup(card, tokenType, tokenCount, shiftDown, subType, temporary)
|
||||
Global.call("callTable", {
|
||||
{ "TokenManager", "spawnTokenGroup" },
|
||||
{
|
||||
@ -78,7 +79,8 @@ do
|
||||
tokenType = tokenType,
|
||||
tokenCount = tokenCount,
|
||||
shiftDown = shiftDown,
|
||||
subType = subType
|
||||
subType = subType,
|
||||
temporary = temporary
|
||||
}
|
||||
})
|
||||
end
|
||||
|
@ -92,33 +92,7 @@ function spawnActionToken(numTokens)
|
||||
local position = self.getPosition()
|
||||
local matColor = playermatApi.getMatColorByPosition(position)
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
||||
local rotation = mat.getRotation()
|
||||
|
||||
-- find empty action token slots by checking snap points
|
||||
local snaps = mat.getSnapPoints()
|
||||
|
||||
-- get empty slots
|
||||
local emptyPositions = {}
|
||||
for i, snap in ipairs(snaps) do
|
||||
if i > 1 then
|
||||
if snap.tags[1] == "UniversalToken" then
|
||||
local snapPos = mat.positionToWorld(snap.position)
|
||||
local searchResult = searchLib.atPosition(snapPos, "isUniversalToken")
|
||||
if #searchResult == 0 then
|
||||
table.insert(emptyPositions, snapPos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local activeInvestigatorData = playermatApi.getActiveInvestigatorData(matColor)
|
||||
local callbackParams = { class = activeInvestigatorData.class, symbol = activeInvestigatorData.class, addTag = "Temporary" }
|
||||
local callbackName = "updateUniversalActionAbilityToken"
|
||||
for i = 1, numTokens do
|
||||
if emptyPositions[i] ~= nil then
|
||||
tokenManagerApi.spawnToken(emptyPositions[i] + Vector(0, 0.7, 0), "universalActionAbility", rotation, callbackName, callbackParams)
|
||||
else
|
||||
tokenManagerApi.spawnToken(position + Vector(0, 0.7, 0), "universalActionAbility", rotation, callbackName, callbackParams)
|
||||
end
|
||||
end
|
||||
tokenManagerApi.spawnTokenGroup(self, "universalActionAbility", numTokens, 0.8, _, true)
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user