using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("DirtyGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DynamicLighting")]
[assembly: AssemblyTitle("DynamicLighting")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 DynamicLighting
{
[BepInPlugin("DirtyGames.DynamicLighting", "DynamicLighting", "1.0.0")]
public class DynamicLighting : BaseUnityPlugin
{
[HarmonyPatch(typeof(EnvironmentDirector), "Setup")]
public class EnvironmentPatches
{
[HarmonyPostfix]
private static void ApplyCustomLighting()
{
//IL_0093: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: 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_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)LevelGenerator.Instance.Level == (Object)null))
{
Level level = LevelGenerator.Instance.Level;
string narrativeName = level.NarrativeName;
Debug.Log((object)("[DynamicLighting] Processing lighting settings for: " + narrativeName));
if (!Instance.originalFogColors.ContainsKey(narrativeName))
{
Instance.InitializeLevelConfig(narrativeName);
}
Debug.Log((object)"[DynamicLighting] Applying configured settings...");
RenderSettings.ambientSkyColor = ((BaseUnityPlugin)Instance).Config.Bind<Color>("Lighting - " + narrativeName, "AmbientSkyColor", Instance.originalSkyColors[narrativeName], "Sky ambient lighting color").Value;
RenderSettings.ambientEquatorColor = ((BaseUnityPlugin)Instance).Config.Bind<Color>("Lighting - " + narrativeName, "AmbientEquatorColor", Instance.originalEquatorColors[narrativeName], "Equator ambient lighting color").Value;
RenderSettings.ambientGroundColor = ((BaseUnityPlugin)Instance).Config.Bind<Color>("Lighting - " + narrativeName, "AmbientGroundColor", Instance.originalGroundColors[narrativeName], "Ground ambient lighting color").Value;
RenderSettings.ambientLight = ((BaseUnityPlugin)Instance).Config.Bind<Color>("Lighting - " + narrativeName, "AmbientLight", Instance.originalAmbientLights[narrativeName], "General ambient lighting color").Value;
RenderSettings.ambientIntensity = ((BaseUnityPlugin)Instance).Config.Bind<float>("Lighting - " + narrativeName, "AmbientIntensity", Instance.originalAmbientIntensity[narrativeName], "Intensity of ambient light").Value;
RenderSettings.fogColor = ((BaseUnityPlugin)Instance).Config.Bind<Color>("Fog - " + narrativeName, "FogColor", Instance.originalFogColors[narrativeName], "Fog color").Value;
RenderSettings.fogDensity = ((BaseUnityPlugin)Instance).Config.Bind<float>("Fog - " + narrativeName, "FogDensity", Instance.originalFogDensity[narrativeName], "Fog density").Value;
RenderSettings.fogMode = ((BaseUnityPlugin)Instance).Config.Bind<FogMode>("Fog - " + narrativeName, "FogMode", Instance.originalFogMode[narrativeName], "Fog mode (Linear, Exponential, ExponentialSquared)").Value;
RenderSettings.fogStartDistance = ((BaseUnityPlugin)Instance).Config.Bind<float>("Fog - " + narrativeName, "FogStartDistance", Instance.originalFogStartDistance[narrativeName], "Fog start distance").Value;
RenderSettings.fogEndDistance = ((BaseUnityPlugin)Instance).Config.Bind<float>("Fog - " + narrativeName, "FogEndDistance", Instance.originalFogEndDistance[narrativeName], "Fog end distance").Value;
if ((Object)(object)Camera.main != (Object)null)
{
Camera.main.backgroundColor = RenderSettings.fogColor;
Debug.Log((object)"[DynamicLighting] Updated camera background to match fog color.");
}
Debug.Log((object)"[DynamicLighting] Custom lighting and fog settings applied!");
}
}
}
private readonly Dictionary<string, Color> originalFogColors = new Dictionary<string, Color>();
private readonly Dictionary<string, float> originalFogDensity = new Dictionary<string, float>();
private readonly Dictionary<string, FogMode> originalFogMode = new Dictionary<string, FogMode>();
private readonly Dictionary<string, float> originalFogStartDistance = new Dictionary<string, float>();
private readonly Dictionary<string, float> originalFogEndDistance = new Dictionary<string, float>();
private readonly Dictionary<string, Color> originalSkyColors = new Dictionary<string, Color>();
private readonly Dictionary<string, Color> originalEquatorColors = new Dictionary<string, Color>();
private readonly Dictionary<string, Color> originalGroundColors = new Dictionary<string, Color>();
private readonly Dictionary<string, Color> originalAmbientLights = new Dictionary<string, Color>();
private readonly Dictionary<string, float> originalAmbientIntensity = new Dictionary<string, float>();
private readonly Dictionary<string, (Color skyColor, Color equatorColor, Color groundColor, Color ambientLight, float ambientIntensity)> defaultLighting = new Dictionary<string, (Color, Color, Color, Color, float)>
{
{
"Headman Manor",
(new Color(0f, 0f, 0.2f, 1f), new Color(0f, 0f, 0.2f, 1f), new Color(0f, 0f, 0f, 1f), new Color(0f, 0f, 0.2f, 1f), 0.6f)
},
{
"Lobby Menu",
(new Color(0f, 0f, 0.2f, 1f), new Color(0f, 0f, 0.2f, 1f), new Color(0f, 0f, 0f, 1f), new Color(0f, 0f, 0.2f, 1f), 1f)
},
{
"Main Menu",
(new Color(0.96f, 0.88f, 0.76f, 1f), new Color(0.79f, 0.64f, 0.45f, 1f), new Color(0.65f, 0.54f, 0.41f, 1f), new Color(0.89f, 0.77f, 0.56f, 1f), 1f)
},
{
"McJannek Station",
(new Color(0f, 0.45f, 0.61f, 1f), new Color(0f, 0.45f, 0.61f, 1f), new Color(0.15f, 0.36f, 0.4f, 1f), new Color(0f, 0.45f, 0.61f, 1f), 0.7f)
},
{
"Swiftbroom Academy",
(new Color(0.29f, 0f, 0.48f, 1f), new Color(0.29f, 0f, 0.48f, 1f), new Color(0f, 0f, 0f, 1f), new Color(0.29f, 0f, 0.48f, 1f), 1f)
}
};
private readonly Dictionary<string, (Color fogColor, float fogDensity, FogMode fogMode, float fogStart, float fogEnd)> defaultFog = new Dictionary<string, (Color, float, FogMode, float, float)>
{
{
"Headman Manor",
(new Color(0.07f, 0.02f, 0f, 1f), 0.15f, (FogMode)2, 0f, 15f)
},
{
"Lobby Menu",
(new Color(0f, 0.03f, 0.13f, 1f), 0.25f, (FogMode)1, 0f, 200f)
},
{
"Main Menu",
(new Color(0.82f, 0.7f, 0.55f, 1f), 0.18f, (FogMode)1, 5f, 200f)
},
{
"McJannek Station",
(new Color(0f, 0f, 0f, 1f), 0.25f, (FogMode)2, 0f, 20f)
},
{
"Swiftbroom Academy",
(new Color(0f, 0f, 0f, 1f), 0.15f, (FogMode)2, 0f, 17f)
}
};
internal static DynamicLighting Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//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_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void InitializeLevelConfig(string levelName)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: 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)
//IL_0146: 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_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: 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_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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)
if (!defaultLighting.ContainsKey(levelName))
{
Debug.LogWarning((object)("[DynamicLighting] No predefined values for " + levelName + ". Capturing current in-game settings."));
defaultLighting[levelName] = (RenderSettings.ambientSkyColor, RenderSettings.ambientEquatorColor, RenderSettings.ambientGroundColor, RenderSettings.ambientLight, RenderSettings.ambientIntensity);
}
if (!defaultFog.ContainsKey(levelName))
{
defaultFog[levelName] = (RenderSettings.fogColor, RenderSettings.fogDensity, RenderSettings.fogMode, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance);
}
originalSkyColors[levelName] = ((BaseUnityPlugin)this).Config.Bind<Color>("Lighting - " + levelName, "AmbientSkyColor", defaultLighting[levelName].skyColor, "Sky ambient lighting color").Value;
originalEquatorColors[levelName] = ((BaseUnityPlugin)this).Config.Bind<Color>("Lighting - " + levelName, "AmbientEquatorColor", defaultLighting[levelName].equatorColor, "Equator ambient lighting color").Value;
originalGroundColors[levelName] = ((BaseUnityPlugin)this).Config.Bind<Color>("Lighting - " + levelName, "AmbientGroundColor", defaultLighting[levelName].groundColor, "Ground ambient lighting color").Value;
originalAmbientLights[levelName] = ((BaseUnityPlugin)this).Config.Bind<Color>("Lighting - " + levelName, "AmbientLight", defaultLighting[levelName].ambientLight, "General ambient lighting color").Value;
originalAmbientIntensity[levelName] = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting - " + levelName, "AmbientIntensity", defaultLighting[levelName].ambientIntensity, "Intensity of ambient light").Value;
originalFogColors[levelName] = ((BaseUnityPlugin)this).Config.Bind<Color>("Fog - " + levelName, "FogColor", defaultFog[levelName].fogColor, "Fog color").Value;
originalFogDensity[levelName] = ((BaseUnityPlugin)this).Config.Bind<float>("Fog - " + levelName, "FogDensity", defaultFog[levelName].fogDensity, "Fog density").Value;
originalFogMode[levelName] = ((BaseUnityPlugin)this).Config.Bind<FogMode>("Fog - " + levelName, "FogMode", defaultFog[levelName].fogMode, "Fog mode (Linear, Exponential, ExponentialSquared)").Value;
originalFogStartDistance[levelName] = ((BaseUnityPlugin)this).Config.Bind<float>("Fog - " + levelName, "FogStartDistance", defaultFog[levelName].fogStart, "Fog start distance").Value;
originalFogEndDistance[levelName] = ((BaseUnityPlugin)this).Config.Bind<float>("Fog - " + levelName, "FogEndDistance", defaultFog[levelName].fogEnd, "Fog end distance").Value;
Debug.Log((object)("[DynamicLighting] Config initialized for level: " + levelName));
}
}
}