
local function cleaningBodyRasSkin(character, pct, factor)
    local decrease = 0
    local decreaseTotal = 0
    local rasSkin = RasBodyModRegistries.Skin
    if character:getWornItem(rasSkin) then
        local skin = character:getWornItem(rasSkin)
        local coveredParts = BloodClothingType.getCoveredParts(skin:getBloodClothingType())
        local value
        if coveredParts then
            for j=0,coveredParts:size()-1 do
                value = skin:getBlood(coveredParts:get(j))
                if value > 0 then
                    decrease = value * pct * factor
                    skin:setBlood(coveredParts:get(j), value - decrease)
                    decreaseTotal = decreaseTotal + decrease
                end
                value = skin:getDirt(coveredParts:get(j))
                if value > 0 then
                    decrease = value * pct * factor
                    skin:setDirt(coveredParts:get(j), value - decrease)
                    decreaseTotal = decreaseTotal + decrease
                end
            end
        end
    end
    syncVisuals(character)
    triggerEvent("OnClothingUpdated", character)
    return decreaseTotal
end

local function patchForRasBodyMod()
    if getActivatedMods():contains("\\rasBodyMod") then
        if RasBodyModRegistries and RasBodyModRegistries.Skin then
            local TABAS_Utils = require("TABAS_Utils")
            TABAS_Utils.cleaningBody = cleaningBodyRasSkin
        else
            DebugLog.log("[TABAS Patch Erorr] Not found rasBodyMod's Body Location!")
        end
    end
end


Events.OnGameBoot.Add(patchForRasBodyMod)
