re-added collision disabling

This commit is contained in:
Chr1Z93 2024-02-04 22:46:52 +01:00
parent d9c89ff2fa
commit b2f08eb466
5 changed files with 33 additions and 33 deletions

View File

@ -20,6 +20,7 @@
"Note": "", "Note": "",
"ObjectStates_order": [ "ObjectStates_order": [
"GUIDReferenceHandler.123456", "GUIDReferenceHandler.123456",
"TokenSpawnTracker.e3ffc9",
"HandTrigger.5fe087", "HandTrigger.5fe087",
"HandTrigger.be2f17", "HandTrigger.be2f17",
"HandTrigger.0285cc", "HandTrigger.0285cc",
@ -167,7 +168,7 @@
"PhaseTrackerCache.49922d", "PhaseTrackerCache.49922d",
"PhaseTrackerCache.16832f", "PhaseTrackerCache.16832f",
"PhaseTrackerCache.645841", "PhaseTrackerCache.645841",
"TokenSpawnTracker.e3ffc9",
"TokenSource.124381", "TokenSource.124381",
"GameData.3dbe47", "GameData.3dbe47",
"SCEDTour.0e5aa8", "SCEDTour.0e5aa8",

View File

@ -19,6 +19,7 @@ local ENCOUNTER_DISCARD_AREA = {
local ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 } local ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 }
local ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1, z = 10.38 } local ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1, z = 10.38 }
local isReshuffling = false local isReshuffling = false
local collisionEnabled = false
local currentScenario, useFrontData, tokenData local currentScenario, useFrontData, tokenData
local TRASH, DATA_HELPER local TRASH, DATA_HELPER
@ -31,6 +32,8 @@ function onLoad(saveState)
end end
TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper")
Wait.time(function() collisionEnabled = true end, 0.1)
end end
function onSave() function onSave()
@ -47,8 +50,14 @@ end
-- TTS event handler. Handles scenario name event triggering and encounter card token resets. -- TTS event handler. Handles scenario name event triggering and encounter card token resets.
function onCollisionEnter(collisionInfo) function onCollisionEnter(collisionInfo)
if not collisionEnabled then return end
local object = collisionInfo.collision_object local object = collisionInfo.collision_object
-- early exit for better performance
if object.type ~= "Card" then return end
-- get scenario name and maybe fire followup event
if object.getName() == "Scenario" then if object.getName() == "Scenario" then
local description = object.getDescription() local description = object.getDescription()
@ -72,7 +81,7 @@ function onCollisionEnter(collisionInfo)
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
tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID()) Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID()) end, 1)
removeTokensFromObject(object) removeTokensFromObject(object)
end end
end end

View File

@ -39,13 +39,12 @@ local LOC_LINK_EXCLUDE_SCENARIOS = {
["The Heart of Madness"] = true ["The Heart of Madness"] = true
} }
local clueData = {}
local spawnedLocationGUIDs = {}
local locations = {} local locations = {}
local locationConnections = {} local locationConnections = {}
local draggingGuids = {} local draggingGuids = {}
local missingData = {} local missingData = {}
local locationData, currentScenario, connectionsEnabled local collisionEnabled = false
local currentScenario, connectionsEnabled
--------------------------------------------------------- ---------------------------------------------------------
-- general code -- general code
@ -67,6 +66,8 @@ function onLoad(savedData)
currentScenario = loadedData.currentScenario currentScenario = loadedData.currentScenario
connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 } connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }
connectionsEnabled = loadedData.connectionsEnabled or true connectionsEnabled = loadedData.connectionsEnabled or true
Wait.time(function() collisionEnabled = true end, 0.1)
end end
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
@ -105,31 +106,30 @@ end
-- TTS event, called for each object that is placed on the playarea -- TTS event, called for each object that is placed on the playarea
function onCollisionEnter(collisionInfo) function onCollisionEnter(collisionInfo)
local obj = collisionInfo.collision_object if not collisionEnabled then return end
local objType = obj.name
-- only continue for cards local object = collisionInfo.collision_object
if objType ~= "Card" and objType ~= "CardCustom" then
if objType == "Deck" then if object.type == "Deck" then
table.insert(missingData, obj) table.insert(missingData, object)
end
return
end end
-- only continue for cards
if object.type ~= "Card" then return end
-- check if we should spawn clues here and do so according to playercount -- check if we should spawn clues here and do so according to playercount
local card = collisionInfo.collision_object if shouldSpawnTokens(object) then
if shouldSpawnTokens(card) then tokenManager.spawnForCard(object)
tokenManager.spawnForCard(card)
end end
-- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send -- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send
-- the dropped card immediately into a deck, so this has to be done here -- the dropped card immediately into a deck, so this has to be done here
if draggingGuids[card.getGUID()] ~= nil then if draggingGuids[object.getGUID()] ~= nil then
card.setVectorLines(nil) object.setVectorLines(nil)
draggingGuids[card.getGUID()] = nil draggingGuids[object.getGUID()] = nil
end end
maybeTrackLocation(card) maybeTrackLocation(object)
end end
function shouldSpawnTokens(card) function shouldSpawnTokens(card)
@ -540,11 +540,6 @@ function isInPlayArea(object)
return position.x > c1.x and position.x < c2.x and position.z > c1.z and position.z < c2.z return position.x > c1.x and position.x < c2.x and position.z > c1.z and position.z < c2.z
end end
-- Reset the play area's tracking of which cards have had tokens spawned.
function resetSpawnedCards()
spawnedLocationGUIDs = {}
end
function onScenarioChanged(scenarioName) function onScenarioChanged(scenarioName)
currentScenario = scenarioName currentScenario = scenarioName
if not showLocationLinks() then if not showLocationLinks() then

View File

@ -41,11 +41,6 @@ do
return getPlayArea().call("shiftContentsRight", playerColor) return getPlayArea().call("shiftContentsRight", playerColor)
end end
-- Reset the play area's tracking of which cards have had tokens spawned.
PlayAreaApi.resetSpawnedCards = function()
return getPlayArea().call("resetSpawnedCards")
end
-- Sets whether location connections should be drawn -- Sets whether location connections should be drawn
PlayAreaApi.setConnectionDrawState = function(state) PlayAreaApi.setConnectionDrawState = function(state)
getPlayArea().call("setConnectionDrawState", state) getPlayArea().call("setConnectionDrawState", state)

View File

@ -144,8 +144,8 @@ function onLoad(saveState)
end end
showDrawButton(isDrawButtonVisible) showDrawButton(isDrawButtonVisible)
collisionEnabled = true
math.randomseed(os.time()) math.randomseed(os.time())
Wait.time(function() collisionEnabled = true end, 0.1)
end end
--------------------------------------------------------- ---------------------------------------------------------