AVG_CAR_WIDTH = 2.8
AVG_CAR_HEIGHT = 4
AVG_CAR_LENGTH = 2.8
AVG_HR1_CHAMPS, AVG_HR1_RACES = {1,2,3}, {1,2}
AVG_HR2_CHAMPS, AVG_HR2_RACES = {4,5,6}, {3,4}
AVG_HR3_CHAMPS, AVG_HR3_RACES = {7,8,9}, {5,6}

RANKS = {
    [1] = { stars = 0, name = "RANK_NEWBIE" },
    [2] = { stars = 10, name = "RANK_AMATEUR" },
    [3] = { stars = 20, name = "RANK_DRIVER" },
    [4] = { stars = 30, name = "RANK_RACER" },
    [5] = { stars = 40, name = "RANK_TALENTED" },
    [6] = { stars = 50, name = "RANK_ROAD_HOG" },
    [7] = { stars = 60, name = "RANK_DAREDEVIL" },
    [8] = { stars = 70, name = "RANK_PRODIGY" },
    [9] = { stars = 80, name = "RANK_RACE_GURU" },
    [10] = { stars = 90, name = "RANK_FOLK_HERO" },
}
CHINESE_LANGUAGE_IN_LIST    = 6
JAPAN_LANGUAGE_IN_LIST      = 7

DIGIT_FONT_BOLD = "MOD/ui/fonts/Chivo_Mono/ChivoMono-Bold.ttf"

RESPAWN_SEC_DISABLED = 5
RESPAWN_MINIMAL_SPEED = 10/3.6
HIT_INCREASE_RESPAWN_COOLDOWN = 4
POINTS_ATTACKER_DECAY_AFTER = 3
POINTS_TOP_AND_PLAYER_MAX_DIFF = 25
POINTS_DECAY_FREQ_CHECK = 1
POINTS_DECAY = 25
POINTS_PER_FRAG = 300
PHONE_READ_SPEED = 40
PHONE_GLYPHS_READ_SPEED = 12

COLLISIONS = {
    WORLD               = 1,
    VEHICLES            = 2,
    AI_BLOCK            = 4,
    WHEEL_SPECIAL       = 8,
    CAMERA_COLLISION    = 16,
    WORLD_SPECIAL       = 32,
    EMPTY3              = 64,
    EMPTY4              = 128,

    MAX                 = 255
}
COLLISIONS.BLOCK_TERRAIN = COLLISIONS.AI_BLOCK + COLLISIONS.WORLD + COLLISIONS.WORLD_SPECIAL

LAYERS_TITLES = {
    ["ai-vehicles"]         = COLLISIONS.VEHICLES,
    ["ai-block"]            = COLLISIONS.AI_BLOCK,
    ["camera-collision"]    = COLLISIONS.CAMERA_COLLISION,
}

-- Mostly the same as in editor
ENTITY_COLORS = {
    shape   = {0, 1, 1},
    body    = {1, 1, 1},
    vehicle = {0, 0, 1}, -- changed to differentiate from body color (BLUE)
    screen  = {1, 1, 0}, -- changed to differentiate from body color (YELLOW)
    joint   = {0, 0.5, 1},
    rope    = {0.5, 0.7, 0.4},
    trigger = {0.5, 1, 0},
    location= {0, 1, 0},
    light   = {1, 0, 1},
    script  = {1, 0.5, 0},
}
ENTITY_WORLD_TRANSFORM = {
    shape   = GetShapeWorldTransform,
    body    = GetBodyTransform,
    location= GetLocationTransform,
    trigger = GetTriggerTransform,
    light   = GetLightTransform,
    vehicle = GetVehicleTransform,
    joint   = function(e) return GetShapeWorldTransform(GetJointShapes(e)[1]) end,
    screen  = function(e) return GetShapeWorldTransform(GetScreenShape(e)) end,
    [""]    = function(e) return e == "camera" and GetCameraTransform() or e == "player" and GetPlayerTransform() end,
}

DROWN_TIME = 0.2
DROWN_DEPTH = 0.25
DEBRIS_SIZE = 7
DEBRIS_CUSTOM_SIZE = DEBRIS_SIZE+2
DEBRIS_VOXELS = 50
DEBRIS_CUSTOM_VOXELS = DEBRIS_VOXELS+20
IsDebris = function(shape, n_axis, voxels)
    if HasTag(shape, "notdebris") then return end

    local vc = GetShapeVoxelCount(shape)
    if n_axis then
        if vc <= (voxels or DEBRIS_CUSTOM_VOXELS) then
            local sx, sy, sz = GetShapeSize(shape)
            if n_axis > 0 and sx <= DEBRIS_CUSTOM_SIZE then n_axis = n_axis - 1 end
            if n_axis > 0 and sy <= DEBRIS_CUSTOM_SIZE then n_axis = n_axis - 1 end
            if n_axis > 0 and sz <= DEBRIS_CUSTOM_SIZE then n_axis = n_axis - 1 end
            return n_axis <= 0
        end
    elseif vc <= DEBRIS_VOXELS then
        local sx, sy, sz = GetShapeSize(shape)
        return sx <= DEBRIS_SIZE and sy <= DEBRIS_SIZE and sz <= DEBRIS_SIZE
    end
    return false
end
