Ejemplo n.º 1
0
    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));
        }
    }
Ejemplo n.º 2
0
    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));
    }
Ejemplo n.º 3
0
 public FalseAfterSeconds(float defaultBubbleTime)
 {
     _isValid = new Not(new TrueAfterSeconds(defaultBubbleTime));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source)
 {
     source.RegisterOnTrue(() => semaphore.Block(source));
     source.RegisterOnFalse(() => semaphore.Release(source));
 }
Ejemplo n.º 6
0
 public void ReleaseOn(IBoolStateObserver source, Func <bool> eventValidation)
 {
     source.RegisterOnTrue(new ConditionalEventListener(() => Release(source), eventValidation));
     source.RegisterOnFalse(new ConditionalEventListener(() => Block(source), eventValidation));
 }
Ejemplo n.º 7
0
 public void ReleaseOn(IBoolStateObserver source)
 {
     source.RegisterOnTrue(() => Release(source));
     source.RegisterOnFalse(() => Block(source));
 }
Ejemplo n.º 8
0
    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); });
    }
Ejemplo n.º 9
0
 public void IgnoreOn(GameObject gameObject, IBoolStateObserver additionalCondition = null)
 {
     _semaphore.ReleaseOn(gameObject, additionalCondition);
 }
Ejemplo n.º 10
0
 public void RequestOn(GameObject gameObject, IBoolStateObserver additionalCondition = null)
 {
     _semaphore.BlockOn(gameObject, additionalCondition);
 }
Ejemplo n.º 11
0
 public void IgnoreOn(IBoolStateObserver source)
 {
     _semaphore.ReleaseOn(source);
 }
Ejemplo n.º 12
0
 public void RequestOn(IBoolStateObserver source)
 {
     _semaphore.BlockOn(source);
 }
Ejemplo n.º 13
0
 public void RequestOn(IBoolStateObserver source, System.Func <bool> validation)
 {
     _semaphore.BlockOn(source, validation);
 }
Ejemplo n.º 14
0
 public Not(IBoolStateObserver variable)
 {
     _variable = variable;
     _variable.OnChange.Register(_events.Validated <bool>(EventReverter));
 }