Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of BoplShader v1.0.0
plugins\BoplShader\BoplShader.dll
Decompiled 12 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BoplShader.Lighting; using BoplShader.Rules; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BoplShader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BoplShader")] [assembly: AssemblyTitle("BoplShader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BoplShader { public enum ModLightShape { Point, Line, Cone } public sealed class ModLight { public GameObject Owner; public ModLightShape Shape; public Vector2 Offset; public Vector2 LineA; public Vector2 LineB; public Vector2 Direction = Vector2.right; public float ConeAngle = 45f; public Color Color = Color.white; public float Radius = 3f; public float Intensity = 0.5f; public float Flicker; public float Pulse; public float PulseSpeed = 6f; public float Bloom; public float Shadows = 1f; public bool Enabled = true; internal float Seed; internal float Envelope; internal LightData Last; internal bool HadFrame; internal bool Removed; } public static class BoplShaderApi { public const int ApiVersion = 1; public static bool IsActive => Plugin.Active; public static ModLight AddLight(GameObject owner, Color color, float radius, float intensity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return ModLights.Add(new ModLight { Owner = owner, Shape = ModLightShape.Point, Color = color, Radius = radius, Intensity = intensity }); } public static ModLight AddLineLight(GameObject owner, Vector2 a, Vector2 b, Color color, float radius, float intensity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return ModLights.Add(new ModLight { Owner = owner, Shape = ModLightShape.Line, LineA = a, LineB = b, Color = color, Radius = radius, Intensity = intensity }); } public static ModLight AddConeLight(GameObject owner, Vector2 localDirection, float halfAngleDegrees, Color color, float radius, float intensity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return ModLights.Add(new ModLight { Owner = owner, Shape = ModLightShape.Cone, Direction = localDirection, ConeAngle = halfAngleDegrees, Color = color, Radius = radius, Intensity = intensity }); } public static void SetLight(object light, Color color, float radius, float intensity) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (light is ModLight modLight) { modLight.Color = color; modLight.Radius = radius; modLight.Intensity = intensity; } } public static void SetIntensity(object light, float intensity) { if (light is ModLight modLight) { modLight.Intensity = intensity; } } public static void SetLine(object light, Vector2 a, Vector2 b) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (light is ModLight modLight) { modLight.LineA = a; modLight.LineB = b; } } public static void SetStyle(object light, float flicker, float pulse, float bloom) { if (light is ModLight modLight) { modLight.Flicker = flicker; modLight.Pulse = pulse; modLight.Bloom = bloom; } } public static void SetEnabled(object light, bool enabled) { if (light is ModLight modLight) { modLight.Enabled = enabled; } } public static void RemoveLight(object light) { if (light is ModLight modLight) { modLight.Removed = true; } } public static void Flash(Vector2 position, Color color, float radius, float intensity, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Flashes.Add(position, position, color, radius, intensity, duration, 0.08f); } public static void LineFlash(Vector2 a, Vector2 b, Color color, float radius, float intensity, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Flashes.Add(a, b, color, radius, intensity, duration, 0.08f); } public static void AddEmissive(Renderer renderer, float strength) { if ((Object)(object)renderer != (Object)null) { ModLights.Emissives[renderer] = strength; } } public static void RemoveEmissive(Renderer renderer) { if ((Object)(object)renderer != (Object)null) { ModLights.Emissives.Remove(renderer); } } public static void AddShadowCaster(GameObject owner, float radius, float opacity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) AddShadowCapsule(owner, Vector2.zero, Vector2.zero, radius, opacity); } public static void AddShadowCapsule(GameObject owner, Vector2 localA, Vector2 localB, float radius, float opacity) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner != (Object)null) { ModLights.Casters.Add(new ModLights.ModCaster { Owner = owner, A = localA, B = localB, Radius = radius, Opacity = Mathf.Clamp01(opacity) }); } } public static void AddSurface(SpriteRenderer renderer, bool smoke) { if ((Object)(object)renderer != (Object)null && Scanner.ClaimSurface(((Component)renderer).gameObject)) { Scanner.Add(new SurfaceTracker(((Component)renderer).gameObject, (SpriteRenderer[])(object)new SpriteRenderer[1] { renderer }, smoke ? SurfaceKind.Smoke : SurfaceKind.Object)); } } public static void RegisterComponentLight(Type componentType, Func<Component, bool> perFrame) { if (componentType != null && perFrame != null) { Scanner.ApiRule(componentType, perFrame); } } public static void FrameLight(Vector2 position, Color color, float radius, float intensity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) Frame.Point(position, color, radius, intensity); } } [BepInPlugin("com.boplshader.lighting", "BoplShader", "1.0.0")] [BepInProcess("BoplBattle.exe")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "com.boplshader.lighting"; public const string DisplayName = "BoplShader"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private static bool loaded; internal static bool Active { get { if (loaded) { return ShaderConfig.Enabled.Value; } return false; } } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; try { ShaderConfig.Bind(((BaseUnityPlugin)this).Config); if (!SystemInfo.supportsRenderTextures || !ShaderAssets.Load()) { Log.LogError((object)"BoplShader could not load its shaders; the game runs with vanilla visuals."); return; } VanillaRules.Install(); Background.Install(); new Harmony("com.boplshader.lighting").PatchAll(typeof(Plugin).Assembly); GameObject val = new GameObject("BoplShader"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<LightingRenderer>(); val.AddComponent<ShaderControls>(); val.AddComponent<UiShading>(); loaded = true; Log.LogInfo((object)string.Format("{0} {1} loaded ({2} quality, {3}).", "BoplShader", "1.0.0", ShaderConfig.Preset.Value, SystemInfo.graphicsDeviceType)); } catch (Exception arg) { Log.LogError((object)string.Format("{0} failed to initialise; the game runs with vanilla visuals. {1}", "BoplShader", arg)); } } } internal sealed class ShaderControls : MonoBehaviour { private string cmdFile; private string outDir; private float nextPoll; private void Start() { cmdFile = Path.Combine(Paths.BepInExRootPath, "boplshader_cmd.txt"); outDir = Path.Combine(Paths.BepInExRootPath, "boplshader_dev"); } private void Update() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null) { if (Pressed(current, ShaderConfig.ToggleKey.Value)) { ShaderConfig.Enabled.Value = !ShaderConfig.Enabled.Value; } if (Pressed(current, ShaderConfig.PresetKey.Value)) { ShaderConfig.Preset.Value = (QualityPreset)((int)(ShaderConfig.Preset.Value + 1) % 3); } } if (ShaderConfig.DevCommands.Value && Time.unscaledTime >= nextPoll) { nextPoll = Time.unscaledTime + 0.25f; Poll(); } } private static bool Pressed(Keyboard kb, Key key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return ((ButtonControl)kb[key]).wasPressedThisFrame; } return false; } private void Poll() { //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(cmdFile)) { return; } string[] array; try { array = File.ReadAllLines(cmdFile); File.Delete(cmdFile); } catch (IOException) { return; } string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i].Trim(); if (text.Length == 0) { continue; } string[] array3 = text.Split(new char[1] { ' ' }); Plugin.Log.LogInfo((object)("shader> " + text)); try { string text2 = array3[0].ToLowerInvariant(); if (text2 == null) { continue; } switch (text2.Length) { case 3: switch (text2[0]) { case 'o': if (text2 == "off") { ShaderConfig.Enabled.Value = false; } break; case 's': if (text2 == "set") { Set(array3[1], float.Parse(array3[2], CultureInfo.InvariantCulture)); } break; } break; case 4: switch (text2[0]) { case 'v': if (text2 == "view") { LightingRenderer.DebugView = int.Parse(array3[1]); } break; case 's': if (text2 == "shot") { Directory.CreateDirectory(outDir); ScreenCapture.CaptureScreenshot(Path.Combine(outDir, ((array3.Length > 1) ? array3[1] : DateTime.Now.ToString("HHmmss")) + ".png")); } break; } break; case 5: switch (text2[0]) { case 's': if (text2 == "stats") { Plugin.Log.LogInfo((object)("shader stats: " + LightingRenderer.Stats)); } break; case 'f': if (text2 == "flash") { Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Flashes.Add(Vector2.op_Implicit(((Component)main).transform.position), Vector2.op_Implicit(((Component)main).transform.position), new Color(0.62f, 0.82f, 1f), 8f, 1.2f, 2f, 0.1f); } } break; } break; case 2: if (text2 == "on") { ShaderConfig.Enabled.Value = true; } break; case 7: if (text2 == "quality") { ShaderConfig.Preset.Value = (QualityPreset)Enum.Parse(typeof(QualityPreset), array3[1], ignoreCase: true); } break; case 6: break; } } catch (Exception ex2) { Plugin.Log.LogWarning((object)("shader command '" + text + "' failed: " + ex2.Message)); } } } private static void Set(string key, float v) { switch (key.ToLowerInvariant()) { case "light": ShaderConfig.LightIntensity.Value = v; break; case "shadow": ShaderConfig.ShadowStrength.Value = v; break; case "bloom": ShaderConfig.BloomStrength.Value = v; break; case "ambient": ShaderConfig.AmbientDarkening.Value = v; break; case "depth": ShaderConfig.DepthShading.Value = v; break; case "sun": ShaderConfig.SunAngle.Value = v; break; } } } internal static class ShaderAssets { public static Material Surface { get; private set; } public static Material Light { get; private set; } public static Material Composite { get; private set; } public static Material Bloom { get; private set; } public static Material Terrain { get; private set; } public static Material Grade { get; private set; } public static bool GradeReady { get { if ((Object)(object)Terrain != (Object)null) { return (Object)(object)Grade != (Object)null; } return false; } } public static Shader UI { get; private set; } public static Material Water { get; private set; } public static Material Post { get; private set; } public static Mesh Quad { get; private set; } public static bool Ready { get { if ((Object)(object)Surface != (Object)null && (Object)(object)Light != (Object)null && (Object)(object)Composite != (Object)null) { return (Object)(object)Bloom != (Object)null; } return false; } } public static bool Load() { byte[] array; using (Stream stream = typeof(ShaderAssets).Assembly.GetManifestResourceStream("BoplShader.boplshader.bundle")) { if (stream == null) { Plugin.Log.LogError((object)"Shader bundle missing from the DLL; run tools/build-shaders.ps1 and rebuild."); return false; } array = new byte[stream.Length]; for (int i = 0; i < array.Length; i += stream.Read(array, i, array.Length - i)) { } } AssetBundle val = AssetBundle.LoadFromMemory(array); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Shader bundle could not be loaded (was it built with Unity 2022.3.60f1?)."); return false; } Surface = Make(val, "Hidden/BoplShader/Surface"); Light = Make(val, "Hidden/BoplShader/Light"); Composite = Make(val, "Hidden/BoplShader/Composite"); Bloom = Make(val, "Hidden/BoplShader/Bloom"); Terrain = Make(val, "Hidden/BoplShader/Terrain"); Grade = Make(val, "Hidden/BoplShader/Grade"); Water = Make(val, "Hidden/BoplShader/Water"); Post = Make(val, "Hidden/BoplShader/Post"); Shader[] array2 = val.LoadAllAssets<Shader>(); foreach (Shader val2 in array2) { if (((Object)val2).name == "Hidden/BoplShader/UI" && val2.isSupported) { UI = val2; } } val.Unload(false); Quad = BuildQuad(); return Ready; } private static Material Make(AssetBundle bundle, string name) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown Shader[] array = bundle.LoadAllAssets<Shader>(); foreach (Shader val in array) { if (!(((Object)val).name != name)) { if (!val.isSupported) { Plugin.Log.LogError((object)(name + " is not supported on this GPU / graphics API.")); return null; } return new Material(val) { hideFlags = (HideFlags)61 }; } } Plugin.Log.LogError((object)(name + " not found in the shader bundle.")); return null; } private static Mesh BuildQuad() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh { name = "BoplShaderQuad", hideFlags = (HideFlags)61 }; val.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val.triangles = new int[6] { 0, 2, 1, 0, 3, 2 }; val.bounds = new Bounds(Vector3.zero, new Vector3(1f, 1f, 1f)); val.UploadMeshData(true); return val; } } public enum QualityPreset { Low, Medium, High } internal sealed class Look { public float BufferScale; public int MaxLights; public int MaxCasters; public bool SunShadows; public bool LightShadows; public bool SpriteShading; public bool WaterLight; public float ShadowSoftness; public float SunStrength; public float ShadeStrength; public float Ambient; public float ShadowStrength; public float LightGain; public float LightHalo; public float Bloom; public float WaterReflect; public float SmokeResponse; public float ContactStrength; public float WaterSamples; public bool Grade = true; public float TerrainScale = 1f; public float TerrainGrade = 1f; public float BackgroundGrade = 1f; public float SunGlow = 1f; public float Relief = 1f; public float Overhang = 1f; public float TerrainAlbedo = 0.62f; public float SkyDepth = 1f; public float SeaDepth = 1f; public float Reflection = 1f; public float Ripple = 1f; public float Cinematic; public float EffectGlow = 1.4f; public float SpillLight = 1.2f; public float SpillGlow = 0.45f; public float UiLight = 1f; public static Look For(QualityPreset p) { return p switch { QualityPreset.Low => new Look { BufferScale = 0.25f, MaxLights = 6, MaxCasters = 0, SunShadows = false, LightShadows = false, SpriteShading = false, WaterLight = false, ShadowSoftness = 0.25f, SunStrength = 0.3f, ShadeStrength = 0.7f, Ambient = 0.025f, ShadowStrength = 0f, LightGain = 1.1f, LightHalo = 0.12f, Bloom = 0.16f, WaterReflect = 0f, SmokeResponse = 0.8f, ContactStrength = 0f, WaterSamples = 1f, TerrainScale = 0.5f, Relief = 0.7f, Overhang = 0.6f, Reflection = 0f, UiLight = 0.7f }, QualityPreset.High => new Look { BufferScale = 0.67f, MaxLights = 24, MaxCasters = 32, SunShadows = true, LightShadows = true, SpriteShading = true, WaterLight = true, ShadowSoftness = 0.3f, SunStrength = 0.32f, ShadeStrength = 0.8f, Ambient = 0.025f, ShadowStrength = 0.28f, LightGain = 1.3f, LightHalo = 0.16f, Bloom = 0.35f, WaterReflect = 0.7f, SmokeResponse = 1f, ContactStrength = 1f, WaterSamples = 3f, Cinematic = 1f, Ripple = 1.3f }, _ => new Look { BufferScale = 0.5f, MaxLights = 12, MaxCasters = 24, SunShadows = true, LightShadows = true, SpriteShading = true, WaterLight = true, ShadowSoftness = 0.24f, SunStrength = 0.32f, ShadeStrength = 0.8f, Ambient = 0.025f, ShadowStrength = 0.28f, LightGain = 1.3f, LightHalo = 0.16f, Bloom = 0.35f, WaterReflect = 0.7f, SmokeResponse = 0.95f, ContactStrength = 1f, WaterSamples = 1f, TerrainScale = 1f, Ripple = 0.8f }, }; } } internal static class ShaderConfig { public static ConfigEntry<bool> Enabled; public static ConfigEntry<QualityPreset> Preset; public static ConfigEntry<float> LightIntensity; public static ConfigEntry<float> ShadowStrength; public static ConfigEntry<float> BloomStrength; public static ConfigEntry<float> AmbientDarkening; public static ConfigEntry<float> DepthShading; public static ConfigEntry<float> SunAngle; public static ConfigEntry<float> BackgroundShading; public static ConfigEntry<Key> ToggleKey; public static ConfigEntry<Key> PresetKey; public static ConfigEntry<bool> DevCommands; private static Look cached; private static QualityPreset cachedFor = (QualityPreset)(-1); public static Look Look { get { if (cached == null || cachedFor != Preset.Value) { cached = Look.For(Preset.Value); cachedFor = Preset.Value; } return cached; } } public static void Bind(ConfigFile cfg) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown Enabled = cfg.Bind<bool>("General", "Enabled", true, "Turn the lighting system on or off."); Preset = cfg.Bind<QualityPreset>("General", "Quality", QualityPreset.High, "Low: level colours, terrain light and ability light with the game's own water reflection. Medium: adds the rebuilt, clear water reflection and cast shadows. High (default): cinematic - god rays, cloud bloom, sea glitter and caustics, aurora curtains, filmic finish."); ToggleKey = cfg.Bind<Key>("General", "ToggleKey", (Key)101, "Key that switches the lighting on and off (handy for comparing with vanilla)."); PresetKey = cfg.Bind<Key>("General", "QualityKey", (Key)102, "Key that cycles Low / Medium / High."); LightIntensity = cfg.Bind<float>("Tuning", "LightIntensity", 1f, new ConfigDescription("Brightness of ability lights. 1 is the intended look; above 1 goes past the reference style.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); ShadowStrength = cfg.Bind<float>("Tuning", "ShadowStrength", 1f, new ConfigDescription("Darkness of cast shadows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); BloomStrength = cfg.Bind<float>("Tuning", "BloomStrength", 1f, new ConfigDescription("Glow around emissive effects only.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); AmbientDarkening = cfg.Bind<float>("Tuning", "AmbientDarkening", 1f, new ConfigDescription("Subtle ambient depth on gameplay surfaces. Daytime sky and water stay bright.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); DepthShading = cfg.Bind<float>("Tuning", "DepthShading", 1f, new ConfigDescription("Rounded shading on players and platforms.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); BackgroundShading = cfg.Bind<float>("Tuning", "BackgroundShading", 1f, new ConfigDescription("Soft sun shading on clouds and floating background objects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); SunAngle = cfg.Bind<float>("Tuning", "SunAngle", 125f, new ConfigDescription("Direction the daylight and sun glow come from, in degrees (90 = straight above, 125 = upper left).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 150f), Array.Empty<object>())); DevCommands = cfg.Bind<bool>("Dev", "EnableDevCommands", false, "Poll BepInEx/boplshader_cmd.txt for on/off/quality/shot commands (for testing)."); } } } namespace BoplShader.Rules { internal static class Background { private static readonly List<SpriteRenderer> sprites = new List<SpriteRenderer>(32); private const float MaxSize = 45f; public static float HorizonY = float.NaN; public static void Install() { SceneManager.sceneLoaded += delegate { Collect(); }; } private static void Collect() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) sprites.Clear(); HorizonY = float.NaN; SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>(); foreach (SpriteRenderer val in array) { Bounds bounds; if (((Object)val).name == "WaterGradient" && ((Renderer)val).enabled) { bounds = ((Renderer)val).bounds; HorizonY = ((Bounds)(ref bounds)).max.y; Plugin.Log.LogInfo((object)$"Horizon at {HorizonY:F2} (water {SceneBounds.WaterHeight})"); } if (((Component)val).gameObject.layer == 20 && !((Object)(object)val.sprite == (Object)null)) { bounds = ((Renderer)val).bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(size.x > 45f) && !(size.y > 45f)) { sprites.Add(val); } } } } public static void Emit() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) for (int num = sprites.Count - 1; num >= 0; num--) { SpriteRenderer val = sprites[num]; if ((Object)(object)val == (Object)null) { sprites.RemoveAt(num); } else if (((Renderer)val).enabled && ((Renderer)val).isVisible && ((Component)val).gameObject.activeInHierarchy && val.color.a > 0.3f) { Frame.Surface((Renderer)(object)val, SurfaceKind.Background); } } } } internal static class VanillaRules { public static readonly Color Tesla = new Color(0.62f, 0.82f, 1f); public static readonly Color Fire = new Color(1f, 0.6f, 0.26f); public static readonly Color Fuse = new Color(1f, 0.68f, 0.32f); public static readonly Color Blast = new Color(1f, 0.84f, 0.58f); public static readonly Color WhiteHole = new Color(1f, 0.97f, 0.9f); public static void Install() { Scanner.Rule<StickyRoundedRectangle>((Func<StickyRoundedRectangle, Tracker>)((StickyRoundedRectangle p) => new PlatformTracker(p))); Scanner.Rule<SlimeController>((Func<SlimeController, Tracker>)((SlimeController s) => new PlayerTracker(s))); Scanner.Rule<SimpleSparkNode>((Func<SimpleSparkNode, Tracker>)((SimpleSparkNode n) => new SparkNodeTracker(n))); Scanner.Rule<StretchableLightning>((Func<StretchableLightning, Tracker>)((StretchableLightning l) => (!((Object)(object)((Component)l).transform.parent != (Object)null) || !((Object)(object)((Component)((Component)l).transform.parent).GetComponent<StretchableLightning>() != (Object)null)) ? new LightningTracker(l) : null)); Scanner.Rule<RocketEngine>((Func<RocketEngine, Tracker>)((RocketEngine e) => new EngineTracker(e))); Scanner.Rule<Grenade>((Func<Grenade, Tracker>)((Grenade g) => new GrenadeTracker(g))); Scanner.Rule<Explosion>((Func<Explosion, Tracker>)((Explosion x) => (!((Object)(object)((Component)x).GetComponent<BeamObject>() != (Object)null)) ? new ExplosionTracker(x) : null)); Scanner.Rule<Mine>((Func<Mine, Tracker>)((Mine m) => new MineTracker(m))); Scanner.Rule<BeamObject>((Func<BeamObject, Tracker>)((BeamObject b) => new BeamTracker(b))); Scanner.Rule<MeteorSmash>((Func<MeteorSmash, Tracker>)((MeteorSmash m) => new MeteorTracker(m))); Scanner.Rule<FlammableSmoke>((Func<FlammableSmoke, Tracker>)((FlammableSmoke s) => new SmokeTracker(s))); Scanner.Rule<BlackHole>((Func<BlackHole, Tracker>)((BlackHole h) => new BlackHoleTracker(h))); Scanner.Rule<TeleportIndicator>((Func<TeleportIndicator, Tracker>)((TeleportIndicator t) => new TeleportTracker(t))); Scanner.Rule<TeleportedObjectEffect>((Func<TeleportedObjectEffect, Tracker>)((TeleportedObjectEffect t) => new OneShot((Component)(object)t, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Flashes.Add(Vector2.op_Implicit(((Component)t).transform.position), Vector2.op_Implicit(((Component)t).transform.position), new Color(0.85f, 0.92f, 1f), 2.6f, 0.6f, 0.3f, 0.1f); }))); Scanner.Rule<ReviveEffect>((Func<ReviveEffect, Tracker>)((ReviveEffect r) => new ReviveTracker(r))); Scanner.Rule<RevivePositionIndicator>((Func<RevivePositionIndicator, Tracker>)((RevivePositionIndicator r) => new ReviveMarkerTracker(r))); Scanner.Rule<Missile>((Func<Missile, Tracker>)((Missile m) => new MissileTracker(m))); } public static float ScaleOf(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Mathf.Clamp(Mathf.Abs(t.lossyScale.x), 0.4f, 3.5f); } public static Color PlayerColor(int id) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) PlayerHandler val = PlayerHandler.Get(); Player val2 = ((val != null) ? val.GetPlayer(id) : null); if (val2 != null && (Object)(object)val2.Color != (Object)null) { if (val2.Color.HasProperty("_MainColor")) { return val2.Color.GetColor("_MainColor"); } if (val2.Color.HasProperty("_ShadowColor")) { return val2.Color.GetColor("_ShadowColor"); } } return Color.white; } } internal abstract class Follow<T> : Tracker where T : Component { protected readonly T C; protected readonly float Seed; protected Follow(T c) { C = c; Seed = (float)(((Object)(object)c).GetInstanceID() & 0x3FF) * 0.731f; } public sealed override bool Tick() { if ((Object)(object)C == (Object)null) { return false; } if (!((Component)C).gameObject.activeInHierarchy) { Inactive(); return true; } Active(); return true; } protected virtual void Inactive() { } protected abstract void Active(); } internal sealed class SurfaceTracker : Tracker { private readonly GameObject go; private readonly int id; private readonly SpriteRenderer[] renderers; private readonly SurfaceKind kind; public SurfaceTracker(GameObject go, SpriteRenderer[] renderers, SurfaceKind kind) { this.go = go; id = ((Object)go).GetInstanceID(); this.renderers = renderers; this.kind = kind; } public override bool Tick() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { Scanner.ReleaseSurface(id); return false; } if (!go.activeInHierarchy) { return true; } float num = ((kind == SurfaceKind.Player) ? 0.97f : 0.3f); for (int i = 0; i < renderers.Length; i++) { SpriteRenderer val = renderers[i]; if ((Object)(object)val != (Object)null && ((Renderer)val).enabled && (Object)(object)val.sprite != (Object)null && ((Renderer)val).isVisible && val.color.a >= num) { Frame.Surface((Renderer)(object)val, kind); if (kind == SurfaceKind.Object) { Frame.Contact((Renderer)(object)val); } } } return true; } } internal sealed class PlatformTracker : Follow<StickyRoundedRectangle> { private readonly SpriteRenderer sr; private readonly SpriteRenderer[] foliage; public PlatformTracker(StickyRoundedRectangle p) : base(p) { sr = ((Component)p).GetComponent<SpriteRenderer>(); SpriteRenderer[] componentsInChildren = ((Component)p).GetComponentsInChildren<SpriteRenderer>(true); List<SpriteRenderer> list = new List<SpriteRenderer>(2); SpriteRenderer[] array = componentsInChildren; foreach (SpriteRenderer val in array) { if ((Object)(object)val != (Object)(object)sr && ((Object)val).name.StartsWith("AnimatedGrass", StringComparison.Ordinal)) { list.Add(val); } } foliage = list.ToArray(); } protected override void Active() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) DPhysicsRoundedRect rr = C.rr; if ((Object)(object)rr == (Object)null || !rr.initHasBeenCalled || ((Object)(object)sr != (Object)null && !((Renderer)sr).enabled)) { return; } Vector2 val = (Vector2)rr.CalcExtents(); float num = (float)rr.radius; if (val.x + num < 0.05f || val.y + num < 0.05f) { return; } Vector2 val2 = Vector2.op_Implicit(((Component)C).transform.position); float num2 = ((Component)C).transform.eulerAngles.z * ((float)Math.PI / 180f); Frame.Platforms.Add(new PlatformSurface { Center = val2, Rotation = num2, Extents = val, Bevel = num, Renderer = sr, Foliage = foliage, Type = C.platformType + 1 }); for (int i = 0; i < foliage.Length; i++) { SpriteRenderer val3 = foliage[i]; if ((Object)(object)val3 != (Object)null && ((Renderer)val3).enabled && (Object)(object)val3.sprite != (Object)null && ((Renderer)val3).isVisible && ((Component)val3).gameObject.activeInHierarchy) { Frame.Surface((Renderer)(object)val3, SurfaceKind.Object); } } Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(Mathf.Cos(num2), Mathf.Sin(num2)); float num3 = val.x; float num4 = val.y; if (val.y > val.x) { ((Vector2)(ref val4))..ctor(0f - val4.y, val4.x); num3 = val.y; num4 = val.x; } float num5 = num4 + num; float num6 = Mathf.Max(0f, num3 + num - num5); Frame.Caster(val2 - val4 * num6, val2 + val4 * num6, num5, 1f); } } internal sealed class PlayerTracker : Follow<SlimeController> { public PlayerTracker(SlimeController s) : base(s) { } protected override void Active() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer playerSprite = C.GetPlayerSprite(); if (!((Object)(object)playerSprite == (Object)null) && ((Renderer)playerSprite).enabled && !((Object)(object)playerSprite.sprite == (Object)null) && ((Renderer)playerSprite).isVisible && !(playerSprite.color.a < 0.97f)) { Frame.Surface((Renderer)(object)playerSprite, SurfaceKind.Player); Bounds bounds = ((Renderer)playerSprite).bounds; Vector2 val = Vector2.op_Implicit(((Bounds)(ref bounds)).center); bounds = ((Renderer)playerSprite).bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = ((Renderer)playerSprite).bounds; float radius = Mathf.Min(x, ((Bounds)(ref bounds)).extents.y) * 0.75f; Frame.Caster(val, val, radius, 0.5f); Frame.Contact((Renderer)(object)playerSprite); } } } internal sealed class SparkNodeTracker : Follow<SimpleSparkNode> { private bool wasLit; public SparkNodeTracker(SimpleSparkNode n) : base(n) { } protected override void Inactive() { wasLit = false; } protected override void Active() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer val = ((C.LitOrbs != null && C.LitOrbs.Length != 0) ? C.LitOrbs[0] : null); Vector2 val2 = (((Object)(object)val != (Object)null) ? Vector2.op_Implicit(((Component)val).transform.position) : Vector2.op_Implicit(((Component)C).transform.position)); float num = VanillaRules.ScaleOf(((Component)C).transform); bool flag = (Object)(object)val != (Object)null && ((Renderer)val).enabled; if (flag) { Frame.Point(val2, VanillaRules.Tesla, 4.2f * num, 0.6f * Frame.Flicker(Seed, 9f, 0.14f), 0.1f, 1f, 1.5f); Frame.Emissive((Renderer)(object)val, 0.18f); if (!wasLit) { Flashes.Add(val2, val2, VanillaRules.Tesla, 6f * num, 1f, 0.2f, 0.14f); } } else { Frame.Point(val2, VanillaRules.Tesla, 1.8f * num, 0.14f, 0f, 1f, 0.4f); } wasLit = flag; } } internal sealed class LightningTracker : Follow<StretchableLightning> { private SpriteRenderer sr; private SpriteRenderer child; private bool wasOn; public LightningTracker(StretchableLightning l) : base(l) { } protected override void Inactive() { wasOn = false; } protected override void Active() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sr == (Object)null) { sr = ((Component)C).GetComponent<SpriteRenderer>(); if (((Component)C).transform.childCount > 0) { child = ((Component)((Component)C).transform.GetChild(0)).GetComponent<SpriteRenderer>(); } } if ((Object)(object)sr == (Object)null || !((Renderer)sr).enabled || (Object)(object)sr.sprite == (Object)null) { wasOn = false; return; } Bounds bounds = sr.sprite.bounds; Vector2 a = Vector2.op_Implicit(((Component)sr).transform.TransformPoint(new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).center.y, 0f))); Vector2 b = Vector2.op_Implicit(((Component)sr).transform.TransformPoint(new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).center.y, 0f))); bool flag = (Object)(object)C.hitbox == (Object)null || ((Behaviour)C.hitbox).enabled; float intensity = (flag ? (0.55f * Frame.Flicker(Seed, 16f, 0.22f)) : 0.16f); Frame.Line(a, b, VanillaRules.Tesla, 2.6f, intensity, flag ? 0.1f : 0f, 1f, 1.4f); if (flag) { Frame.Emissive((Renderer)(object)sr, 0.22f); Frame.Emissive((Renderer)(object)child, 0.22f); } if (flag && !wasOn) { Flashes.Add(a, b, VanillaRules.Tesla, 4f, 1.1f, 0.18f, 0.12f); } wasOn = flag; } } internal sealed class EngineTracker : Follow<RocketEngine> { private SpriteRenderer flame; private readonly SpriteRenderer body; private float fade; private Vector3 flameOffset; private bool hasFlame; public EngineTracker(RocketEngine e) : base(e) { body = ((Component)e).GetComponent<SpriteRenderer>(); } protected override void Inactive() { fade = 0f; hasFlame = false; } protected override void Active() { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body != (Object)null && ((Renderer)body).enabled) { Frame.Contact((Renderer)(object)body); } fade = Mathf.MoveTowards(fade, C.isEngineOn ? 1f : 0f, Time.deltaTime * (C.isEngineOn ? 18f : 9f)); if (fade <= 0f) { return; } if ((Object)(object)flame == (Object)null && ((Component)C).transform.childCount > 0) { flame = ((Component)((Component)C).transform.GetChild(0)).GetComponent<SpriteRenderer>(); } if ((Object)(object)flame != (Object)null && (Object)(object)flame.sprite != (Object)null) { Transform transform = ((Component)C).transform; Bounds bounds = ((Renderer)flame).bounds; flameOffset = transform.InverseTransformPoint(((Bounds)(ref bounds)).center); hasFlame = true; } if (hasFlame) { Vector2 val = Vector2.op_Implicit(((Component)C).transform.position); Vector2 val2 = Vector2.op_Implicit(((Component)C).transform.TransformPoint(flameOffset)); Vector2 val3 = val2 - val; if (((Vector2)(ref val3)).sqrMagnitude < 0.0001f) { val3 = -Vector2.op_Implicit(((Component)C).transform.up); } ((Vector2)(ref val3)).Normalize(); float num = VanillaRules.ScaleOf(((Component)C).transform); float num2 = Frame.Flicker(Seed, 12f, 0.16f) * fade; Frame.Cone(val + val3 * 0.4f * num, val3, 0.3f, VanillaRules.Fire, 5.5f * num, 0.75f * num2, 0.1f, 1.5f); Frame.Point(val2, VanillaRules.Fire, 2.2f * num, 0.35f * num2, 0f, 1f, 0.8f); if ((Object)(object)flame != (Object)null && ((Renderer)flame).enabled && (Object)(object)flame.sprite != (Object)null) { Frame.Emissive((Renderer)(object)flame, 0.3f * fade); } } } } internal sealed class GrenadeTracker : Follow<Grenade> { private readonly SpriteRenderer sr; public GrenadeTracker(Grenade g) : base(g) { sr = ((Component)g).GetComponent<SpriteRenderer>(); } protected override void Active() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sr != (Object)null) || ((Renderer)sr).enabled) { float num; if (!((Object)(object)sr != (Object)null)) { num = 0.4f; } else { Bounds bounds = ((Renderer)sr).bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = ((Renderer)sr).bounds; num = Mathf.Max(x, ((Bounds)(ref bounds)).extents.y) * 0.85f; } float num2 = num; Frame.Point(Vector2.op_Implicit(((Component)C).transform.position) + Vector2.op_Implicit(((Component)C).transform.up) * num2, VanillaRules.Fuse, 1.7f, 0.42f * Frame.Flicker(Seed, 20f, 0.3f), 0.14f, 1f, 0.7f); } } } internal sealed class ExplosionTracker : Follow<Explosion> { private bool wasActive; public ExplosionTracker(Explosion x) : base(x) { } protected override void Inactive() { wasActive = false; } protected override void Active() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!wasActive) { wasActive = true; SpriteRenderer componentInChildren = ((Component)C).GetComponentInChildren<SpriteRenderer>(); float num; if (!((Object)(object)componentInChildren != (Object)null)) { num = 0f; } else { Bounds bounds = ((Renderer)componentInChildren).bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = ((Renderer)componentInChildren).bounds; num = Mathf.Max(x, ((Bounds)(ref bounds)).extents.y); } float num2 = num; if (num2 < 0.3f) { num2 = Mathf.Abs(((Component)C).transform.lossyScale.x) * 1.5f; } float radius = Mathf.Clamp(num2 * 2.4f, 3f, 12f); Flashes.Add(Vector2.op_Implicit(((Component)C).transform.position), Vector2.op_Implicit(((Component)C).transform.position), VanillaRules.Blast, radius, 1.15f, 0.28f, 0.1f); } } } internal sealed class MineTracker : Follow<Mine> { public MineTracker(Mine m) : base(m) { } protected override void Active() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer light = C.Light; if (!((Object)(object)light == (Object)null) && ((Renderer)light).enabled && !(light.color.a < 0.02f)) { float num = Mathf.Clamp01(light.color.a / 0.784f); Color c = default(Color); ((Color)(ref c))..ctor(light.color.r, light.color.g, light.color.b); Frame.Point(Vector2.op_Implicit(((Component)light).transform.position), c, 2.1f, 0.5f * num, 0.08f, 1f, 0.9f); Frame.Emissive((Renderer)(object)light, 0.3f); } } } internal sealed class BeamTracker : Follow<BeamObject> { public BeamTracker(BeamObject b) : base(b) { } protected override void Active() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) BeamEffect beamEffect = C.beamEffect; if (!((Object)(object)beamEffect == (Object)null) && !((Object)(object)C.fixTrans == (Object)null) && !((Object)(object)C.hitbox == (Object)null) && C.hitbox.initHasBeenCalled && !(beamEffect.beamLength <= 0.05f)) { Vector2 val = (Vector2)C.fixTrans.position; Vector2 val2 = (Vector2)C.hitbox.right; Vector2 normalized = ((Vector2)(ref val2)).normalized; Vector2 b = val + normalized * beamEffect.beamLength; float num = Mathf.Abs(((Component)C).transform.localScale.y); Color c = (Color)(((Object)(object)beamEffect.orange != (Object)null) ? beamEffect.orange.color : new Color(1f, 0.8f, 0.4f)); c.a = 1f; Frame.Line(val, b, c, 2f + num, 0.55f * Frame.Flicker(Seed, 22f, 0.08f), 0.05f, 1f, 2f); Frame.Emissive((Renderer)(object)beamEffect.white, 0.22f); Frame.Emissive((Renderer)(object)beamEffect.yellow, 0.15f); } } } internal sealed class MeteorTracker : Follow<MeteorSmash> { private bool wasDashing; public MeteorTracker(MeteorSmash m) : base(m) { } protected override void Inactive() { wasDashing = false; } protected override void Active() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)C.state == 3; Vector2 val = Vector2.op_Implicit(((Component)C).transform.position); if (flag) { Frame.Point(val, VanillaRules.Fire, 3.8f, 0.6f * Frame.Flicker(Seed, 14f, 0.15f), 0.06f, 1f, 1.5f); } else if (wasDashing) { Flashes.Add(val, val, new Color(1f, 0.72f, 0.42f), 5.5f, 1f, 0.22f, 0.08f); } wasDashing = flag; } } internal sealed class SmokeTracker : Follow<FlammableSmoke> { private readonly SpriteRenderer puff; public SmokeTracker(FlammableSmoke s) : base(s) { puff = ((Component)s).GetComponentInChildren<SpriteRenderer>(); if (Scanner.ClaimSurface(((Component)s).gameObject)) { Scanner.Add(new SurfaceTracker(((Component)s).gameObject, ((Component)s).GetComponentsInChildren<SpriteRenderer>(true), SurfaceKind.Smoke)); } } protected override void Active() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)puff != (Object)null && ((Renderer)puff).enabled && puff.color.a > 0.3f) { Bounds bounds = ((Renderer)puff).bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = ((Renderer)puff).bounds; float radius = Mathf.Min(x, ((Bounds)(ref bounds)).extents.y) * 0.6f; bounds = ((Renderer)puff).bounds; Vector2 a = Vector2.op_Implicit(((Bounds)(ref bounds)).center); bounds = ((Renderer)puff).bounds; Frame.Caster(a, Vector2.op_Implicit(((Bounds)(ref bounds)).center), radius, 0.08f * puff.color.a); } if (!(C.timeSinceDetonated < 0L)) { float num = Mathf.Clamp01((float)C.timeSinceDetonated / Mathf.Max(0.05f, (float)C.detonationDelay)); Frame.Point(Vector2.op_Implicit(((Component)C).transform.position), VanillaRules.Fire, 2.5f, 0.2f + 0.5f * num); } } } internal sealed class BlackHoleTracker : Follow<BlackHole> { public BlackHoleTracker(BlackHole h) : base(h) { } protected override void Active() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer spriteRen = C.spriteRen; if (!((Object)(object)spriteRen == (Object)null) && ((Renderer)spriteRen).enabled) { Bounds bounds = ((Renderer)spriteRen).bounds; float num = Mathf.Max(((Bounds)(ref bounds)).extents.x, 0.1f); Vector2 p = Vector2.op_Implicit(((Component)C).transform.position); if (C.mass < 0L) { Frame.Point(p, VanillaRules.WhiteHole, 2.5f + num * 3.5f, 0.7f * Frame.Pulse(3f, 0.06f, Seed), 0.12f, 0.6f, 1.6f); Frame.Emissive((Renderer)(object)spriteRen, 0.3f); } else { Frame.Darken(p, Mathf.Min(8f, 1.5f + num * 2f), 0.35f); Frame.Point(p, new Color(1f, 0.6f, 0.25f), 2.5f + num * 4.5f, 0.55f * Frame.Pulse(4f, 0.12f, Seed), 0.1f, 0f, 1.6f); Frame.Emissive((Renderer)(object)spriteRen, 0.25f); } } } } internal sealed class TeleportTracker : Follow<TeleportIndicator> { public TeleportTracker(TeleportIndicator t) : base(t) { } protected override void Active() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.8f, 0.85f, 1f); if ((Object)(object)C.particle != (Object)null) { MainModule main = C.particle.main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; color = ((MinMaxGradient)(ref startColor)).color; } color.a = 1f; Frame.Point(Vector2.op_Implicit(((Component)C).transform.position), color, 3f, 0.45f * Frame.Pulse(7f, 0.25f, Seed), 0.08f, 0.8f, 1.2f); } } internal sealed class ReviveTracker : Follow<ReviveEffect> { public ReviveTracker(ReviveEffect r) : base(r) { } protected override void Active() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Color c = Color.white; if (C.player != null && (Object)(object)C.player.Color != (Object)null) { c = VanillaRules.PlayerColor(C.player.Id); } c.a = 1f; Frame.Point(Vector2.op_Implicit(((Component)C).transform.position), c, 3.5f, 0.55f * Frame.Pulse(9f, 0.3f, Seed), 0.08f, 0.8f, 1.2f); } } internal sealed class ReviveMarkerTracker : Follow<RevivePositionIndicator> { public ReviveMarkerTracker(RevivePositionIndicator r) : base(r) { } protected override void Active() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Color c = VanillaRules.PlayerColor(C.GetPlayerId()); c.a = 1f; Frame.Point(Vector2.op_Implicit(((Component)C).transform.position), c, 2.4f, 0.3f * Frame.Pulse(5f, 0.35f, Seed), 0f, 0.8f, 0.8f); } } internal sealed class MissileTracker : Follow<Missile> { public MissileTracker(Missile m) : base(m) { } protected override void Active() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Frame.Point(Vector2.op_Implicit(((Component)C).transform.position), VanillaRules.Fire, 2.2f, 0.4f * Frame.Flicker(Seed, 18f, 0.2f), 0.06f); } } internal sealed class OneShot : Tracker { private readonly Component c; private readonly Action fire; private bool fired; public OneShot(Component c, Action fire) { this.c = c; this.fire = fire; } public override bool Tick() { if ((Object)(object)c == (Object)null) { return false; } if (!c.gameObject.activeInHierarchy) { fired = false; return true; } if (!fired) { fired = true; fire(); } return true; } } } namespace BoplShader.Lighting { internal static class ModLights { internal struct ModCaster { public GameObject Owner; public Vector2 A; public Vector2 B; public float Radius; public float Opacity; } private static readonly List<ModLight> lights = new List<ModLight>(32); internal static readonly Dictionary<Renderer, float> Emissives = new Dictionary<Renderer, float>(); internal static readonly List<ModCaster> Casters = new List<ModCaster>(16); private static readonly List<Renderer> dead = new List<Renderer>(); internal static ModLight Add(ModLight l) { if ((Object)(object)l.Owner != (Object)null) { l.Seed = (float)(((Object)l.Owner).GetInstanceID() & 0x3FF) * 0.731f; lights.Add(l); } return l; } internal static void Emit() { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) for (int num = lights.Count - 1; num >= 0; num--) { ModLight modLight = lights[num]; bool flag = modLight.Removed || (Object)(object)modLight.Owner == (Object)null; if (flag || !modLight.Enabled || !modLight.Owner.activeInHierarchy) { modLight.Envelope = Mathf.MoveTowards(modLight.Envelope, 0f, Time.deltaTime * 12f); if (modLight.HadFrame && modLight.Envelope > 0f) { LightData l = modLight.Last; l.Intensity *= modLight.Envelope; Frame.Add(in l); } if (flag && modLight.Envelope <= 0f) { lights.RemoveAt(num); } } else { modLight.Envelope = Mathf.MoveTowards(modLight.Envelope, 1f, Time.deltaTime * 18f); if (!(modLight.Envelope <= 0f)) { float num2 = modLight.Intensity; if (modLight.Flicker > 0f) { num2 *= Frame.Flicker(modLight.Seed, 12f, modLight.Flicker); } if (modLight.Pulse > 0f) { num2 *= Frame.Pulse(modLight.PulseSpeed, modLight.Pulse, modLight.Seed); } Transform transform = modLight.Owner.transform; LightData l2 = new LightData { Color = modLight.Color, Intensity = num2, Radius = modLight.Radius, ConeCos = -2f, Height = 0.3f, Shadows = modLight.Shadows, NormalResponse = 1f, Bloom = modLight.Bloom, Priority = 1.2f }; Vector2 val; switch (modLight.Shape) { case ModLightShape.Line: l2.A = modLight.LineA; l2.B = modLight.LineB; break; case ModLightShape.Cone: val = (l2.A = (l2.B = Vector2.op_Implicit(transform.TransformPoint(Vector2.op_Implicit(modLight.Offset))))); val = Vector2.op_Implicit(transform.TransformDirection(Vector2.op_Implicit(modLight.Direction))); l2.ConeDir = ((Vector2)(ref val)).normalized; l2.ConeCos = Mathf.Cos(Mathf.Clamp(modLight.ConeAngle, 1f, 179f) * ((float)Math.PI / 180f)); break; default: val = (l2.A = (l2.B = Vector2.op_Implicit(transform.TransformPoint(Vector2.op_Implicit(modLight.Offset))))); break; } modLight.Last = l2; modLight.HadFrame = true; l2.Intensity *= modLight.Envelope; Frame.Add(in l2); } } } foreach (KeyValuePair<Renderer, float> emissife in Emissives) { if ((Object)(object)emissife.Key == (Object)null) { dead.Add(emissife.Key); } else if (emissife.Key.enabled && ((Component)emissife.Key).gameObject.activeInHierarchy) { Frame.Emissive(emissife.Key, emissife.Value); } } if (dead.Count > 0) { foreach (Renderer item in dead) { Emissives.Remove(item); } dead.Clear(); } for (int num3 = Casters.Count - 1; num3 >= 0; num3--) { ModCaster modCaster = Casters[num3]; if ((Object)(object)modCaster.Owner == (Object)null) { Casters.RemoveAt(num3); } else if (modCaster.Owner.activeInHierarchy) { Transform transform2 = modCaster.Owner.transform; Frame.Caster(Vector2.op_Implicit(transform2.TransformPoint(Vector2.op_Implicit(modCaster.A))), Vector2.op_Implicit(transform2.TransformPoint(Vector2.op_Implicit(modCaster.B))), modCaster.Radius, modCaster.Opacity); } } } } internal static class EffectEmitters { private static readonly List<Renderer> found = new List<Renderer>(64); public static readonly List<Renderer> Visible = new List<Renderer>(64); private static float nextScan; private static int effectLayer = int.MinValue; private static int explosionLayer = int.MinValue; private const float ScanInterval = 0.2f; private const int MaxPerFrame = 96; public static void Tick() { if (effectLayer == int.MinValue) { effectLayer = SortingLayer.NameToID("effect"); explosionLayer = SortingLayer.NameToID("explosion"); } if (Time.unscaledTime >= nextScan) { nextScan = Time.unscaledTime + 0.2f; found.Clear(); Renderer[] array = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val in array) { int sortingLayerID = val.sortingLayerID; if (sortingLayerID == effectLayer || sortingLayerID == explosionLayer || ((Component)val).gameObject.layer == 18) { found.Add(val); } } } Visible.Clear(); for (int j = 0; j < found.Count; j++) { if (Visible.Count >= 96) { break; } Renderer val2 = found[j]; if ((Object)(object)val2 != (Object)null && val2.enabled && val2.isVisible && ((Component)val2).gameObject.activeInHierarchy && (Object)(object)val2.sharedMaterial != (Object)null && val2.sharedMaterial.passCount == 1) { Visible.Add(val2); } } } public static void Clear() { found.Clear(); Visible.Clear(); } } internal sealed class FinalStages { private const int OnlyMainCamera = 2; private readonly MeshRenderer water; private readonly MeshRenderer post; private readonly Transform root; public FinalStages() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown GameObject val = new GameObject("BoplShaderFinal") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); root = val.transform; Mesh mesh = BigQuad(); water = Make("Water", mesh, ShaderAssets.Water, 0); post = Make("Post", mesh, ShaderAssets.Post, 1); } private MeshRenderer Make(string name, Mesh mesh, Material material, int order) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { hideFlags = (HideFlags)61, layer = 2 }; val.transform.SetParent(root, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = material; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; ((Renderer)obj).lightProbeUsage = (LightProbeUsage)0; ((Renderer)obj).reflectionProbeUsage = (ReflectionProbeUsage)0; ((Renderer)obj).sortingLayerName = "PostProcessing"; ((Renderer)obj).sortingOrder = 32000 + order; ((Renderer)obj).enabled = false; return obj; } private static Mesh BigQuad() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh { name = "BoplShaderFinalQuad", hideFlags = (HideFlags)61 }; val.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val.triangles = new int[6] { 0, 2, 1, 0, 3, 2 }; val.bounds = new Bounds(Vector3.zero, new Vector3(100000f, 100000f, 100000f)); val.UploadMeshData(true); return val; } public void Update(Camera cam, bool waterOn, bool postOn) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { MeshRenderer obj = water; bool enabled = (((Renderer)post).enabled = false); ((Renderer)obj).enabled = enabled; return; } float num = cam.orthographicSize * 2f; float num2 = num * cam.aspect; Vector3 position = ((Component)cam).transform.position + ((Component)cam).transform.forward * (cam.nearClipPlane + 0.6f); root.position = position; root.rotation = ((Component)cam).transform.rotation; root.localScale = new Vector3(num2 * 1.3f, num * 1.3f, 1f); ((Renderer)water).enabled = waterOn && (Object)(object)((Renderer)water).sharedMaterial != (Object)null; ((Renderer)post).enabled = postOn && (Object)(object)((Renderer)post).sharedMaterial != (Object)null; } public void Hide() { MeshRenderer obj = water; bool enabled = (((Renderer)post).enabled = false); ((Renderer)obj).enabled = enabled; } public void Destroy() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)((Component)root).gameObject); } } } internal static class Flashes { private struct Flash { public Vector2 A; public Vector2 B; public Color Color; public float Radius; public float Intensity; public float Start; public float Duration; public float Bloom; } private static readonly List<Flash> active = new List<Flash>(16); private const int Max = 24; public static void Add(Vector2 a, Vector2 b, Color color, float radius, float intensity, float duration, float bloom) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (active.Count >= 24) { active.RemoveAt(0); } active.Add(new Flash { A = a, B = b, Color = color, Radius = radius, Intensity = intensity, Start = Time.time, Duration = Mathf.Max(0.02f, duration), Bloom = bloom }); } public static void Emit() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; for (int num = active.Count - 1; num >= 0; num--) { Flash flash = active[num]; float num2 = (time - flash.Start) / flash.Duration; if (num2 >= 1f || num2 < 0f) { active.RemoveAt(num); } else { float num3 = Mathf.Min(1f, num2 * 12f) * (1f - num2) * (1f - num2); LightData l = new LightData { A = flash.A, B = flash.B, Color = flash.Color, Intensity = flash.Intensity * num3, Radius = flash.Radius * (0.85f + 0.15f * num2), ConeCos = -2f, Height = 0.35f, Shadows = 1f, NormalResponse = 0.8f, Bloom = flash.Bloom, Priority = 3f }; Frame.Add(in l); } } } public static void Clear() { active.Clear(); } } internal enum SurfaceKind { Object, Smoke, Player, Background } internal struct LightData { public Vector2 A; public Vector2 B; public Color Color; public float Intensity; public float Radius; public Vector2 ConeDir; public float ConeCos; public float Height; public float Shadows; public float NormalResponse; public float Bloom; public float Priority; } internal struct Capsule { public Vector2 A; public Vector2 B; public float Radius; public float Opacity; } internal struct PlatformSurface { public Vector2 Center; public float Rotation; public Vector2 Extents; public float Bevel; public SpriteRenderer Renderer; public SpriteRenderer[] Foliage; public float Type; } internal struct SpriteSurface { public Renderer Renderer; public SurfaceKind Kind; } internal struct EmissiveSprite { public Renderer Renderer; public float Strength; } internal static class Frame { public static readonly List<LightData> Lights = new List<LightData>(64); public static readonly List<Capsule> Casters = new List<Capsule>(64); public static readonly List<PlatformSurface> Platforms = new List<PlatformSurface>(32); public static readonly List<SpriteSurface> Sprites = new List<SpriteSurface>(64); public static readonly List<EmissiveSprite> Emissives = new List<EmissiveSprite>(64); public static readonly List<Renderer> Contacts = new List<Renderer>(16); private static readonly HashSet<Renderer> surfaceSet = new HashSet<Renderer>(); public static Rect View; public static bool HasView; private const float MaxRadius = 18f; public static void Clear() { Lights.Clear(); Casters.Clear(); Platforms.Clear(); Sprites.Clear(); Emissives.Clear(); Contacts.Clear(); surfaceSet.Clear(); } private static bool Near(Vector2 a, Vector2 b, float r) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!HasView) { return true; } float num = Mathf.Min(a.x, b.x) - r; float num2 = Mathf.Max(a.x, b.x) + r; float num3 = Mathf.Min(a.y, b.y) - r; float num4 = Mathf.Max(a.y, b.y) + r; if (num2 >= ((Rect)(ref View)).xMin && num <= ((Rect)(ref View)).xMax && num4 >= ((Rect)(ref View)).yMin) { return num3 <= ((Rect)(ref View)).yMax; } return false; } public static void Add(in LightData l) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (l.Intensity != 0f && !(l.Radius <= 0.01f) && !float.IsNaN(l.Radius) && !float.IsNaN(l.Intensity) && Near(l.A, l.B, l.Radius)) { LightData item = l; item.Radius = Mathf.Min(l.Radius, 18f); Lights.Add(item); } } public static void Point(Vector2 p, Color c, float radius, float intensity, float bloom = 0f, float shadows = 1f, float priority = 1f) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) LightData l = new LightData { A = p, B = p, Color = c, Intensity = intensity, Radius = radius, ConeCos = -2f, Height = 0.3f, Shadows = shadows, NormalResponse = 1f, Bloom = bloom, Priority = priority }; Add(in l); } public static void Line(Vector2 a, Vector2 b, Color c, float radius, float intensity, float bloom = 0f, float shadows = 1f, float priority = 1f) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) LightData l = new LightData { A = a, B = b, Color = c, Intensity = intensity, Radius = radius, ConeCos = -2f, Height = 0.3f, Shadows = shadows, NormalResponse = 1f, Bloom = bloom, Priority = priority }; Add(in l); } public static void Cone(Vector2 p, Vector2 dir, float cosAngle, Color c, float radius, float intensity, float bloom = 0f, float priority = 1f) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) LightData l = new LightData { A = p, B = p, Color = c, Intensity = intensity, Radius = radius, ConeDir = ((Vector2)(ref dir)).normalized, ConeCos = cosAngle, Height = 0.25f, Shadows = 1f, NormalResponse = 1f, Bloom = bloom, Priority = priority }; Add(in l); } public static void Darken(Vector2 p, float radius, float amount) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) LightData l = new LightData { A = p, B = p, Color = new Color(-1f, -1f, -1f), Intensity = amount, Radius = radius, ConeCos = -2f, Height = 0.3f, Shadows = 0f, NormalResponse = 0f, Priority = 0.8f }; Add(in l); } public static void Caster(Vector2 a, Vector2 b, float radius, float opacity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (Near(a, b, radius + 8f)) { Casters.Add(new Capsule { A = a, B = b, Radius = radius, Opacity = opacity }); } } public static void Surface(Renderer r, SurfaceKind kind) { if ((Object)(object)r != (Object)null && surfaceSet.Add(r)) { Sprites.Add(new SpriteSurface { Renderer = r, Kind = kind }); } } public static void Contact(Renderer r) { if ((Object)(object)r != (Object)null && r.isVisible) { Contacts.Add(r); } } public static void Emissive(Renderer r, float strength) { if ((Object)(object)r != (Object)null && strength > 0f) { Emissives.Add(new EmissiveSprite { Renderer = r, Strength = strength }); } } public static float Flicker(float seed, float speed, float amount) { float num = Mathf.PerlinNoise(Time.time * speed, seed * 13.37f) * 2f - 1f; return 1f + num * amount; } public static float Pulse(float speed, float amount, float phase = 0f) { return 1f + Mathf.Sin(Time.time * speed + phase) * amount; } } internal sealed class LightingRenderer : MonoBehaviour { private const CameraEvent Event = (CameraEvent)16; private const CameraEvent FinalEvent = (CameraEvent)18; private const int MaxCasterSlots = 32; private CommandBuffer cb; private CommandBuffer cbFinal; private Camera attached; private RenderTexture surfaceRT; private RenderTexture lightRT; private RenderTexture shadowRT; private RenderTexture bloomRT; private RenderTexture bloomSmallA; private RenderTexture bloomSmallB; private RenderTexture terrainRT; private RenderTexture emitRT; private RenderTexture spillA; private RenderTexture spillB; private readonly HashSet<Renderer> foliage = new HashSet<Renderer>(); private int lastW; private int lastH; private float lastScale; private float lastTerrainScale; private readonly List<MaterialPropertyBlock> blocks = new List<MaterialPropertyBlock>(64); private int blockCursor; private readonly Vector4[] casterA = (Vector4[])(object)new Vector4[32]; private readonly Vector4[] casterB = (Vector4[])(object)new Vector4[32]; private readonly List<LightData> sorted = new List<LightData>(64); private static readonly int SurfaceTexId = Shader.PropertyToID("_BSSurfaceTex"); private static readonly int LightTexId = Shader.PropertyToID("_BSLightTex"); private static readonly int LightTexelId = Shader.PropertyToID("_BSLightTex_TexelSize"); private static readonly int ShadowTexId = Shader.PropertyToID("_BSShadowTex"); private static readonly int BloomTexId = Shader.PropertyToID("_BSBloomTex"); private static readonly int CamRectId = Shader.PropertyToID("_BSCamRect"); p