Stop event from firing multiple times for the same scenario

A card can collide with the area more than once; many of the campaign memory bags caused a double collision on placement, and it would happen if the user picked up or flipped the card.

This would cause any behavior that triggered from the event to each time, so suppress further events which don't actually change the scenario.
This commit is contained in:
Buhallin 2022-12-15 13:08:32 -08:00
parent 7339646ae7
commit 45a5870121
No known key found for this signature in database
GPG Key ID: DB3C362823852294

View File

@ -20,12 +20,14 @@ end
function onCollisionEnter(collisionInfo)
local object = collisionInfo.collision_object
if object.getName() == "Scenario" then
log("Collision: " .. object.getGUID())
currentScenario = object.getDescription()
fireScenarioChangedEvent()
if currentScenario ~= object.getDescription() then
currentScenario = object.getDescription()
fireScenarioChangedEvent()
end
end
end
function fireScenarioChangedEvent()
log("Firing")
playAreaApi.onScenarioChanged(currentScenario)
end