; Helps to quickly replace rims for a car, needs a KN5 with a single wheel, which should be aligned like that:
; https://i.imgur.com/pqfeIJi.png
;
; Here is an example of it in action for Miura:
;
; [INCLUDE: common/custom_rims.ini]
; [ReplaceRims]
; File = lamborghini_miura_sv.kn5  ; name of KN5
; OriginalRims = RIM_?             ; list of original rims to hide
; Model = rim.kn5, 0.276, 0.238    ; KN5 with a new rim, its radius and width
; Offset = 0, -0.03                ; offset for front and rear wheels (negative value move rim deeper inside)
;
; If needed, you can also set `Radius` and `Width` to specify dimensions of inserted rim, but by default, config would use `RIM_RADIUS` and `WIDTH` from “tyres.ini”. Values `Offset`, `Radius` and `Width` can be either single or double: if single, they would affect both sides, if double, first value would be used for front wheels and second for rear wheels.
;
; Whole thing can be limited to a certain side with `FrontOnly = 1` or `RearOnly = 1`.
;
; More information:
; https://github.com/ac-custom-shaders-patch/acc-extension-config/wiki/General-%E2%80%93-Model-replacements#custom-rims-commoncustom_rimsini

[TEMPLATE: _ReplaceRims_Side]
@ACTIVE = $" ( (not ${FrontOnly:bool} or $Front) and 1 or 0 ) * ( (not ${RearOnly:bool} or $Rear) and 1 or 0 ) "
@OUTPUT = MODEL_REPLACEMENT_0REPLACE_RIMS_...
FILE = $File
SKINS = ${Skins:?}
INSERT = ${Model:1}
INSERT_IN = $" 'WHEEL_' .. ($1 == 1 and 'L' or 'R') .. ($Front and 'F' or 'R') "
MULTIPLE = 1
SCALE = $" ${_Width:num} / ${Model:3} ", $" ${_Radius:num} / ${Model:2} ", $" ${_Radius:num} / ${Model:2} "
ROTATION = $" $1 == 2 and 180 or 0 ", 0, 0
OFFSET = $" $1 == 2 and -(${_Offset:num}) or ${_Offset:num} ", 0, 0

[TEMPLATE: ReplaceRims]
@OUTPUT = MODEL_REPLACEMENT_0HIDE_RIMS_...
FILE = $File
SKINS = ${Skins:?}
HIDE = $OriginalRims

_Radius = $" ${Radius:exists} and ${Radius:1} or read('data/tyres.ini/FRONT/RIM_RADIUS', 0.276) "
_Width = $" ${Width:exists} and ${Width:1} or read('data/tyres.ini/FRONT/WIDTH', 0.238) "
_Offset = ${Offset:1}
@GENERATOR = _ReplaceRims_Side, 2, Front

_Radius = $" ${Radius:exists} and ${Radius:-1} or read('data/tyres.ini/REAR/RIM_RADIUS', 0.276) "
_Width = $" ${Width:exists} and ${Width:-1} or read('data/tyres.ini/REAR/WIDTH', 0.238) "
_Offset = ${Offset:-1}
@GENERATOR = _ReplaceRims_Side, 2, Rear


