예제 #1
0
    /// <summary>
    /// Notifies the provider that an observer is to receive notifications.
    /// </summary>
    /// <param name="observer">The object that is to receive notifications.</param>
    /// <returns>
    /// A reference to an interface that allows observers to stop receiving notifications before
    /// the provider has finished sending them.
    /// </returns>
    public IDisposable Subscribe(IObserver <T> observer)
    {
        if (IsDisposed)
        {
            observer.OnCompleted();
            return(InternalDisposable.Empty);
        }

        if (IsRaiseLatestValueOnSubscribe)
        {
            observer.OnNext(_latestValue);
        }

        // subscribe node, node as subscription.
        var next = new ObserverNode <T>(this, observer);

        if (_root == null)
        {
            _root = _last = next;
        }
        else
        {
            _last !.Next  = next;
            next.Previous = _last;
            _last         = next;
        }

        return(next);
    }
예제 #2
0
    /// <summary>
    /// Unsubscribe all subscription.
    /// </summary>
    public void Dispose()
    {
        if (IsDisposed)
        {
            return;
        }

        var node = _root;

        _root = _last = null;
        _mode = (ReactivePropertyMode)IsDisposedFlagNumber;

        while (node != null)
        {
            node.OnCompleted();
            node = node.Next;
        }

        ValidationTrigger.Dispose();
        SourceDisposable.Dispose();
        ValidateNotifyErrorSubscription.Dispose();
        if (ErrorsTrigger.IsValueCreated)
        {
            ErrorsTrigger.Value.OnCompleted();
            ErrorsTrigger.Value.Dispose();
        }
    }
예제 #3
0
 public void SendSignal(ObserverNode on1, ObserverNode on2, Vector2 angle)
 {
     Debug.Log("SignalSending");
     signal.SetActive(true);
     signal.transform.position = on1.transform.position;
     signal.GetComponent <Signalmovement>().velocity = angle * signalSpeed;
     on2.GetComponent <CircleCollider2D>().enabled   = true;
 }
예제 #4
0
    void CallObserverAction(ObserverNode on1, ObserverNode on2)
    {
        Debug.Log("Nodes/Observers called");
        Vector2 signalangle = new Vector2(on2.transform.position.x - on1.transform.position.x, on2.transform.position.y - on1.transform.position.y).normalized;

        Debug.Log("signal Angle Set");
        Mediator.Instance.SendSignal(on1, on2, signalangle);
    }
예제 #5
0
        private void createObserverLink(ObserverNode observerNode, MoleculeNode moleculeNode)
        {
            var observerLink = new ObserverLink();

            observerLink.Initialize(observerNode, moleculeNode);
            observerLink.SetColorFrom(DiagramOptions.DiagramColors);
            observerLink.IsVisible = DiagramOptions.ObserverLinksVisible;
        }
예제 #6
0
 /// <summary>
 /// Create json string from ObserverNode.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public static string ToJson(this ObserverNode node)
 {
     return(Object(null, true,
                   Field("type", node.NodeName),
                   Field("ID", node.Id),
                   Field("functionID", node.FuncIndex),
                   //Field("functionName", node.FuncNames[node.FuncIndex]),
                   Field("functionName", node.ConditionGroup != ConditionGroup.Time ? node.FunctionName : node.FormattedTime),
                   Field("conditionGroup", node.ConditionGroup),
                   Field("minTime", node.MinTime),
                   Field("maxTime", node.MaxTime),
                   node.Rect.ToJson()));
 }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log(" Space Clicked");

            ObserverNode on1 = _observers[Random.Range(0, 4)];
            ObserverNode on2 = _observers[Random.Range(0, 4)];
            while (on1 == on2)
            {
                on2 = _observers[Random.Range(0, 4)];
            }
            CallObserverAction(on1, on2);
        }
    }
예제 #8
0
        /// <summary>
        /// Create ObserverNode from json string.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="jObj"></param>
        /// <returns></returns>
        private static Node Serialize(this ObserverNode node, JsonObject jObj)
        {
            node.NodeName = jObj["type"].String;
            node.Id       = jObj["ID"].String;
            //node.FuncIndex = jObj["functionID"].Int;
            node.ConditionGroup = jObj["conditionGroup"].ConditionGroup;
            node.FuncNames      = AgentFunctions.GetConditionStrings(node.ConditionGroup);
            try
            { node.FunctionName = jObj["functionName"].String; }
            catch (Exception) { /*Debug.Log("Your behaviour has a deprecated format");*/ }

            try
            {
                node.MinTime = jObj["minTime"].Float;
                node.MaxTime = jObj["maxTime"].Float;
            }
            catch (Exception) { /*Debug.Log("Your behaviour has a deprecated format");*/ }

            var sortedFunctions = node.FuncNames;

            System.Array.Sort(sortedFunctions, StringComparer.InvariantCulture);

            if (node.FunctionName != null)
            {
                for (var i = 0; i < node.FuncNames.Length; i++)
                {
                    if (node.FuncNames[i] == node.FunctionName)
                    {
                        node.FuncIndex = i;
                    }
                }
            }

            if (node.FuncIndex == -1)
            {
                node.FuncIndex = jObj["functionID"].Int;
            }

            var x = jObj["rect"]["posX"].Float;
            var y = jObj["rect"]["posY"].Float;
            var w = jObj["rect"]["width"].Float;
            var h = jObj["rect"]["height"].Float;

            node.Rect = new Rect(x, y, w, h);

            return(node);
        }
예제 #9
0
    /// <summary>
    /// Performs application-defined tasks associated with freeing, releasing, or resetting
    /// unmanaged resources.
    /// </summary>
    public void Dispose()
    {
        if (IsDisposed)
        {
            return;
        }

        var node = _root;

        _root = _last = null;
        _mode = (ReactivePropertyMode)IsDisposedFlagNumber;

        while (node != null)
        {
            node.OnCompleted();
            node = node.Next;
        }
    }
예제 #10
0
 void IObserverLinkedList <TState> .UnsubscribeNode(ObserverNode <TState> node)
 {
     if (node == root)
     {
         root = node.Next;
     }
     if (node == last)
     {
         last = node.Previous;
     }
     if (node.Previous != null)
     {
         node.Previous.Next = node.Next;
     }
     if (node.Next != null)
     {
         node.Next.Previous = node.Previous;
     }
 }
예제 #11
0
    void IObserverLinkedList <T> .UnsubscribeNode(ObserverNode <T> node)
    {
        if (node == _root)
        {
            _root = node.Next;
        }
        if (node == _last)
        {
            _last = node.Previous;
        }

        if (node.Previous != null)
        {
            node.Previous.Next = node.Next;
        }
        if (node.Next != null)
        {
            node.Next.Previous = node.Previous;
        }
    }
예제 #12
0
파일: Store.cs 프로젝트: Dekorg/ReduxSharp
        /// <summary>
        /// Notifies the provider that an observer is to receive notifications.
        /// </summary>
        /// <param name="observer">
        /// The object that is to receive notifications.
        /// </param>
        /// <returns>
        /// A reference to an interface that allows observers to stop receiving notifications
        /// before the provider has finished sending them.
        /// </returns>
        public IDisposable Subscribe(IObserver <TState> observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer));
            }

            var next = new ObserverNode <TState>(this, observer);

            if (root == null)
            {
                root = last = next;
            }
            else
            {
                last.Next     = next;
                next.Previous = last;
                last          = next;
            }
            return(next);
        }
예제 #13
0
				public ObserverEntry(ObserverNode _enclosing, android.database.IContentObserver o
					, bool n, object observersLock, int _uid, int _pid)
				{
					throw new System.NotImplementedException();
				}
예제 #14
0
 public ObserverEntry(ObserverNode _enclosing, android.database.IContentObserver o
                      , bool n, object observersLock, int _uid, int _pid)
 {
     throw new System.NotImplementedException();
 }
예제 #15
0
 void RemoveObserver(ObserverNode on)
 {
     _observers.Remove(on);
 }