326 lines
9.0 KiB
Plaintext
326 lines
9.0 KiB
Plaintext
-- Bundled by luabundle {"version":"1.6.0"}
|
|
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
|
|
local loadingPlaceholder = {[{}] = true}
|
|
|
|
local register
|
|
local modules = {}
|
|
|
|
local require
|
|
local loaded = {}
|
|
|
|
register = function(name, body)
|
|
if not modules[name] then
|
|
modules[name] = body
|
|
end
|
|
end
|
|
|
|
require = function(name)
|
|
local loadedModule = loaded[name]
|
|
|
|
if loadedModule then
|
|
if loadedModule == loadingPlaceholder then
|
|
return nil
|
|
end
|
|
else
|
|
if not modules[name] then
|
|
if not superRequire then
|
|
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
|
|
error('Tried to require ' .. identifier .. ', but no such module has been registered')
|
|
else
|
|
return superRequire(name)
|
|
end
|
|
end
|
|
|
|
loaded[name] = loadingPlaceholder
|
|
loadedModule = modules[name](require, loaded, register, modules)
|
|
loaded[name] = loadedModule
|
|
end
|
|
|
|
return loadedModule
|
|
end
|
|
|
|
return require, loaded, register, modules
|
|
end)(nil)
|
|
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
require("core/GUIDReferenceHandler")
|
|
end)
|
|
__bundle_register("core/GUIDReferenceHandler", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
local searchLib = require("util/SearchLib")
|
|
|
|
local GuidReferences = {
|
|
White = {
|
|
ClueCounter = "d86b7c",
|
|
ClickableClueCounter = "db85d6",
|
|
DamageCounter = "eb08d6",
|
|
HandZone = "a70eee",
|
|
HorrorCounter = "468e88",
|
|
InvestigatorSkillTracker = "e598c2",
|
|
Playermat = "8b081b",
|
|
ResourceCounter = "4406f0",
|
|
TokenDiscardZone = "457de3",
|
|
Trash = "147e80"
|
|
},
|
|
Orange = {
|
|
ClueCounter = "1769ed",
|
|
ClickableClueCounter = "3f22e5",
|
|
DamageCounter = "e64eec",
|
|
HandZone = "5fe087",
|
|
HorrorCounter = "0257d9",
|
|
InvestigatorSkillTracker = "b4a5f7",
|
|
Playermat = "bd0ff4",
|
|
ResourceCounter = "816d84",
|
|
TokenDiscardZone = "457de4",
|
|
Trash = "f7b6c8"
|
|
},
|
|
Green = {
|
|
ClueCounter = "032300",
|
|
ClickableClueCounter = "891403",
|
|
DamageCounter = "1f5a0a",
|
|
HandZone = "0285cc",
|
|
HorrorCounter = "7b5729",
|
|
InvestigatorSkillTracker = "af7ed7",
|
|
PoolResources = "0168ae",
|
|
PoolDamage = "b0ef6c",
|
|
PoolHorror = "ae1a4e",
|
|
PoolClues = "fae2f6",
|
|
PoolDoom = "16724b",
|
|
Playermat = "383d8b",
|
|
ResourceCounter = "cd15ac",
|
|
TokenDiscardZone = "457de5",
|
|
TokenRemover = "2ba7a5",
|
|
Trash = "5f896a"
|
|
},
|
|
Red = {
|
|
ClueCounter = "37be78",
|
|
ClickableClueCounter = "4111de",
|
|
DamageCounter = "591a45",
|
|
HandZone = "be2f17",
|
|
HorrorCounter = "beb964",
|
|
InvestigatorSkillTracker = "e74881",
|
|
PoolResources = "fd617a",
|
|
PoolDamage = "93f4a0",
|
|
PoolHorror = "7bd2a0",
|
|
PoolClues = "3b2550",
|
|
PoolDoom = "16fcd6",
|
|
Playermat = "0840d5",
|
|
ResourceCounter = "a4b60d",
|
|
TokenDiscardZone = "457de6",
|
|
TokenRemover = "39b175",
|
|
Trash = "4b8594"
|
|
},
|
|
Mythos = {
|
|
AdditionalPlayerCardsBag = "2cba6b",
|
|
AllCardsBag = "15bb07",
|
|
BlessCurseManager = "5933fb",
|
|
CampaignThePathToCarcosa = "aca04c",
|
|
ChaosBagZone = "83ef06",
|
|
DataHelper = "708279",
|
|
DeckImporter = "a28140",
|
|
DoomCounter = "85c4c6",
|
|
DoomInPlayCounter = "652ff3",
|
|
InvestigatorCounter = "f182ee",
|
|
MasterClueCounter = "4a3aa4",
|
|
MythosArea = "9f334f",
|
|
NavigationOverlayHandler = "797ede",
|
|
OptionPanelSource = "830bd0",
|
|
PlaceholderBoxDummy = "a93466",
|
|
PlayArea = "721ba2",
|
|
PlayAreaImageSelector = "b7b45b",
|
|
PlayAreaZone = "a2f932",
|
|
PlayerCardPanel = "2d30ee",
|
|
ResourceTokenBag = "9fadf9",
|
|
RulesReference = "d99993",
|
|
SoundCube = "3c988f",
|
|
TokenArranger = "022907",
|
|
TokenSource = "124381",
|
|
TokenSpawnTracker = "e3ffc9",
|
|
TourStarter = "0e5aa8",
|
|
Trash = "70b9f6",
|
|
VictoryDisplay = "6ccd6d"
|
|
}
|
|
}
|
|
|
|
local editsToIndex = {
|
|
White = {},
|
|
Orange = {},
|
|
Green = {},
|
|
Red = {},
|
|
Mythos = {}
|
|
}
|
|
|
|
-- save function to keep edits to the index
|
|
function onSave() return JSON.encode({ editsToIndex = editsToIndex }) end
|
|
|
|
-- load function to restore edits to the index
|
|
function onLoad(savedData)
|
|
if savedData and savedData ~= "" then
|
|
local loadedData = JSON.decode(savedData)
|
|
editsToIndex = loadedData.editsToIndex
|
|
updateMainIndex()
|
|
end
|
|
end
|
|
|
|
-- merges the main index and the edits
|
|
function updateMainIndex()
|
|
for owner, subTable in pairs(editsToIndex) do
|
|
for type, guid in pairs(subTable) do
|
|
GuidReferences[owner][type] = guid
|
|
end
|
|
end
|
|
end
|
|
|
|
-- returns an object reference for the requested owner and type
|
|
function getObjectByOwnerAndType(params)
|
|
local owner = params.owner or "Mythos"
|
|
local type = params.type
|
|
return getObjectFromGUID(GuidReferences[owner][type])
|
|
end
|
|
|
|
-- returns a list of objects for the requested type
|
|
function getObjectsByType(type)
|
|
local objList = {}
|
|
for owner, objects in pairs(GuidReferences) do
|
|
local obj = getObjectFromGUID(objects[type])
|
|
if obj then
|
|
objList[owner] = obj
|
|
end
|
|
end
|
|
return objList
|
|
end
|
|
|
|
-- returns a list of objects for the requested owner
|
|
function getObjectsByOwner(owner)
|
|
local objList = {}
|
|
for type, guid in pairs(GuidReferences[owner]) do
|
|
local obj = getObjectFromGUID(guid)
|
|
if obj then
|
|
objList[type] = obj
|
|
end
|
|
end
|
|
return objList
|
|
end
|
|
|
|
-- makes an edit to the main index
|
|
function editIndex(params)
|
|
editsToIndex[params.owner][params.type] = params.guid
|
|
updateMainIndex()
|
|
end
|
|
|
|
-- Returns the owner of the provided object (either the matColor or "Mythos")
|
|
---@param object tts__GameObject Object to check
|
|
function getOwnerOfObject(object)
|
|
if object == nil then return end
|
|
|
|
-- use GUID to check owners instead of obtaining each as reference
|
|
local objectGuid = object.getGUID()
|
|
|
|
-- check if object is directly owned
|
|
for owner, subtable in pairs(GuidReferences) do
|
|
for type, guid in pairs(subtable) do
|
|
if guid == objectGuid then
|
|
return owner
|
|
end
|
|
end
|
|
end
|
|
|
|
-- check if the object is in a handzone
|
|
for owner, subtable in pairs(GuidReferences) do
|
|
for type, guid in pairs(subtable) do
|
|
for _, zone in ipairs(object.getZones()) do
|
|
if guid == zone.getGUID() then
|
|
return owner
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- check if it is on an owned object
|
|
local result = searchLib.belowPosition(object.getPosition())
|
|
|
|
for owner, subtable in pairs(GuidReferences) do
|
|
for type, guid in pairs(subtable) do
|
|
for _, searchObj in ipairs(result) do
|
|
if guid == searchObj.getGUID() then
|
|
return owner
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- default to "Mythos"
|
|
return "Mythos"
|
|
end
|
|
end)
|
|
__bundle_register("util/SearchLib", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
do
|
|
local SearchLib = {}
|
|
local filterFunctions = {
|
|
isCard = function(x) return x.type == "Card" end,
|
|
isDeck = function(x) return x.type == "Deck" end,
|
|
isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end,
|
|
isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end,
|
|
isTileOrToken = function(x) return x.type == "Tile" end,
|
|
isUniversalToken = function(x) return x.getMemo() == "universalActionAbility" end,
|
|
}
|
|
|
|
-- performs the actual search and returns a filtered list of object references
|
|
---@param pos tts__Vector Global position
|
|
---@param rot? tts__Vector Global rotation
|
|
---@param size table Size
|
|
---@param filter? string Name of the filter function
|
|
---@param direction? table Direction (positive is up)
|
|
---@param maxDistance? number Distance for the cast
|
|
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
|
local filterFunc
|
|
if filter then
|
|
filterFunc = filterFunctions[filter]
|
|
end
|
|
local searchResult = Physics.cast({
|
|
origin = pos,
|
|
direction = direction or { 0, 1, 0 },
|
|
orientation = rot or { 0, 0, 0 },
|
|
type = 3,
|
|
size = size,
|
|
max_distance = maxDistance or 0
|
|
})
|
|
|
|
-- filter the result for matching objects
|
|
local objList = {}
|
|
for _, v in ipairs(searchResult) do
|
|
if not filter or filterFunc(v.hit_object) then
|
|
table.insert(objList, v.hit_object)
|
|
end
|
|
end
|
|
return objList
|
|
end
|
|
|
|
-- searches the specified area
|
|
SearchLib.inArea = function(pos, rot, size, filter)
|
|
return returnSearchResult(pos, rot, size, filter)
|
|
end
|
|
|
|
-- searches the area on an object
|
|
SearchLib.onObject = function(obj, filter)
|
|
local pos = obj.getPosition()
|
|
local size = obj.getBounds().size:setAt("y", 1)
|
|
return returnSearchResult(pos, _, size, filter)
|
|
end
|
|
|
|
-- searches the specified position (a single point)
|
|
SearchLib.atPosition = function(pos, filter)
|
|
local size = { 0.1, 2, 0.1 }
|
|
return returnSearchResult(pos, _, size, filter)
|
|
end
|
|
|
|
-- searches below the specified position (downwards until y = 0)
|
|
SearchLib.belowPosition = function(pos, filter)
|
|
local size = { 0.1, 2, 0.1 }
|
|
local direction = { 0, -1, 0 }
|
|
local maxDistance = pos.y
|
|
return returnSearchResult(pos, _, size, filter, direction, maxDistance)
|
|
end
|
|
|
|
return SearchLib
|
|
end
|
|
end)
|
|
return __bundle_require("__root") |