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("\065\120\105\115 \077\111\110\105\116\111\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=require(script.Parent)local g=require(script.Parent:WaitForChild("\066\105\110\097\114\121\077\111\110\105\116\111\114"))local L=require(script.Parent.Parent:WaitForChild("\073\110\112\117\116\084\121\112\101"))local P=require(script.Parent.Parent:WaitForChild("\065\120\105\115\068\105\114\101\099\116\105\111\110"))s.log("\073\110\105\116\105\097\108\105\122\105\110\103 \099\111\110\115\116\097\110\116\115\046\046\046")local p={[P.Up]=1.0,[P.Down]=-1.0}s.log("\073\110\105\116\105\097\108\105\122\105\110\103 \118\097\114\105\097\098\108\101\115\046\046\046")local i=U.new()s.log("\067\111\110\115\116\114\117\099\116\105\110\103 \111\098\106\101\099\116\115\046\046\046")i.__index=i function i.new()local s=setmetatable({},i)return s end function i.transformValue(g,s,U)local i=s.Type local C=s.Offset or 0 if i==L.None or i==L.Keyboard or i==L.MouseButton or i==L.GamepadButton then return(U and 1 or 0)+C,1 elseif i==L.MouseMovement or i==L.GamepadDirection then if s.Code==Enum.KeyCode.ButtonL2 or s.Code==Enum.KeyCode.ButtonR2 then return U.Z+C,1 else return U.Y+C,1 end elseif i==L.Scheme then local U=0 for g,L in pairs(P)do local P=s.Code[g]U=U+(P:Update()and p[L]or 0)end return U+C,1 end return 0,1 end function i.addValue(g,s,U)return s+U end function i.scaleValue(g,s,U)return s/U end function i.nullValue(s)return 0 end function i.processEntry(U,s)if s.Type==L.Scheme then local U=s.Code s.Code={}for L,P in pairs(P)do if U.ControlSet[L]~=nil then local P=g.new()P:Bind(U.ControlSet[L])s.Code[L]=P end end end end function i.clean(s) end s.log("\068\111\110\101\046")return i.new()
--- A Monitor with an axis value.
-- Provides a floating point value for the Control being activated. This can be
-- thought of as a 1 dimensional vector.
--
-- @author LastTalon
-- @version 0.1.1, 2020-10-01
-- @since 0.1
--
-- @module AxisMonitor

local Console = require(game:GetService("ReplicatedStorage"):WaitForChild("Scripts"):WaitForChild("Console")).sourced("Axis Monitor")

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

local Monitor = require(script.Parent)
local BinaryMonitor = require(script.Parent:WaitForChild("BinaryMonitor"))
local InputType = require(script.Parent.Parent:WaitForChild("InputType"))
local Direction = require(script.Parent.Parent:WaitForChild("AxisDirection"))

-- Constants --
Console.log("Initializing constants...")

-- Direction floats
local directional_value = {
	[Direction.Up] = 1.0,
	[Direction.Down] = -1.0
}

-- Variables --
Console.log("Initializing variables...")

local AxisMonitor = Monitor.new()

-- Local Objects --
Console.log("Constructing objects...")

AxisMonitor.__index = AxisMonitor

--- The default constructor.
--
-- @return the new AxisMonitor
function AxisMonitor.new()
	local self = setmetatable({}, AxisMonitor)
	return self
end

--- Transforms the value to a floating point number.
-- For most binary InputTypes true is transformed to 1 and false transformed to
-- 0. For vector InputTypes the vector is transformed to a single axis of the
-- vector. For scheme InputTypes the scheme's Monitor is updated and the value
-- retrieved. An offset is applied to all InputTypes and all InputTypes get an
-- equal scale.
--
-- @param input the input that produced the value being transformed
-- @param value the value being transformed
-- @return the transformed value. A floating point number.
-- @return the scaling factor. Always 1, all scaling is even.
function AxisMonitor:transformValue(input, value)
	local type = input.Type
	local offset = (input.Offset or 0)
	if type == InputType.None or type == InputType.Keyboard or type == InputType.MouseButton or type == InputType.GamepadButton then
		return ((value and 1) or 0) + offset, 1
	elseif type == InputType.MouseMovement or type == InputType.GamepadDirection then
		if input.Code == Enum.KeyCode.ButtonL2 or input.Code == Enum.KeyCode.ButtonR2 then
			return value.Z + offset, 1
		else
			return value.Y + offset, 1
		end
	elseif type == InputType.Scheme then
		local schemeValue = 0
		for id, enum in pairs(Direction) do
			local monitor = input.Code[id]
			schemeValue = schemeValue + ((monitor:Update() and directional_value[enum]) or 0)
		end
		return schemeValue + offset, 1
	end
	return 0, 1
end

--- Adds two axis values together.
-- Combines the values using floating point addition.
--
-- @param lhs the left hand side operand of the add operation
-- @param rhs the right hand side operand of the add operation
-- @return the added value.
function AxisMonitor:addValue(original, new)
	return original + new
end

--- Scales an Input's value by a scaling factor.
-- Scales using floating point division.
--
-- @param value the value to be scaled
-- @param scale the scaling factor
-- @return the scaled value
function AxisMonitor:scaleValue(value, scale)
	return value / scale
end

--- Gets the default value of 0 for a AxisMonitor.
--
-- @return the default value. Always 0.
function AxisMonitor:nullValue()
	return 0
end

--- Creates a Monitor for any entries with binary schemes.
--
-- @param entry the entry to process
function AxisMonitor:processEntry(entry)
	if entry.Type == InputType.Scheme then
		local scheme = entry.Code
		entry.Code = {}
		for id, _ in pairs(Direction) do
			if scheme.ControlSet[id] ~= nil then
				local monitor = BinaryMonitor.new()
				monitor:Bind(scheme.ControlSet[id])
				entry.Code[id] = monitor
			end
		end
	end
end

--- Does no cleaning.
-- AxisMonitor keeps no special state, so no special cleaning is needed.
function AxisMonitor:clean()
end

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

return AxisMonitor.new()
