private void AssignPrefabToDestinationTileConnection(Prefab prefab) { ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = PathObjectPlacement.Get().PathSettings.TileConnectionSettings.GetSettingsForTileConnectionType(_destinationTileConnectionType); UndoEx.RecordForToolAction(tileConnectionTypeSettings); tileConnectionTypeSettings.Prefab = prefab; }
private static void EnsureGuideUsesBeginTileConnectionPrefab() { ObjectPlacementPathTileConnectionSettings tileConnectionSettings = ObjectPlacement.Get().PathObjectPlacement.PathSettings.TileConnectionSettings; ObjectPlacementPathTileConnectionTypeSettings beginTileConnectionSettings = tileConnectionSettings.GetSettingsForTileConnectionType(ObjectPlacementPathTileConnectionType.Begin); if (CanRefreshGuideToUseBeginTileConnectionPrefab(beginTileConnectionSettings)) { PrefabCategory categoryWhichContainsBeginPrefab = PrefabCategoryDatabase.Get().GetPrefabCategoryWhichContainsPrefab(beginTileConnectionSettings.Prefab); if (categoryWhichContainsBeginPrefab == null) { return; } PrefabCategoryDatabase.Get().SetActivePrefabCategory(categoryWhichContainsBeginPrefab); categoryWhichContainsBeginPrefab.SetActivePrefab(beginTileConnectionSettings.Prefab); ObjectPlacement.Get().DestroyPlacementGuide(); ObjectPlacementGuide.CreateFromActivePrefabIfNotExists(); } // Note: When using tile connections, we will always use the original prefab scale if (ObjectPlacementGuide.ExistsInScene) { ObjectPlacementGuide.Instance.WorldScale = beginTileConnectionSettings.Prefab.InitialWorldScale; } }
private void InitializePathTileConnectionTypeSettingsArray() { _tileConnectionTypeSettings = new ObjectPlacementPathTileConnectionTypeSettings[ObjectPlacementPathTileConnectionTypes.Count]; for (int tileConnectionTypeIndex = 0; tileConnectionTypeIndex < _tileConnectionTypeSettings.Length; ++tileConnectionTypeIndex) { ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = Octave3DWorldBuilder.ActiveInstance.CreateScriptableObject <ObjectPlacementPathTileConnectionTypeSettings>(); tileConnectionTypeSettings.TileConnectionType = (ObjectPlacementPathTileConnectionType)tileConnectionTypeIndex; _tileConnectionTypeSettings[tileConnectionTypeIndex] = tileConnectionTypeSettings; } }
public void RemovePrefabAssociation(Prefab prefab) { List <ObjectPlacementPathTileConnectionType> allTileConnectionTypes = ObjectPlacementPathTileConnectionTypes.GetAll(); foreach (ObjectPlacementPathTileConnectionType tileConnectionType in allTileConnectionTypes) { ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = GetSettingsForTileConnectionType(tileConnectionType); if (tileConnectionTypeSettings.Prefab == prefab) { tileConnectionTypeSettings.Prefab = null; } } }
public bool UsesSprites() { List <ObjectPlacementPathTileConnectionType> allTileConnectionTypes = ObjectPlacementPathTileConnectionTypes.GetAll(); foreach (ObjectPlacementPathTileConnectionType tileConnectionType in allTileConnectionTypes) { ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = GetSettingsForTileConnectionType(tileConnectionType); if (tileConnectionTypeSettings.Prefab != null && tileConnectionTypeSettings.Prefab.UnityPrefab.IsSprite()) { return(true); } } return(false); }
public void ApplyConfigurationDataToSettings(ObjectPlacementPathTileConnectionSettings tileConnectionSettings) { List <ObjectPlacementPathTileConnectionType> allTileConnectionTypes = ObjectPlacementPathTileConnectionTypes.GetAll(); foreach (ObjectPlacementPathTileConnectionType tileConnectionType in allTileConnectionTypes) { int tileConnectionIndex = (int)tileConnectionType; ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = tileConnectionSettings.GetSettingsForTileConnectionType(tileConnectionType); tileConnectionTypeSettings.YAxisRotation = _tileConnectionYAxisRotations[tileConnectionIndex]; tileConnectionTypeSettings.YOffset = _tileConnectionYOffsets[tileConnectionIndex]; tileConnectionTypeSettings.UpwardsExtrusionAmount = _tileConnectionUpwardsExtrusionAmount[tileConnectionIndex]; tileConnectionTypeSettings.DownwardsExtrusionAmount = _tileConnectionDownwardsExtrusionAmount[tileConnectionIndex]; tileConnectionTypeSettings.Prefab = _tileConnectionPrefabs[tileConnectionIndex]; } }
private void UpdateTileConnectionInformation() { List <ObjectPlacementPathTileConnectionGridCell> tileConnectionGridCells = _tileConnectionDetector.Detect(_path, _tileConnectionXZSize); if (tileConnectionGridCells.Count == 0) { return; } _tileConnectionGridCells.Clear(); _tileConnectionGridCells.AddRange(tileConnectionGridCells); bool usingSprites = _pathSettings.TileConnectionSettings.UsesSprites(); List <OrientedBox> tileConnectionPrefabWorldOrientedBoxesExceptAutofill = PrefabQueries.GetHierarchyWorldOrientedBoxesForAllPrefabs(_tileConnectionSettings.GetAllTileConnectionPrefabs(true)); foreach (ObjectPlacementPathTileConnectionGridCell tileConnectionGridCell in _tileConnectionGridCells) { ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = _tileConnectionSettings.GetSettingsForTileConnectionType(tileConnectionGridCell.TileConnectionType); tileConnectionGridCell.TileConnectionStack.SetBoxSize(GetTileConnectionSize(tileConnectionPrefabWorldOrientedBoxesExceptAutofill[(int)tileConnectionTypeSettings.TileConnectionType], usingSprites)); tileConnectionGridCell.TileConnectionStack.PlaceOnPlane(_pathExtensionPlane.Plane); } }
public ObjectPlacementPathTileConnectionTypeSettingsView(ObjectPlacementPathTileConnectionTypeSettings settings) { _settings = settings; }
public static List <OrientedBox> GetTileConnectionExtrusionOrientedBoxes(ObjectPlacementPathTileConnectionGridCell tileConnectionGridCell) { ObjectPlacementBoxStack tileConnectionStack = tileConnectionGridCell.TileConnectionStack; ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings = tileConnectionGridCell.TileConnectionPath.Settings.TileConnectionSettings.GetSettingsForTileConnectionType(tileConnectionGridCell.TileConnectionType); if (tileConnectionStack != null) { if (tileConnectionStack.NumberOfBoxes == 0) { return(new List <OrientedBox>()); } if (tileConnectionTypeSettings.IsAnyExtrusionNecessary()) { // Handle upwards extrusion Vector3 nextTilePositionForUpwardsExtrusion; Vector3 extrudeOffset; Vector3 pathExtensionPlaneNormal = tileConnectionGridCell.TileConnectionPath.ExtensionPlane.normal; var tileConnectionYOffsetVectorCalculator = new ObjectPlacementPathTileConnectionYOffsetVectorCalculator(); Vector3 yOffsetVector = tileConnectionYOffsetVectorCalculator.Calculate(tileConnectionTypeSettings, tileConnectionGridCell.TileConnectionPath); extrudeOffset = pathExtensionPlaneNormal * tileConnectionStack.GetBoxSizeAlongNormalizedDirection(pathExtensionPlaneNormal); if (tileConnectionStack.IsGrowingUpwards) { nextTilePositionForUpwardsExtrusion = tileConnectionStack.GetBoxByIndex(tileConnectionStack.NumberOfBoxes - 1).Center + extrudeOffset; } else { nextTilePositionForUpwardsExtrusion = tileConnectionStack.GetBoxByIndex(0).Center + extrudeOffset; } var extrudedBox = new OrientedBox(); extrudedBox.Rotation = tileConnectionStack.Rotation; extrudedBox.ModelSpaceSize = tileConnectionStack.BoxSize; var extrusionOrientedBoxes = new List <OrientedBox>(); for (int extrudeIndex = 0; extrudeIndex < tileConnectionTypeSettings.UpwardsExtrusionAmount; ++extrudeIndex) { extrudedBox.Center = nextTilePositionForUpwardsExtrusion + yOffsetVector; extrusionOrientedBoxes.Add(new OrientedBox(extrudedBox)); nextTilePositionForUpwardsExtrusion += extrudeOffset; } // Handle downwards extrusion extrudeOffset = -pathExtensionPlaneNormal *tileConnectionStack.GetBoxSizeAlongNormalizedDirection(pathExtensionPlaneNormal); if (tileConnectionStack.IsGrowingDownwards) { nextTilePositionForUpwardsExtrusion = tileConnectionStack.GetBoxByIndex(tileConnectionStack.NumberOfBoxes - 1).Center + extrudeOffset; } else { nextTilePositionForUpwardsExtrusion = tileConnectionStack.GetBoxByIndex(0).Center + extrudeOffset; } for (int extrudeIndex = 0; extrudeIndex < tileConnectionTypeSettings.DownwardsExtrusionAmount; ++extrudeIndex) { extrudedBox.Center = nextTilePositionForUpwardsExtrusion + yOffsetVector; extrusionOrientedBoxes.Add(new OrientedBox(extrudedBox)); nextTilePositionForUpwardsExtrusion += extrudeOffset; } return(extrusionOrientedBoxes); } else { return(new List <OrientedBox>()); } } else { return(new List <OrientedBox>()); } }
public Vector3 Calculate(ObjectPlacementPathTileConnectionTypeSettings tileConnectionTypeSettings, ObjectPlacementPath path) { return(path.ExtensionPlane.normal * (tileConnectionTypeSettings.YOffset + path.Settings.ManualConstructionSettings.OffsetAlongGrowDirection)); }
private static bool CanRefreshGuideToUseBeginTileConnectionPrefab(ObjectPlacementPathTileConnectionTypeSettings beginTileConnectionSettings) { return((ObjectPlacementGuide.ExistsInScene && beginTileConnectionSettings.Prefab != ObjectPlacementGuide.Instance.SourcePrefab) || !ObjectPlacementGuide.ExistsInScene); }