local y=require(script:WaitForChild("\082\069\065\068\077\069"))local K={}K.Settings={Enabled=true;DefaultIntensity=1;DefaultDuration=.5,MinIntensity=.1,MaxIntensity=10,IntensityStep=.1,SmoothingEnabled=false;SmoothingSpeed=.05,FadeInEnabled=false,FadeInDuration=.2,FadeOutEnabled=false;FadeOutDuration=.3;PatternSpeed=1;Balance={Enabled=false,Intensity=1,Sway=.5}}local s=require(script:WaitForChild("\077\111\100\117\108\101\115"))function K.Configure(K,y)for y,s in pairs(y)do if K.Settings[y]~=nil then K.Settings[y]=s end end end function K.Vibrate(G,y,K,I,V)if not G.Settings.Enabled then warn("\091\077\097\115\086\105\098\114\097\116\101\093 \086\105\098\114\097\116\105\111\110\115 \097\114\101 \100\105\115\097\098\108\101\100\046")return end y=y or G.Settings.DefaultIntensity K=K or G.Settings.DefaultDuration if y<G.Settings.MinIntensity then y=G.Settings.MinIntensity elseif y>G.Settings.MaxIntensity then y=G.Settings.MaxIntensity end s:Apply(y,K,G.Settings,I,V)end function K.Stop(K,y)s:Stop(y)end function K.CustomVibration(G,y,K,I,V)if G.Settings.Enabled then s:Apply(G.Settings.DefaultIntensity,G.Settings.DefaultDuration,G.Settings,I,V)end end function K.PatternVibration(G,y,K,I,V)if G.Settings.Enabled then s:Apply(G.Settings.DefaultIntensity,G.Settings.DefaultDuration,G.Settings,I,V)end end function K.FadeIn(G,y,K,I,V)if G.Settings.Enabled and G.Settings.FadeInEnabled then s:Apply(y,K,G.Settings,I,V)end end function K.FadeOut(I,y,K)if I.Settings.Enabled and I.Settings.FadeOutEnabled then task.delay(y,function()s:Stop(K)end)end end function K.Plugin(s,y,K,...)local I=script:WaitForChild("\080\108\117\103\105\110\115")local V=require(I:WaitForChild(y))if V and V[K]then V[K](V,...)else warn("\091\077\097\115\086\105\098\114\097\116\101\093 \078\111 \109\101\116\104\111\100 \'"..(tostring(K).."\' \102\111\117\110\100 \105\110 \112\108\117\103\105\110\058"),y)end end return K
--[[ Made by: WunderMaschine
  __  __        __      ___ _               _       
 |  \/  |       \ \    / (_) |             | |      
 | \  / | __ _ __\ \  / / _| |__  _ __ __ _| |_ ___ 
 | |\/| |/ _` / __\ \/ / | | '_ \| '__/ _` | __/ _ \
 | |  | | (_| \__ \\  /  | | |_) | | | (_| | ||  __/
 |_|  |_|\__,_|___/ \/   |_|_.__/|_|  \__,_|\__\___|

!!! Please read the README file and the documantations on GitHub before using this module !!!]]

local readmeVersion = require(script:WaitForChild("README"))

local MasVibrate = {}

--[]--[]-- SETTINGS --[]--[]--
MasVibrate.Settings = {
    Enabled = true,          
    DefaultIntensity = 1,    
    DefaultDuration = 0.5,   
    MinIntensity = 0.1,      
    MaxIntensity = 10,       
    IntensityStep = 0.1,

    SmoothingEnabled = false,
    SmoothingSpeed = 0.05,
    FadeInEnabled = false,
    FadeInDuration = 0.2,
    FadeOutEnabled = false,
    FadeOutDuration = 0.3,
    PatternSpeed = 1,

    Balance = {
        Enabled = false,
        Intensity = 1,
        Sway = 0.5
    }
}

--[]--[]-- DEPENDENCIES --[]--[]--
local Modules = require(script:WaitForChild("Modules"))

--[]--[]-- CONFIGURE --[]--[]--
function MasVibrate:Configure(settingsTable)
    for k, v in pairs(settingsTable) do
        if self.Settings[k] ~= nil then
            self.Settings[k] = v
        end
    end
end

--[]--[]-- VIBRATE --[]--[]--
-- Added optional channelName so multiple channels can coexist.
function MasVibrate:Vibrate(intensity, duration, motorChoice, channelName)
    if not self.Settings.Enabled then
        warn("[MasVibrate] Vibrations are disabled.")
        return
    end
    intensity = intensity or self.Settings.DefaultIntensity
    duration = duration or self.Settings.DefaultDuration
    if intensity < self.Settings.MinIntensity then
        intensity = self.Settings.MinIntensity
    elseif intensity > self.Settings.MaxIntensity then
        intensity = self.Settings.MaxIntensity
    end
    Modules:Apply(intensity, duration, self.Settings, motorChoice, channelName)
end

--[]--[]-- STOP --[]--[]--
-- Also supports optional channelName to only stop a specific channel.
function MasVibrate:Stop(channelName)
    Modules:Stop(channelName)
end

--[]--[]-- CUSTOM PATTERNS --[]--[]--
function MasVibrate:CustomVibration(pattern, customData, motorChoice, channelName)
    if self.Settings.Enabled then
        Modules:Apply(self.Settings.DefaultIntensity, self.Settings.DefaultDuration, self.Settings, motorChoice, channelName)
    end
end

function MasVibrate:PatternVibration(pattern, speed, motorChoice, channelName)
    if self.Settings.Enabled then
        Modules:Apply(self.Settings.DefaultIntensity, self.Settings.DefaultDuration, self.Settings, motorChoice, channelName)
    end
end

--[]--[]-- FADE --[]--[]--
function MasVibrate:FadeIn(intensity, duration, motorChoice, channelName)
    if self.Settings.Enabled and self.Settings.FadeInEnabled then
        Modules:Apply(intensity, duration, self.Settings, motorChoice, channelName)
    end
end

function MasVibrate:FadeOut(duration, channelName)
    if self.Settings.Enabled and self.Settings.FadeOutEnabled then
        task.delay(duration, function()
            Modules:Stop(channelName)
        end)
    end
end

--[]--[]-- PLUGIN HANDLER --[]--[]--
function MasVibrate:Plugin(pluginName, command, ...)
    local pluginFolder = script:WaitForChild("Plugins")
    local pluginModule = require(pluginFolder:WaitForChild(pluginName))
    if pluginModule and pluginModule[command] then
        pluginModule[command](pluginModule, ...)
    else
        warn("[MasVibrate] No method '" .. tostring(command) .. "' found in plugin:", pluginName)
    end
end

return MasVibrate