public void ChangeSource(IBoolStateObserver newSource) { if (newSource == _currentSource) { return; } var oldValue = Value; _events.Void(); _currentSource = newSource; var newValue = Value; if (oldValue != newValue) { _onChange.Trigger(newValue); if (newValue) { _onTrueState.Trigger(); } else { _onFalseState.Trigger(); } } if (_currentSource != null) { _currentSource.OnChange.Register(_events.Validated <bool>(_onChange)); _currentSource.OnTrueState.Register(_events.Validated(_onTrueState)); _currentSource.OnFalseState.Register(_events.Validated(_onFalseState)); } }
public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, IEventValidator eventValidation) { Action releaseAction = () => semaphore.Release(source); source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation.CurrentValidationCheck)); source.RegisterOnFalse(new ConditionalEventListener(releaseAction, eventValidation.CurrentValidationCheck)); eventValidation.OnVoid.Register(new CallOnce(releaseAction)); }
public FalseAfterSeconds(float defaultBubbleTime) { _isValid = new Not(new TrueAfterSeconds(defaultBubbleTime)); }
public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, Func <bool> eventValidation) { source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation)); source.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Release(source), eventValidation)); }
public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source) { source.RegisterOnTrue(() => semaphore.Block(source)); source.RegisterOnFalse(() => semaphore.Release(source)); }
public void ReleaseOn(IBoolStateObserver source, Func <bool> eventValidation) { source.RegisterOnTrue(new ConditionalEventListener(() => Release(source), eventValidation)); source.RegisterOnFalse(new ConditionalEventListener(() => Block(source), eventValidation)); }
public void ReleaseOn(IBoolStateObserver source) { source.RegisterOnTrue(() => Release(source)); source.RegisterOnFalse(() => Block(source)); }
public static void ReleaseOn(this ISemaphoreInterection semaphore, UnityEngine.GameObject go, IBoolStateObserver additionalCondition = null) { var goEvents = go.EventRelay(); bool isValid = true; var name = go.HierarchyNameOrNull(); IBoolStateObserver condition = new BoolStateOperations.Not(goEvents.IsActive); if (additionalCondition != null) { condition = new BoolStateOperations.And(condition, additionalCondition); } Func <bool> eventValidation = () => isValid; condition.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Release(condition), eventValidation)); condition.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Block(condition), eventValidation)); goEvents.OnDestroy.Register(() => { isValid = false; semaphore.Release(condition); }); }
public void IgnoreOn(GameObject gameObject, IBoolStateObserver additionalCondition = null) { _semaphore.ReleaseOn(gameObject, additionalCondition); }
public void RequestOn(GameObject gameObject, IBoolStateObserver additionalCondition = null) { _semaphore.BlockOn(gameObject, additionalCondition); }
public void IgnoreOn(IBoolStateObserver source) { _semaphore.ReleaseOn(source); }
public void RequestOn(IBoolStateObserver source) { _semaphore.BlockOn(source); }
public void RequestOn(IBoolStateObserver source, System.Func <bool> validation) { _semaphore.BlockOn(source, validation); }
public Not(IBoolStateObserver variable) { _variable = variable; _variable.OnChange.Register(_events.Validated <bool>(EventReverter)); }