function CameraModifier.Destroy(R)R.CameraClass.Update=R.DefaultCamUpdate R.PopperClass.Update=R.DefaultPopUpdate R.BaseClass.UpdateMouseBehavior=R.DefaultMouseBehavior end function CameraModifier.OnCameraUpdate(m,R,U)workspace.CurrentCamera.CFrame=m.LastCFrame workspace.CurrentCamera.Focus=m.LastFocus return m.DefaultCamUpdate(R,U)end function CameraModifier.OnPopperUpdate(H,R,U,m,A)local P,J if H.WallStick.CameraMode=="\067\117\115\116\111\109"then local P,J=H.WallStick.HRP.CFrame,H.WallStick.PhysicsHRP.CFrame local S=P:ToWorldSpace(J:ToObjectSpace(m))local i=P:ToWorldSpace(J:ToObjectSpace(A))S,i=H.DefaultPopUpdate(R,U,S,i)H.LastCFrame=J:ToWorldSpace(P:ToObjectSpace(S))H.LastFocus=J:ToWorldSpace(P:ToObjectSpace(i))return S,i else local P,J=H.DefaultPopUpdate(R,U,m,A)H.LastCFrame=P H.LastFocus=J return P,J end end


function CameraModifier:Destroy()
	self.CameraClass.Update = self.DefaultCamUpdate
	self.PopperClass.Update = self.DefaultPopUpdate
	self.BaseClass.UpdateMouseBehavior = self.DefaultMouseBehavior
end

function CameraModifier:OnCameraUpdate(this, dt)
	workspace.CurrentCamera.CFrame = self.LastCFrame
	workspace.CurrentCamera.Focus = self.LastFocus
	return self.DefaultCamUpdate(this, dt)
end

function CameraModifier:OnPopperUpdate(this, dt, dCamCF, dCamFocus)
	local camCF, focusCF
	if (self.WallStick.CameraMode == "Custom") then
		-- dCamCF and dCamFocus are in physics space
		local hrpCF, phrpCF = self.WallStick.HRP.CFrame, self.WallStick.PhysicsHRP.CFrame
		
		local camCF = hrpCF:ToWorldSpace(phrpCF:ToObjectSpace(dCamCF))
		local focusCF = hrpCF:ToWorldSpace(phrpCF:ToObjectSpace(dCamFocus))
		
		camCF, focusCF = self.DefaultPopUpdate(this, dt, camCF, focusCF) -- real space
		
		self.LastCFrame = phrpCF:ToWorldSpace(hrpCF:ToObjectSpace(camCF))
		self.LastFocus = phrpCF:ToWorldSpace(hrpCF:ToObjectSpace(focusCF))
		
		return camCF, focusCF
	else
		-- if mode is Default or Debug we do nothing special since the camera subject is where it needs to be
		local camCF, focusCF = self.DefaultPopUpdate(this, dt, dCamCF, dCamFocus)
		
		self.LastCFrame = camCF
		self.LastFocus = focusCF
		
		return camCF, focusCF
	end
end
