local function AddHUD(playerObj)
    local vehicle = playerObj:getVehicle()
    if not (vehicle and GetPanzerType(vehicle)) then
        return
    end
    if not HasUnlockThisReasearch(vehicle, "BetterHUD") then
        return
    end
    local EnginePart = vehicle:getPartById("Engine")
    if not EnginePart then
        return
    end
    local type = GetPanzerType(vehicle)
    local Shovel = vehicle:getPartById(type .. "_Shovel")
    local EngineCondition = EnginePart:getCondition()
    local EngineCon = TextDrawObject.new()
    local ShovelCondition = Shovel:getCondition()
    local ShoveCon = TextDrawObject.new()
    local RenderList = {}
    EngineCon:setDefaultColors(1, 1, 0.1, 0.7)
    EngineCon:setOutlineColors(0, 0, 0, 1)
    local AimBox = tostring(EngineCondition) .. "\n" .. tostring(ShovelCondition)
    EngineCon:ReadString(UIFont.Middle, AimBox, -1)
    local sx = IsoUtils.XToScreen(playerObj:getX(), playerObj:getY(), playerObj:getZ(), 0);
    local sy = IsoUtils.YToScreen(playerObj:getX(), playerObj:getY(), playerObj:getZ(), 0);
    sx = sx - IsoCamera.getOffX() + playerObj:getOffsetX();
    sy = sy - IsoCamera.getOffY() + playerObj:getOffsetY();
    sy = sy - 64
    sx = sx / getCore():getZoom(0)
    sy = sy / getCore():getZoom(0)
    sy = sy - EngineCon:getHeight()
    local vehicle = playerObj:getVehicle()
    if not vehicle then
        return
    end
    local Angele = 1
    local PlayerAngle = playerObj:getDirectionAngle()
    Angele = math.rad(PlayerAngle)
    local reduceModity = math.abs(vehicle:getAngleY())
    local dx = (200 - reduceModity) * math.cos(Angele) -- 计算 x 方向上的偏移量
    local dy = (200 - reduceModity) * math.sin(Angele) -- 计算 y 方向上的偏移量
    sx = sx + dx -- 计算新的 x 坐标
    sy = sy + dy -- 计算新的 y 坐标
    table.insert(RenderList, {60, EngineCon, sx, sy, sx, sy})
    local timemultiplier = getGameTime():getMultiplier()
    for la, lb in pairs(RenderList) do
        lb[1] = lb[1] - timemultiplier
        if lb[1] < 0 then
            lb = nil
        else
            lb[3] = lb[3] + timemultiplier
            lb[4] = lb[4] - timemultiplier
            lb[2]:AddBatchedDraw(lb[3], lb[4], true)
        end
    end
end

local EnterFlag = false
local function CheckLocalVehicle()
    local player = getPlayer()
    if player then
        local vehicle = player:getVehicle()
        if (vehicle and GetPanzerType(vehicle)) and not EnterFlag then
            EnterFlag = true
            Events.OnPlayerUpdate.Add(AddHUD);
        else
            Events.OnPlayerUpdate.Remove(AddHUD);
            EnterFlag = false
        end
    end

end

Events.EveryOneMinute.Add(CheckLocalVehicle)
