Last active
January 15, 2022 18:02
-
-
Save ManickYoj/38a6ee19e204a40bc6cc95a8610966c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Registry : MonoBehaviour { | |
// ... | |
public static void GetNewReceiver(Transmitter transmitter) { | |
// If the controller is already controlling a receiver, we'll look for the next | |
// free receiver starting above that index. Otherwise, we'll start the search | |
// from receiver 0 | |
int transmitterIdx = Array.IndexOf(_instance.transmitterAssignments, transmitter); | |
int nextFreeIndex = NextFreeRecvIdx(transmitterIdx); | |
// If there is no free receiver, abort. | |
if (nextFreeIndex == -1) return; | |
RevokeReceiver(transmitter, transmitterIdx); | |
AssignReceiver(transmitter, nextFreeIndex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment