internal static void AddNewOtherConnectionRelay(PowerRelay originalRelay, PowerControl powerControl) { OtherConnectionRelay additionalRelay = originalRelay.gameObject.AddComponent <OtherConnectionRelay>(); additionalRelay.dontConnectToRelays = powerControl.otherConnectionsDisabled; additionalRelay.maxOutboundDistance = Main.config.GreenBeamRange; additionalRelay.constructable = originalRelay.constructable; if (originalRelay.powerFX != null && originalRelay.powerFX.vfxPrefab != null) { OtherRelayPowerFX powerFX = originalRelay.gameObject.AddComponent <OtherRelayPowerFX>(); powerFX.attachPoint = originalRelay.powerFX.attachPoint; powerFX.vfxPrefab = GameObject.Instantiate(originalRelay.powerFX.vfxPrefab); powerFX.vfxPrefab.SetActive(false); powerFX.vfxPrefab.GetComponent <LineRenderer>().material.SetColor(ShaderPropertyID._Color, Color.green); additionalRelay.powerFX = powerFX; } additionalRelay.AddInboundPower(originalRelay); powerControl.otherConnectionRelays.Add(additionalRelay); }
internal static BaseInboundRelay AddNewBaseConnectionRelay(PowerRelay originalRelay, PowerControl powerControl) { var additionalRelay = originalRelay.gameObject.AddComponent <BaseInboundRelay>(); additionalRelay.dontConnectToRelays = powerControl.BaseConnectionsDisabled; additionalRelay.maxOutboundDistance = 10000; additionalRelay.constructable = originalRelay.constructable; if (originalRelay.powerFX != null && originalRelay.powerFX.vfxPrefab != null) { var powerFX = originalRelay.gameObject.AddComponent <BaseInboundRelayPowerFX>(); powerFX.attachPoint = originalRelay.powerFX.attachPoint; powerFX.vfxPrefab = Instantiate(originalRelay.powerFX.vfxPrefab); powerFX.vfxPrefab.SetActive(false); powerFX.vfxPrefab.GetComponent <LineRenderer>().material.SetColor(ShaderPropertyID._Color, Color.magenta); additionalRelay.powerFX = powerFX; } additionalRelay.AddInboundPower(originalRelay); return(additionalRelay); }