jaipack17 / Nature2D

A 2D physics engine for Roblox. Create versatile physics simulations and mechanics with GUIs!
https://jaipack17.github.io/Nature2D/
MIT License
147 stars 8 forks source link

Made Connection property `.Connected` public & other Signal changes #18

Closed lucasmz-dev closed 2 years ago

lucasmz-dev commented 2 years ago

This PR has made these changes:

The :DisconnectAll change means that the signal class is more consistent with BindableEvents and RBXScriptSignal behaviour as a whole.

For example, this piece of code changes what connections are fired depending on whether you're using my modified code or not. The modified version is consistent with what happens with a normal RBXScriptSignal.

local Event = Signal.new()

Event:Connect(function()
    -- Fired second

    print("This will not fire with the new changes")
end)

Event:Connect(function()
    -- Fired first

    Event:DisconnectAll() -- Same as :Destroy on instances
    -- On RBXScriptSignals, and on the modified version, these connections are tagged as not connected, once :Fire goes over the next node (next connection), it will see that it's not connected, and not run it.
end)

Event:Fire()

Note: This PR has not been tested.

jaipack17 commented 2 years ago

Looks great to me! Will merge this before the next release. Thanks for the contribution!