Remove commented-out filteredSystem() typechecks
Pull ingredients.lua up a directory
This commit is contained in:
parent
590121f7a6
commit
cedf7cb945
|
@ -28,7 +28,7 @@ import("systems/draw.lua")
|
|||
import("systems/input.lua")
|
||||
import("systems/menu.lua")
|
||||
|
||||
import("ingredients/ingredients.lua")
|
||||
import("ingredients.lua")
|
||||
import("cart.lua")
|
||||
import("utils.lua")
|
||||
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
local isSimulator = playdate.isSimulator
|
||||
|
||||
-- local function keysContain(key, allowedKeys)
|
||||
-- for _, allowedKey in pairs(allowedKeys) do
|
||||
-- if key == allowedKey then
|
||||
-- return true
|
||||
-- end
|
||||
-- end
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
---@generic T
|
||||
---@param shape T
|
||||
---@param process fun(entity: T, dt: number, system: System)
|
||||
|
@ -18,7 +7,10 @@ function filteredSystem(name, shape, process)
|
|||
system.name = name
|
||||
local keys = {}
|
||||
for key, value in pairs(shape) do
|
||||
if type(value) ~= "table" or value.maybe == nil then
|
||||
local isTable = type(value) == "table"
|
||||
local isMaybe = isTable and value.maybe ~= nil
|
||||
|
||||
if not isMaybe then
|
||||
-- ^ Don't require any Maybe types
|
||||
keys[#keys + 1] = key
|
||||
end
|
||||
|
@ -27,33 +19,8 @@ function filteredSystem(name, shape, process)
|
|||
if not process then
|
||||
return world:addSystem(system)
|
||||
end
|
||||
if isSimulator then
|
||||
-- local acceptableKeys = ""
|
||||
-- for _, key in ipairs(keys) do
|
||||
-- acceptableKeys = acceptableKeys .. "'" .. key .. "', "
|
||||
-- end
|
||||
-- acceptableKeys = acceptableKeys .. "]"
|
||||
function system:process(e, dt)
|
||||
-- local _e = e
|
||||
-- e = setmetatable({}, {
|
||||
-- __newindex = function()
|
||||
-- error("Do not attempt to mutate entity data!")
|
||||
-- end,
|
||||
-- __index = function(_, key)
|
||||
-- -- TODO: also assert their types
|
||||
-- assert(
|
||||
-- keysContain(key, keys),
|
||||
-- "Attempted to use key '" .. key .. "' - should be one of [ " .. acceptableKeys
|
||||
-- )
|
||||
-- return _e[key]
|
||||
-- end,
|
||||
-- })
|
||||
process(e, dt, self)
|
||||
end
|
||||
else
|
||||
function system:process(e, dt)
|
||||
process(e, dt, self)
|
||||
end
|
||||
function system:process(e, dt)
|
||||
process(e, dt, self)
|
||||
end
|
||||
return world:addSystem(system)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue