Exemple #1
0
        private void RemoveNode(ChainNode node, bool recurse, bool isTransfer = false)
        {
            if (!isTransfer)
            {
                node.RequestUntargeting();
            }

            UnbindFromNode(node);

            if (recurse)
            {
                foreach (var target in node.Router.UniqueTargets)
                {
                    RemoveNode(target, true, isTransfer);
                }
            }

            if (!isTransfer)
            {
                node.Router.UntargetAllTargets();
            }

            Nodes.Remove(node);

            UpdateHasError();

            NodeRemoved(node, isTransfer);
        }
Exemple #2
0
        private void HandleStateTargetAdded(SelectionState stateWithNewTarget, ChainNode newTarget, List <UndoItem> returnUndos)
        {
            // Cache this before the next step...
            bool isNewTargetForThisRouter = SelectionStates.SelectMany(s => s).Count(t => t == newTarget) == 1;

            // If a state adds a new target, all the other states in the router which are from a different group or no group, which contain the new target, remove that target.
            if (returnUndos != null)
            {
                returnUndos.AddRange(SelectionStates.Where(s => s != stateWithNewTarget && (s.GroupId != stateWithNewTarget.GroupId || s.GroupId == "") && s.Contains(newTarget))
                                     .Select(s => s.RemoveTarget(newTarget, true)));
            }
            else
            {
                foreach (var state in SelectionStates.Where(s => s != stateWithNewTarget && (s.GroupId != stateWithNewTarget.GroupId || s.GroupId == "") && s.Contains(newTarget)))
                {
                    state.RemoveTarget(newTarget, false);
                }
            }

            if (isNewTargetForThisRouter)
            {
                // This won't target this router, we're not listening to it yet...
                newTarget.RequestUntargeting();

                // Bind to this event AFTER requesting the untargeting...
                newTarget.UntargetRequested += HandleTargetUntargetRequested;

                UniqueTargetAdded(newTarget);

                if (NodeParents.ContainsKey(newTarget))
                {
                    Debug.LogWarning("Interesting... adding entry to NodeParents despite entry existing.  Clearing... ");
                    NodeParents.Remove(newTarget);
                }
                NodeParents[newTarget] = new NodeSelectionStatesPair()
                {
                    Node = Owner
                };
                NodeParents[newTarget].States.Add(stateWithNewTarget);
            }
            else
            {
                if (!NodeParents.ContainsKey(newTarget))
                {
                    Debug.LogError("Uhm... modifying entry in NodeParents despite entry being missing.  Correcting... ");
                    NodeParents[newTarget] = new NodeSelectionStatesPair()
                    {
                        Node = Owner
                    };
                }
                NodeParents[newTarget].States.Add(stateWithNewTarget);
            }

            if (SelectionStates.SelectMany(s => s).Count(t => t == newTarget) == 1)
            {
                OutputSchemaRefreshRequested();
            }
        }