Пример #1
0
        private void ReconnectAllSegments()
        {
            for (int segmentIndex = 1; segmentIndex < _pathSegments.Count; ++segmentIndex)
            {
                ObjectPlacementBoxStackSegment currentSegment  = _pathSegments[segmentIndex];
                ObjectPlacementBoxStackSegment previousSegment = _pathSegments[segmentIndex - 1];

                currentSegment.ConnectFirstStackToLastStackInSegment(previousSegment, CalculateSegmentConnectionOffset(currentSegment, previousSegment));
            }
        }
        public void Attach2NewSegments()
        {
            if (_isActive)
            {
                RemoveSegmentsWithNoStacks();

                // First create the 2 new segments which will replace the current penultimate and last segments
                ObjectPlacementBoxStackSegment oldLastSegment        = LastSegment;
                ObjectPlacementBoxStackSegment newPenultimateSegment = CreateNewSegment();
                CreateNewSegment();

                // We will want the first stack in the new penultimate segment to replace the last stack in 'LastSegment'.
                // Otherwise, when this function is called, an additional box will suddenly appear in the scene apparently
                // out of nowhere and it doesn't look very good. Not to mention that it can be quite confusing :).
                oldLastSegment.Shrink(1);
                newPenultimateSegment.Extend(1);

                newPenultimateSegment.SetExtensionDirection(oldLastSegment.ExtensionDirection);
                if (CanRotateObjectsToFollowPath())
                {
                    newPenultimateSegment.SetRotationForAllStacks(oldLastSegment.StackRotation);
                    MakeSegmentFollowPath(LastSegment);
                }
                newPenultimateSegment.ConnectFirstStackToLastStackInSegment(oldLastSegment, CalculateSegmentConnectionOffset(newPenultimateSegment, oldLastSegment));

                AdjustHeightForEntireSegment(PenultimateSegment);

                UpdateStackOverlapDataForLast2Segments();
                if (_borderSettings.UseBorders)
                {
                    _borderApplyOperation.ApplyBordersToAllPathSegments(_pathSegments, _borderSettings);
                }
                if (_tileConnectionSettings.UseTileConnections)
                {
                    UpdateTileConnectionInformation();
                }
            }
        }