entity_visualiser.luau Coverage

Total Execution Hits: 1

Function Coverage Overview: 25.00%

Function Coverage:

FunctionHits
1
pe:60
name:110
components:150

Source Code:

>>>>>>>>>>>
LineHitsCode
11local jecs = require("@jecs")
21local ECS_GENERATION = jecs.ECS_GENERATION
31local ECS_ID = jecs.ECS_ID
41local ansi = require("@tools/ansi")
5N/A
61local function pe(e: any)
70local gen = ECS_GENERATION(e)
80return ansi.green(`e{ECS_ID(e)}`) .. ansi.yellow(`v{gen}`)
9N/Aend
10N/A
111local function name(world: jecs.World, id: any)
120return world:get(id, jecs.Name) or `${id}`
13N/Aend
14N/A
151local function components(world: jecs.World, entity: any)
160local r = jecs.entity_index_try_get(world.entity_index, entity)
170if not r then
180return false
19N/Aend
20N/A
210local archetype = r.archetype
220local row = r.row
230print(`Entity {pe(entity)}`)
240print("-----------------------------------------------------")
250for i, column in archetype.columns do
260local component = archetype.types[i]
270local n
280if jecs.IS_PAIR(component) then
290n = `({name(world, jecs.pair_first(world, component))}, {name(world, jecs.pair_second(world, component))})`
300else
310n = name(world, component)
32N/Aend
330local data = column[row] or "TAG"
340print(`| {n} | {data} |`)
35N/Aend
360print("-----------------------------------------------------")
370return true
38N/Aend
39N/A
401return {
411components = components,
421prettify = pe,
430}