local TS = require(
	game:GetService("ReplicatedStorage")
		:WaitForChild("RobloxTS")
		:WaitForChild("Include")
		:WaitForChild("RuntimeLib")
);
local _exports = {};
local RunService = require(TS.getModule("rbx-services", script.Parent)).RunService;
local MovementController;
do
	MovementController = {};
	MovementController.__index = {
		bounce = function(self, height)
			if self.humanoid then
				self.humanoid.JumpPower = height;
				self.humanoid:ChangeState(Enum.HumanoidStateType.Jumping);
			end;
		end;
		move = function(self, position)
			if self.humanoid then
				self.humanoid:Move(position);
			end;
		end;
		isMoving = function(self)
			if self.humanoid then
				return (self.humanoid.MoveDirection ~= Vector3.new());
			end;
		end;
		isGrounded = function(self)
			if self.humanoid then
				return (self.humanoid.FloorMaterial ~= Enum.Material.Air);
			end;
		end;
		humanoidStateChanged = function(self, event)
			if self.humanoid then
				return self.humanoid.StateChanged:Connect(function(humanoidState)
					event(humanoidState);
				end);
			else
				return Instance.new("BindableEvent").Event:Connect(function()
				end);
			end;
		end;
		landed = function(self, event)
			return self:humanoidStateChanged(function(humanoidState)
				if humanoidState == Enum.HumanoidStateType.Landed then
					event();
				end;
			end);
		end;
	};
	MovementController.new = function(...)
		return MovementController.constructor(setmetatable({}, MovementController), ...);
	end;
	MovementController.constructor = function(self, characterController)
		self.velocity = Vector3.new();
		self.mobile = true;
		self.characterController = characterController;
		local character = characterController.character;
		local primaryPart = character.PrimaryPart;
		self.primaryPart = primaryPart;
		self.humanoid = character:FindFirstChildWhichIsA("Humanoid");
		local last = tick();
		RunService.Stepped:Connect(function()
			local current = tick();
			local delta = current - last;
			last = current;
			if delta <= 1 and self.mobile then
				local velocityCframe = (CFrame.new((primaryPart.Position + ((self.velocity * (delta))))) * ((primaryPart.CFrame - (primaryPart.Position))));
				character:SetPrimaryPartCFrame(velocityCframe);
			end;
		end);
		return self;
	end;
end;
_exports.MovementController = MovementController;
return _exports;
