-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
83 lines (63 loc) · 2.31 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
local windowWidth = 1000
local windowHeight = 800
love.window.setMode(windowWidth, windowHeight, { resizable=true })
love.graphics.setDefaultFilter('nearest', 'nearest')
--require("libs.batteries.stable_sort")
--require("libs.batteries.table")
require("libs.batteries"):export()
local entityRegistry = require 'models.entityRegistry'
local inspect = require('libs.inspect')
local lume = require('libs.lume')
limits = love.graphics.getSystemLimits( )
print(inspect(limits))
DEBUG = false
--PROFILER = true
local Concord = require("libs.concord")
ECS = {}
ECS.Component = function (path, ...)
local name = string.match(path, '%.([^%.]*)$')
return Concord.component(name, ...)
end
ECS.c = Concord.components
ECS.System = Concord.system
ECS.World = Concord.world
ECS.Entity = Concord.entity
--local assemblageNames = { "creatures", "doors", "food", "jobs", "lights", "plants", "rawMaterials", "seeds", "walls", "abstract" }
local assemblageNames = love.filesystem.getDirectoryItems("assemblages")
ECS.a = { }
for _, name in ipairs(assemblageNames) do
ECS.a[name] = {}
Concord.utils.loadNamespace("assemblages/" .. name, ECS.a[name])
end
local function getAssemblageBySelectorTable(data, selectorTable)
--print("selectorTable", selectorTable, data)
if #selectorTable == 0 then
return data
end
local newTable = {unpack(selectorTable)}
local lastSelector = table.remove(newTable, 1)
--print("lastSelector", lastSelector)
return getAssemblageBySelectorTable(data[lastSelector], newTable)
--if #selectorTable > 1 and data[lastSelector] then return getAssemblageBySelectorTable(data[lastSelector], newTable) end
--if #selectorTable == 1 then return getAssemblageBySelectorTable(
end
ECS.a.getBySelector = function(selector)
local selectorTable = lume.split(selector, ".")
local assemblage = getAssemblageBySelectorTable(ECS.a, selectorTable)
return function(e)
e:give('selector', selector)
e:give('id', entityRegistry.generateId())
e:assemble(assemblage)
end
end
Concord.utils.loadNamespace("components")
ECS.Systems = Concord.utils.loadNamespace("systems", {})
local Gamestate = require("libs.hump.gamestate")
local gameStates = {
inGame = require("states.inGame"),
mainMenu = require("states.mainMenu")
}
function love.load()
Gamestate.registerEvents()
Gamestate.switch(gameStates.mainMenu)
end