-- Constructor/Destructor

function WaypointPath.new(player, startPos, endPos)
	local self = setmetatable({}, WaypointPath)

	-- Player variables
	self.player = player
	self.character = player.Character or player.CharacterAdded:wait()
	self.humanoid = self.character:WaitForChild("Humanoid")
	self.humanoidRoot = self.character.HumanoidRootPart
	
	-- Create the path object
	self.path = PathfindingService:CreatePath()
	
	-- Compute the path
	self.path:ComputeAsync(startPos, endPos)
	
	-- Get the path waypoints
	self.waypoints = self.path:GetWaypoints()
	
	self.currentIndex = 2
	self.count = 1
	
	self._WaypointReachedEvent = Instance.new("BindableEvent")
	self.WaypointReached = self._WaypointReachedEvent.Event
	
	self._NodeReachedEvent = Instance.new("BindableEvent")
	self.NodeReached = self._NodeReachedEvent.Event
	
	self._FinishedMovingEvent = Instance.new("BindableEvent")
	self.FinishedMoving = self._FinishedMovingEvent.Event
	
	return self
end

function WaypointPath:Destroy()
	self._WaypointReachedEvent:Destroy()
	
	self._WaypointReachedEvent:Destroy()
	self._NodeReachedEvent:Destroy()
	self._FinishedMovingEvent:Destroy()
end
