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 tokenCount = params.tokenCount
|
||||||
local shiftDown = params.shiftDown
|
local shiftDown = params.shiftDown
|
||||||
local subType = params.subType
|
local subType = params.subType
|
||||||
|
local temporary = params.temporary
|
||||||
|
|
||||||
if tokenType == "damage" or tokenType == "horror" then
|
if tokenType == "damage" or tokenType == "horror" then
|
||||||
TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)
|
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
|
elseif tokenType == "resource" and optionPanel["useResourceCounters"] == "custom" and tokenCount == 0 then
|
||||||
TokenManager.spawnResourceCounterToken(card, tokenCount)
|
TokenManager.spawnResourceCounterToken(card, tokenCount)
|
||||||
else
|
else
|
||||||
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)
|
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType, temporary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2089,7 +2090,8 @@ end
|
|||||||
---@param tokenCount number How many tokens to spawn
|
---@param tokenCount number How many tokens to spawn
|
||||||
---@param shiftDown? number An offset for the z-value of this group of 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 or action 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
|
if tokenCount < 1 then return end
|
||||||
|
|
||||||
local offsets = {}
|
local offsets = {}
|
||||||
@ -2124,6 +2126,7 @@ function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
||||||
|
log(temporary)
|
||||||
local callbackName = nil
|
local callbackName = nil
|
||||||
local callbackParams = nil
|
local callbackParams = nil
|
||||||
local stateID = stateTable[string.lower(subType or "")]
|
local stateID = stateTable[string.lower(subType or "")]
|
||||||
@ -2134,8 +2137,12 @@ function TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown
|
|||||||
local matColor = playermatApi.getMatColorByPosition(card.getPosition())
|
local matColor = playermatApi.getMatColorByPosition(card.getPosition())
|
||||||
local activeInvestigatorData = playermatApi.getActiveInvestigatorData(matColor)
|
local activeInvestigatorData = playermatApi.getActiveInvestigatorData(matColor)
|
||||||
callbackName = "updateUniversalActionAbilityToken"
|
callbackName = "updateUniversalActionAbilityToken"
|
||||||
|
if temporary then
|
||||||
|
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class, addTag = "Temporary" }
|
||||||
|
else
|
||||||
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class}
|
callbackParams = { class = activeInvestigatorData.class, symbol = subType or activeInvestigatorData.class}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, tokenCount do
|
for i = 1, tokenCount do
|
||||||
TokenManager.spawnToken({
|
TokenManager.spawnToken({
|
||||||
|
@ -70,7 +70,8 @@ do
|
|||||||
-- spawned state object rather than spawning multiple tokens
|
-- spawned state object rather than spawning multiple tokens
|
||||||
---@param shiftDown? number An offset for the z-value of this group of 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
|
---@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", {
|
Global.call("callTable", {
|
||||||
{ "TokenManager", "spawnTokenGroup" },
|
{ "TokenManager", "spawnTokenGroup" },
|
||||||
{
|
{
|
||||||
@ -78,7 +79,8 @@ do
|
|||||||
tokenType = tokenType,
|
tokenType = tokenType,
|
||||||
tokenCount = tokenCount,
|
tokenCount = tokenCount,
|
||||||
shiftDown = shiftDown,
|
shiftDown = shiftDown,
|
||||||
subType = subType
|
subType = subType,
|
||||||
|
temporary = temporary
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -92,33 +92,7 @@ function spawnActionToken(numTokens)
|
|||||||
local position = self.getPosition()
|
local position = self.getPosition()
|
||||||
local matColor = playermatApi.getMatColorByPosition(position)
|
local matColor = playermatApi.getMatColorByPosition(position)
|
||||||
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
||||||
local rotation = mat.getRotation()
|
|
||||||
|
|
||||||
-- find empty action token slots by checking snap points
|
tokenManagerApi.spawnTokenGroup(self, "universalActionAbility", numTokens, 0.8, _, true)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user