local s=(require(((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\083\099\114\105\112\116\115")):WaitForChild("\067\111\110\115\111\108\101"))).sourced("\067\111\110\116\114\111\108 \077\097\110\097\103\101\114")s.log("\076\111\097\100\105\110\103 \100\101\112\101\110\100\101\110\099\105\101\115\046\046\046")local U=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer local g=U:WaitForChild("\080\108\097\121\101\114\083\099\114\105\112\116\115")local L=require((g:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101"))local P=require(((g:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\083\099\104\101\109\101"))local p=require((((g:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\083\099\104\101\109\101")):WaitForChild("\067\111\110\116\114\111\108\077\101\116\104\111\100"))local i=require((((g:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\083\099\104\101\109\101")):WaitForChild("\068\105\114\101\099\116\105\111\110\077\101\116\104\111\100"))local C=require((((g:WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101")):WaitForChild("\067\111\110\116\114\111\108\083\099\104\101\109\101")):WaitForChild("\073\110\112\117\116\084\121\112\101"))s.log("\067\111\110\115\116\114\117\099\116\105\110\103 \102\117\110\099\116\105\111\110\115\046\046\046")local function F()local s=P.new()local U U=s:Add("\086\101\114\116\105\099\097\108")U.Name="\086\101\114\116\105\099\097\108"U.Method=p.Axis U=s:Add("\072\111\114\105\122\111\110\116\097\108")U.Name="\072\111\114\105\122\111\110\116\097\108"U.Method=p.Axis return s end local function d()local s=P.new()local U U=s:Add("\085\112")U.Name="\085\112"U.Method=p.Binary U=s:Add("\068\111\119\110")U.Name="\068\111\119\110"U.Method=p.Binary return s end local function Q()local s=P.new()local U U=s:Add("\077\111\118\101")U.Name="\077\111\118\101"U.Description="\077\111\118\101\115 \116\104\101 \099\104\097\114\097\099\116\101\114\046"U.Method=p.Vector U=s:Add("\068\105\114\101\099\116\105\111\110")U.Name="\068\105\114\101\099\116\105\111\110"U.Description="\084\117\114\110\115 \116\104\101 \099\104\097\114\097\099\116\101\114\'\115 \102\097\099\105\110\103 \100\105\114\101\099\116\105\111\110\046"U.Method=p.Vector U=s:Add("\065\098\105\108\105\116\121\049")U.Name="\065\098\105\108\105\116\121 \049"U.Description="\065\099\116\105\118\097\116\101\115 \116\104\101 \099\104\097\114\097\099\116\101\114\'\115 \102\105\114\115\116 \097\098\105\108\105\116\121\046"U.Method=p.Binary U=s:Add("\065\098\105\108\105\116\121\050")U.Name="\065\098\105\108\105\116\121 \050"U.Description="\065\099\116\105\118\097\116\101\115 \116\104\101 \099\104\097\114\097\099\116\101\114\'\115 \115\101\099\111\110\100 \097\098\105\108\105\116\121\046"U.Method=p.Binary U=s:Add("\065\098\105\108\105\116\121\051")U.Name="\065\098\105\108\105\116\121 \051"U.Description="\065\099\116\105\118\097\116\101\115 \116\104\101 \099\104\097\114\097\099\116\101\114\'\115 \116\104\105\114\100 \097\098\105\108\105\116\121\046"U.Method=p.Binary U=s:Add("\065\098\105\108\105\116\121\052")U.Name="\065\098\105\108\105\116\121 \052"U.Description="\065\099\116\105\118\097\116\101\115 \116\104\101 \099\104\097\114\097\099\116\101\114\'\115 \102\111\117\114\116\104 \097\098\105\108\105\116\121\046"U.Method=p.Binary U=s:Add("\077\101\110\117")U.Name="\071\097\109\101 \077\101\110\117"U.Description="\068\105\115\112\108\097\121\115 \116\104\101 \105\110-\103\097\109\101 \109\101\110\117\046"U.Method=p.Binary return s end local function I()local s=Q()local U local g local L s.Name="\068\101\102\097\117\108\116 \083\099\104\101\109\101"U=s.ControlSet.Move:Add()U.Type=C.Scheme U.Code=F()g=U.Code.ControlSet.Vertical:Add()g.Type=C.Scheme g.Code=d()L=g.Code.ControlSet.Up:Add()L.Type=C.Keyboard L.Code=Enum.KeyCode.W L=g.Code.ControlSet.Down:Add()L.Type=C.Keyboard L.Code=Enum.KeyCode.S g=U.Scheme.ControlSet.Horizontal:Add()g.Type=C.Scheme g.Code=d()L=g.Code.ControlSet.Up:Add()L.Type=C.Keyboard L.Code=Enum.KeyCode.A L=g.Code.ControlSet.Down:Add()L.Type=C.Keyboard L.Code=Enum.KeyCode.D U=s.ControlSet.Direction:Add()U.Type=C.MouseMovement U.Code=i.Absolute U.Offset=UDim2.new(.5,0,.5,0)U=s.ControlSet.Ability1:Add()U.Type=C.MouseButton U.Code=Enum.UserInputType.MouseButton1 U=s.ControlSet.Ability2:Add()U.Type=C.MouseButton U.Code=Enum.UserInputType.MouseButton2 U=s.ControlSet.Ability3:Add()U.Type=C.Keybaord U.Code=Enum.KeyCode.E U=s.ControlSet.Ability4:Add()U.Type=C.Keybaord U.Code=Enum.KeyCode.Q U=s.ControlSet.Menu:Add()U.Type=C.Keybaord U.Code=Enum.KeyCode.Tab return s end s.log("\082\117\110\110\105\110\103\046\046\046")L.ControlScheme=I()L:BindControls()L:SetMove("\077\111\118\101")s.log("\068\111\110\101\046")
--- Sets up the player controls.
-- Creates the default controls and binds them to the ControlManager.
--
-- @author LastTalon
-- @version 0.1.0, 2020-04-28
-- @since 0.1
--
-- @module ControlManager

local Console = require(game:GetService("ReplicatedStorage"):WaitForChild("Scripts"):WaitForChild("Console")).sourced("Control Manager")

-- Dependencies --
Console.log("Loading dependencies...")

local Player = game:GetService("Players").LocalPlayer
local PlayerScripts = Player:WaitForChild("PlayerScripts")

local Controls = require(PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
local ControlScheme = require(PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"):WaitForChild("ControlScheme"))
local ControlMethod = require(PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"):WaitForChild("ControlScheme"):WaitForChild("ControlMethod"))
local DirectionMethod = require(PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"):WaitForChild("ControlScheme"):WaitForChild("DirectionMethod"))
local InputType = require(PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"):WaitForChild("ControlScheme"):WaitForChild("InputType"))

-- Functions --
Console.log("Constructing functions...")

--- Creates a control scheme of axis controls to use as a vector control.
--
-- @return the control scheme scheme
local function vectorScheme()
	local scheme = ControlScheme.new()
	local control
	
	control = scheme:Add("Vertical")
		control.Name = "Vertical"
		control.Method = ControlMethod.Axis
	control = scheme:Add("Horizontal")
		control.Name = "Horizontal"
		control.Method = ControlMethod.Axis
	
	return scheme
end

--- Creates a control scheme of binary controls to use as an axis control.
--
-- @return the control scheme
local function axisScheme()
	local scheme = ControlScheme.new()
	local control
	
	control = scheme:Add("Up")
		control.Name = "Up"
		control.Method = ControlMethod.Binary
	control = scheme:Add("Down")
		control.Name = "Down"
		control.Method = ControlMethod.Binary
	
	return scheme
end

--- Creates the main control scheme without inputs.
--
-- @return the control scheme
local function controlScheme()
	local scheme = ControlScheme.new()
	local control
	
	control = scheme:Add("Move")
		control.Name = "Move"
		control.Description = "Moves the character."
		control.Method = ControlMethod.Vector
	control = scheme:Add("Direction")
		control.Name = "Direction"
		control.Description = "Turns the character's facing direction."
		control.Method = ControlMethod.Vector
	control = scheme:Add("Ability1")
		control.Name = "Ability 1"
		control.Description = "Activates the character's first ability."
		control.Method = ControlMethod.Binary
	control = scheme:Add("Ability2")
		control.Name = "Ability 2"
		control.Description = "Activates the character's second ability."
		control.Method = ControlMethod.Binary
	control = scheme:Add("Ability3")
		control.Name = "Ability 3"
		control.Description = "Activates the character's third ability."
		control.Method = ControlMethod.Binary
	control = scheme:Add("Ability4")
		control.Name = "Ability 4"
		control.Description = "Activates the character's fourth ability."
		control.Method = ControlMethod.Binary
	control = scheme:Add("Menu")
		control.Name = "Game Menu"
		control.Description = "Displays the in-game menu."
		control.Method = ControlMethod.Binary
	
	return scheme
end

--- Creates the main control scheme with default inputs.
--
-- @return the control scheme
local function defaultControlScheme()
	local default = controlScheme()
	local input
	local vectorInput
	local axisInput
	
	default.Name = "Default Scheme"
	input = default.ControlSet.Move:Add()
		input.Type = InputType.Scheme
		input.Code = vectorScheme()
		vectorInput = input.Code.ControlSet.Vertical:Add()
			vectorInput.Type = InputType.Scheme
			vectorInput.Code = axisScheme()
			axisInput = vectorInput.Code.ControlSet.Up:Add()
				axisInput.Type = InputType.Keyboard
				axisInput.Code = Enum.KeyCode.W
			axisInput = vectorInput.Code.ControlSet.Down:Add()
				axisInput.Type = InputType.Keyboard
				axisInput.Code = Enum.KeyCode.S
		vectorInput = input.Scheme.ControlSet.Horizontal:Add()
			vectorInput.Type = InputType.Scheme
			vectorInput.Code = axisScheme()
			axisInput = vectorInput.Code.ControlSet.Up:Add()
				axisInput.Type = InputType.Keyboard
				axisInput.Code = Enum.KeyCode.A
			axisInput = vectorInput.Code.ControlSet.Down:Add()
				axisInput.Type = InputType.Keyboard
				axisInput.Code = Enum.KeyCode.D
	input = default.ControlSet.Direction:Add()
		input.Type = InputType.MouseMovement
		input.Code = DirectionMethod.Absolute
		input.Offset = UDim2.new(0.5, 0, 0.5, 0)
	input = default.ControlSet.Ability1:Add()
		input.Type = InputType.MouseButton
		input.Code = Enum.UserInputType.MouseButton1
	input = default.ControlSet.Ability2:Add()
		input.Type = InputType.MouseButton
		input.Code = Enum.UserInputType.MouseButton2
	input = default.ControlSet.Ability3:Add()
		input.Type = InputType.Keybaord
		input.Code = Enum.KeyCode.E
	input = default.ControlSet.Ability4:Add()
		input.Type = InputType.Keybaord
		input.Code = Enum.KeyCode.Q
	input = default.ControlSet.Menu:Add()
		input.Type = InputType.Keybaord
		input.Code = Enum.KeyCode.Tab
	
	return default
end

-- Main --
Console.log("Running...")

Controls.ControlScheme = defaultControlScheme()
Controls:BindControls()
Controls:SetMove("Move")

-- End --
Console.log("Done.")
