Exemple #1
0
        private void HandleStateTargetRemoved(SelectionState state, ChainNode target)
        {
            var isUniqueTarget = SelectionStates.SelectMany(s => s).Count(t => t == target) == 0;

            if (isUniqueTarget)
            {
                target.UntargetRequested -= HandleTargetUntargetRequested;

                target.Schema = MutableObject.Empty;

                UniqueTargetRemoved(target);

                if (!NodeParents.ContainsKey(target))
                {
                    Debug.LogWarning("Odd... removing entry from NodeParents despite entry being missing.  Kay... ");
                }
                else
                {
                    NodeParents.Remove(target);
                }
            }
            else
            {
                if (!NodeParents.ContainsKey(target))
                {
                    Debug.LogError("Crap... modifying entry in NodeParents despite entry being missing.  That's a problem... ");
                }
                else
                {
                    NodeParents[target].States.Remove(state);
                }
            }
        }
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();
            }
        }