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> /// 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(); } } }