Example #1
0
        private bool IsSessionDataReady()
        {
            bool isReady = (_path != null && _pathSegments != null && _startObject != null && _pathExtensionPlane != null);

            if (!isReady)
            {
                return(false);
            }

            if (_heightAdjustmentSettings.HeightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.AutomaticPattern &&
                ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern == null)
            {
                Debug.LogWarning("Can not begin path construction because the automatic pattern height adjustment mode is selected but there is no active pattern.");
                isReady = false;
            }

            if (_tileConnectionSettings.UseTileConnections && !_tileConnectionSettings.DoAllTileConnectionsHavePrefabAssociated(true))
            {
                Debug.LogWarning("You are using tile connections, but not all tiles have an associated prefab. Please associate a prefab with each tile in order to being path construction.");
                isReady = false;
            }

            OrientedBox hierarchyWorldOrientedBox = _startObject.GetHierarchyWorldOrientedBox();
            float       absSizeRight = hierarchyWorldOrientedBox.GetRotatedAndScaledSizeAlongDirection(_pathExtensionPlane.RightAxis);
            float       absSizeLook  = hierarchyWorldOrientedBox.GetRotatedAndScaledSizeAlongDirection(_pathExtensionPlane.LookAxis);

            if (absSizeRight < 1e-4f || absSizeLook < 1e-4f)
            {
                Debug.LogWarning("Can not begin path construction because the object has a 0 size component along the extention plane axes.");
                isReady = false;
            }

            return(isReady);
        }
Example #2
0
 private void RenderRemovePatternButton()
 {
     if (GUILayout.Button(GetContentForRemovePatternButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth)))
     {
         UndoEx.RecordForToolAction(ObjectPlacementPathHeightPatternDatabase.Get());
         ObjectPlacementPathHeightPatternDatabase.Get().RemoveAndDestroyPattern(_heightPattern);
     }
 }
 private void RenderCreateNewHeightPatternButton()
 {
     if (GUILayout.Button(GetContentForCreateNewHeightPatternButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth)))
     {
         UndoEx.RecordForToolAction(ObjectPlacementPathHeightPatternDatabase.Get());
         ObjectPlacementPathHeightPatternDatabase.Get().CreateHeightPattern(ViewData.NameForNewHeightPattern);
     }
 }
        private void RenderViewsForFilteredPatterns()
        {
            List <ObjectPlacementPathHeightPattern> filteredHeightPatterns = ObjectPlacementPathHeightPatternDatabase.Get().GetFilteredPatterns();

            foreach (ObjectPlacementPathHeightPattern heightPattern in filteredHeightPatterns)
            {
                heightPattern.View.Render();
            }
        }
Example #5
0
 private void RenderPatternActivationButton()
 {
     EditorGUIColor.Push(GetPatternActivationButtonColor());
     if (GUILayout.Button(GetContentForPatternActivationButton(), GetStyleForPatternActivationButton(), GUILayout.ExpandWidth(true)))
     {
         UndoEx.RecordForToolAction(ObjectPlacementPathHeightPatternDatabase.Get());
         ObjectPlacementPathHeightPatternDatabase.Get().SetActivePattern(_heightPattern);
     }
     EditorGUIColor.Pop();
 }
Example #6
0
 private Color GetPatternActivationButtonColor()
 {
     if (_heightPattern == ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern)
     {
         return(ObjectPlacementPathHeightPatternDatabase.Get().View.ColorForActivePatternButton);
     }
     else
     {
         return(GUI.color);
     }
 }
Example #7
0
        private void RenderPatternNameChangeTextField()
        {
            ObjectPlacementPathHeightPatternDatabase patternDatabase = ObjectPlacementPathHeightPatternDatabase.Get();
            string newString = EditorGUILayoutEx.DelayedTextField(GetContentForPatternNameChangeField(), _heightPattern.Name);

            if (newString != _heightPattern.Name)
            {
                UndoEx.RecordForToolAction(_heightPattern);
                patternDatabase.RenamePattern(_heightPattern, newString);
            }
        }
        private void RenderPathPlacementControls()
        {
            _settings.PathPlacementSettings.View.Render();

            EditorGUILayout.Separator();
            PathObjectPlacement.Get().PathSettings.View.Render();

            EditorGUILayout.Separator();
            if (PathObjectPlacement.Get().PathSettings.ManualConstructionSettings.HeightAdjustmentSettings.HeightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.AutomaticPattern)
            {
                ObjectPlacementPathHeightPatternDatabase.Get().View.Render();
            }
        }
Example #9
0
        public void OnHeightPatternRemoved()
        {
            if (_isActive && _heightAdjustmentSettings.HeightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.AutomaticPattern)
            {
                ObjectPlacementPathHeightPattern activePattern = ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern;
                if (activePattern != null)
                {
                    AdjustHeightForAllStacksInPath();
                    if (_borderSettings.UseBorders)
                    {
                        _borderApplyOperation.ApplyBordersToAllPathSegments(_pathSegments, _borderSettings);
                    }
                }
                else
                {
                    Debug.LogWarning("There is no height pattern currently available. Path construction was cancelled.");
                    End();
                }

                SceneView.RepaintAll();
            }
        }
        private List <ObjectPlacementPathHeightPattern> FilterPatternsByFilterProperties(List <INamedEntity> namedPatternEntities)
        {
            var filteredPatterns = new List <ObjectPlacementPathHeightPattern>();
            ObjectPlacementPathHeightPattern activePattern = ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern;

            foreach (ObjectPlacementPathHeightPattern pattern in namedPatternEntities)
            {
                if (_onlyActive.IsActive)
                {
                    if (pattern == activePattern)
                    {
                        filteredPatterns.Add(pattern);
                        return(filteredPatterns);
                    }
                }
                else
                {
                    filteredPatterns.Add(pattern);
                }
            }

            return(filteredPatterns);
        }
Example #11
0
 private void AdjustHeightForAllStacksInPath()
 {
     if (_heightAdjustmentSettings.HeightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.Manual)
     {
         _manualHeightAdjuster.AdjustHeightForSegments(_pathSegments, _currentManualPathHeight);
     }
     else if (_heightAdjustmentSettings.HeightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.AutomaticRandom)
     {
         _automaticRandomHeightAdjuster.AdjustHeightForSegments(_pathSegments, _heightAdjustmentSettings.AutomaticRandomHeightAdjustmentSettings);
     }
     else
     {
         _automaticPatternHeightAdjuster.AdjustHeightForAllSegmentsInPath(_pathSegments, _heightAdjustmentSettings.AutomaticPatternHeightAdjustmentSettings, ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern);
     }
 }
Example #12
0
        private void AdjustHeightForStackRangeInSegment(ObjectPlacementBoxStackSegment segment, int indexOfFirstStackToAdjust)
        {
            ObjectPlacementPathHeightAdjustmentMode heightAdjustmentMode = _heightAdjustmentSettings.HeightAdjustmentMode;

            if (heightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.Manual)
            {
                _manualHeightAdjuster.AdjustSegmentHeight(segment, indexOfFirstStackToAdjust, _currentManualPathHeight);
            }
            else if (heightAdjustmentMode == ObjectPlacementPathHeightAdjustmentMode.AutomaticRandom)
            {
                _automaticRandomHeightAdjuster.AdjustSegmentHeight(segment, indexOfFirstStackToAdjust, _heightAdjustmentSettings.AutomaticRandomHeightAdjustmentSettings);
            }
            else
            {
                _automaticPatternHeightAdjuster.AdjustSegmentHeight(segment, _pathSegments, _heightAdjustmentSettings.AutomaticPatternHeightAdjustmentSettings, ObjectPlacementPathHeightPatternDatabase.Get().ActivePattern);
            }
        }