Example #1
0
        public override void UnlinkFrom(CGModuleSlot outputSlot)
        {
            if (HasLinkTo(outputSlot))
            {
                var l1 = Module.GetInputLink(this, (CGModuleOutputSlot)outputSlot);
                Module.InputLinks.Remove(l1);
                var l2 = outputSlot.Module.GetOutputLink((CGModuleOutputSlot)outputSlot, this);
                outputSlot.Module.OutputLinks.Remove(l2);

                LinkedSlots.Remove(outputSlot);
                outputSlot.LinkedSlots.Remove(this);

                base.UnlinkFrom(outputSlot);
            }
        }
Example #2
0
        private VFXSlot InternalSanitize(int version)
        {
            // Remove invalid links (without owners)
            if (owner == null)
            {
                UnlinkAll();
            }

            foreach (var link in LinkedSlots.ToArray())
            {
                if (link.owner == null || ((VFXModel)(link.owner)).GetGraph() != ((VFXModel)owner).GetGraph())
                {
                    Unlink(link);
                }
            }

            // Here we check if hierarchy of type match with slot hierarchy
            var  subProperties = property.SubProperties().ToList();
            bool hierarchySane = subProperties.Count == GetNbChildren();

            if (hierarchySane)
            {
                for (int i = 0; i < GetNbChildren(); ++i)
                {
                    if (subProperties[i].type != this[i].property.type)
                    {
                        hierarchySane = false;
                        break;
                    }
                    else
                    {
                        // Just ensure potential renaming of property is taken into account
                        this[i].m_Property = subProperties[i];
                    }
                }
            }

            if (!hierarchySane)
            {
                Debug.LogWarningFormat("Slot {0} holding {1} didnt match the type layout. It is recreated and all links are lost.", property.name, property.type);
                return(Recreate());
            }
            return(this);
        }
Example #3
0
        public override void LinkTo(CGModuleSlot outputSlot)
        {
            if (!HasLinkTo(outputSlot))
            {
                Module.InputLinks.Add(new CGModuleLink(this, outputSlot));
                outputSlot.Module.OutputLinks.Add(new CGModuleLink(outputSlot, this));
                if (!LinkedSlots.Contains(outputSlot))
                {
                    LinkedSlots.Add(outputSlot);
                }

                if (!outputSlot.LinkedSlots.Contains(this))
                {
                    outputSlot.LinkedSlots.Add(this);
                }

                base.LinkTo(outputSlot);
            }
        }
Example #4
0
        public override void LinkTo(CGModuleSlot inputSlot)
        {
            if (!HasLinkTo(inputSlot))
            {
                if (!inputSlot.Info.Array && inputSlot.IsLinked)
                {
                    inputSlot.UnlinkAll();
                }
                Module.OutputLinks.Add(new CGModuleLink(this, inputSlot));
                inputSlot.Module.InputLinks.Add(new CGModuleLink(inputSlot, this));
                if (!LinkedSlots.Contains(inputSlot))
                {
                    LinkedSlots.Add(inputSlot);
                }
                if (!inputSlot.LinkedSlots.Contains(this))
                {
                    inputSlot.LinkedSlots.Add(this);
                }

                base.LinkTo(inputSlot);
            }
        }
Example #5
0
        private VFXSlot InternalSanitize(int version)
        {
            // Remove invalid links (without owners)
            if (owner == null)
            {
                UnlinkAll();
            }

            foreach (var link in LinkedSlots.ToArray())
            {
                if (link.owner == null || ((VFXModel)(link.owner)).GetGraph() != ((VFXModel)owner).GetGraph())
                {
                    Unlink(link);
                }
            }

            // Here we check if hierarchy of type match with slot hierarchy
            var  subProperties = property.SubProperties().ToList();
            bool hierarchySane = subProperties.Count == GetNbChildren();

            if (hierarchySane)
            {
                for (int i = 0; i < GetNbChildren(); ++i)
                {
                    if (subProperties[i].type != this[i].property.type)
                    {
                        hierarchySane = false;
                        break;
                    }
                    else
                    {
                        // Just ensure potential renaming of property is taken into account
                        this[i].m_Property = subProperties[i];
                    }
                }
            }

            if (!hierarchySane)
            {
                Debug.LogWarningFormat("Slot {0} holding {1} didnt match the type layout. It is recreated and all links are lost.", property.name, property.type);

                // Try to retrieve the value
                object previousValue = null;
                try
                {
                    previousValue = this.value;
                }
                catch (Exception e)
                {
                    Debug.LogWarningFormat("Exception while trying to retrieve value: {0}: {1}", e, e.StackTrace);
                }

                // Recreate the slot
                var newSlot = Create(property, direction, previousValue);
                if (IsMasterSlot())
                {
                    var owner = this.owner;
                    if (owner != null)
                    {
                        int index = owner.GetSlotIndex(this);
                        owner.RemoveSlot(this);
                        owner.AddSlot(newSlot, index);
                    }
                }
                else
                {
                    var parent = GetParent();
                    var index  = parent.GetIndex(this);
                    parent.RemoveChild(this, false);
                    parent.AddChild(newSlot, index);
                }

                CopyLinks(newSlot, this, true);
                CopySpace(newSlot, this, true);
                UnlinkAll(true);
                return(newSlot);
            }
            return(this);
        }