private void MarkSolidRecursive(Solid3D solid) { markedDeleteSet.Add(solid); solid.ToggleMarkForDelete(true, false); foreach (Solid3D child in solid.Children) { MarkSolidRecursive(child); } }
private void MarkSolidForDeletion(Solid3D solid) { UnmarkSolidForDeletion(); solid.ToggleMarkForDelete(true, true); markedDeleteSolid = solid; foreach (Solid3D child in solid.Children) { MarkSolidRecursive(child); } }
private void DeleteMarkedSolid() { markedDeleteSet.Add(markedDeleteSolid); foreach (Solid3D solid in markedDeleteSet) { placedSolids.Remove(solid); solid.ParentButton.Count += 1; Destroy(solid.gameObject); } markedDeleteSolid = null; markedDeleteSet = new HashSet <Solid3D>(); }
private void UnmarkSolidForDeletion() { if (markedDeleteSolid != null) { markedDeleteSolid.ToggleMarkForDelete(false, false); foreach (Solid3D child in markedDeleteSet) { child.ToggleMarkForDelete(false, false); } markedDeleteSet = new HashSet <Solid3D>(); markedDeleteSolid = null; } }
private void PowerRecursive(Solid3D solid, ref HashSet <Solid3D> checkedSolids) { solid.IsPowered = true; checkedSolids.Add(solid); if (solid.ParentSolid != null && !checkedSolids.Contains(solid.ParentSolid)) { PowerRecursive(solid.ParentSolid, ref checkedSolids); } foreach (Solid3D child in solid.Children) { if (!checkedSolids.Contains(child)) { PowerRecursive(child, ref checkedSolids); } } }
private void ConfirmOrCancelPreviewSolid(bool isConfirmed) { if (isConfirmed) { previewSolid.SetMode(Solid3D.MODE.DEFAULT); if (!selectedFace.ParentPrimitive.ParentSolid.isStatic) { previewSolid.ParentSolid = selectedFace.ParentPrimitive.ParentSolid; } if (selectedFace.ParentPrimitive.ParentSolid.IsPowered) { previewSolid.IsPowered = true; } selectedFace.ParentPrimitive.ParentSolid.Children.Add(previewSolid); placedSolids.Add(previewSolid); previewSolid.ParentButton.Count -= 1; if (previewSolid.ParentButton.Count == 0) { previewSolid = null; // break reference to newly placed solid so that setting ReadySolid to null doesn't destroy it ReadySolid = null; } previewSolid = null; selectedFace = null; Destroy(activeFaceSelector.gameObject); CheckWinConditions(); } else { Destroy(previewSolid.gameObject); } previewSolid = null; }
private void CreatePreviewSolidAtSelectedFace() { if (previewSolid != null) { Destroy(previewSolid.gameObject); } previewSolid = Instantiate(ReadySolid.gameObject).GetComponent <Solid3D>(); previewSolid.SetMode(Solid3D.MODE.PREVIEW); previewSolid.SelectFaceByNumberOfSides(selectedFace.sides); if (previewSolid.ActivePrimitive == null) { Destroy(previewSolid.gameObject); // TODO: no valid face } else { previewSolid.AlignToSelectedFace(selectedFace); previewSolid.ParentButton = ReadySolid.ParentButton; } }