using System; using UnityEngine; public class AddRecoverToCabinet : MonoBehaviour { static float KickHeight; static float CounterHeight; static float KickFrontProjection; //static Vector3 CenterBox; public static void Add(GameObject BASE, string[] C, float leftBox, float rightBox, float backBox, float frontBox, Vector3 CenterBox) { //C is ADN of the cabinet string Model = C[4]; string[] Recipe = C[81].Split(',');//Recover Recipe float W = DOIT.ConvertStringToNumber(C[6]);//Box Cabinet Wide float H = DOIT.ConvertStringToNumber(C[7]);//Box Cabinet Height float D = DOIT.ConvertStringToNumber(C[8]);//Box Cabinet depth float E = DOIT.ConvertStringToNumber(C[28]);//Box Cabinet Side value E float F = DOIT.ConvertStringToNumber(C[29]);//Box Cabinet Side value F float t = 0.625f; KickHeight = DOIT.ConvertStringToNumber(C[10]); CounterHeight = DOIT.ConvertStringToNumber(_G.SC[11]); KickFrontProjection = DOIT.ConvertStringToNumber(C[33]); Vector3 Position, Size, Rotation; int objectIndex = Get.GetObjectIndex(C[0]); string defaultRecover = GetDefaultRecoverValue(objectIndex); if (Model == "B1" || Model == "W1" || Model == "T1") { if (string.IsNullOrEmpty(Recipe[0])) { C[81] = $"{defaultRecover},{defaultRecover},{defaultRecover}"; Recipe = C[81].Split(','); } if (Recipe[0] != "0") { Size = new(D, H, t); Position = new(leftBox - t * 0.5f, CenterBox.y, CenterBox.z); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 0, Size, Position, Rotation); } if (Recipe[1] != "0") { Size = new(W, H, t); Position = new(CenterBox.x, CenterBox.y, backBox + t * 0.5f); Rotation = new(0, 0, 0); AddRecvertoCabinet(BASE, Recipe, 1, Size, Position, Rotation); } if (Recipe[2] != "0") { Size = new(D, H, t); Position = new(rightBox + t * 0.5f, CenterBox.y, CenterBox.z); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 2, Size, Position, Rotation); } } if (Get.Bool(Model, "B2_B4_B9_B6_B11_W2_W4_W9_W6_W11")) { if (string.IsNullOrEmpty(Recipe[0])) { C[81] = $"{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover}"; Recipe = C[81].Split(','); } if (Recipe[0] != "0") { Size = new(E, H, t); Position = new(leftBox + E * 0.5f, CenterBox.y, frontBox - t * 0.5f); Rotation = new(0, 180, 0); AddRecvertoCabinet(BASE, Recipe, 0, Size, Position, Rotation); } if (Recipe[1] != "0") { Size = new(D, H, t); Position = new(leftBox - t * 0.5f, CenterBox.y, CenterBox.z); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 1, Size, Position, Rotation); } if (Recipe[2] != "0") { Size = new(W, H, t); Position = new(CenterBox.x, CenterBox.y, backBox + t * 0.5f); Rotation = new(0, 180, 0); AddRecvertoCabinet(BASE, Recipe, 2, Size, Position, Rotation); } if (Recipe[3] != "0") { Size = new(F, H, t); Position = new(rightBox + t * 0.5f, CenterBox.y, backBox - F * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 3, Size, Position, Rotation); } } if (Get.Bool(Model, "B3_B5_B10_B7_B12_B26_B27_W3_W5_W10_W7_W12_W26_W27")) { if (string.IsNullOrEmpty(Recipe[0])) { C[81] = $"{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover}"; Recipe = C[81].Split(','); } if (Recipe[0] != "0") { Size = new(D, H, t); Position = new(leftBox - t * 0.5f, CenterBox.y, backBox - E * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 0, Size, Position, Rotation); } if (Recipe[1] != "0") { Size = new(W, H, t); Position = new(CenterBox.x, CenterBox.y, backBox + t * 0.5f); Rotation = new(0, 0, 0); AddRecvertoCabinet(BASE, Recipe, 1, Size, Position, Rotation); } if (Recipe[2] != "0") { Size = new(D, H, t); Position = new(rightBox + t * 0.5f, CenterBox.y, CenterBox.z); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 2, Size, Position, Rotation); } if (Recipe[3] != "0") { Size = new(F, H, t); Position = new(rightBox - F * 0.5f, CenterBox.y, frontBox - t * 0.5f); Rotation = new(0, 180, 0); AddRecvertoCabinet(BASE, Recipe, 3, Size, Position, Rotation); } } if (Get.Bool(Model, "B19_W19")) { if (string.IsNullOrEmpty(Recipe[0])) { C[81] = $"{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover}"; Recipe = C[81].Split(','); } if (Recipe[0] != "0") { Size = new(E, H, t); Position = new(leftBox + E * 0.5f, CenterBox.y, frontBox - t * 0.5f); Rotation = new(0, 0, 0); AddRecvertoCabinet(BASE, Recipe, 0, Size, Position, Rotation); } if (Recipe[1] != "0") { Size = new(D - 12, H, t); Position = new(leftBox - t * 0.5f, CenterBox.y, frontBox + (D - 12) * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 1, Size, Position, Rotation); } if (Recipe[2] != "0") { float BackWide = Mathf.Sqrt(12 * 12 + 12 * 12); Size = new(BackWide, H, t); Position = new(leftBox + 6 - t * 0.125f, CenterBox.y, backBox - 6 + t * 0.125f); Rotation = new(0, -45, 0); AddRecvertoCabinet(BASE, Recipe, 2, Size, Position, Rotation); } if (Recipe[3] != "0") { Size = new(W - 12, H, t); Position = new(rightBox - (W - 12) * 0.5f, CenterBox.y, backBox + t * 0.5f); Rotation = new(0, 180, 0); AddRecvertoCabinet(BASE, Recipe, 3, Size, Position, Rotation); } if (Recipe[4] != "0") { Size = new(F, H, t); Position = new(rightBox + t * 0.5f, CenterBox.y, backBox - F * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 4, Size, Position, Rotation); } } if (Get.Bool(Model, "B20_W20")) { if (string.IsNullOrEmpty(Recipe[0])) { C[81] = $"{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover},{defaultRecover}"; Recipe = C[81].Split(','); } if (Recipe[0] != "0") { Size = new(E, H, t); Position = new(leftBox - t * 0.5f, CenterBox.y, backBox - E * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 0, Size, Position, Rotation); } if (Recipe[1] != "0") { Size = new(W - 12, H, t); Position = new(leftBox + (W - 12) * 0.5f, CenterBox.y, backBox + t * 0.5f); Rotation = new(0, 180, 0); AddRecvertoCabinet(BASE, Recipe, 1, Size, Position, Rotation); } if (Recipe[2] != "0") { float BackWide = Mathf.Sqrt(12 * 12 + 12 * 12); Size = new(BackWide, H, t); Position = new(rightBox - 6 + t * 0.125f, CenterBox.y, backBox - 6 + t * 0.125f); Rotation = new(0, 45, 0); AddRecvertoCabinet(BASE, Recipe, 2, Size, Position, Rotation); } if (Recipe[3] != "0") { Size = new(D - 12, H, t); Position = new(rightBox + t * 0.5f, CenterBox.y, frontBox + (D - 12) * 0.5f); Rotation = new(0, -90, 0); AddRecvertoCabinet(BASE, Recipe, 3, Size, Position, Rotation); } if (Recipe[4] != "0") { Size = new(F, H, t); Position = new(rightBox - F * 0.5f, CenterBox.y, backBox - t * 0.5f); Rotation = new(0, 0, 0); AddRecvertoCabinet(BASE, Recipe, 4, Size, Position, Rotation); } } } public static void AddRecvertoCabinet(GameObject BASE, string[] Recipe, int IndexRecipe, Vector3 Size, Vector3 Position, Vector3 Rotation) { string[] recoverRecipe = Recipe[IndexRecipe].Split('?'); string model = recoverRecipe[0]; string texture = recoverRecipe[1]; GameObject RecoverPanel = CreateRecoverPnl("RecoverRight", model, Size, Position, Rotation, texture); RecoverPanel.transform.position = Position; RecoverPanel.transform.eulerAngles = Rotation; RecoverPanel.transform.SetParent(BASE.transform); } static GameObject CreateRecoverPnl(string Name, string Model, Vector3 Size, Vector3 Position, Vector3 Rotation, string texcode) { //print("Position.x===================================="+Position.x); if (texcode.Split('?').Length == 1) texcode += "?0"; GameObject RecoverPanel = new(Name); if (Model == "Over") { GameObject Panel = GameObject.CreatePrimitive(PrimitiveType.Cube); Panel.name = "PanelOver"; Panel.GetComponent().enabled = false; Panel.transform.localScale = Size; Panel.GetComponent().material = Instantiate(_G.TEXTURE); SetMat(Panel, texcode); DOIT.SetSizeTex(Panel, 2 * 12, 2 * 12, 0, 0, 0, 0, 0, 0); //RecoverPanel.transform.position=Position; Panel.transform.SetParent(RecoverPanel.transform); } else if (Model == "Std") { GameObject Panel = GameObject.CreatePrimitive(PrimitiveType.Cube); Panel.name = "Standard"; Panel.GetComponent().enabled = false; Size.y -= KickHeight; Panel.transform.localScale = Size; Panel.transform.position += new Vector3(0, KickHeight * 0.5f, 0); Panel.GetComponent().material = Instantiate(_G.TEXTURE); SetMat(Panel, texcode); DOIT.SetSizeTex(Panel, 2 * 12, 2 * 12, 0, 0, 0, 0, 0, 0); Panel.transform.SetParent(RecoverPanel.transform); } else if (Model == "Notch") { float PanelHeight = Size.y; GameObject Panel = GameObject.CreatePrimitive(PrimitiveType.Cube); Panel.name = "NocthTop"; Panel.GetComponent().enabled = false; Size.y -= KickHeight; Panel.transform.localScale = Size; Panel.transform.position += new Vector3(0, KickHeight * 0.5f, 0); Panel.GetComponent().material = Instantiate(_G.TEXTURE); SetMat(Panel, texcode); DOIT.SetSizeTex(Panel, 2 * 12, 2 * 12, 0, 0, 0, 0, 0, 0); Panel.transform.SetParent(RecoverPanel.transform); GameObject PanelBelow = GameObject.CreatePrimitive(PrimitiveType.Cube); PanelBelow.name = "NocthBelow"; PanelBelow.GetComponent().enabled = false; Size.y = KickHeight; Size.x -= KickFrontProjection; PanelBelow.transform.localScale = Size; float PositionY = -PanelHeight * 0.5f + KickHeight * 0.5f; PanelBelow.transform.position += new Vector3(KickFrontProjection * 0.5f, PositionY, 0); PanelBelow.GetComponent().material = Instantiate(_G.TEXTURE); SetMat(PanelBelow, texcode); DOIT.SetSizeTex(PanelBelow, 2 * 12, 2 * 12, 0, 0, 0, 0, 0, 0); PanelBelow.transform.SetParent(RecoverPanel.transform); } return RecoverPanel; } public static void SetMat(GameObject obj, string colorValue) { string colorID = colorValue.Split('?')[0]; string rotation = colorValue.Split('?')[1]; rotation = rotation == "V" ? "0" : rotation == "H" ? "90" : rotation; obj.GetComponent().material = UIT_MATERIAL.GetMaterial(colorID); obj.GetComponent().probeAnchor = ReflectionProbesUpdater.ReflectionProbeNormal.transform; } public static string GetDefaultRecoverValue(int objectIndex) { return "0_0_0_0_0_0_0"; } }