A quick (one evening) port of my old Duck Hunt VR game to the Oculus (a.k.a. Meta) Quest 2. Mainly to check what kind of performance I can expect from this device.
The build is still a little rough especially on the light and shading side. Also the mapping of the Zapper (gun) to the Quest 2 controllers needs some polishing, as the trigger is off-center on the physical controllers.
It’s not super useful in practice, but a nice little exercise that combines two cool C# features into a fun asynchronous “magic” trick.
privateconstint INFINITE = -1;
publicstaticasyncTask MutableWhenAll(thisObservableCollection<Task> collection)
await MutableWhenSomething(collection, Task.WhenAll);
publicstaticasyncTask MutableWhenAny(thisObservableCollection<Task> collection)
await MutableWhenSomething(collection, Task.WhenAny);
privatestaticasyncTask MutableWhenSomething(thisObservableCollection<Task> collection, Func<IEnumerable<Task>, Task> whenSomething)
Task waitAllTask = null;
Task helperTask = null;
bool isCollectionChanged = false;
//Cancellation on collection changed eventvar cts = newCancellationTokenSource();
var cancelActionHandler = (sender, arg) => cts.Cancel(false);
collection.CollectionChanged += cancelActionHandler;
waitAllTask = whenSomething(collection);
//Wait on current collection or collection changed eventtry
helperTask = Task.Delay(INFINITE, cts.Token);
isCollectionChanged = cts.IsCancellationRequested;
collection.CollectionChanged -= cancelActionHandler;
//Return the WaitAll on collection resultsawait waitAllTask;
A simple example application that demonstrates the MutableWhenAll extension on an observable collection of tasks. The longest running task is added to the observable collection after MutableWhenAll is called, but the MutableWhenAll will complete only when all tasks (included this longest running task) are completed.