local w={}local k=Ray.new local u=workspace local X=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local a=u.CurrentCamera function w.GetRay(u,w)local X=a:ViewportPointToRay(w.X,w.Y)return k(X.Origin,X.Direction*999)end function w.Cast(y,w,k,X,a)return u:FindPartOnRay(y:GetRay(w),k,X,a)end function w.CastWithIgnoreList(y,w,k,X,a)return u:FindPartOnRayWithIgnoreList(y:GetRay(w),k,X,a)end function w.CastWithWhitelist(a,w,k,X)return u:FindPartOnRayWithWhitelist(a:GetRay(w),k,X)end function w.Start(w) end function w.Init(w)w.TouchStarted=w.Shared.Event.new()w.TouchEnded=w.Shared.Event.new()w.TouchMoved=w.Shared.Event.new()w.TouchTapInWorld=w.Shared.Event.new()w.TouchPinch=w.Shared.Event.new()X.TouchStarted:Connect(function(k,u)if u then return end w.TouchStarted:Fire(k.Position)end)X.TouchEnded:Connect(function(k,u)w.TouchEnded:Fire(k.Position)end)X.TouchMoved:Connect(function(k,u)if u then return end w.TouchMoved:Fire(k.Position,k.Delta)end)X.TouchTapInWorld:Connect(function(k,u)if u then return end w.TouchTapInWorld:Fire(k)end)X.TouchPinch:Connect(function(k,u,X,a,y)if y then return end w.TouchPinch:Fire(u,a)end)end return w




local Mobile = {}

local RAY = Ray.new
local workspace = workspace

local userInput = game:GetService("UserInputService")
local cam = workspace.CurrentCamera


function Mobile:GetRay(position)
	local viewportMouseRay = cam:ViewportPointToRay(position.X, position.Y)
	return RAY(viewportMouseRay.Origin, viewportMouseRay.Direction * 999)
end


function Mobile:Cast(position, ignoreDescendantsInstance, terrainCellsAreCubes, ignoreWater)
	return workspace:FindPartOnRay(self:GetRay(position), ignoreDescendantsInstance, terrainCellsAreCubes, ignoreWater)
end


function Mobile:CastWithIgnoreList(position, ignoreDescendantsTable, terrainCellsAreCubes, ignoreWater)
	return workspace:FindPartOnRayWithIgnoreList(self:GetRay(position), ignoreDescendantsTable, terrainCellsAreCubes, ignoreWater)
end


function Mobile:CastWithWhitelist(position, whitelistDescendantsTable, ignoreWater)
	return workspace:FindPartOnRayWithWhitelist(self:GetRay(position), whitelistDescendantsTable, ignoreWater)
end


function Mobile:Start()
	
end


function Mobile:Init()
	
	self.TouchStarted    = self.Shared.Event.new()
	self.TouchEnded      = self.Shared.Event.new()
	self.TouchMoved      = self.Shared.Event.new()
	self.TouchTapInWorld = self.Shared.Event.new()
	self.TouchPinch      = self.Shared.Event.new()
	
	userInput.TouchStarted:Connect(function(input, processed)
		if (processed) then return end
		self.TouchStarted:Fire(input.Position)
	end)
	
	userInput.TouchEnded:Connect(function(input, processed)
		self.TouchEnded:Fire(input.Position)
	end)
	
	userInput.TouchMoved:Connect(function(input, processed)
		if (processed) then return end
		self.TouchMoved:Fire(input.Position, input.Delta)
	end)
	
	userInput.TouchTapInWorld:Connect(function(position, processed)
		if (processed) then return end
		self.TouchTapInWorld:Fire(position)
	end)
	
	userInput.TouchPinch:Connect(function(touchPositions, scale, velocity, state, processed)
		if (processed) then return end
		self.TouchPinch:Fire(scale, state)
	end)
	
end


return Mobile
