Firstborn/Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Utilities/Observables/WhereObservable.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

49 lines
1.3 KiB
C#

using System;
namespace UnityEngine.InputSystem.Utilities
{
internal class WhereObservable<TValue> : IObservable<TValue>
{
private readonly IObservable<TValue> m_Source;
private readonly Func<TValue, bool> m_Predicate;
public WhereObservable(IObservable<TValue> source, Func<TValue, bool> predicate)
{
m_Source = source;
m_Predicate = predicate;
}
public IDisposable Subscribe(IObserver<TValue> observer)
{
return m_Source.Subscribe(new Where(this, observer));
}
private class Where : IObserver<TValue>
{
private WhereObservable<TValue> m_Observable;
private readonly IObserver<TValue> m_Observer;
public Where(WhereObservable<TValue> observable, IObserver<TValue> observer)
{
m_Observable = observable;
m_Observer = observer;
}
public void OnCompleted()
{
}
public void OnError(Exception error)
{
Debug.LogException(error);
}
public void OnNext(TValue evt)
{
if (m_Observable.m_Predicate(evt))
m_Observer.OnNext(evt);
}
}
}
}