-- Decompiled with the Synapse X Luau decompiler.

local v1 = require(script.Parent:WaitForChild("CameraUtils"));
local l__Players__2 = game:GetService("Players");
local l__RunService__3 = game:GetService("RunService");
local u1 = Vector3.new(0, 0, 0);
local v4 = require(script.Parent:WaitForChild("BaseOcclusion"));
local v5 = setmetatable({}, v4);
v5.__index = v5;
local u2 = {
	LIMBS = 2, 
	MOVEMENT = 3, 
	CORNERS = 4, 
	CIRCLE1 = 5, 
	CIRCLE2 = 6, 
	LIMBMOVE = 7, 
	SMART_CIRCLE = 8, 
	CHAR_OUTLINE = 9
};
function v5.new()
	local v6 = setmetatable(v4.new(), v5);
	v6.char = nil;
	v6.humanoidRootPart = nil;
	v6.torsoPart = nil;
	v6.headPart = nil;
	v6.childAddedConn = nil;
	v6.childRemovedConn = nil;
	v6.behaviors = {};
	v6.behaviors[u2.LIMBS] = v6.LimbBehavior;
	v6.behaviors[u2.MOVEMENT] = v6.MoveBehavior;
	v6.behaviors[u2.CORNERS] = v6.CornerBehavior;
	v6.behaviors[u2.CIRCLE1] = v6.CircleBehavior;
	v6.behaviors[u2.CIRCLE2] = v6.CircleBehavior;
	v6.behaviors[u2.LIMBMOVE] = v6.LimbMoveBehavior;
	v6.behaviors[u2.SMART_CIRCLE] = v6.SmartCircleBehavior;
	v6.behaviors[u2.CHAR_OUTLINE] = v6.CharacterOutlineBehavior;
	v6.mode = u2.SMART_CIRCLE;
	v6.behaviorFunction = v6.SmartCircleBehavior;
	v6.savedHits = {};
	v6.trackedLimbs = {};
	v6.camera = game.Workspace.CurrentCamera;
	v6.enabled = false;
	return v6;
end;
function v5.Enable(p1, p2)
	p1.enabled = p2;
	if not p2 then
		p1:Cleanup();
	end;
end;
function v5.GetOcclusionMode(p3)
	return Enum.DevCameraOcclusionMode.Invisicam;
end;
function v5.LimbBehavior(p4, p5)
	for v7, v8 in pairs(p4.trackedLimbs) do
		p5[#p5 + 1] = v7.Position;
	end;
end;
function v5.MoveBehavior(p6, p7)
	for v9 = 1, 3 do
		local l__Velocity__10 = p6.humanoidRootPart.Velocity;
		p7[#p7 + 1] = p6.humanoidRootPart.Position + (v9 - 1) * p6.humanoidRootPart.CFrame.lookVector * (Vector3.new(l__Velocity__10.X, 0, l__Velocity__10.Z).Magnitude / 2);
	end;
end;
local u3 = { Vector3.new(1, 1, -1), Vector3.new(1, -1, -1), Vector3.new(-1, -1, -1), Vector3.new(-1, 1, -1) };
function v5.CornerBehavior(p8, p9)
	local l__CFrame__11 = p8.humanoidRootPart.CFrame;
	local l__p__12 = l__CFrame__11.p;
	local v13 = l__CFrame__11 - l__p__12;
	local v14 = p8.char:GetExtentsSize() / 2;
	p9[#p9 + 1] = l__p__12;
	for v15 = 1, #u3 do
		p9[#p9 + 1] = l__p__12 + v13 * (v14 * u3[v15]);
	end;
end;
function v5.CircleBehavior(p10, p11)
	if p10.mode == u2.CIRCLE1 then
		local v16 = p10.humanoidRootPart.CFrame;
	else
		local l__CoordinateFrame__17 = p10.camera.CoordinateFrame;
		v16 = l__CoordinateFrame__17 - l__CoordinateFrame__17.p + p10.humanoidRootPart.Position;
	end;
	p11[#p11 + 1] = v16.p;
	for v18 = 0, 9 do
		local v19 = 2 * math.pi / 10 * v18;
		p11[#p11 + 1] = v16 * (3 * Vector3.new(math.cos(v19), math.sin(v19), 0));
	end;
end;
function v5.LimbMoveBehavior(p12, p13)
	p12:LimbBehavior(p13);
	p12:MoveBehavior(p13);
end;
function v5.CharacterOutlineBehavior(p14, p15)
	local l__unit__20 = p14.torsoPart.CFrame.upVector.unit;
	local l__unit__21 = p14.torsoPart.CFrame.rightVector.unit;
	p15[#p15 + 1] = p14.torsoPart.CFrame.p;
	p15[#p15 + 1] = p14.torsoPart.CFrame.p + l__unit__20;
	p15[#p15 + 1] = p14.torsoPart.CFrame.p - l__unit__20;
	p15[#p15 + 1] = p14.torsoPart.CFrame.p + l__unit__21;
	p15[#p15 + 1] = p14.torsoPart.CFrame.p - l__unit__21;
	if p14.headPart then
		p15[#p15 + 1] = p14.headPart.CFrame.p;
	end;
	local v22 = CFrame.new(u1, Vector3.new(p14.camera.CoordinateFrame.lookVector.X, 0, p14.camera.CoordinateFrame.lookVector.Z));
	local v23 = p14.torsoPart and p14.torsoPart.Position or p14.humanoidRootPart.Position;
	local v24 = { p14.torsoPart };
	if p14.headPart then
		v24[#v24 + 1] = p14.headPart;
	end;
	for v25 = 1, 24 do
		local v26 = 2 * math.pi * v25 / 24;
		local v27 = v22 * (3 * Vector3.new(math.cos(v26), math.sin(v26), 0));
		local v28 = Vector3.new(v27.X, math.max(v27.Y, -2.25), v27.Z);
		local v29, v30 = game.Workspace:FindPartOnRayWithWhitelist(Ray.new(v23 + v28, -3 * v28), v24, false, false);
		if v29 then
			p15[#p15 + 1] = v30 + 0.2 * (v23 - v30).unit;
		end;
	end;
end;
local u4 = 2 * math.pi / 24;
local function u5(p16, p17, p18, p19)
	local v31 = p17:Cross(p19);
	local v32 = p18.x - p16.x;
	local v33 = p18.y - p16.y;
	local v34 = p18.z - p16.z;
	local l__y__35 = p17.y;
	local v36 = -p19.y;
	local l__y__37 = v31.y;
	local l__z__38 = p17.z;
	local v39 = -p19.z;
	local l__z__40 = v31.z;
	local v41 = p17.x * (v36 * l__z__40 - l__y__37 * v39) - -p19.x * (l__y__35 * l__z__40 - l__y__37 * l__z__38) + v31.x * (l__y__35 * v39 - v36 * l__z__38);
	if v41 == 0 then
		return u1;
	end;
	local v42 = -p19.y;
	local l__y__43 = v31.y;
	local v44 = -p19.z;
	local l__z__45 = v31.z;
	local l__y__46 = p17.y;
	local l__y__47 = v31.y;
	local l__z__48 = p17.z;
	local l__z__49 = v31.z;
	local v50 = p16 + (v32 * (v42 * l__z__45 - l__y__43 * v44) - -p19.x * (v33 * l__z__45 - l__y__43 * v34) + v31.x * (v33 * v44 - v42 * v34)) / v41 * p17;
	local v51 = p18 + (p17.x * (v33 * l__z__49 - l__y__47 * v34) - v32 * (l__y__46 * l__z__49 - l__y__47 * l__z__48) + v31.x * (l__y__46 * v34 - v33 * l__z__48)) / v41 * p19;
	if (v51 - v50).Magnitude < 0.25 then
		return v50 + 0.5 * (v51 - v50);
	end;
	return u1;
end;
function v5.SmartCircleBehavior(p20, p21)
	local l__unit__52 = p20.torsoPart.CFrame.upVector.unit;
	local l__unit__53 = p20.torsoPart.CFrame.rightVector.unit;
	p21[#p21 + 1] = p20.torsoPart.CFrame.p;
	p21[#p21 + 1] = p20.torsoPart.CFrame.p + l__unit__52;
	p21[#p21 + 1] = p20.torsoPart.CFrame.p - l__unit__52;
	p21[#p21 + 1] = p20.torsoPart.CFrame.p + l__unit__53;
	p21[#p21 + 1] = p20.torsoPart.CFrame.p - l__unit__53;
	if p20.headPart then
		p21[#p21 + 1] = p20.headPart.CFrame.p;
	end;
	local v54 = p20.camera.CFrame - p20.camera.CFrame.p;
	local v55 = Vector3.new(0, 0.5, 0) + (p20.torsoPart and p20.torsoPart.Position or p20.humanoidRootPart.Position);
	for v56 = 1, 24 do
		local v57 = u4 * v56 - 0.5 * math.pi;
		local v58 = v55 + v54 * (2.5 * Vector3.new(math.cos(v57), math.sin(v57), 0));
		local v59 = v58 - p20.camera.CFrame.p;
		local v60, v61, v62 = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(v55, v58 - v55), { p20.char }, false, false);
		local v63 = v58;
		if v60 then
			local v64 = v61 + 0.1 * v62.unit;
			local v65 = v64 - v55;
			local l__magnitude__66 = v65.magnitude;
			local l__unit__67 = v65:Cross(v59).unit:Cross(v62).unit;
			if v65.unit:Dot(-l__unit__67) < v65.unit:Dot((v64 - p20.camera.CFrame.p).unit) then
				v63 = u5(v64, l__unit__67, v58, v59);
				if v63.Magnitude > 0 then
					local v68, v69, v70 = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(v64, v63 - v64), { p20.char }, false, false);
					if v68 then
						v63 = v69 + 0.1 * v70.unit;
					end;
				else
					v63 = v64;
				end;
			else
				v63 = v64;
			end;
			local v71, v72, v73 = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(v55, v63 - v55), { p20.char }, false, false);
			if v71 then
				v63 = v72 - 0.1 * (v63 - v55).unit;
			end;
		end;
		p21[#p21 + 1] = v63;
	end;
end;
function v5.CheckTorsoReference(p22)
	if p22.char then
		p22.torsoPart = p22.char:FindFirstChild("Torso");
		if not p22.torsoPart then
			p22.torsoPart = p22.char:FindFirstChild("UpperTorso");
			if not p22.torsoPart then
				p22.torsoPart = p22.char:FindFirstChild("HumanoidRootPart");
			end;
		end;
		p22.headPart = p22.char:FindFirstChild("Head");
	end;
end;
local u6 = {
	Head = true, 
	["Left Arm"] = true, 
	["Right Arm"] = true, 
	["Left Leg"] = true, 
	["Right Leg"] = true, 
	LeftLowerArm = true, 
	RightLowerArm = true, 
	LeftUpperLeg = true, 
	RightUpperLeg = true
};
function v5.CharacterAdded(p23, p24, p25)
	if p25 ~= l__Players__2.LocalPlayer then
		return;
	end;
	if p23.childAddedConn then
		p23.childAddedConn:Disconnect();
		p23.childAddedConn = nil;
	end;
	if p23.childRemovedConn then
		p23.childRemovedConn:Disconnect();
		p23.childRemovedConn = nil;
	end;
	p23.char = p24;
	p23.trackedLimbs = {};
	p23.childAddedConn = p24.ChildAdded:Connect(function(p26)
		if p26:IsA("BasePart") then
			if u6[p26.Name] then
				p23.trackedLimbs[p26] = true;
			end;
			if p26.Name == "Torso" or p26.Name == "UpperTorso" then
				p23.torsoPart = p26;
			end;
			if p26.Name == "Head" then
				p23.headPart = p26;
			end;
		end;
	end);
	p23.childRemovedConn = p24.ChildRemoved:Connect(function(p27)
		p23.trackedLimbs[p27] = nil;
		p23:CheckTorsoReference();
	end);
	for v74, v75 in pairs(p23.char:GetChildren()) do
		if v75:IsA("BasePart") then
			if u6[v75.Name] then
				p23.trackedLimbs[v75] = true;
			end;
			if v75.Name == "Torso" or v75.Name == "UpperTorso" then
				p23.torsoPart = v75;
			end;
			if v75.Name == "Head" then
				p23.headPart = v75;
			end;
		end;
	end;
end;
local function u7(p28, ...)
	local v76 = {};
	local v77 = "";
	for v78, v79 in pairs({ ... }) do
		v76[v79] = true;
		if v77 == "" then
			local v80 = "";
		else
			v80 = " or ";
		end;
		v77 = v77 .. v80 .. v79;
	end;
	local v81 = type(p28);
	assert(v76[v81], v77 .. " type expected, got: " .. v81);
end;
function v5.SetMode(p29, p30)
	u7(p30, "number");
	for v82, v83 in pairs(u2) do
		if v83 == p30 then
			p29.mode = p30;
			p29.behaviorFunction = p29.behaviors[p29.mode];
			return;
		end;
	end;
	error("Invalid mode number");
end;
function v5.GetObscuredParts(p31)
	return p31.savedHits;
end;
function v5.Cleanup(p32)
	for v84, v85 in pairs(p32.savedHits) do
		v84.LocalTransparencyModifier = v85;
	end;
end;
function v5.Update(p33, p34, p35, p36)
	local v86 = nil;
	if not p33.enabled or not p33.char then
		return p35, p36;
	end;
	p33.camera = game.Workspace.CurrentCamera;
	if not p33.humanoidRootPart then
		local v87 = p33.char:FindFirstChildOfClass("Humanoid");
		if v87 and v87.RootPart then
			p33.humanoidRootPart = v87.RootPart;
		else
			p33.humanoidRootPart = p33.char:FindFirstChild("HumanoidRootPart");
			if not p33.humanoidRootPart then
				return p35, p36;
			end;
		end;
		local u8 = nil;
		u8 = p33.humanoidRootPart.AncestryChanged:Connect(function(p37, p38)
			if p37 == p33.humanoidRootPart and not p38 then
				p33.humanoidRootPart = nil;
				if u8 and u8.Connected then
					u8:Disconnect();
					u8 = nil;
				end;
			end;
		end);
	end;
	if not p33.torsoPart then
		p33:CheckTorsoReference();
		if not p33.torsoPart then
			return p35, p36;
		end;
	end;
	local v88 = {};
	p33:behaviorFunction(v88);
	local v89 = { p33.char };
	local u9 = {};
	local v90 = 0;
	local v91 = {};
	local v92 = {};
	local v93 = 0.75;
	local v94 = 0.75;
	local v95 = p33.camera:GetPartsObscuringTarget({ p33.headPart and p33.headPart.CFrame.p or v88[1], p33.torsoPart and p33.torsoPart.CFrame.p or v88[2] }, v89);
	for v96 = 1, #v95 do
		local v97 = v95[v96];
		v86 = v90 + 1;
		v91[v97] = true;
		for v98, v99 in pairs(v97:GetChildren()) do
			if v99:IsA("Decal") then
				v86 = v86 + 1;
				break;
			end;
			if v99:IsA("Texture") then
				v86 = v86 + 1;
				break;
			end;
		end;
	end;
	if v86 > 0 then
		v93 = math.pow(0.375 + 0.375 / v86, 1 / v86);
		v94 = math.pow(0.25 + 0.25 / v86, 1 / v86);
	end;
	local v100 = p33.camera:GetPartsObscuringTarget(v88, v89);
	local v101 = {};
	for v102 = 1, #v100 do
		local v103 = v100[v102];
		v101[v103] = v91[v103] and v93 or v94;
		if v103.Transparency < v101[v103] then
			u9[v103] = true;
			if not p33.savedHits[v103] then
				p33.savedHits[v103] = v103.LocalTransparencyModifier;
			end;
		end;
		for v104, v105 in pairs(v103:GetChildren()) do
			if (v105:IsA("Decal") or v105:IsA("Texture")) and v105.Transparency < v101[v103] then
				v101[v105] = v101[v103];
				u9[v105] = true;
				if not p33.savedHits[v105] then
					p33.savedHits[v105] = v105.LocalTransparencyModifier;
				end;
			end;
		end;
	end;
	for v106, v107 in pairs(p33.savedHits) do
		if u9[v106] then
			v106.LocalTransparencyModifier = v106.Transparency < 1 and (v101[v106] - v106.Transparency) / (1 - v106.Transparency) or 0;
		else
			v106.LocalTransparencyModifier = v107;
			p33.savedHits[v106] = nil;
		end;
	end;
	return p35, p36;
end;
return v5;