using System; using System.Collections; using System.Collections.Generic; using System.Linq; //using Habrador_Computational_Geometry; using UnityEngine; using UnityEngine.UI.Extensions; public class RoomCreation : MonoBehaviour { static private RoomCreation _instance; //[SerializeField] private Transform _roomContainer; //[SerializeField] private Transform _sceneContainer; private List _pointPositions = new(); private List _wallIndexPairs = new(); private const float _presetRoomSize = 192.0f; private const float _presetRoomHeight = 96.0f; private Vector3 _roomPosition; private float _roomHeight = _presetRoomHeight; private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); return; } else { _instance = this; } } private void CreateRoom2D(List lineData = null, List pointsData = null) { print("---------------------------------------------CreateRoom2D"); _G.isExteriorWall = true; RectTransform wallLineContainer = WallCreationManager.GetWallLineContainer(); RectTransform wallPointContainer = WallCreationManager.GetWallPointContainer(); //Clear wall LINE for (int i = wallLineContainer.childCount - 1; i >= 0; i--) { Transform wallTransform = wallLineContainer.GetChild(i); wallTransform.GetComponent().DestroyWall(); wallTransform.SetParent(WallCreationManager.GetDeletionContainer()); } // Clear wall POINTS for (int i = wallPointContainer.childCount - 1; i >= 0; i--) { Transform pointTransform = wallPointContainer.GetChild(i); pointTransform.GetComponent().DestroyPoint(); pointTransform.SetParent(WallCreationManager.GetDeletionContainer()); } List points = new(); int j = 0; foreach (Vector2 pointPosition in _pointPositions) { if (pointsData != null) { points.Add(WallCreationManager.CreatePoint(pointsData[j])); } else { points.Add(WallCreationManager.CreatePoint(pointPosition)); } j++; } j = 0; print("_wallIndexPairs========"+_wallIndexPairs.Count); foreach (Vector2Int wallIndexPair in _wallIndexPairs) { print("wallIndexPair====="+wallIndexPair); if (lineData != null) { WallCreationManager.CreateLine(points[lineData[j].pointPair.x], points[lineData[j].pointPair.y], lineData[j]); } else { WallCreationManager.CreateLine(points[wallIndexPair.x], points[wallIndexPair.y]); } j++; } points.Clear(); _G.isExteriorWall = false; } public void CreatePlan2D() { _G.Down = false; _G.Open = true; _G.WIDE = 192; _G.DEPTH = 168; _G.HEIGHT = 96; _G.closingWall = 1; _G.NW = 1; _G.WallsPointStart = new(new Vector2[24]); print("CreateRoomPreset======"+_G.ROOM); CreateRoomPreset(int.Parse(_G.ROOM[1..])); print("CreateRoomPreset======"+_G.ROOM); } public void CreateRoomPreset(RoomTypes roomType) { print("CreateRoomPreset======"+roomType); // TODO : clear undo redo? _G.WALLS_HIDDEN_LIST = new(); _pointPositions.Clear(); _wallIndexPairs.Clear(); _roomHeight = _presetRoomHeight; Vector2 halfScreen = WallCreationManager.GetWallLineContainer().anchoredPosition; // TODO : use canvas size? also change elsewhere in scripts float halfRoomSize = _presetRoomSize; // / 2.0f; _G.EXTERIOR_WALL_PLAN_CLOSED = true; switch (roomType) { case RoomTypes.Empty_RDRAW: _G.EXTERIOR_WALL_PLAN_CLOSED = false; break; case RoomTypes.Square_R1: _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 0)); break; case RoomTypes.L_Shaped_Right_R4: _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize / 3.0f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize / 3.0f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 5)); _wallIndexPairs.Add(new Vector2Int(5, 0)); break; case RoomTypes.L_Shaped_Left_R5: _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize / 3.0f) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize / 3.0f) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 5)); _wallIndexPairs.Add(new Vector2Int(5, 0)); break; case RoomTypes.Corner_Angled_Right_R2: _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize / 3.0f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 0)); break; case RoomTypes.Corner_Angled_Left_R3: _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize / 3.0f) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 0)); break; case RoomTypes.U_Shaped_R6: _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize / 2.0f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize / 2.0f) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 5)); _wallIndexPairs.Add(new Vector2Int(5, 6)); _wallIndexPairs.Add(new Vector2Int(6, 7)); _wallIndexPairs.Add(new Vector2Int(7, 0)); break; case RoomTypes.Podium_R10: _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize / 3f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize / 3f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 5)); _wallIndexPairs.Add(new Vector2Int(5, 6)); _wallIndexPairs.Add(new Vector2Int(6, 7)); _wallIndexPairs.Add(new Vector2Int(7, 0)); break; case RoomTypes.Bump_R9: _pointPositions.Add(new Vector2(halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize / 1.5f, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 1.5f, halfRoomSize / 1.5f) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize / 3.0f, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); _wallIndexPairs.Add(new Vector2Int(3, 4)); _wallIndexPairs.Add(new Vector2Int(4, 5)); _wallIndexPairs.Add(new Vector2Int(5, 6)); _wallIndexPairs.Add(new Vector2Int(6, 7)); _wallIndexPairs.Add(new Vector2Int(7, 0)); break; case RoomTypes.Open_Corner_R8: // TODO : use square room with seperators _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); break; case RoomTypes.Open_Bottom_R7: // TODO : use square room with seperators _pointPositions.Add(new Vector2(-halfRoomSize, -halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(-halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, halfRoomSize) + halfScreen); _pointPositions.Add(new Vector2(halfRoomSize, -halfRoomSize) + halfScreen); _wallIndexPairs.Add(new Vector2Int(0, 1)); _wallIndexPairs.Add(new Vector2Int(1, 2)); _wallIndexPairs.Add(new Vector2Int(2, 3)); break; case RoomTypes.FreeHandDraw: _G.EXTERIOR_WALL_PLAN_CLOSED = false; break; default: break; } _G.NW = 0; _G.NWExterior = 0; _G.NWInterior = 0; CreateRoom2D(); } public void CreateRoomPreset(GameObject button) { CreateRoomPreset(button.name); } public void CreateRoomPreset(string objectName) { RoomTypes roomType = RoomTypes.Empty_RDRAW; if (int.TryParse(objectName[1..], out int enumIndex)) { roomType = (RoomTypes)enumIndex; } CreateRoomPreset(roomType); } public void CreateRoomPreset(int roomNumber) { RoomTypes roomType = (RoomTypes)roomNumber; CreateRoomPreset(roomType); } static public void CreateRoomPreset() { _instance.CreateRoomPreset(RoomTypes.Square_R1); } public void CreateRoomPresetEmpty() { CreateRoomPreset(RoomTypes.Empty_RDRAW); } public void CreateRoomPresetSquare() { CreateRoomPreset(RoomTypes.Square_R1); } public void CreateRoomPresetCornerAngledRight() { CreateRoomPreset(RoomTypes.Corner_Angled_Right_R2); } public void CreateRoomPresetCornerAngledLeftt() { CreateRoomPreset(RoomTypes.Corner_Angled_Left_R3); } public void CreateRoomPresetLShapedRight() { CreateRoomPreset(RoomTypes.L_Shaped_Right_R4); } public void CreateRoomPresetLShapedLeft() { CreateRoomPreset(RoomTypes.L_Shaped_Left_R5); } public void CreateRoomPresetUShaped() { CreateRoomPreset(RoomTypes.U_Shaped_R6); } public void CreateRoomPresetPodium() { CreateRoomPreset(RoomTypes.Podium_R10); } public void CreateRoomPresetBump() { CreateRoomPreset(RoomTypes.Bump_R9); } public void CreateRoomPresetOpenCorner() { CreateRoomPreset(RoomTypes.Open_Corner_R8); } public void CreateRoomPresetOpenBottom() { CreateRoomPreset(RoomTypes.Open_Bottom_R7); } // temporary for quick integration // static public void CreateRoomTo3D() // { // _instance.CreateRoom3D(); // } // temporary for quick integration // public void CreateRoom3D() // { // RectTransform wallContainer = WallCreationManager.GetWallLineContainer(); // //_G.ROOM = "RDRAW"; // _G.FloorPoints=new List[1]; // _G.FloorPoints[0]=new(){}; // Vector3 floorNormal = Vector3.zero; // bool isRoomCounterClockwise = floorNormal.z > 0; // if (isRoomCounterClockwise) // { // List wallTransforms = new(); // foreach (RectTransform item in wallContainer) // { // wallTransforms.Add(item); // WallLine wallLine = item.GetComponent(); // wallLine.InitPoints(wallLine._pointEnd, wallLine._pointStart); // } // wallTransforms.Reverse(); // for (int i = 0; i < wallTransforms.Count; i++) // { // wallTransforms[i].SetSiblingIndex(i); // } // } // _G.WallAssociateWallLine.Clear(); // _G.WallsWidth.Clear(); // _G.WallsPointCenter.Clear(); // _G.WallsPointStart.Clear(); // _G.WallsAngle.Clear(); // _G.WallsDirection.Clear(); // GameObject colliderObject = new(); // Collider collider = colliderObject.AddComponent(); // int wallIndex = 0; // float MinX=0; // float MaxX=0; // float MinY=0; // float MaxY=0; // foreach (RectTransform item in wallContainer) // { // if (item.gameObject.GetComponent()._category == "Exterior") // { // WallLine wallLine = item.GetComponent(); // RectTransform colliderRectTransform = wallLine.GetColliderTransform(); // WallPoint startPoint, endPoint; // WallLineInfo wallInfo; // bool connectToPrevious, connectToNext; // WallLine.CreateWallInfo(wallLine, out startPoint, out endPoint, out wallInfo, out connectToPrevious, out connectToNext); // _G.WallAssociateWallLine.Add("w" + (wallIndex + 1) + "_" + wallIndex); // _G.WallsWidth.Add(Vector3.Distance(wallInfo.frontProjectionStart, wallInfo.frontProjectionEnd)); // float wallThickness = 0.0f; //rectTransform.sizeDelta.y / WallLine.RatioWorldToScreen; // TODO : implementation // Vector3 centerPoint = Vector3.Lerp(wallInfo.frontProjectionStart, wallInfo.frontProjectionEnd, 0.5f); // _G.WallsPointCenter.Add(new Vector2(centerPoint.x, centerPoint.z)); // Vector3 pointStart = wallInfo.frontProjectionStart; // _G.WallsPointStart.Add(new Vector2(pointStart.x, pointStart.z)); // _G.WallsAngle.Add(Mathf.Repeat(Vector2.SignedAngle(wallLine._pointEnd.GetWorldPosition() - _G.WallsPointStart[wallIndex], Vector2.right), 360.0f)); // _G.WallsDirection.Add(Mathf.RoundToInt(_G.WallsAngle[wallIndex] / 45.0f) % 8 + 1); // Vector3 position = new(_G.WallsPointCenter[wallIndex].x, 0.0f, _G.WallsPointCenter[wallIndex].y); // collider.transform.SetPositionAndRotation(position, Quaternion.AngleAxis(_G.WallsAngle[wallIndex], Vector3.up)); // collider.transform.localScale = new Vector3(_G.WallsWidth[wallIndex], _G.HEIGHT, wallThickness); // if(pointStart.xMaxX)MaxX=pointStart.x; // if(pointStart.zMaxY)MaxY=pointStart.z; // wallIndex++; // wallLine.name = $"WallLine{wallIndex}"; // } // } // _G.NW = wallIndex;//wallContainer.childCount;//wallIndex; // _G.NWExterior = wallIndex; // _G.NWInterior = 0; // _G.WIDE = MaxX-MinX; // _G.DEPTH = MaxY-MinY; // Vector2 centerOffsetWalls = new( (MaxX+MinX)*0.5f, (MaxY+MinY)*0.5f ); // for (int i = 0; i < _G.NWExterior; i++) // { // _G.WallsPointCenter[i] -= centerOffsetWalls; // _G.WallsPointStart[i] -= centerOffsetWalls; // WallLine wallLine = WallCreationManager.GetWallLineWithWallIndex(i); // wallLine.LineInfo.ApplyOffset(centerOffsetWalls); // } // _G.RoomOffset = new(-centerOffsetWalls.x, 0, -centerOffsetWalls.y); // // foreach (Transform item in _sceneContainer) // // { // // if (item.gameObject.TryGetComponent(out WallLine wallLine)) // // { // // if (wallLine._category == "Exterior") // // { // // //item.position += _G.RoomOffset; // // //DOIT.SaveObjectPositionInData(item); // // } // // } // // } // _roomPosition = _G.RoomOffset; // //print("_G.RoomOffset====="+_G.RoomOffset); // //Exterior Walls // //Create3D.CreateRoom(); // //Interior Walls // //CreateInteriorWalls.InteriorWall(); // //ConstructOpen.RedrawOpen(); // Destroy(collider.gameObject); // SaveRoomRecipeVariables(); // //Set.WallColorQueueRenderingAllWalls(); // //ReflectionProbesUpdater.ReflectionProbeNormal.size = new(_G.WIDE + 1+_G.RoomOffset.x, _G.HEIGHT + 1, _G.DEPTH + 1+_G.RoomOffset.z); // } // Vector3 GetCentroid(Vector3[] points) // { // Vector3 centroid = Vector3.zero; // float maxX=0; // float minX=0; // float maxZ=0; // float minZ=0; // foreach (Vector3 point in points) // { // if(maxXpoint.x)minX=point.x; // if(maxZpoint.z)minZ=point.z; // } // centroid.x = (maxX+minX)*0.5f; // centroid.z = (maxZ+minZ)*0.5f; // return centroid; // } public static void SaveRoomRecipeVariables() { RectTransform LineContainer = WallCreationManager.GetWallLineContainer(); RectTransform PointContainer = WallCreationManager.GetWallPointContainer(); _G.ExteriorWalllist = new(); _G.ThicknessyWalllist = new(); _G.CategoryWalllist = new(); _G.HeightyWalllist = new(); for (int i = 0; i < LineContainer.childCount; i++) { WallLine Wall = LineContainer.GetChild(i).GetComponent(); if (Wall._category == "Exterior") { _G.ExteriorWalllist.Add("w" + (i + 1).ToString()); } _G.CategoryWalllist.Add(Wall._category); _G.ThicknessyWalllist.Add(Wall.Thickness); //print("Wallnumber==" + "w" + (i + 1).ToString() + " thickness===" + Wall.Thickness); } for (int i = 0; i < PointContainer.childCount; i++) { WallPoint Point = PointContainer.GetChild(i).GetComponent(); _G.HeightyWalllist.Add(Point._PointHeight); } } // public void CreateRoom3D_TODO() // { // return; // // TODO : delete or repurpose old walls (or use dirty flags from 2D) // foreach (Transform item in _roomContainer) // { // Destroy(item.gameObject); // } // // create room walls // Bounds roomBounds = new(); // bool isFirstIteration = true; // RectTransform wallContainer = WallCreationManager.GetWallLineContainer(); // foreach (RectTransform item in wallContainer) // { // Transform wallTransform = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; // wallTransform.parent = _roomContainer; // WallLine wallLine = item.GetComponent(); // RectTransform colliderRectTransform = wallLine.GetColliderTransform(); // Vector3 position = new Vector3(colliderRectTransform.position.x, 0.0f, colliderRectTransform.position.y); // float angle = Vector2.SignedAngle(wallLine._pointEnd.transform.position - wallLine._pointStart.transform.position, Vector2.right); // flipped for Y axis rotation // wallTransform.SetPositionAndRotation(position, Quaternion.AngleAxis(angle, Vector3.up)); // Vector2 size = colliderRectTransform.sizeDelta; // wallTransform.localScale = new Vector3(size.x, _roomHeight, size.y); // if (isFirstIteration) // { // roomBounds.center = position; // isFirstIteration = false; // } // roomBounds.Encapsulate(wallTransform.GetComponent().bounds); // } // // center room walls // Vector3 centerOffset = roomBounds.center; // foreach (Transform item in _roomContainer) // { // item.position -= centerOffset; // } // roomBounds.center = Vector3.zero; // // create room floor // Transform floorTransform = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; // floorTransform.parent = _roomContainer; // float floorThickness = 0.5f; // floorTransform.position = new Vector3(roomBounds.center.x, -(_roomHeight + floorThickness) / 2.0f, roomBounds.center.z); // floorTransform.localScale = new(roomBounds.size.x, floorThickness, roomBounds.size.z); // } static public void LoadRoomPlanFromSave(string wallPointPositions, string wallPointPairings) { _instance._pointPositions.Clear(); _instance._wallIndexPairs.Clear(); _instance._roomHeight = _G.HEIGHT; if (!string.IsNullOrEmpty(wallPointPositions)) { string[] positions = wallPointPositions.Split(";", System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < positions.Length; i++) { string[] vectorPair = positions[i].Split(","); _instance._pointPositions.Add(new Vector2(float.Parse(vectorPair[0]), float.Parse(vectorPair[1]))); } } else { for (int i = 0; i < _G.NWExterior; i++) { _instance._pointPositions.Add(_G.WallsPointStart[i] * 2.0f); } } if (!string.IsNullOrEmpty(wallPointPairings)) { string[] indexes = wallPointPairings.Split(";", System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < indexes.Length; i++) { string[] vectorPair = indexes[i].Split(","); _instance._wallIndexPairs.Add(new Vector2Int(int.Parse(vectorPair[0]), int.Parse(vectorPair[1]))); } } else { int count = _instance._pointPositions.Count; for (int i = 0; i < count; i++) { int indexesCount = _instance._wallIndexPairs.Count; _instance._wallIndexPairs.Add(new Vector2Int(indexesCount, (indexesCount + 1) % count)); } } _instance.CreateRoom2D(); } static public void SetRoomPlanFromLists(List wallPointData, List wallLineData, float roomHeight) { _instance._pointPositions.Clear(); _instance._wallIndexPairs.Clear(); SetRoomHeight(roomHeight); _instance._pointPositions.AddRange(wallPointData.Select(point => point._Position).ToList()); _instance._wallIndexPairs.AddRange(wallLineData.Select(line => line.pointPair).ToList()); _instance.CreateRoom2D(wallLineData, wallPointData); } static public void SetRoomHeight(float value) { _instance._roomHeight = value; _G.HEIGHT = value; } static public void UpdateMeasementSystem() { Get.o2("Canvas/Panel_DRAWPlan_NEW/CeilingHeight/MCe", "mCe").GetComponent().text = DOIT.ConvertNumberToString(_G.HEIGHT); foreach (RectTransform item in WallCreationManager.GetWallLineContainer()) { item.GetComponent().UpdateInputFieldValue(); } } } public enum RoomTypes { Empty_RDRAW, Square_R1, Corner_Angled_Right_R2, Corner_Angled_Left_R3, L_Shaped_Right_R4, L_Shaped_Left_R5, U_Shaped_R6, Open_Bottom_R7, Open_Corner_R8, Bump_R9, Podium_R10, FreeHandDraw }