From f25cb59aebeb4caa10bdb22cf41a18b0d098bdbe Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 25 Mar 2023 00:08:48 +0100 Subject: [PATCH] automatically detecting sideways deck --- src/playercards/PlayerCardSpawner.ttslua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/playercards/PlayerCardSpawner.ttslua b/src/playercards/PlayerCardSpawner.ttslua index 5877206e..b4c51d16 100644 --- a/src/playercards/PlayerCardSpawner.ttslua +++ b/src/playercards/PlayerCardSpawner.ttslua @@ -37,7 +37,7 @@ Spawner.spawnCards = function(cardList, pos, rot, sort, callback) -- Spawn each of the three types individually. Each Y position shift accounts for the thickness -- of the spawned deck local position = { x = pos.x, y = pos.y, z = pos.z } - Spawner.spawn(investigatorCards, position, { rot.x, rot.y - 90, rot.z }, callback, true) + Spawner.spawn(investigatorCards, position, { rot.x, rot.y - 90, rot.z }, callback) position.y = position.y + (#investigatorCards + #standardCards) * 0.07 Spawner.spawn(standardCards, position, rot, callback) @@ -78,11 +78,11 @@ end -- Spawn a specific list of cards. This method is for internal use and should not be called -- directly, use spawnCards instead. --- @param cardList: A list of Player Card data structures (data/metadata) --- @param pos Position table where the cards should be spawned (global) --- @param rot Rotation table for the orientation of the spawned cards (global) --- @param callback Function, callback to be called after the card/deck spawns. -Spawner.spawn = function(cardList, pos, rot, callback, sidewaysDeck) +---@param cardList: A list of Player Card data structures (data/metadata) +---@param pos table Position where the cards should be spawned (global) +---@param rot table Rotation for the orientation of the spawned cards (global) +---@param callback function callback to be called after the card/deck spawns. +Spawner.spawn = function(cardList, pos, rot, callback) if (#cardList == 0) then return end @@ -105,13 +105,17 @@ Spawner.spawn = function(cardList, pos, rot, callback, sidewaysDeck) scaleY = 1, scaleZ = cardList[1].data.Transform.scaleZ, } + local sidewaysDeck = true + for _, spawnCard in ipairs(cardList) do + Spawner.addCardToDeck(deck, spawnCard.data) + if not spawnCard.data.SidewaysCard then + sidewaysDeck = false + end + end -- set the alt view angle for sideway decks if sidewaysDeck then deck.AltLookAngle = { x = 0, y = 180, z = 90 } end - for _, spawnCard in ipairs(cardList) do - Spawner.addCardToDeck(deck, spawnCard.data) - end spawnObjectData({ data = deck, position = pos,