diff --git a/lib/debugger/getAllComponentData.luau b/lib/debugger/getAllComponentData.luau new file mode 100644 index 0000000..2dc8934 --- /dev/null +++ b/lib/debugger/getAllComponentData.luau @@ -0,0 +1,19 @@ +local function getAllComponentData(world, entity: number): { [{ [any]: any }]: { [any]: any } } + local componentToData = {} + + local location = world.allEntities[entity] + local archetype = location.archetype + local indexInArchetype = location.indexInArchetype + + for index, field in archetype.fields do + local componentId = archetype.componentIds[index] + local component = world.componentIdToComponent[componentId] + local data = field[indexInArchetype] + + componentToData[component] = data + end + + return componentToData +end + +return getAllComponentData diff --git a/lib/debugger/widgets/entityInspect.luau b/lib/debugger/widgets/entityInspect.luau index 893607d..966c7c7 100644 --- a/lib/debugger/widgets/entityInspect.luau +++ b/lib/debugger/widgets/entityInspect.luau @@ -1,4 +1,5 @@ local formatTableModule = require(script.Parent.Parent.formatTable) +local getAllComponentData = require(script.Parent.Parent.getAllComponentData) local formatTable = formatTableModule.formatTable local FormatMode = formatTableModule.FormatMode @@ -38,19 +39,10 @@ return function(plasma) end local items = { { "Component", "Data" } } - - local location = world.allEntities[debugger.debugEntity] - local archetype = location.archetype - local indexInArchetype = location.indexInArchetype - - for index, field in archetype.fields do - local componentId = archetype.componentIds[index] - local component = world.componentIdToComponent[componentId] - local data = field[indexInArchetype] - + for component, componentData in getAllComponentData(world, debugger.debugEntity) do table.insert(items, { tostring(component), - formatTable(data, FormatMode.Long), + formatTable(componentData, FormatMode.Long), }) end diff --git a/lib/debugger/widgets/hoverInspect.luau b/lib/debugger/widgets/hoverInspect.luau index c0c10d8..cbfc307 100644 --- a/lib/debugger/widgets/hoverInspect.luau +++ b/lib/debugger/widgets/hoverInspect.luau @@ -1,10 +1,11 @@ local formatTableModule = require(script.Parent.Parent.formatTable) +local getAllComponentData = require(script.Parent.Parent.getAllComponentData) local formatTable = formatTableModule.formatTable local FormatMode = formatTableModule.FormatMode return function(plasma) return plasma.widget(function(world, id, custom) - local entityData = world:_getEntity(id) + local entityData = getAllComponentData(world, id) local str = "Entity " .. id .. "\n\n" diff --git a/lib/debugger/widgets/worldInspect.luau b/lib/debugger/widgets/worldInspect.luau index a23c0ec..358f72d 100644 --- a/lib/debugger/widgets/worldInspect.luau +++ b/lib/debugger/widgets/worldInspect.luau @@ -1,4 +1,5 @@ local formatTableModule = require(script.Parent.Parent.formatTable) +local getAllComponentData = require(script.Parent.Parent.getAllComponentData) local formatTable = formatTableModule.formatTable local BY_COMPONENT_NAME = "ComponentName" @@ -140,7 +141,7 @@ return function(plasma) continue end - for component, value in world:_getEntity(entityId) do + for component, value in getAllComponentData(world, entityId) do if component == debugComponent then continue end