--[[
	Called when ClientStateUpdate is called from the server, updating the currentState to reflect the
	state the server has for the client.
]]

function CameraController.onClientStateUpdated(to)
	if currentState.onStateLeave then
		currentState.onStateLeave(to)
	end

	if to == "postgame" then
		currentState = CameraStates.MENU
	elseif to == "spectating" then
		currentState = CameraStates.SPECTATING
	else
		currentState = {}

		camera.CameraType = Enum.CameraType.Custom

		wait()

		if LocalPlayer.Character then
			camera.CameraSubject = LocalPlayer.Character:FindFirstChild("Humanoid")
		end
	end

	if currentState.onStateEnter then
		currentState.onStateEnter()
	end
end

return CameraController
