AssetProtected

Check if protected asset is safe

Usage: Used in 13 task(s)

Lua Implementation

-- Asset Protected
function evaluate(params)
    local asset = params.asset

    if not asset or not asset:isValid() then
        return false
    end

    -- Check for threats near asset
    local threats = 0
    local contacts = this:getContactList()
    for _, contact in ipairs(contacts) do
        if contact:isValid() and IsHostile{target = contact} then
            local distance = spatialUtil.distance(asset:getLocation3D(), contact:getLocation3D())
            if distance < params.threat_radius or 5000 then
                threats = threats + 1
            end
        end
    end

    return threats == 0
end