local sdk = sdk
local require = require
local string = string
local thread = thread

local Core = require("_CatLib")

local mod = Core.NewMod("Auto Hide Mantle")

local RequestTime = 0

mod.OnUpdateBehavior(function ()
    if RequestTime > 0 and Core.GetTime() > RequestTime then
        RequestTime = 0
        Core.GetPlayerCharacter():get_ArmorCtrl():requestPutOffMantle()
        if mod.Config.Debug then
            Core.SendMessage("Hide Mantle")
        end
    end
end)

mod.HookFunc("app.mcActiveSkillController", "startASkill(app.HunterDef.ACTIVE_SKILL)", function (args)
    local this = sdk.to_managed_object(args[2])
    local hunter = this._Hunter
    if not hunter:get_IsMaster() then return end

    RequestTime = Core.GetTime() + 1
end, function (retval)
    return retval
end)
