Skip to content

Instantly share code, notes, and snippets.

@ManickYoj
Last active January 15, 2022 18:02
Show Gist options
  • Save ManickYoj/38a6ee19e204a40bc6cc95a8610966c1 to your computer and use it in GitHub Desktop.
Save ManickYoj/38a6ee19e204a40bc6cc95a8610966c1 to your computer and use it in GitHub Desktop.
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