Exemplo n.º 1
0
        protected static void InnerLink(VFXContext from, VFXContext to, int fromIndex, int toIndex, bool notify = true)
        {
            if (!CanLink(from, to, fromIndex, toIndex))
            {
                throw new ArgumentException(string.Format("Cannot link contexts {0} and {1}", from, to));
            }

            // Handle constraints on connections
            foreach (var link in from.m_OutputFlowSlot[fromIndex].link.ToArray())
            {
                if (!link.context.CanLinkFromMany() ||
                    !CanMixingFrom(from.contextType, link.context.contextType, to.contextType))
                {
                    if (link.context.inputFlowCount > toIndex) //Special case from SubGraph, not sure how this test could be false
                    {
                        InnerUnlink(from, link.context, fromIndex, toIndex, notify);
                    }
                }
            }

            foreach (var link in to.m_InputFlowSlot[toIndex].link.ToArray())
            {
                if (!link.context.CanLinkToMany() ||
                    !CanMixingTo(link.context.contextType, to.contextType, from.contextType))
                {
                    InnerUnlink(link.context, to, fromIndex, toIndex, notify);
                }
            }

            if ((from.ownedType & to.ownedType) == to.ownedType)
            {
                to.InnerSetData(from.GetData(), false);
            }

            from.m_OutputFlowSlot[fromIndex].link.Add(new VFXContextLink()
            {
                context = to, slotIndex = toIndex
            });
            to.m_InputFlowSlot[toIndex].link.Add(new VFXContextLink()
            {
                context = from, slotIndex = fromIndex
            });

            if (notify)
            {
                from.Invalidate(InvalidationCause.kConnectionChanged);
                to.Invalidate(InvalidationCause.kConnectionChanged);
            }
        }
Exemplo n.º 2
0
        private static void InnerLink(VFXContext from, VFXContext to, int fromIndex, int toIndex, bool notify = true)
        {
            if (!CanLink(from, to, fromIndex, toIndex))
            {
                throw new ArgumentException(string.Format("Cannot link contexts {0} and {1}", from, to));
            }

            // Handle constraints on connections
            foreach (var link in from.m_OutputFlowSlot[fromIndex].link.ToArray())
            {
                if (!link.context.CanLinkFromMany() || (IsExclusiveLink(link.context.contextType, to.contextType) && from.contextType == link.context.contextType))
                {
                    if (link.context.inputFlowCount > toIndex)
                    {
                        InnerUnlink(from, link.context, fromIndex, toIndex, notify);
                    }
                }
            }

            foreach (var link in to.m_InputFlowSlot[toIndex].link.ToArray())
            {
                if (!link.context.CanLinkToMany() || IsExclusiveLink(link.context.contextType, from.contextType))
                {
                    InnerUnlink(link.context, to, fromIndex, toIndex, notify);
                }
            }

            if ((from.ownedType & to.ownedType) == to.ownedType)
            {
                to.InnerSetData(from.GetData(), false);
            }

            from.m_OutputFlowSlot[fromIndex].link.Add(new VFXContextLink()
            {
                context = to, slotIndex = toIndex
            });
            to.m_InputFlowSlot[toIndex].link.Add(new VFXContextLink()
            {
                context = from, slotIndex = fromIndex
            });

            if (notify)
            {
                // TODO Might need a specific event ?
                from.Invalidate(InvalidationCause.kStructureChanged);
                to.Invalidate(InvalidationCause.kStructureChanged);
            }
        }
Exemplo n.º 3
0
        private static void InnerUnlink(VFXContext from, VFXContext to, int fromIndex = 0, int toIndex = 0, bool notify = true)
        {
            if (from.GetData() == to.GetData() && from.GetData() != null)
            {
                to.SetDefaultData(false);
            }

            int count = from.m_OutputFlowSlot[fromIndex].link.RemoveAll(o => o.context == to && o.slotIndex == toIndex);

            count += to.m_InputFlowSlot[toIndex].link.RemoveAll(o => o.context == from && o.slotIndex == fromIndex);

            if (count > 0 && notify)
            {
                from.Invalidate(InvalidationCause.kConnectionChanged);
                to.Invalidate(InvalidationCause.kConnectionChanged);
            }
        }
Exemplo n.º 4
0
        private static void InnerUnlink(VFXContext from, VFXContext to, int fromIndex = 0, int toIndex = 0, bool notify = true)
        {
            if (from.GetData() == to.GetData() && from.GetData() != null)
            {
                to.SetDefaultData(false);
            }

            from.m_OutputFlowSlot[fromIndex].link.RemoveAll(o => o.context == to && o.slotIndex == toIndex);
            to.m_InputFlowSlot[toIndex].link.RemoveAll(o => o.context == from && o.slotIndex == fromIndex);

            // TODO Might need a specific event ?
            if (notify)
            {
                from.Invalidate(InvalidationCause.kStructureChanged);
                to.Invalidate(InvalidationCause.kStructureChanged);
            }
        }