local V={}V.__index=V function V.new(B,I)return setmetatable({_connected=true,_signal=B;_fn=I,_next=false},V)end function V.Disconnect(V)assert(V._connected,"\067\097\110\'\116 \100\105\115\099\111\110\110\101\099\116 \097 \099\111\110\110\101\099\116\105\111\110 \116\119\105\099\101\046",2)V._connected=false local B=V._signal if B._handlerListHead==V then B._handlerListHead=V._next else local I=B._handlerListHead while I and I._next~=V do I=I._next end if I then I._next=V._next end end if B.connectionsChanged then B.totalConnections-=1 B.connectionsChanged:Fire(-1)end end

local Connection = {}
Connection.__index = Connection

function Connection.new(signal, fn)
	return setmetatable({
		_connected = true,
		_signal = signal,
		_fn = fn,
		_next = false,
	}, Connection)
end

function Connection:Disconnect()
	assert(self._connected, "Can't disconnect a connection twice.", 2)
	self._connected = false

	-- Unhook the node, but DON'T clear it. That way any fire calls that are
	-- currently sitting on this node will be able to iterate forwards off of
	-- it, but any subsequent fire calls will not hit it, and it will be GCed
	-- when no more fire calls are sitting on it.
    local signal = self._signal
	if signal._handlerListHead == self then
		signal._handlerListHead = self._next
	else
		local prev = signal._handlerListHead
		while prev and prev._next ~= self do
			prev = prev._next
		end
		if prev then
			prev._next = self._next
		end
	end

    if signal.connectionsChanged then
		signal.totalConnections -= 1
        signal.connectionsChanged:Fire(-1)
    end
end
