// Custom Light Effects Scripts // Adds custom light effects to props. // Multiple effects can be added, including vanilla ones. // The mod is not required to run the scripts or save the asset. // It's only required for loading them. // // Custom Light Effects - Main Script // Adds custom light effects to props in asset editor, visible in realtime, saves data in the prop mesh name. // DO NOT save with these effects visible! // YOU MUST run the presave script as well (below) before saving the prop asset! var slot = 0; // light effect slot, start with 0, continue adding more if needed // if you have multiple slots used, you can overwrite any of them var type = "spot"; // spot or point var intensity = 2.0f; // brightness 1-8 var range = 8.0f; // distance and glow size var bloom = 0.5f; // strength of additional spotlight glow effect var angle = 180.0f; // angle of spotlight beam var color = new Color(0.580f, 0.0f, 0.827f, 1.0f); // main color of the lightRGBA var variations = false; // set to true to use color variations Color variation1 = new Color(1.0f, 1.0f, 1.0f, 1.0f); // random color variations Color variation2 = new Color(1.0f, 1.0f, 1.0f, 1.0f); // final color appears somewhere between Color variation3 = new Color(1.0f, 1.0f, 1.0f, 1.0f); // main color and one of the variations var position = new Vector3(-16.0f, 5.2f, 0.0f); // position of the light effect var direction = new Vector3(0.0f, -1.0f, 0.0f); // direction of the light effect var off = 15.0f; // amount of hours the light is turned off during the day (15 max) (0 means always on) var random = 0.3f; // adds randomness to time lights turn on/off, if 0 then all lights turn on/off at the same time var blink = "none"; // none, blink, fade, pulse var rotation = new Vector3(0.0f, 0.0f, 0.0f); // enable rotation on X Y Z, confusing once direction is changed var rpm = 0; // rotations per minute // Light Effect Processing var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo; asset.m_hasEffects = true; var existingLightEffect = EffectCollection.FindEffect("Flood Light Orange") as LightEffect; LightEffect lightEffect = LightEffect.Instantiate(existingLightEffect); lightEffect.transform.parent = existingLightEffect.transform; Light light = lightEffect.gameObject.GetComponent(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length(); light.color = color; light.intensity = intensity; light.range = range; light.spotAngle = angle; if(type=="spot") light.type = LightType.Spot; else light.type = LightType.Point; if(blink=="blink") lightEffect.m_blinkType = LightEffect.BlinkType.Blink_050_050; else if(blink=="fade") lightEffect.m_blinkType = LightEffect.BlinkType.MediumFade_500_500; else if(blink=="pulse") lightEffect.m_blinkType = LightEffect.BlinkType.StrongBlaze_0125_0125; else lightEffect.m_blinkType = LightEffect.BlinkType.None; lightEffect.m_rotationAxis = rotation; lightEffect.m_rotationSpeed = rpm; lightEffect.m_spotLeaking = bloom; lightEffect.m_offRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09))); lightEffect.m_offRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6); if(variations==true) { lightEffect.m_variationColors[0] = variation1; lightEffect.m_variationColors[1] = variation2; lightEffect.m_variationColors[2] = variation3; } else { lightEffect.m_variationColors[0] = color; variation1 = color; lightEffect.m_variationColors[1] = color; variation2 = color; lightEffect.m_variationColors[2] = color; variation3 = color; } lightEffect.m_batchedLight = false; var inf = false; typeof(EffectInfo).GetField("m_refCount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightEffect, 0); lightEffect.InitializeEffect(); if(asset.m_effects.Length