{
"pilot25_spadie_tailgate": {
    "information":{
        "authors":"BeamNG",
        "name":"Tailgate",
        "value":400,
    },
    "slotType" : "pilot25_spadie_tailgate",
    "slots": [
        ["type", "default", "description"],
        ["pilot25_spadie_tailgateglass","pilot25_spadie_tailgateglass", "Tailgate Glass"],
    ],
    "flexbodies": [
        ["mesh", "[group]:", "nonFlexMaterials"],
        ["pilot25_spadie_tailgate_a", ["pilot25_spadie_tailgate"]],
        ["pilot25_spadie_tailgate_carp", ["pilot25_spadie_tailgate"]],
        ["pilot25_spadie_wiper_R", ["pilot25_spadie_tailgate"]],
        ["pilot25_spadie_logo_tailgate_b", ["pilot25_spadie_tailgate"]],

        {"deformGroup":"tailgateglass_break", "deformMaterialBase":"pilot25_spadie_lights", "deformMaterialDamaged":"pilot25_spadie_lights"},
        ["pilot25_spadie_tailgate_chmsl", ["pilot25_spadie_tailgate"]],

        {"deformGroup":"tailgatelight_L_break", "deformMaterialBase":"pilot25_spadie_lights", "deformMaterialDamaged":"pilot25_spadie_lights"},
        ["pilot25_spadie_tailgate_a_light_L", ["pilot25_spadie_tailgate"],[]{"deformSound":"event:>Destruction>Vehicle>Glass>glassbreaksound3", "deformVolume":0.3}],
        {"deformGroup":"tailgatelight_R_break", "deformMaterialBase":"pilot25_spadie_lights", "deformMaterialDamaged":"pilot25_spadie_lights"},
        ["pilot25_spadie_tailgate_a_light_R", ["pilot25_spadie_tailgate"],[]{"deformSound":"event:>Destruction>Vehicle>Glass>glassbreaksound4", "deformVolume":0.3}],

        {"deformGroup":"tailgatelight_L_break", "deformMaterialBase":"pilot25_spadie_glass", "deformMaterialDamaged":"pilot25_spadie_glass_dmg"},
        ["pilot25_spadie_tailgate_a_lightglass_L", ["pilot25_spadie_tailgate"]],
        {"deformGroup":"tailgatelight_R_break", "deformMaterialBase":"pilot25_spadie_glass", "deformMaterialDamaged":"pilot25_spadie_glass_dmg"},
        ["pilot25_spadie_tailgate_a_lightglass_R", ["pilot25_spadie_tailgate"]],
        {"deformGroup":""},
    ],
    "props": [
        ["func", "mesh", "idRef:", "idX:", "idY:", "baseRotation", "rotation", "translation", "min", "max", "offset", "multiplier"],
        //chmsl
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":10, "b":0, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleBrakeLightFlare",
        },
        ["brakelights", "SPOTLIGHT", "t2r", "t2l", "t3rr", {"x":120,"y":0,"z":0}, {"x":0,"y":0,"z":0}, {"x":0,"y":0,"z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.5,"y":0.2,"z":-0.05},"flareScale":0,"lightBrightness":0.06,"deformGroup":"tailgateglass_break"}],
        //taillights
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":10, "b":0, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleBrakeLightFlare",
        },
        ["brakelights" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.1, "z":0.01},"flareScale":0,"lightBrightness":0.06,"deformGroup":"tailgatelight_R_break"}],
        ["brakelights" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.1, "z":-0.01},"flareScale":0,"lightBrightness":0.06,"deformGroup":"tailgatelight_L_break"}],
        ["lowhighbeam" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0, "z":0.01},"flareScale":0,"lightBrightness":0,"lightRange":8,"deformGroup":"tailgatelight_R_break"}],
        ["lowhighbeam" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0, "z":-0.01},"flareScale":0,"lightBrightness":0,"lightRange":8,"deformGroup":"tailgatelight_L_break"}],
        //turn signals
        {"lightColor":{"r":255, "g":200, "b":20, "a":255},},
        ["signal_R" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.1, "y":-0.1, "z":0.0},"flareScale":0,"lightBrightness":0.05,"deformGroup":"tailgatelight_R_break"}],
        ["signal_L" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.1 "y":-0.1, "z":0.0},"flareScale":0,"lightBrightness":0.05,"deformGroup":"tailgatelight_L_break"}],
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":255, "b":200, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleReverseLightFlare",
            "cookieName":"art/special/BNG_light_cookie_headlight.dds"
            "texSize":512,
            "shadowSoftness":0.5,
        },
        ["reverse" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-60, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.52, "y":-0.1, "z":-0.02},"flareScale":0.025,"lightBrightness":0.2,"deformGroup":"tailgatelight_R_break"}],
        ["reverse" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-120, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.52 "y":-0.1, "z":0.02},"flareScale":0.025,"lightBrightness":0.2,"deformGroup":"tailgatelight_L_break"}],
    ],
    "controller": [
        ["fileName"],
        ["advancedCouplerControl", {"name":"tailgateCoupler"}],
    ]
    "tailgateCoupler":{
        "groupType": "autoCoupling",
        "couplerNodes":[
            ["cid1",    "cid2",     "autoCouplingStrength",    "autoCouplingRadius",   "autoCouplingLockRadius",   "autoCouplingSpeed", "couplingStartRadius",  "breakGroup"]
            ["r4",      "t7",        40000,                     0.01,                   0.005,                      0.2,                 0.1,                   "tailgate_latch"]
        ]
        "attachSoundVolume":1,
        "detachSoundVolume":1,
        "soundNode:":["r4"]
        "attachSoundEvent": "event:>Vehicle>Latches>Trunk>modern_05_close",
        "detachSoundEvent": "event:>Vehicle>Latches>Trunk>modern_05_open",
        "breakSoundEvent":""
        "openForceMagnitude": 0,
        "openForceDuration": 0,
        "closeForceMagnitude": 650,
        "closeForceDuration": 3.0,
    }
    "triggers":[
        ["id", "label", "idRef:", "idX:", "idY:", "type", "size", "baseRotation", "rotation", "translation", "baseTranslation"],
        ["tailgate", "", "t5","t5r","t4", "box", {"x":0.08, "y":0.08, "z":0.08}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":-0, "y":-0, "z":-0.02}],
    ],
    "triggerEventLinks":[
        ["triggerId:triggers", "action", "targetEventId:events"],
        ["tailgate", "action0", "tailgateLatch"],
    ],
    "events":[
        ["id", "title", "desc"],
        ["tailgateLatch", "ui.inputActions.pilot25_spadie.tailgateLatch.title", "ui.inputActions.pilot25_spadie.tailgateLatch.description", {"onUp":"controller.getControllerSafe('tailgateCoupler').toggleGroup()"}],
    ],
    "nodes": [
        ["id", "posX", "posY", "posZ"],
         //--TAILGATE--
         {"collision":true},
         {"selfCollision":true},
         {"nodeMaterial":"|NM_METAL"},
         {"frictionCoef":0.5},
         {"group":"pilot25_spadie_tailgate"},
         {"nodeWeight":1.1},
         ["t1r", -0.68683, 2.07980, 1.50520, {"nodeWeight":1.5}],
         ["t1", 0.00000, 2.08655, 1.53613, {"group":["tailgatefix","pilot25_spadie_tailgate"]}],
         ["t1l", 0.68683, 2.07980, 1.50520, {"nodeWeight":1.5}],

         ["t2rr", -0.80149, 2.16415, 1.19942],
         ["t2r", -0.67307, 2.21341, 1.48482],
         ["t2", 0.00000, 2.28561, 1.49396],
         ["t2l", 0.67307, 2.21341, 1.48482],
         ["t2ll", 0.80149, 2.16415, 1.19942],

         {"nodeWeight":1.3},
         ["t3rr", -0.70403, 2.44331, 1.05412],
         ["t3r", -0.35620, 2.53848, 1.03880],
         ["t3l", 0.35620, 2.53848, 1.03880],
         ["t3ll", 0.70403, 2.44331, 1.05412],

         ["t4rr", -0.67549, 2.51519, 0.84026],
         ["t4r", -0.31159, 2.54285, 0.87645],
         ["t4", 0.00000, 2.54960, 0.88063],
         ["t4l", 0.31159, 2.54285, 0.87645],
         ["t4ll", 0.67549, 2.51519, 0.84026],

         ["t5rr", -0.60434, 2.50926, 0.61216,{"selfCollision":false}],
         ["t5r", -0.29734, 2.56928, 0.59128],
         ["t5", 0.00000, 2.57603, 0.59128],
         ["t5l", 0.29734, 2.56928, 0.59128],
         ["t5ll", 0.60434, 2.50926, 0.61216,{"selfCollision":false}]

         {"collision":false},
         {"selfCollision":false},
         {"nodeWeight":2.5},
         {"group":""},
         ["t6", 0.00000, 2.24470, 0.74281],
         {"group":""},

         //latch node
         {"nodeWeight":0.8},
         ["t7", 0.00000, 2.38270, 0.59973],
    ],
    "beams": [
          ["id1:", "id2:"],
          //--TAILGATE--
          {"beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"beamSpring":1201000,"beamDamp":100},
          {"beamDeform":32550,"beamStrength":"FLT_MAX"},
          //tailgate main shape
          {"deformLimitExpansion":1.2},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.005},
          ["t3ll", "t2ll"],
          ["t2ll", "t1l"],
          ["t3rr", "t2rr"],
          ["t2rr", "t1r"],
          ["t2r", "t1r"],
          ["t2", "t1"],
          ["t2l", "t1l"],
          ["t1l", "t1"],
          ["t1", "t1r"],
          ["t2l", "t2"],
          ["t2", "t2r"],
          ["t2r", "t2rr"],
          ["t2l", "t2ll"],
          ["t3ll", "t3l"],
          ["t3l", "t3r"],
          ["t3r", "t3rr"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t3rr", "t4rr"],
          ["t4rr", "t5rr"],
          ["t3r", "t4r"],
          ["t4r", "t5r"],
          ["t5rr", "t5r"],
          ["t4rr", "t4r"],
          ["t3rr", "t3r"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t3ll", "t4ll"],
          ["t4ll", "t5ll"],
          ["t3l", "t4l"],
          ["t4l", "t5l"],
          ["t5ll", "t5l"],
          ["t4ll", "t4l"],
          ["t3ll", "t3l"],
          {"deformGroup":""},
          ["t5l", "t5"],
          ["t5", "t5r"],
          ["t4r", "t4"],
          ["t4", "t4l"],
          ["t3l", "t3r"],
          ["t5", "t4"],

          //surficial crossing
          {"deformLimitExpansion":""},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.005},
          {"beamDeform":14550,"beamStrength":"FLT_MAX"},
          ["t2l", "t3ll"],
          ["t2r", "t3rr"],
          ["t3rr", "t1r"],
          ["t3ll", "t1l"],
          ["t1l", "t2"],
          ["t1", "t2l"],
          ["t1", "t2r"],
          ["t2", "t1r"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t5rr", "t4r"],
          ["t5r", "t4rr"],
          ["t4rr", "t3r"],
          ["t4r", "t3rr"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t5ll", "t4l"],
          ["t5l", "t4ll"],
          ["t4ll", "t3l"],
          ["t4l", "t3ll"],
          {"deformGroup":""},
          ["t4l", "t3r"],
          ["t4r", "t3l"],
          ["t3l", "t4"],
          ["t4", "t3r"],
          ["t4", "t5r"],
          ["t4r", "t5"],
          ["t5", "t4l"],
          ["t4", "t5l"],

          //corners
          {"beamDeform":10550,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.01},
          ["t2ll", "t1"],
          ["t2ll", "t2"],
          ["t2rr", "t2"],
          ["t2rr", "t1"],
          ["t2rr", "t1l"],
          ["t2ll", "t1r"],
          ["t3ll", "t2"],
          ["t3rr", "t2"],
          ["t3r", "t2r"],
          ["t3l", "t2l"],
          ["t3r", "t2l"],
          ["t3l", "t2r"],
          {"deformGroup":""},

          //rigids
          {"beamSpring":801000,"beamDamp":120},
          {"beamDeform":5550,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.01},
          ["t3ll", "t3r"],
          ["t3rr", "t3l"],
          ["t4ll", "t2l"],
          ["t4rr", "t2r"],
          ["t4rr", "t2rr"],
          ["t4ll", "t2ll"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t5rr", "t3rr"],
          ["t5r", "t3r"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t5ll", "t3ll"],
          ["t5l", "t3l"],
          {"deformGroup":""},
          ["t4ll", "t4"],
          ["t5ll", "t5"],
          ["t4rr", "t4"],
          ["t5rr", "t5"],
          ["t5l", "t5r"],
          ["t4l", "t4r"],
          ["t5", "t3l"],
          ["t5", "t3r"],

          //rigidifier
          {"beamSpring":2201000,"beamDamp":30},
          {"beamDeform":5000,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.05},
          ["t6", "t1"],
          ["t6", "t1r"],
          ["t6", "t1l"],
          ["t6", "t2"],
          ["t6", "t2r"],
          ["t6", "t2l"],
          ["t6", "t2rr"],
          ["t6", "t2ll"],
          ["t6", "t3r"],
          ["t6", "t3l"],
          ["t6", "t3rr"],
          ["t6", "t3ll"],
          ["t6", "t4rr"],
          ["t6", "t4r"],
          ["t6", "t4ll"],
          ["t6", "t4l"],
          ["t6", "t4"],
          ["t6", "t5"],
          ["t6", "t5r"],
          ["t6", "t5l"],
          ["t6", "t5rr"],
          ["t6", "t5ll"],
          {"deformGroup":""},

          //latch node
          {"beamSpring":601000,"beamDamp":250},
          {"beamDeform":6000,"beamStrength":"FLT_MAX"},
          ["t7", "t3l"],
          ["t7", "t3r"],
          ["t7", "t3ll"],
          ["t7", "t3rr"],
          ["t7", "t4ll"],
          ["t7", "t4rr"],
          ["t7", "t4l"],
          ["t7", "t4r"],
          ["t7", "t5"],

          //tailgate hinge
          {"beamSpring":1201000,"beamDamp":120},
          {"beamDeform":18000,"beamStrength":44000},
          {"breakGroup":"tailgatehinge_R"},
          ["t1r", "rf4r", {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.1}],
          ["t1r", "rf3r", {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.1}],
          ["t1r", "rf4"],
          ["t1r", "p10r"],
          ["t1r", "p9r"],
          {"breakGroup":"tailgatehinge_L"},
          ["t1l", "rf4l", {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.1}],
          ["t1l", "rf3l", {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.1}],
          ["t1l", "rf4"],
          ["t1l", "p10l"],
          ["t1l", "p9l"],
          {"breakGroup":""},

          //gas struts
          {"breakGroupType":1},
          {"beamSpring":300,"beamDamp":200},
          {"beamDeform":4000,"beamStrength":10000},
          {"beamPrecompression":4.5},
          ["t3rr", "r4rr", {"breakGroup":"tailgatehinge_R"}],
          ["t3ll", "r4ll", {"breakGroup":"tailgatehinge_L"}],
          {"beamPrecompression":1},
          {"breakGroupType":0},
          {"breakGroup":""},

          //pop open
          {"beamPrecompression":1.03,"beamSpring":50000,"beamDamp":1320,"beamDeform":40000,"beamStrength":10000,"breakGroupType":1,"beamType":"|SUPPORT", "beamLongBound":25},
          ["t5r", "r2rr", {"breakGroup":"tailgatehinge_R"}],
          ["t5l", "r2ll", {"breakGroup":"tailgatehinge_L"}],
          {"beamPrecompression":1},
          {"breakGroupType":0},

          //tailgate support beams
          {"beamType":"|SUPPORT", "beamLongBound":4},
          {"beamSpring":1001000,"beamDamp":50},
          {"beamDeform":7500,"beamStrength":230000},
          ["t1r", "rf3r"],
          ["t1l", "rf3l"],
          ["t2rr", "p9r"],
          ["t2ll", "p9l"],
          ["t3rr", "q2r"],
          ["t3ll", "q2l"],
          ["t5ll", "r2ll"],
          ["t5rr", "r2rr"],
          ["t5", "r2"],
          ["t5rr", "r3rr"],
          ["t5ll", "r3ll"],
          ["t2r", "q2r"],
          ["t1r", "q2r"],
          ["t1l", "q2l"],
          ["t2l", "q2l"],
          ["t1r", "rf4"],
          ["t2r", "rf4"],
          ["t1l", "rf4"],
          ["t2l", "rf4"],
          {"beamPrecompression":0.8},
          ["t2l", "rf3l"],
          ["t2r", "rf3r"],
          {"beamPrecompression":1, "beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"deformLimitExpansion":1.2},
    ],
    "triangles": [
            ["id1:","id2:","id3:"],
            //tailgate
            {"group":"pilot25_spadie_tailgate"},
            {"dragCoef":8},
            ["t3l", "t4", "t3r"],
            ["t3r", "t4", "t4r"],
            ["t3l", "t4l", "t4"],
            ["t4", "t5", "t4r"],
            ["t4l", "t5", "t4"],
            ["t4r", "t5", "t5r"],
            ["t4l", "t5l", "t5"],
            ["t5r", "t5rr", "t4rr"],
            ["t4rr", "t4r", "t5r"],
            ["t4l", "t4ll", "t5l"],
            ["t4ll", "t5ll", "t5l"],
            ["t3r", "t4r", "t3rr"],
            ["t3rr", "t4r", "t4rr"],
            ["t3ll", "t4l", "t3l"],
            ["t3ll", "t4ll", "t4l"],
            ["t2r", "t3rr", "t2rr"],
            ["t2r", "t2rr", "t1r"],
            ["t2l", "t2ll", "t3ll"],
            ["t1l", "t2ll", "t2l"],
            ["t1", "t2r", "t1r"],
            ["t1", "t2", "t2r"],
            ["t1l", "t2l", "t1"],
            ["t1", "t2l", "t2"],
            ["t2", "t3l", "t3r"],
            ["t2l", "t3l", "t2"],
            ["t2", "t3r", "t2r"],
            ["t2r", "t3r", "t3rr"],
            ["t2l", "t3ll", "t3l"],
    ],
},
}