local S=nil local Q={}local X=require(script:WaitForChild("\077\097\115\116\101\114\067\111\110\116\114\111\108"))local y=require(script.MasterControl:WaitForChild("\075\101\121\098\111\097\114\100\077\111\118\101\109\101\110\116"))function getTouchModule()local S=nil if not IsUserChoice then if DevMovementMode==Enum.DevTouchMovementMode.Scriptable then S=nil end else if UserMovementMode==Enum.TouchMovementMode.ClickToMove then S=nil end end return S end function setJumpModule(S) end function setClickToMove()if DevMovementMode==Enum.DevTouchMovementMode.ClickToMove or DevMovementMode==Enum.DevComputerMovementMode.ClickToMove or UserMovementMode==Enum.ComputerMovementMode.ClickToMove or UserMovementMode==Enum.TouchMovementMode.ClickToMove then if lastInputType==Enum.UserInputType.Touch then S=ControlState.Current end elseif S then S:Disable()S=nil end end Q.Touch={}Q.Touch.Current=nil Q.Touch.LocalPlayerChangedCon=nil Q.Touch.GameSettingsChangedCon=nil function Q.Touch.RefreshControlStyle(S)Q.Touch.Current:Disable()setJumpModule(false)Q.Touch:Enable()end function Q.Touch.DisconnectEvents(S)if Q.Touch.LocalPlayerChangedCon then Q.Touch.LocalPlayerChangedCon:disconnect()Q.Touch.LocalPlayerChangedCon=nil end if Q.Touch.GameSettingsChangedCon then Q.Touch.GameSettingsChangedCon:disconnect()Q.Touch.GameSettingsChangedCon=nil end end function Q.Touch.Enable(S)DevMovementMode=LocalPlayer.DevTouchMovementMode IsUserChoice=DevMovementMode==Enum.DevTouchMovementMode.UserChoice if IsUserChoice then UserMovementMode=GameSettings.TouchMovementMode end local X=getTouchModule()if X then setClickToMove()setJumpModule(isJumpEnabled)X:Enable()Q.Touch.Current=X Q.Touch:DisconnectEvents()Q.Touch.LocalPlayerChangedCon=LocalPlayer.Changed:connect(function(S)if S=="\068\101\118\084\111\117\099\104\077\111\118\101\109\101\110\116\077\111\100\101"then Q.Touch:RefreshControlStyle()end end)Q.Touch.GameSettingsChangedCon=GameSettings.Changed:connect(function(S)if S=="\084\111\117\099\104\077\111\118\101\109\101\110\116\077\111\100\101"then Q.Touch:RefreshControlStyle()end end)end end function Q.Touch.Disable(S)Q.Touch:DisconnectEvents()local X=getTouchModule()end local function V()local S=nil if not IsUserChoice then if DevMovementMode==Enum.DevComputerMovementMode.KeyboardMouse then S=y elseif DevMovementMode==Enum.DevComputerMovementMode.ClickToMove then S=y end else if UserMovementMode==Enum.ComputerMovementMode.KeyboardMouse or UserMovementMode==Enum.ComputerMovementMode.Default then S=y elseif UserMovementMode==Enum.ComputerMovementMode.ClickToMove then S=y end end return S end Q.Keyboard={}function Q.Keyboard.Enable(S)DevMovementMode=LocalPlayer.DevComputerMovementMode IsUserChoice=DevMovementMode==Enum.DevComputerMovementMode.UserChoice if IsUserChoice then UserMovementMode=GameSettings.ComputerMovementMode end local Q=V()if Q then if Q then Q:Enable()end end end function Q.Keyboard.Disable(S)local Q=V()if Q then Q:Disable()end end if IsTouchDevice then BindableEvent_OnFailStateChanged=script.Parent:WaitForChild("\079\110\067\108\105\099\107\084\111\077\111\118\101\070\097\105\108\083\116\097\116\101\067\104\097\110\103\101")end
--[[ Modules ]]
--
local ClickToMoveTouchControls = nil
local ControlModules = {}

local MasterControl = require(script:WaitForChild("MasterControl"))

local keyboardModule = require(script.MasterControl:WaitForChild("KeyboardMovement"))

function getTouchModule()
	local module = nil
	if not IsUserChoice then
		if DevMovementMode == Enum.DevTouchMovementMode.Scriptable then
			module = nil
		end
	else
		if UserMovementMode == Enum.TouchMovementMode.ClickToMove then
			-- Managed by CameraScript
			module = nil
		end
	end

	return module
end

function setJumpModule(isEnabled) end

function setClickToMove()
	if
		DevMovementMode == Enum.DevTouchMovementMode.ClickToMove
		or DevMovementMode == Enum.DevComputerMovementMode.ClickToMove
		or UserMovementMode == Enum.ComputerMovementMode.ClickToMove
		or UserMovementMode == Enum.TouchMovementMode.ClickToMove
	then
		--
		if lastInputType == Enum.UserInputType.Touch then
			ClickToMoveTouchControls = ControlState.Current
		end
	elseif ClickToMoveTouchControls then
		ClickToMoveTouchControls:Disable()
		ClickToMoveTouchControls = nil
	end
end

ControlModules.Touch = {}
ControlModules.Touch.Current = nil
ControlModules.Touch.LocalPlayerChangedCon = nil
ControlModules.Touch.GameSettingsChangedCon = nil

function ControlModules.Touch:RefreshControlStyle()
	ControlModules.Touch.Current:Disable()
	setJumpModule(false)
	ControlModules.Touch:Enable()
end
function ControlModules.Touch:DisconnectEvents()
	if ControlModules.Touch.LocalPlayerChangedCon then
		ControlModules.Touch.LocalPlayerChangedCon:disconnect()
		ControlModules.Touch.LocalPlayerChangedCon = nil
	end
	if ControlModules.Touch.GameSettingsChangedCon then
		ControlModules.Touch.GameSettingsChangedCon:disconnect()
		ControlModules.Touch.GameSettingsChangedCon = nil
	end
end
function ControlModules.Touch:Enable()
	DevMovementMode = LocalPlayer.DevTouchMovementMode
	IsUserChoice = DevMovementMode == Enum.DevTouchMovementMode.UserChoice
	if IsUserChoice then
		UserMovementMode = GameSettings.TouchMovementMode
	end

	local newModuleToEnable = getTouchModule()
	if newModuleToEnable then
		setClickToMove()
		setJumpModule(isJumpEnabled)

		newModuleToEnable:Enable()
		ControlModules.Touch.Current = newModuleToEnable

		ControlModules.Touch:DisconnectEvents()
		ControlModules.Touch.LocalPlayerChangedCon = LocalPlayer.Changed:connect(function(property)
			if property == "DevTouchMovementMode" then
				ControlModules.Touch:RefreshControlStyle()
			end
		end)

		ControlModules.Touch.GameSettingsChangedCon = GameSettings.Changed:connect(function(property)
			if property == "TouchMovementMode" then
				ControlModules.Touch:RefreshControlStyle()
			end
		end)
	end
end
function ControlModules.Touch:Disable()
	ControlModules.Touch:DisconnectEvents()

	local newModuleToDisable = getTouchModule()
end

local function getKeyboardModule()
	-- NOTE: Click to move still uses keyboard. Leaving cases in case this ever changes.
	local whichModule = nil
	if not IsUserChoice then
		if DevMovementMode == Enum.DevComputerMovementMode.KeyboardMouse then
			whichModule = keyboardModule
		elseif DevMovementMode == Enum.DevComputerMovementMode.ClickToMove then
			-- Managed by CameraScript
			whichModule = keyboardModule
		end
	else
		if
			UserMovementMode == Enum.ComputerMovementMode.KeyboardMouse
			or UserMovementMode == Enum.ComputerMovementMode.Default
		then
			whichModule = keyboardModule
		elseif UserMovementMode == Enum.ComputerMovementMode.ClickToMove then
			-- Managed by CameraScript
			whichModule = keyboardModule
		end
	end

	return whichModule
end

ControlModules.Keyboard = {}
function ControlModules.Keyboard:Enable()
	DevMovementMode = LocalPlayer.DevComputerMovementMode
	IsUserChoice = DevMovementMode == Enum.DevComputerMovementMode.UserChoice
	if IsUserChoice then
		UserMovementMode = GameSettings.ComputerMovementMode
	end

	local newModuleToEnable = getKeyboardModule()
	if newModuleToEnable then
		if newModuleToEnable then
			newModuleToEnable:Enable()
		end
	end
end
function ControlModules.Keyboard:Disable()
	local newModuleToDisable = getKeyboardModule()
	if newModuleToDisable then
		newModuleToDisable:Disable()
	end
end

if IsTouchDevice then
	BindableEvent_OnFailStateChanged = script.Parent:WaitForChild("OnClickToMoveFailStateChange")
end
