local constructionutil = require "constructionutil" local paramsutil = require "paramsutil" local vec3 = require "vec3" local transf = require "transf" local streetutil = require "streetutil" local BridgeHeights = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 } local WaterDepths = { 0, 1, 2, 3, 4, 5, 6, 7, 8 } local Scales = { 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 } function data() local BridgeHeightsValue = {} for i = 1, #BridgeHeights do BridgeHeightsValue[i] = _("%s").format(tostring(BridgeHeights[i])) end local WaterDepthsValue = {} for i = 1, #WaterDepths do WaterDepthsValue[i] = _("%s").format(tostring(WaterDepths[i])) end local ScalesValue = {} for i = 1, #Scales do ScalesValue[i] = _("%s").format(tostring(Scales[i])) end return { type = "STREET_CONSTRUCTION", description = { name = _("YXLL_QingChuan_Bridge"), description = _(" "), }, categories = { "bridges" }, availability = { yearFrom = 1997, yearTo = 9999 }, --skipCollision = true, params = { { key = "bridge_color", name = "Color", values = {_("red"), _("blue"), }, defaultIndex = 0, }, { key = "water_depth", name = "Water depth", uiType = "SLIDER", values = WaterDepthsValue, defaultIndex = 5, }, { key = "bridge_height", name = "Bridge Height", uiType = "SLIDER", values = BridgeHeightsValue, defaultIndex = 2, }, { key = "height_scale", name = "Bridge Height Scale", uiType = "SLIDER", values = ScalesValue, defaultIndex = 3, }, { key = "length_scale", name = "Bridge Length Scale", uiType = "SLIDER", values = ScalesValue, defaultIndex = 3, }, { key = "bridge_road", name = "Road", values = {_("one_way_2_lane"), _("one_way_3_lane"), _("one_way_2_lane x2"), _("one_way_3_lane x2"), _("two_way_2_lane"), _("two_way_4_lane"), _("two_way_6_lane"), }, defaultIndex = 2, }, }, updateFn = function(params) local result = { } local TotalHeight = BridgeHeights[params.bridge_height+1] + WaterDepths[params.water_depth+1] local BridgeHeight = BridgeHeights[params.bridge_height+1] local WaterDepth = WaterDepths[params.water_depth+1] result.edgeLists = { } result.models = { } result.groundFaces = { } local moduleString = " " local roadString = " " local xscale = 1 local yscale = 1 local zscale = 1 local yflip = 1 if params.bridge_road == 0 then yscale = 8.2/20 roadString = "YXLLRoads/UE60_oneway_2lane.lua" elseif params.bridge_road == 1 then yscale = 11.8/20 roadString = "YXLLRoads/UE60_oneway_3lane.lua" elseif params.bridge_road == 2 then yscale = 16.4/20 yflip = 4.1 roadString = "YXLLRoads/UE60_oneway_2lane.lua" elseif params.bridge_road == 3 then yscale = 23.6/20 yflip = 5.9 roadString = "YXLLRoads/UE60_oneway_3lane.lua" elseif params.bridge_road == 4 then yscale = 8.2/20 roadString = "YXLLRoads/UE60_twoway_2lane.lua" elseif params.bridge_road == 5 then yscale = 15.4/20 roadString = "YXLLRoads/UE60_twoway_4lane.lua" elseif params.bridge_road == 6 then yscale = 22.6/20 roadString = "YXLLRoads/UE60_twoway_6lane.lua" end xscale = Scales[params.length_scale+1] zscale = Scales[params.height_scale+1] if params.bridge_color == 0 then result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_MID_red.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, yscale, zscale ), transf.degToRad(0, 0, 0), vec3.new(0, 0, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_SIDE_red.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, zscale ), transf.degToRad(0, 0, 0), vec3.new(0, -10 * yscale, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_SIDE_red.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, zscale ), transf.degToRad(180, 0, 0), vec3.new(0, 10 * yscale, TotalHeight)) } elseif params.bridge_color == 1 then result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_MID_blue.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, yscale, zscale ), transf.degToRad(0, 0, 0), vec3.new(0, 0, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_SIDE_blue.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, zscale ), transf.degToRad(0, 0, 0), vec3.new(0, -10 * yscale, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_SIDE_blue.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, zscale ), transf.degToRad(180, 0, 0), vec3.new(0, 10 * yscale, TotalHeight)) } end result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_BOT1.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, 1.5 - zscale ), transf.degToRad(0, 0, 0), vec3.new(0, -10 * yscale, TotalHeight - zscale)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_BOT1.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, 1.5 - zscale ), transf.degToRad(180, 0, 0), vec3.new(0, 10 * yscale, TotalHeight - zscale)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_BOT2.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, 1 ), transf.degToRad(0, 0, 0), vec3.new(0, -10 * yscale, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_BOT2.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, 1, 1 ), transf.degToRad(180, 0, 0), vec3.new(0, 10 * yscale, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_BOT3.mdl", transf = transf.scaleRotZYXTransl(vec3.new( xscale, yscale, 1 ), transf.degToRad(0, 0, 0), vec3.new(0, 0, TotalHeight)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(50.5 * xscale - 1, -10 * yscale - 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(43.5 * xscale + 1, -10 * yscale - 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(-50.5 * xscale + 1, -10 * yscale - 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(-43.5 * xscale - 1, -10 * yscale - 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(50.5 * xscale - 1, 10 * yscale + 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(43.5 * xscale + 1, 10 * yscale + 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(-50.5 * xscale + 1, 10 * yscale + 1.2, TotalHeight - 5)) } result.models[#result.models + 1] = { id = "YXLL_QCB/YXLL_QCB_PIL.mdl", transf = transf.scaleRotZYXTransl(vec3.new( 1, 1, (TotalHeight - 5)/20 ), transf.degToRad(0, 0, 0), vec3.new(-43.5 * xscale - 1, 10 * yscale + 1.2, TotalHeight - 5)) } if params.bridge_road == 2 or params.bridge_road == 3 then result.edgeLists[#result.edgeLists + 1] = { type = "STREET", params = {type = roadString, }, edgeType = "BRIDGE", edgeTypeName = "epbridge_no_pillar.lua", edges = { {{55 * xscale, -yflip, TotalHeight}, {-55 * xscale, 0, 0}}, {{0, -yflip, TotalHeight}, {-55 * xscale, 0, 0}}, {{0, -yflip, TotalHeight}, {-55 * xscale, 0, 0}}, {{-55 * xscale, -yflip, TotalHeight}, {-55 * xscale, 0, 0}}, }, snapNodes = {0,3}, freeNodes = {}, } result.edgeLists[#result.edgeLists + 1] = { type = "STREET", params = {type = roadString, }, edgeType = "BRIDGE", edgeTypeName = "epbridge_no_pillar.lua", edges = { {{-55 * xscale, yflip, TotalHeight}, {55 * xscale, 0, 0}}, {{0, yflip, TotalHeight}, {55 * xscale, 0, 0}}, {{0, yflip, TotalHeight}, {55 * xscale, 0, 0}}, {{55 * xscale, yflip, TotalHeight}, {55 * xscale, 0, 0}}, }, snapNodes = {0,3}, freeNodes = {}, } elseif params.bridge_road == 0 or params.bridge_road == 1 or params.bridge_road == 4 or params.bridge_road == 5 or params.bridge_road == 6 then result.edgeLists[#result.edgeLists + 1] = { type = "STREET", params = {type = roadString, }, edgeType = "BRIDGE", edgeTypeName = "epbridge_no_pillar.lua", edges = { {{-55 * xscale, 0, TotalHeight}, {55 * xscale, 0, 0}}, {{0, 0, TotalHeight}, {55 * xscale, 0, 0}}, {{0, 0, TotalHeight}, {55 * xscale, 0, 0}}, {{55 * xscale, 0, TotalHeight}, {55 * xscale, 0, 0}}, }, snapNodes = {0,3}, freeNodes = {}, } end result.terrainAlignmentLists = { { type = "EQUAL", faces = { {{52 * xscale, 10 * yscale + 5, 0}, {52 * xscale, -10 * yscale - 5, 0}, {42 * xscale, -10 * yscale - 5, 0}, {42 * xscale, 10 * yscale + 5, 0},}, {{-52 * xscale, 10 * yscale + 5, 0}, {-52 * xscale, -10 * yscale - 5, 0}, {-42 * xscale, -10 * yscale - 5, 0}, {-42 * xscale, 10 * yscale + 5, 0},}, }, } } result.cost = -8987678 return result end } end