MSW_Visual = MSW_Visual or {}

local TARGET_PART_ID = "ATAMultiSlotWrecker"

local function anySlotOccupied(part)
	local modData = part and part:getModData() or nil
	local slots = modData and modData.msw and modData.msw.slots or nil
	if type(slots) ~= "table" then
		return false
	end

	for _, slotData in pairs(slots) do
		if slotData then
			return true
		end
	end

	return false
end

function MSW_Visual.applyForVehicle(vehicle)
	local part = vehicle and vehicle.getPartById and vehicle:getPartById(TARGET_PART_ID) or nil
	if not part then
		return false
	end

	local showDefault = anySlotOccupied(part)
	pcall(function() part:setModelVisible("Default", showDefault) end)
	return showDefault
end

return MSW_Visual