INC_CLIENT()

SWEP.Slot = 3
SWEP.SlotPos = 0

SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 58

SWEP.HUD3DBone = "Base"
SWEP.HUD3DPos = Vector(3, -0.5, -13)
SWEP.HUD3DAng = Angle(180, 0, 0)
SWEP.HUD3DScale = 0.03

SWEP.VElements = {
	["egon_base++++++"] = { type = "Model", model = "models/props_phx/misc/iron_beam2.mdl", bone = "", rel = "egon_base", pos = Vector(1.5, -4, -2), angle = Angle(-17.532, 90, 0), size = Vector(0.119, 0.119, 0.119), color = Color(255, 255, 255, 255), surpresslightning = false, material = "models/weapons/v_stunstick/v_stunstick_diffuse", skin = 0, bodygroup = {} },
	["egon_base+"] = { type = "Model", model = "models/props_phx/construct/metal_wire_angle360x2.mdl", bone = "", rel = "egon_base", pos = Vector(18.181, 0, 0), angle = Angle(90, 0, 0), size = Vector(0.095, 0.095, 0.11), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++++++"] = { type = "Model", model = "models/props_wasteland/laundry_washer001a.mdl", bone = "", rel = "egon_base", pos = Vector(-3.5, 5, 1), angle = Angle(90, -90, 0), size = Vector(0.05, 0.05, 0.14), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base++++++++"] = { type = "Model", model = "models/props_combine/combine_interface001a.mdl", bone = "", rel = "egon_base", pos = Vector(-3, 4, 0.6), angle = Angle(70, 0, 0), size = Vector(0.15, 0.15, 0.15), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++++"] = { type = "Model", model = "models/props_lab/reciever01a.mdl", bone = "", rel = "egon_base", pos = Vector(-10.91, 3.635, 1.557), angle = Angle(120, 0, 0), size = Vector(0.2, 0.2, 0.2), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++"] = { type = "Model", model = "models/props_c17/factorymachine01.mdl", bone = "", rel = "egon_base", pos = Vector(4, 0, -1.601), angle = Angle(180, 90, 0), size = Vector(0.064, 0.064, 0.064), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++"] = { type = "Model", model = "models/props_phx/construct/metal_plate_curve360.mdl", bone = "", rel = "egon_base", pos = Vector(-10.91, 0, 0), angle = Angle(90, 0, 0), size = Vector(0.079, 0.079, 0.237), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base"] = { type = "Model", model = "models/props_wasteland/laundry_washer003.mdl", bone = "Base", rel = "", pos = Vector(0.699, 1, -7.792), angle = Angle(90, -90, 0), size = Vector(0.301, 0.1, 0.1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base++"] = { type = "Model", model = "models/props_c17/factorymachine01.mdl", bone = "", rel = "egon_base", pos = Vector(3.635, 0, 1.5), angle = Angle(0, 90, 0), size = Vector(0.064, 0.064, 0.064), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}

SWEP.WElements = {
	["egon_base++++++"] = { type = "Model", model = "models/props_phx/misc/iron_beam2.mdl", bone = "", rel = "egon_base", pos = Vector(1.5, -4, -2), angle = Angle(-17.532, 90, 0), size = Vector(0.119, 0.119, 0.119), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+"] = { type = "Model", model = "models/props_phx/construct/metal_wire_angle360x2.mdl", bone = "", rel = "egon_base", pos = Vector(15.064, 0, 0), angle = Angle(90, 0, 0), size = Vector(0.071, 0.071, 0.08), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base++++++++++"] = { type = "Model", model = "models/props_wasteland/laundry_basket001.mdl", bone = "", rel = "egon_base", pos = Vector(-4.676, 0.5, -6), angle = Angle(0, 0, 0), size = Vector(0.029, 0.029, 0.159), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++"] = { type = "Model", model = "models/props_c17/factorymachine01.mdl", bone = "", rel = "egon_base", pos = Vector(4, 0, -1.601), angle = Angle(180, 90, 0), size = Vector(0.05, 0.05, 0.05), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base"] = { type = "Model", model = "models/props_wasteland/laundry_washer003.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(8.8, 1, -7), angle = Angle(0, 0, -170), size = Vector(0.17, 0.1, 0.1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base++++++++"] = { type = "Model", model = "models/props_combine/combine_interface001a.mdl", bone = "", rel = "egon_base", pos = Vector(4.675, 5, 0.6), angle = Angle(70, 0, 0), size = Vector(0.15, 0.15, 0.15), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++++++"] = { type = "Model", model = "models/props_wasteland/laundry_washer001a.mdl", bone = "", rel = "egon_base", pos = Vector(0.518, 5, 1), angle = Angle(90, -90, 0), size = Vector(0.039, 0.039, 0.119), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++"] = { type = "Model", model = "models/props_phx/construct/metal_plate_curve360.mdl", bone = "", rel = "egon_base", pos = Vector(-2.597, 0, 0), angle = Angle(90, 0, 0), size = Vector(0.079, 0.079, 0.129), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base+++++++"] = { type = "Model", model = "models/props_lab/reciever01a.mdl", bone = "", rel = "egon_base", pos = Vector(-2, 5, 1.557), angle = Angle(120, 0, 0), size = Vector(0.2, 0.2, 0.2), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
	["egon_base++"] = { type = "Model", model = "models/props_c17/factorymachine01.mdl", bone = "", rel = "egon_base", pos = Vector(3.635, 0, 1.5), angle = Angle(0, 90, 0), size = Vector(0.05, 0.05, 0.05), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}

SWEP.ViewModelBoneMods = {
	["ValveBiped.Bip01_L_UpperArm"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, -3), angle = Angle(0, 0, 0) },
	["Base"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 3), angle = Angle(0, 0, 0) }
}

local colBG = Color(16, 16, 16, 90)
local colRed = Color(220, 0, 0, 230)
local colWhite = Color(220, 220, 220, 230)

local function DrawHeatBar(self, x, y, wid, hei, is3d)
	local heatcolor = (1 - (self:GetShortHeat() + self:GetLongHeat())) * 220
	colWhite.g = heatcolor
	colWhite.b = heatcolor
	colWhite.a = 230

	local barrelcol = self.VElements["egon_base+"].color
	barrelcol.g = heatcolor
	barrelcol.b = heatcolor

	local shortdiv = self:GetShortHeat()
	local longdiv = self:GetLongHeat()
	local barheight = 20
	local bary = y + hei * 0.6
	local barshortwid = math.max(wid * shortdiv - 8, 0)
	local barlongwid = math.max(wid * longdiv - 8, 0)

	surface.SetDrawColor(0, 0, 0, 220)
	surface.DrawRect(x, bary, wid - 8, barheight)
	surface.SetDrawColor(255, 30, 10, 220)
	surface.DrawRect(x + 4, bary + 4, barlongwid, barheight - 8)
	surface.SetDrawColor(255, 190, 0, 220)
	surface.DrawRect(x + 4 + barlongwid, bary + 4, barshortwid, barheight - 8)
	surface.SetDrawColor(100, 0, 0, 255)
	surface.DrawRect(x - 12 + wid, bary - 4, 4, barheight + 8)

	if self:GetGunState() == 2 then
		colWhite.b = 0
		colWhite.g = 0
		if ((CurTime() * 4) % 2) > 1 then
			colWhite.a = 0
		else
			draw.SimpleTextBlurry("VENTING", is3d and "ZS3D2DFontSmaller" or "ZSHUDFontSmaller", x + wid/2, bary + hei * 0.15, colRed, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
		end
	end
end

function SWEP:Draw2DHUD()
	local screenscale = BetterScreenScale()

	local wid, hei = 180 * screenscale, 64 * screenscale
	local x, y = ScrW() - wid - screenscale * 128, ScrH() - hei - screenscale * 72
	local spare = self:GetPrimaryAmmoCount()

	local yy = ScrH() - hei * 2 - screenscale * 84

	DrawHeatBar(self, x + wid * 0.25 - wid/4, yy + hei * 0.2, wid, hei)

	draw.RoundedBox(16, x, y, wid, hei, colBG)
	draw.SimpleTextBlurry(spare, spare >= 1000 and "ZSHUDFont" or "ZSHUDFontBig", x + wid * 0.5, y + hei * 0.5, spare == 0 and colRed or colWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
	draw.SimpleTextBlurry("Heat", "ZSHUDFont", x + wid * 0.5, yy + hei * 0.45, colRed, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

function SWEP:Draw3DHUD(vm, pos, ang)
	local wid, hei = 180, 64
	local x, y = wid * -0.6, hei * -0.5
	local spare = self:GetPrimaryAmmoCount()

	cam.Start3D2D(pos, ang, self.HUD3DScale / 2)
		DrawHeatBar(self, x + wid * 0.25 - wid/4, y - hei * 1, wid, hei, true)

		draw.RoundedBoxEx(32, x, y, wid, hei, colBG, true, false, true, false)
		draw.SimpleTextBlurry(spare, spare >= 1000 and "ZS3D2DFontSmall" or "ZS3D2DFont", x + wid * 0.5, y + hei * 0.5, spare == 0 and colRed or colWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
		draw.SimpleTextBlurry("Heat", "ZS3D2DFontSmall", x + wid * 0.5, y - hei * 1, colRed, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
	cam.End3D2D()
end
