updated casts
This commit is contained in:
parent
25e07b1e46
commit
5005800a79
@ -40,6 +40,11 @@
|
|||||||
"Nickname": "Investigator Count",
|
"Nickname": "Investigator Count",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
|
"Tags": [
|
||||||
|
"CameraZoom_ignore",
|
||||||
|
"CleanUpHelper_ignore",
|
||||||
|
"displacement_excluded"
|
||||||
|
],
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": -12.03,
|
"posX": -12.03,
|
||||||
|
@ -41,7 +41,9 @@
|
|||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
"Tags": [
|
"Tags": [
|
||||||
"CleanUpHelper_ignore"
|
"CameraZoom_ignore",
|
||||||
|
"CleanUpHelper_ignore",
|
||||||
|
"displacement_excluded"
|
||||||
],
|
],
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
"Tags": [
|
"Tags": [
|
||||||
"LinkedPhaseTracker",
|
"LinkedPhaseTracker",
|
||||||
|
"CameraZoom_ignore",
|
||||||
"CleanUpHelper_ignore",
|
"CleanUpHelper_ignore",
|
||||||
"displacement_excluded"
|
"displacement_excluded"
|
||||||
],
|
],
|
||||||
|
@ -977,6 +977,11 @@
|
|||||||
"Nickname": "Playarea",
|
"Nickname": "Playarea",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
|
"Tags": [
|
||||||
|
"CameraZoom_ignore",
|
||||||
|
"CleanUpHelper_ignore",
|
||||||
|
"displacement_excluded"
|
||||||
|
],
|
||||||
"Tooltip": false,
|
"Tooltip": false,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": -27.94,
|
"posX": -27.94,
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
"Nickname": "Playmat Image Swapper",
|
"Nickname": "Playmat Image Swapper",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
|
"Tags": [
|
||||||
|
"CameraZoom_ignore",
|
||||||
|
"CleanUpHelper_ignore",
|
||||||
|
"displacement_excluded"
|
||||||
|
],
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": -10.36,
|
"posX": -10.36,
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": -27.873,
|
"posX": -27.94,
|
||||||
"posY": 3.5,
|
"posY": 3.5,
|
||||||
"posZ": 0,
|
"posZ": 0,
|
||||||
"rotX": 0,
|
"rotX": 0,
|
||||||
|
@ -48,6 +48,11 @@
|
|||||||
"Nickname": "TableSurface",
|
"Nickname": "TableSurface",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
|
"Tags": [
|
||||||
|
"CameraZoom_ignore",
|
||||||
|
"CleanUpHelper_ignore",
|
||||||
|
"displacement_excluded"
|
||||||
|
],
|
||||||
"Tooltip": false,
|
"Tooltip": false,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": 0,
|
"posX": 0,
|
||||||
|
@ -38,9 +38,9 @@ playButtonData = {
|
|||||||
{ id = "20", width = "20", height = "20", offset = "10 80" }
|
{ id = "20", width = "20", height = "20", offset = "10 80" }
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultCameraParams = {
|
defaultCameraData = {
|
||||||
{ position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. ActAgenda
|
{ position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. ActAgenda
|
||||||
{ position = { -28, 1.55, 0.42 }, distance = -1 }, -- 2. Map
|
{ position = { -28, 1.55, 0 }, distance = -1 }, -- 2. Map
|
||||||
{ position = { -31.6, 1.55, 26.4 }, distance = -1 }, -- 3. Green playmat
|
{ position = { -31.6, 1.55, 26.4 }, distance = -1 }, -- 3. Green playmat
|
||||||
{ position = { -55, 1.55, 12.05 }, distance = -1 }, -- 4. White playmat
|
{ position = { -55, 1.55, 12.05 }, distance = -1 }, -- 4. White playmat
|
||||||
{ position = { -55, 1.55, -11.48 }, distance = -1 }, -- 5. Orange playmat
|
{ position = { -55, 1.55, -11.48 }, distance = -1 }, -- 5. Orange playmat
|
||||||
@ -61,7 +61,7 @@ defaultCameraParams = {
|
|||||||
|
|
||||||
local editing = false
|
local editing = false
|
||||||
local claiming = false
|
local claiming = false
|
||||||
local cameraParams = {}
|
local cameraData = {}
|
||||||
local visibility = {}
|
local visibility = {}
|
||||||
local claims = {}
|
local claims = {}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ local claims = {}
|
|||||||
|
|
||||||
function onSave()
|
function onSave()
|
||||||
return JSON.encode({
|
return JSON.encode({
|
||||||
cameras = cameraParams,
|
cameras = cameraData,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
claims = claims
|
claims = claims
|
||||||
})
|
})
|
||||||
@ -80,7 +80,7 @@ end
|
|||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData ~= "" then
|
if savedData ~= "" then
|
||||||
local loadedData = JSON.decode(savedData)
|
local loadedData = JSON.decode(savedData)
|
||||||
cameraParams = loadedData.cameras
|
cameraData = loadedData.cameras
|
||||||
visibility = loadedData.visibility
|
visibility = loadedData.visibility
|
||||||
claims = loadedData.claims
|
claims = loadedData.claims
|
||||||
else
|
else
|
||||||
@ -258,71 +258,86 @@ function buttonClicked(player, _, idValue)
|
|||||||
loadCamera(player, _, index)
|
loadCamera(player, _, index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getDynamicViewBounds(objList)
|
||||||
|
local count = 0
|
||||||
|
local totalBounds = {
|
||||||
|
minX = 0,
|
||||||
|
maxX = -70,
|
||||||
|
minZ = 60,
|
||||||
|
maxZ = -60
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, obj in pairs(objList) do
|
||||||
|
-- handling for Physics.cast() results
|
||||||
|
if not obj.type then obj = obj.hit_object end
|
||||||
|
|
||||||
|
if not obj.hasTag("CameraZoom_ignore") then
|
||||||
|
count = count + 1
|
||||||
|
local bounds = obj.getBounds()
|
||||||
|
local x1 = bounds['center'][1] - bounds['size'][1] / 2
|
||||||
|
local x2 = bounds['center'][1] + bounds['size'][1] / 2
|
||||||
|
local z1 = bounds['center'][3] - bounds['size'][3] / 2
|
||||||
|
local z2 = bounds['center'][3] + bounds['size'][3] / 2
|
||||||
|
|
||||||
|
totalBounds.minX = math.min(x1, totalBounds.minX)
|
||||||
|
totalBounds.maxX = math.max(x2, totalBounds.maxX)
|
||||||
|
totalBounds.minZ = math.min(z1, totalBounds.minZ)
|
||||||
|
totalBounds.maxZ = math.max(z2, totalBounds.maxZ)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- default values (mainly for play area if nothing is found)
|
||||||
|
if count == 0 then
|
||||||
|
totalBounds.minX = -10
|
||||||
|
totalBounds.maxX = -50
|
||||||
|
totalBounds.minZ = -20
|
||||||
|
totalBounds.maxZ = 20
|
||||||
|
end
|
||||||
|
|
||||||
|
totalBounds.middleX = (totalBounds.maxX + totalBounds.minX) / 2
|
||||||
|
totalBounds.middleZ = (totalBounds.maxZ + totalBounds.minZ) / 2
|
||||||
|
totalBounds.diffX = totalBounds.maxX - totalBounds.minX
|
||||||
|
totalBounds.diffZ = totalBounds.maxZ - totalBounds.minZ
|
||||||
|
|
||||||
|
return totalBounds
|
||||||
|
end
|
||||||
|
|
||||||
function loadCamera(player, _, index)
|
function loadCamera(player, _, index)
|
||||||
local lookHere
|
local lookHere
|
||||||
|
|
||||||
-- only do map zooming if the camera hasn't been specially set by user
|
-- only do map zooming if the camera hasn't been specially set by user
|
||||||
if index == 2 and cameraParams[player.color][index].distance <= 0 then
|
if index == 2 and cameraData[player.color][index].distance <= 0 then
|
||||||
local zone = getObjectFromGUID("a2f932")
|
local bounds = getDynamicViewBounds(getObjectFromGUID("a2f932").getObjects())
|
||||||
local minX, minZ, maxX, maxZ = 100, 100, -100, -100
|
|
||||||
|
|
||||||
for _, obj in pairs(zone.getObjects()) do
|
|
||||||
if obj.type == 'Card' or obj.type == 'Infinite' then
|
|
||||||
local bounds = obj.getBounds()
|
|
||||||
local x1 = bounds['center'][1] - bounds['size'][1] / 2
|
|
||||||
local x2 = bounds['center'][1] + bounds['size'][1] / 2
|
|
||||||
local z1 = bounds['center'][3] - bounds['size'][3] / 2
|
|
||||||
local z2 = bounds['center'][3] + bounds['size'][3] / 2
|
|
||||||
|
|
||||||
minX = math.min(x1, minX)
|
|
||||||
maxX = math.max(x2, maxX)
|
|
||||||
minZ = math.min(z1, minZ)
|
|
||||||
maxZ = math.max(z2, maxZ)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
lookHere = {
|
lookHere = {
|
||||||
position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 },
|
position = { bounds.middleX, 1.55, bounds.middleZ },
|
||||||
pitch = 75,
|
pitch = 75,
|
||||||
yaw = 90,
|
yaw = 90,
|
||||||
distance = 0.96 * math.max(maxX - minX, (maxZ - minZ) / 1.6) + 5
|
distance = 0.8 * math.max(bounds.diffX, bounds.diffZ) + 7
|
||||||
}
|
}
|
||||||
elseif index >= 3 and index <= 6 then
|
elseif index >= 3 and index <= 6 then
|
||||||
local colorList = { "White", "Orange", "Green", "Red" }
|
local matColorList = { "White", "Orange", "Green", "Red" }
|
||||||
local newMatColor = colorList[index - 2] -- mat index 1 - 4
|
local matColor = matColorList[index - 2] -- mat index 1 - 4
|
||||||
local newPlayerColor = playmatApi.getPlayerColor(newMatColor)
|
|
||||||
|
if #getSeatedPlayers() == 1 or claims[player.color][matColor] then
|
||||||
if newMatColor ~= nil and (#getSeatedPlayers() == 1 or claims[player.color][newMatColor]) then
|
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
||||||
copyVisibility({startColor = player.color, targetColor = newPlayerColor})
|
copyVisibility({startColor = player.color, targetColor = newPlayerColor})
|
||||||
player.changeColor(newPlayerColor)
|
player.changeColor(newPlayerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
if cameraParams[player.color][index].distance <= 0 then
|
if cameraData[player.color][index].distance <= 0 then
|
||||||
local minX, maxX, minZ, maxZ
|
local bounds = getDynamicViewBounds(playmatApi.searchPlaymat(matColor))
|
||||||
|
|
||||||
for _, v in pairs(playmatApi.searchPlaymat(newMatColor)) do
|
|
||||||
local bounds = v.hit_object.getBounds()
|
|
||||||
local x1 = bounds['center'][1] - bounds['size'][1] / 2
|
|
||||||
local x2 = bounds['center'][1] + bounds['size'][1] / 2
|
|
||||||
local z1 = bounds['center'][3] - bounds['size'][3] / 2
|
|
||||||
local z2 = bounds['center'][3] + bounds['size'][3] / 2
|
|
||||||
|
|
||||||
minX = math.min(x1, minX or x1)
|
|
||||||
maxX = math.max(x2, maxX or x2)
|
|
||||||
minZ = math.min(z1, minZ or z1)
|
|
||||||
maxZ = math.max(z2, maxZ or z2)
|
|
||||||
end
|
|
||||||
|
|
||||||
lookHere = {
|
lookHere = {
|
||||||
position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 },
|
position = { bounds.middleX, 0, bounds.middleZ },
|
||||||
pitch = 75,
|
pitch = 75,
|
||||||
yaw = playmatApi.returnRotation(newMatColor).y + 180,
|
yaw = playmatApi.returnRotation(matColor).y + 180,
|
||||||
distance = 0.42 * math.max(maxX - minX, maxZ - minZ) + 7
|
distance = 0.42 * math.max(bounds.diffX, bounds.diffZ) + 7
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- delay is to account for colorswap
|
-- delay is to account for colorswap
|
||||||
Wait.frames(function() player.lookAt(lookHere or cameraParams[player.color][index]) end, 2)
|
Wait.frames(function() player.lookAt(lookHere or cameraData[player.color][index]) end, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function beginClaimColor()
|
function beginClaimColor()
|
||||||
@ -355,13 +370,13 @@ end
|
|||||||
|
|
||||||
function resetCameras()
|
function resetCameras()
|
||||||
for _, color in ipairs(Player.getColors()) do
|
for _, color in ipairs(Player.getColors()) do
|
||||||
cameraParams[color] = {}
|
cameraData[color] = {}
|
||||||
for i = 1, #defaultCameraParams do
|
for i = 1, #defaultCameraData do
|
||||||
cameraParams[color][i] = {}
|
cameraData[color][i] = {}
|
||||||
cameraParams[color][i].yaw = 90
|
cameraData[color][i].yaw = 90
|
||||||
cameraParams[color][i].pitch = 75
|
cameraData[color][i].pitch = 75
|
||||||
cameraParams[color][i].position = defaultCameraParams[i].position
|
cameraData[color][i].position = defaultCameraData[i].position
|
||||||
cameraParams[color][i].distance = defaultCameraParams[i].distance
|
cameraData[color][i].distance = defaultCameraData[i].distance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user