protected void Start() { ModConfig modConfig = new ModConfig("SinkSettings", typeof(SinkSettings)); Settings = (SinkSettings)modConfig.Settings; if (moduleType == Type.Faulty && Settings.fault == "0") { moduleType = Type.Normal; BombModule.ModuleDisplayName = "Sink"; BombModule.ModuleType = "Sink"; } Sink_moduleId = Sink_moduleIdCounter++; ColKnobs = UnityEngine.Random.Range(0, 3); ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); Rules = new bool[6] { BombInfo.GetOffIndicators().Contains("NSA"), BombInfo.GetSerialNumberLetters().Any("AEIOU".Contains), (ColKnobs == 2), (ColFaucet == 1), (ColPipe == 0), (BombInfo.GetPorts().Contains("HDMI") || BombInfo.GetPorts().Contains("RJ45")) }; if (moduleType == Type.Normal && BombModule.GetComponent <KMSelectable>().Children.Count() > 2) { for (int i = 1; i < 8; i++) { if (i != 2) { BombModule.GetComponent <KMSelectable>().Children[i] = null; } } } if (moduleType == Type.Faulty) { spin = UnityEngine.Random.Range(0, 20); if (spin > 15) { rotate = true; } var faulty = UnityEngine.Random.Range(0, 5); Faucet = BombModule.GetComponent <KMSelectable>().Children[1]; Basin = BombModule.GetComponent <KMSelectable>().Children[3]; Pipe = BombModule.GetComponent <KMSelectable>().Children[7]; BombModule.GetComponent <KMSelectable>().Children[1] = null; for (int i = 3; i < 8; i++) { BombModule.GetComponent <KMSelectable>().Children[i] = null; } switch (faulty) { case 0: PipeMesh.material.color = Color.black; ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; for (int i = 3; i < 6; i++) { BombModule.GetComponent <KMSelectable>().Children[i] = Basin; } Basin.OnInteract += delegate() { FaultyPVC(1); return(false); }; Hot.OnInteract += delegate() { FaultyPVC(0); return(false); }; Cold.OnInteract += delegate() { FaultyPVC(2); return(false); }; BombModule.GetComponent <KMSelectable>().UpdateChildren(); goto start; case 1: ColPipe = 2; PipeMesh.material.color = new Color(0, 157 / 255f, 1); Rules[4] = false; Rules = Rules.Select(x => !x).ToArray(); break; case 2: var r = UnityEngine.Random.Range(0, 2); ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; if (r == 0) { ColdMesh.material = null; } else { HotMesh.material = null; } BombModule.GetComponent <KMSelectable>().Children[1] = Faucet; BombModule.GetComponent <KMSelectable>().Children[7] = Pipe; BombModule.GetComponent <KMSelectable>().UpdateChildren(); while (ColFaucet == ColPipe && ColKnobs == ColPipe) { ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); } if (!ColFaucet.Equals(ColKnobs) && !ColPipe.Equals(ColKnobs)) { ColPipe = ColKnobs; } FaucetMesh.material.mainTexture = knobColors[ColFaucet]; PipeMesh.material.mainTexture = knobColors[ColPipe]; if (!ColPipe.Equals(ColKnobs)) { PipeMesh.material.mainTexture = null; } Faucet.OnInteract = ButtonHandler(Faucet, 1, r); Pipe.OnInteract = ButtonHandler(Pipe, 1, r); Cold.OnInteract = ButtonHandler(Cold, 1, r); Hot.OnInteract = ButtonHandler(Hot, 1, r); Rules[3] = ColFaucet.Equals(1); Rules[4] = ColPipe.Equals(0); goto start; case 3: rotate = false; var s = UnityEngine.Random.Range(0, 2); var selectable = new[] { Faucet, Pipe }; Hot.OnInteract += delegate() { BombModule.HandleStrike(); DebugLog("Warning: Overheating"); return(false); }; if (s == 0) { Hot = Faucet; BombModule.GetComponent <KMSelectable>().Children[1] = Faucet; } else { Hot = Pipe; BombModule.GetComponent <KMSelectable>().Children[7] = Pipe; } ColKnobs = 0; ColFaucet = 0; ColPipe = 2; Rules[2] = false; Rules[3] = false; Rules[4] = false; ColdMesh.material.color = Color.black; HotMesh.material.color = Color.black; FaucetMesh.material.color = Color.black; PipeMesh.material.color = Color.black; Steps(); goto start; case 4: BombModule.transform.Rotate(0, 180, 0); Rules = Rules.Reverse().ToArray(); switch (BombInfo.GetBatteryCount()) { case 0: case 1: selectedRules = new[] { 4, 6, 5 }; break; case 2: case 3: selectedRules = new[] { 1, 3, 5 }; Rules = Rules.Select(x => !x).ToArray(); break; case 4: case 5: selectedRules = new[] { 2, 6, 3 }; Rules = Rules.Select(x => !x).ToArray(); break; default: selectedRules = new[] { 4, 1, 2 }; break; } ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; knob1 = Rules[selectedRules[0] - 1]; knob2 = Rules[selectedRules[1] - 1]; knob3 = Rules[selectedRules[2] - 1]; if (ColPipe != 2) { PipeMesh.material.mainTexture = knobColors[ColPipe]; } DebugLog("Third Knob: {0}", knob1 ? "Hot" : "Cold"); DebugLog("Second Knob: {0}", knob2 ? "Hot" : "Cold"); DebugLog("First Knob: {0}", knob3 ? "Hot" : "Cold"); DebugLog("Knobs are {0}, Faucet is {1}, Drain Pipe is {2}", textureList[ColKnobs], textureList[ColFaucet], colorList[ColPipe]); StartCoroutine(CheckForTurn()); Cold.OnInteract = ButtonHandler(Cold, 0); Hot.OnInteract = ButtonHandler(Hot, 0); canPress = true; BombModule.GetComponent <KMSelectable>().UpdateChildren(); goto start; } } ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; if (ColPipe != 2) { PipeMesh.material.mainTexture = knobColors[ColPipe]; } Steps(); start : return; }
protected void Start() { isFaulty = ModuleType == Type.Faulty; ColKnobs = UnityEngine.Random.Range(0, 3); ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); Rules = new bool[6] { Info.GetOffIndicators().Contains("NSA"), Info.GetSerialNumberLetters().Any("AEIOU".Contains), (ColKnobs == 2), (ColFaucet == 1), (ColPipe == 0), Info.GetPorts().Contains("HDMI") || Info.GetPorts().Contains("RJ45") }; if (!isFaulty) { moduleID = sink_moduleIDCounter++; } else { Module.ModuleDisplayName = "Faulty Sink"; Module.ModuleType = "Faulty Sink"; moduleID = fSink_moduleIDCounter++; HotHandler = Hot.OnInteract; ColdHandler = Cold.OnInteract; coroutine3 = Spin(); StartCoroutine(coroutine3); spin = forceSpin + UnityEngine.Random.Range(0, 20); forceSpin = spin; if (spin > 10) { rotate = true; } faulty = UnityEngine.Random.Range(0, 5); switch (faulty) { case 0: PipeMesh.material.color = Color.black; Apply(new[] { 0, 1, 2 }); for (int i = 3; i < 6; i++) { Module.GetComponent <KMSelectable>().Children[i] = Basin; } Basin.OnInteract = delegate() { FaultyPVC(1); return(false); }; Hot.OnInteract = delegate() { FaultyPVC(0); return(false); }; Cold.OnInteract = delegate() { FaultyPVC(2); return(false); }; UpdateChildren(); DebugLog("Module status is unknown. Please submit [Hot] [Basin] to automatically disable the module."); goto start; case 1: ColPipe = 2; PipeMesh.material.color = new Color(0, 157 / 255f, 1); Rules[4] = false; Rules = Rules.Select(x => !x).ToArray(); DebugLog("Debug: PVC reported as blue."); break; case 2: var r = UnityEngine.Random.Range(0, 2); GetComponent <KMSelectable>().Children[1] = Faucet; GetComponent <KMSelectable>().Children[7] = Pipe; UpdateChildren(); while (new[] { ColFaucet, ColPipe }.All(x => x == ColKnobs) || new[] { ColFaucet, ColPipe }.All(x => x != ColKnobs)) { ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); } Apply(new[] { 0, 1, 2 }); PipeMesh.material.mainTexture = knobColors[ColPipe]; if (r == 0) { ColdMesh.material = null; } else { HotMesh.material = null; } Faucet.OnInteract = ButtonHandler(Faucet, 1, r); Pipe.OnInteract = ButtonHandler(Pipe, 1, r); Cold.OnInteract = ButtonHandler(Cold, 1, r); Hot.OnInteract = ButtonHandler(Hot, 1, r); Rules[3] = ColFaucet.Equals(1); Rules[4] = ColPipe.Equals(0); DebugLog("Debug: Cannot determine status of Button{0}. Please select one of the following textures:", r); DebugLog("Knobs: {0}", knobColors[ColKnobs].name); DebugLog("Faucet: {0}", FaucetMesh.material.mainTexture.name); DebugLog("Drain Pipe: {0}", PipeMesh.material.mainTexture.name); goto start; case 3: rotate = false; var s = UnityEngine.Random.Range(0, 2); Hot.OnInteract = delegate() { Module.HandleStrike(); DebugLog("Warning: Overheating"); processingInput = false; return(false); }; hotHolder = Hot; if (s == 0) { Hot = Faucet; Module.GetComponent <KMSelectable>().Children[1] = Faucet; } else { Hot = Pipe; Module.GetComponent <KMSelectable>().Children[7] = Pipe; } ColKnobs = 0; ColKnobs = 0; ColFaucet = 0; ColPipe = 2; Rules[2] = false; Rules[3] = false; Rules[4] = false; ColdMesh.material.color = Color.black; HotMesh.material.color = Color.black; FaucetMesh.material.color = Color.black; PipeMesh.material.color = Color.black; Steps(false); goto start; case 4: transform.Rotate(0, 180, 0); Steps(true); Apply(new[] { 3, 2, 1, 0 }); goto start; } } Apply(new[] { 0, 1, 2, 3 }); Steps(false); start : Module.OnActivate += delegate { canPress = true; }; }