Merge pull request #841 from argonui/mythos-area
Added position check to scenario reference detection
This commit is contained in:
commit
d6d9e7a019
@ -16,6 +16,10 @@ local ENCOUNTER_DISCARD_AREA = {
|
|||||||
upperLeft = { x = 1.77, z = 0.15 },
|
upperLeft = { x = 1.77, z = 0.15 },
|
||||||
lowerRight = { x = 1.42, z = 0.59 }
|
lowerRight = { x = 1.42, z = 0.59 }
|
||||||
}
|
}
|
||||||
|
local SCENARIO_REFERENCE_AREA = {
|
||||||
|
upperLeft = { x = -1.45, z = 0.15 },
|
||||||
|
lowerRight = { x = -1.75, z = 0.59 }
|
||||||
|
}
|
||||||
|
|
||||||
-- global position of encounter deck and discard pile
|
-- global position of encounter deck and discard pile
|
||||||
local ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 }
|
local ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 }
|
||||||
@ -48,10 +52,17 @@ function onLoad(savedData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function copyScenarioReferenceCard()
|
function copyScenarioReferenceCard()
|
||||||
if scenarioCard == nil then broadcastToAll("No scenario reference card found.", "Red") return end
|
if scenarioCard == nil then
|
||||||
|
broadcastToAll("No scenario reference card found.", "Red")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local usedColors = playermatApi.getUsedMatColors()
|
local usedColors = playermatApi.getUsedMatColors()
|
||||||
if #usedColors == 0 then broadcastToAll("No investigators placed.", "Red") return end
|
if #usedColors == 0 then
|
||||||
|
broadcastToAll("No investigators placed.", "Red")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for _, color in ipairs(usedColors) do
|
for _, color in ipairs(usedColors) do
|
||||||
local cardPosition = playermatApi.transformLocalPosition({ -1.365, 0.1, -0.625 }, color)
|
local cardPosition = playermatApi.transformLocalPosition({ -1.365, 0.1, -0.625 }, color)
|
||||||
local searchResult = searchLib.atPosition(cardPosition, "isCardOrDeck")
|
local searchResult = searchLib.atPosition(cardPosition, "isCardOrDeck")
|
||||||
@ -80,27 +91,25 @@ function onCollisionEnter(collisionInfo)
|
|||||||
|
|
||||||
local object = collisionInfo.collision_object
|
local object = collisionInfo.collision_object
|
||||||
|
|
||||||
-- early exit for better performance (but should exclude Tiles again in 4.0)
|
-- early exit for better performance
|
||||||
if object.type ~= "Card" and object.type ~= "Tile" then return end
|
if object.type ~= "Card" then return end
|
||||||
|
|
||||||
-- reset spawned tokens and remove tokens from cards in encounter deck / discard area
|
|
||||||
local localPos = self.positionToLocal(object.getPosition())
|
local localPos = self.positionToLocal(object.getPosition())
|
||||||
|
|
||||||
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
||||||
|
-- reset spawned tokens and remove tokens from cards in encounter deck / discard area
|
||||||
Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object) end, 1)
|
Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object) end, 1)
|
||||||
removeTokensFromObject(object)
|
removeTokensFromObject(object)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get metadata
|
elseif inArea(localPos, SCENARIO_REFERENCE_AREA) then
|
||||||
|
-- detect scenario reference card and attempt to load data from it
|
||||||
local md = JSON.decode(object.getGMNotes()) or {}
|
local md = JSON.decode(object.getGMNotes()) or {}
|
||||||
|
|
||||||
-- get scenario name and maybe fire followup event
|
|
||||||
local cardName = object.getName()
|
local cardName = object.getName()
|
||||||
if object.getName() == "Scenario" or md.type == "ScenarioReference" then
|
|
||||||
|
if cardName == "Scenario" or md.type == "ScenarioReference" then
|
||||||
getDataFromReferenceCard(object, cardName, md)
|
getDataFromReferenceCard(object, cardName, md)
|
||||||
scenarioCard = object
|
scenarioCard = object
|
||||||
if scenarioCard.type == "Card" then
|
scenarioCard.setPosition({ -3.85, 1.60, -10.39 })
|
||||||
scenarioCard.setPosition{-3.85, 1.60, -10.39}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user