Example #1
0
        private void DropInNestedSeries(IChainableSeries <IScriptableEntry> newNested)
        {
            Debug.Log($"adding {(newNested as MonoBehaviour)?.name} as nested under {this.name}");
            if (newNested == null || !newNested.GetCanHaveParents())
            {
                throw new Exception("ERROR: invalid nesting. see logs");
            }

            var originalNested = this.nestedSeries;

            this.nestedSeries = newNested;
            newNested.SetParent(this);

            ChainableSeriesUtilities.UpdateOriginalChildAfterSplice(originalNested, newNested);

            this.nestedSeries?.OnParentUpdated(this.GetNestedChildTransform());
            this.OnChildUpdated(this.nestedSeries);
            //var currentTerminator = ChainableSeriesUtilities.GetChainTerminator(this.nestedSeries);
            //if (currentTerminator.GetCanHaveChildren())
            //{
            //    this.pairedNestedBlockTerminator.GetParent()?.AbortChild(this.pairedNestedBlockTerminator);
            //    this.pairedNestedBlockTerminator.SetParent(null);
            //    currentTerminator.SpliceChildIn(this.pairedNestedBlockTerminator);
            //}

            //(newNested as SeriesDragDrop).UpdatePositionRelativeToParent(this.GetNestedChildTransform());
        }
    /// <summary>
    /// Iterate through the children of origin until an entry with no child is found
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="origin"></param>
    /// <returns></returns>
    public static IChainableSeries <T> GetChainTerminator <T>(IChainableSeries <T> origin)
    {
        var currentTerminator = origin;

        while (currentTerminator.GetChild() != null)
        {
            currentTerminator = currentTerminator.GetChild();
        }
        return(currentTerminator);
    }
Example #3
0
        public override bool AbortChild(IChainableSeries <IScriptableEntry> child)
        {
            if (base.AbortChild(child))
            {
                return(true);
            }

            if (this.nestedSeries == child)
            {
                this.nestedSeries = null;
                return(true);
            }
            return(false);
        }
Example #4
0
        public override void OnChildUpdated(IChainableSeries <IScriptableEntry> child)
        {
            if (child == this.nestedSeries)
            {
                var currentTerminator = ChainableSeriesUtilities.GetChainTerminator(this.nestedSeries);
                if (currentTerminator != this.pairedNestedBlockTerminator)
                {
                    this.pairedNestedBlockTerminator.AbortSelf();

                    if (currentTerminator.GetCanHaveChildren())
                    {
                        currentTerminator.SimpleAppendChild(this.pairedNestedBlockTerminator);
                    }
                }
                this.GetChild()?.OnParentUpdated(this.GetChildTransform());
            }
            base.OnChildUpdated(child);
        }
    /// <summary>
    /// after a child has been replaced by a new chain spliced in place of it, this method will attempt to append the original child
    ///     at the end of the chain which was spliced in. If that's not possible, then the original child is ejected
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="originalChild">The child which has been displaced from its parent</param>
    /// <param name="newChild">The head of the chainable chain which took the place of the original child</param>
    /// <returns></returns>
    public static void UpdateOriginalChildAfterSplice <T>(IChainableSeries <T> originalChild, IChainableSeries <T> newChild)
    {
        if (originalChild != null)
        {
            originalChild.SetParent(null);

            var newTerminator = GetChainTerminator(newChild);

            if (newTerminator.GetCanHaveChildren())
            {
                //May not need to go full recursive here -- at this point, newTerminator has no children and originaChild has no parents
                // Could end up being a simple linking method??
                newTerminator.SimpleAppendChild(originalChild);
            }
            else
            {
                //the new chain has a no-append terminator. Kick out the old chain after to replacing it with the new
                originalChild.OnSelfEjected();
            }
        }
    }
Example #6
0
 public void SetParent(IChainableSeries <IScriptableEntry> parent)
 {
     this.parent = parent;
 }
Example #7
0
 public bool AbortChild(IChainableSeries <IScriptableEntry> child)
 {
     return(false);
 }
Example #8
0
 public void AbortSelf()
 {
     this.parent?.AbortChild(this);
     this.parent = null;
 }
Example #9
0
 public override void ChildLinked(IChainableSeries <IScriptableEntry> child)
 {
     base.ChildLinked(child);
     this.pairedNestedBlockTerminator.SetScriptChild(this.nextExecutingChild?.GetData());
 }
Example #10
0
 public void SimpleAppendChild(IChainableSeries <IScriptableEntry> child)
 {
     throw new InvalidOperationException("Cannot append child to component, no children allowed");
 }
Example #11
0
 public void OnChildUpdated(IChainableSeries <IScriptableEntry> child)
 {
 }
Example #12
0
 public void SpliceChildIn(IChainableSeries <IScriptableEntry> chainHead)
 {
 }