local N={}N.ClassName="\083\117\109\109\101\100\067\097\109\101\114\097"function N.new(C,F)local h=setmetatable({},N)h._mode="\087\111\114\108\100"h._cameraA=C or error("\078\111 \099\097\109\101\114\097\065")h._cameraB=F or error("\078\111 \099\097\109\101\114\097\066")return h end function N.SetMode(C,N)assert(N=="\087\111\114\108\100"or N=="\082\101\108\097\116\105\118\101")C._mode=N return C end function N.__addClass(F,C)return N.new(F,C)end function N.__add(F,C)return(N.new(F,C)):SetMode(F._mode)end function N.__sub(C,N)if C._cameraA==N then return C._cameraA elseif C._cameraB==N then return C._cameraB else error("\085\110\097\098\108\101 \116\111 \115\117\098\116\114\097\099\116 \115\117\099\099\101\115\115\102\117\108\108\121")end end function N.__index(F,C)if C=="\083\116\097\116\101"or C=="\067\097\109\101\114\097\083\116\097\116\101"or C=="\067\097\109\101\114\097"then if F._mode=="\087\111\114\108\100"then return F.CameraAState+F.CameraBState else local N=F.CameraAState local C=F.CameraBState local h=N+C h.Position=N.CFrame*C.Position return h end elseif C=="\067\097\109\101\114\097\065\083\116\097\116\101"then return F._cameraA.CameraState or F._cameraA elseif C=="\067\097\109\101\114\097\066\083\116\097\116\101"then return F._cameraB.CameraState or F._cameraB elseif N[C]then return N[C]else error(("\091\083\117\109\109\101\100\067\097\109\101\114\097\093 - \'\037\115\' \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114"):format(tostring(C)))end end return N
--- Add two cameras together
-- @classmod SummedCamera

local SummedCamera = {}
SummedCamera.ClassName = "SummedCamera"

--- Construct a new summed camera
-- @constructor
-- @param cameraA A CameraState or another CameraEffect to be used
-- @param cameraB A CameraState or another CameraEffect to be used
function SummedCamera.new(cameraA, cameraB)
	local self = setmetatable({}, SummedCamera)

	self._mode = "World"
	self._cameraA = cameraA or error("No cameraA")
	self._cameraB = cameraB or error("No cameraB")

	return self
end

---
-- @param mode Mode to set
-- If "World", then it just adds positions.
-- If "Relative", then it moves position relative to cameraA's CFrame.
function SummedCamera:SetMode(mode)
	assert(mode == "World" or mode == "Relative")
	self._mode = mode

	return self
end

function SummedCamera:__addClass(other)
	return SummedCamera.new(self, other)
end

function SummedCamera:__add(other)
	return SummedCamera.new(self, other):SetMode(self._mode)
end

function SummedCamera:__sub(camera)
	if self._cameraA == camera then
		return self._cameraA
	elseif self._cameraB == camera then
		return self._cameraB
	else
		error("Unable to subtract successfully");
	end
end

function SummedCamera:__index(index)
	if index == "State" or index == "CameraState" or index == "Camera" then
		if self._mode == "World" then
			return self.CameraAState + self.CameraBState
		else
			local StateA = self.CameraAState
			local StateB = self.CameraBState

			local Result = StateA + StateB
			Result.Position = StateA.CFrame * StateB.Position
			return Result
		end
	elseif index == "CameraAState" then
		return self._cameraA.CameraState or self._cameraA
	elseif index == "CameraBState" then
		return self._cameraB.CameraState or self._cameraB
	elseif SummedCamera[index] then
		return SummedCamera[index]
	else
		error(("[SummedCamera] - '%s' is not a valid member"):format(tostring(index)))
	end
end

return SummedCamera