Add some cleanup for playmat snap type setting, as well as a get() method to return the current state

This commit is contained in:
Buhallin 2022-12-04 14:49:34 -08:00 committed by Chr1Z93
parent bd89174377
commit 5231609f44
2 changed files with 18 additions and 21 deletions

View File

@ -653,8 +653,7 @@ end
-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all
-- cards.
-- @param matchTypes Boolean. Whether snap points should only snap for the matching card types.
function setLimitSnapsByType(params)
local matchTypes = params.matchTypes
function setLimitSnapsByType(matchTypes)
local snaps = self.getSnapPoints()
for i, snap in ipairs(snaps) do
local snapPos = snap.position
@ -691,7 +690,7 @@ end
-- @param bounds Table. Defined area to see if the point is within. See MAIN_PLAY_AREA for sample
-- bounds definition.
-- @return Boolean. True if the point is in the area defined by bounds
local function inArea(point, bounds)
function inArea(point, bounds)
return (point.x < bounds.upperLeft.x
and point.x > bounds.lowerRight.x
and point.z < bounds.upperLeft.z

View File

@ -2,10 +2,12 @@ do
local PlaymatApi = { }
local internal = { }
local WHITE_MAT_GUID = "8b081b"
local ORANGE_MAT_GUID = "bd0ff4"
local GREEN_MAT_GUID = "383d8b"
local RED_MAT_GUID = "0840d5"
local MAT_IDS = {
White = "8b081b",
Orange = "bd0ff4",
Green = "383d8b",
Red = "0840d5",
}
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If
-- matchTypes is true, the main card slot snap points will only snap assets, while the
@ -17,7 +19,7 @@ do
-- accepts "All" as a special value which will apply the setting to all four mats.
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("setLimitSnapsByType", { matchTypes = matchCardTypes })
mat.call("setLimitSnapsByType", matchCardTypes)
end
end
@ -27,20 +29,16 @@ do
-- @return Array of playermat objects. If a single mat is requested, will return a single-element
-- array to simplify processing by consumers.
internal.getMatForColor = function(matColor)
if matColor == "White" then
return { getObjectFromGUID(WHITE_MAT_GUID) }
elseif matColor == "Orange" then
return { getObjectFromGUID(ORANGE_MAT_GUID) }
elseif matColor == "Green" then
return { getObjectFromGUID(GREEN_MAT_GUID) }
elseif matColor == "Red" then
return { getObjectFromGUID(RED_MAT_GUID) }
elseif matColor == "All" then
local targetMatGuid = MAT_IDS[matColor]
if targetMatGuid != nil then
return { getObjectFromGUID(targetMatGuid) }
end
if matColor == "All" then
return {
getObjectFromGUID(WHITE_MAT_GUID),
getObjectFromGUID(ORANGE_MAT_GUID),
getObjectFromGUID(GREEN_MAT_GUID),
getObjectFromGUID(RED_MAT_GUID),
getObjectFromGUID(MAT_IDS.White),
getObjectFromGUID(MAT_IDS.Orange),
getObjectFromGUID(MAT_IDS.Green),
getObjectFromGUID(MAT_IDS.Red),
}
end
end