local class = require("class") local DebugWindow = require("debug_overlay.debugwindow") local ECS = require("ecs.ECS") require "imgui" local ECSDebug = class(DebugWindow) function ECSDebug:init() self.ecs = ecs self.once = true end function ECSDebug:render() imgui.Begin("ECS") imgui.BeginChild("Entity table", 0,-imgui.GetItemsLineHeightWithSpacing()*2) imgui.Columns(ecs.n_components+1) imgui.SetColumnOffset(1, 64) -- Header imgui.TextUnformatted("Entities") imgui.NextColumn() for i,v in pairs(ecs.components) do imgui.TextUnformatted(string.format("%s", i)) imgui.NextColumn() end imgui.Separator() for i=0,ECS.N_ENTITIES-1 do if ecs.entities[i] then imgui.TextUnformatted(string.format("%d", i)) imgui.NextColumn() for j,c in pairs(ecs.components) do if c[i]._alive then imgui.TextUnformatted(tostring(c[i])) else imgui.NewLine() end imgui.NextColumn() end end end imgui.EndChild() imgui.End() end return ECSDebug