Decompiled source of LycansVisibilityControlPlugin v1.1.0

plugins/LycansVisibilityControlPlugin/LycansVisibilityControlPlugin.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 Fusion;
using Helpers.Collections;
using Microsoft.CodeAnalysis;
using On;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;
using VisibilityControlPlugin.domain;
using VisibilityControlPlugin.patch;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("LycansVisibilityControlPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4b8eafc55fe067a59e4eb38924841264c614fbef")]
[assembly: AssemblyProduct("LycansVisibilityControlPlugin")]
[assembly: AssemblyTitle("LycansVisibilityControlPlugin")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VisibilityControlPlugin
{
	public static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("com.namhto.mods.lycans.visibility-control", "Visibility Control", "1.0.0")]
	[BepInProcess("Lycans.exe")]
	public class VisibilityControlPlugin : BaseUnityPlugin
	{
		public static Settings Settings;

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			Log.Info("Initializing Visibility Control");
			Settings = new Settings(((BaseUnityPlugin)this).Config);
			GameSettingsMenuPatch.Hook();
			NetworkingPatch.Hook();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LycansVisibilityControlPlugin";

		public const string PLUGIN_NAME = "LycansVisibilityControlPlugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace VisibilityControlPlugin.patch
{
	public static class GameSettingsMenuPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__0_0;

			public static Action<Locale> <>9__1_0;

			internal void <Hook>b__0_0(orig_Start orig, GameManager self)
			{
				orig.Invoke(self);
				Settings settings = VisibilityControlPlugin.Settings;
				AddSection(self.gameUI, "VC_LABEL");
				AddSlider(self.gameUI, "VC_POINT_LIGHT", settings.SetPointLightIntensity, settings.GetPointLightIntensity(), settings.GetDefaultPointLightIntensity());
				AddSlider(self.gameUI, "VC_AMBIENT", settings.SetAmbientIntensity, settings.GetAmbientIntensity(), settings.GetDefaultAmbientIntensity());
				AddToggle(self.gameUI, "VC_FOG", settings.SetFogDisabled, settings.GetFogDisabled(), settings.GetDefaultFogDisabled());
				MakeSettingsMenuScrollable(self.gameUI);
			}

			internal void <RegisterTranslations>b__1_0(Locale _)
			{
				RegisterTranslations();
			}
		}

		public static void Hook()
		{
			//IL_001b: 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_0026: Expected O, but got Unknown
			RegisterTranslations();
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, GameManager self)
				{
					orig.Invoke(self);
					Settings settings = VisibilityControlPlugin.Settings;
					AddSection(self.gameUI, "VC_LABEL");
					AddSlider(self.gameUI, "VC_POINT_LIGHT", settings.SetPointLightIntensity, settings.GetPointLightIntensity(), settings.GetDefaultPointLightIntensity());
					AddSlider(self.gameUI, "VC_AMBIENT", settings.SetAmbientIntensity, settings.GetAmbientIntensity(), settings.GetDefaultAmbientIntensity());
					AddToggle(self.gameUI, "VC_FOG", settings.SetFogDisabled, settings.GetFogDisabled(), settings.GetDefaultFogDisabled());
					MakeSettingsMenuScrollable(self.gameUI);
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			GameManager.Start += (hook_Start)obj;
		}

		private static void RegisterTranslations()
		{
			//IL_000b: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), LocalizationSettings.AvailableLocales.GetLocale(LocaleIdentifier.op_Implicit("en")));
			StringTable table2 = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), LocalizationSettings.AvailableLocales.GetLocale(LocaleIdentifier.op_Implicit("fr")));
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("VC_LABEL", "Visibility Control");
			((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("VC_LABEL", "Contrôle de la visibilité");
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("VC_FOG", "Disable fog");
			((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("VC_FOG", "Désactiver le brouillard");
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("VC_POINT_LIGHT", "Intensity of local lights (lanterns, camp fires, etc)");
			((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("VC_POINT_LIGHT", "Intensité des lumières locales (lanternes, feux de camp, etc)");
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("VC_AMBIENT", "Intensity of ambient light");
			((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("VC_AMBIENT", "Intensité de la lumière ambiente");
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("VC_ALLOW_NO_PLUGIN", "Allow players to join without this mod");
			((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("VC_ALLOW_NO_PLUGIN", "Autoriser les joueurs à rejoindre sans ce mod");
			LocalizationSettings.Instance.OnSelectedLocaleChanged += delegate
			{
				RegisterTranslations();
			};
		}

		private static void AddSection(GameUI gameUi, string label)
		{
			Transform val = Object.Instantiate<Transform>(gameUi.settingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/SettingsGroup/GraphicsTitle"), gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup"));
			((Component)val).GetComponentInChildren<LocalizeStringEvent>().SetEntry(label);
		}

		private static void AddSlider(GameUI gameUi, string label, UnityAction<float> onValueChangedListener, float initialValue, float defaultValue)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			Transform val = Object.Instantiate<Transform>(gameUi.settingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/SettingsGroup/MasterVolumeSetting"), gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup"));
			((Component)val).GetComponentInChildren<LocalizeStringEvent>().SetEntry(label);
			Slider slider = ((Component)val).GetComponentInChildren<Slider>();
			slider.onValueChanged = new SliderEvent();
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener(onValueChangedListener);
			GameSettingsUI.ResetSettings += (hook_ResetSettings)delegate(orig_ResetSettings orig, GameSettingsUI self)
			{
				orig.Invoke(self);
				slider.SetValueWithoutNotify(defaultValue);
				onValueChangedListener.Invoke(defaultValue);
			};
			slider.SetValueWithoutNotify(initialValue);
		}

		private static void AddToggle(GameUI gameUi, string label, UnityAction<bool> onValueChangedListener, bool initialValue, bool defaultValue)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			Transform val = Object.Instantiate<Transform>(gameUi.settingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/SettingsGroup/VSyncSettings"), gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup"));
			((Component)val).GetComponentInChildren<LocalizeStringEvent>().SetEntry(label);
			Toggle toggle = ((Component)val).GetComponentInChildren<Toggle>();
			toggle.onValueChanged = new ToggleEvent();
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(onValueChangedListener);
			GameSettingsUI.ResetSettings += (hook_ResetSettings)delegate(orig_ResetSettings orig, GameSettingsUI self)
			{
				orig.Invoke(self);
				toggle.SetIsOnWithoutNotify(defaultValue);
				onValueChangedListener.Invoke(defaultValue);
			};
			toggle.SetIsOnWithoutNotify(initialValue);
		}

		private static void MakeSettingsMenuScrollable(GameUI gameUi)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			Transform val = gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder");
			((Component)((Component)val).gameObject.AddComponent<Image>()).GetComponent<RectTransform>().sizeDelta = new Vector2(-20f, -10f);
			((Component)val).gameObject.AddComponent<Mask>().showMaskGraphic = false;
			val.Find("QuitButton").SetParent(val.parent);
			Transform val2 = val.Find("LayoutGroup");
			GameObject val3 = new GameObject("ScrollView");
			val3.transform.SetParent(val);
			val3.transform.SetAsFirstSibling();
			ScrollRect val4 = val3.AddComponent<ScrollRect>();
			val4.vertical = true;
			val4.horizontal = false;
			val4.movementType = (MovementType)2;
			val4.content = ((Component)val2).GetComponent<RectTransform>();
			val4.viewport = ((Component)val).GetComponent<RectTransform>();
			val2.SetParent(val3.transform);
			((Component)val2).gameObject.AddComponent<ContentSizeFitter>();
			((Component)val2).GetComponent<ContentSizeFitter>().verticalFit = (FitMode)1;
			foreach (Transform item in val2)
			{
				Transform val5 = item;
				((Component)val5).GetComponent<LayoutElement>().minHeight = 40f;
			}
		}
	}
	public static class NetworkingPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Spawned <>9__1_0;

			public static hook_Start <>9__2_0;

			internal void <Hook>b__1_0(orig_Spawned orig, GameManager self)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				((SimulationBehaviour)self).Runner.Spawn(_id, (Vector3?)null, (Quaternion?)null, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
			}

			internal void <RegisterNetworkingPrefab>b__2_0(orig_Start orig, GameManager self)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Expected O, but got Unknown
				//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)
				//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_005b: Expected O, but got Unknown
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				GameObject val = new GameObject("VisibilityControlNetworkPrefab");
				NetworkObject val2 = val.AddComponent<NetworkObject>();
				val2.NetworkedBehaviours = (NetworkBehaviour[])(object)new NetworkBehaviour[1] { val.AddComponent<VisibilityController>() };
				val2.NetworkGuid = NetworkObjectGuid.Parse(Guid.NewGuid().ToString());
				NetworkPrefabSourceStatic val3 = new NetworkPrefabSourceStatic
				{
					PrefabReference = val2
				};
				NetworkProjectConfig.Global.PrefabTable.TryAdd(val2.NetworkGuid, (INetworkPrefabSource)(object)val3, ref _id);
			}
		}

		private static NetworkPrefabId _id;

		public static void Hook()
		{
			//IL_001b: 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_0026: Expected O, but got Unknown
			RegisterNetworkingPrefab();
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				hook_Spawned val = delegate(orig_Spawned orig, GameManager self)
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self);
					((SimulationBehaviour)self).Runner.Spawn(_id, (Vector3?)null, (Quaternion?)null, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			GameManager.Spawned += (hook_Spawned)obj;
		}

		private static void RegisterNetworkingPrefab()
		{
			//IL_0015: 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_0020: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, GameManager self)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Expected O, but got Unknown
					//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)
					//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_005b: Expected O, but got Unknown
					//IL_0066: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self);
					GameObject val2 = new GameObject("VisibilityControlNetworkPrefab");
					NetworkObject val3 = val2.AddComponent<NetworkObject>();
					val3.NetworkedBehaviours = (NetworkBehaviour[])(object)new NetworkBehaviour[1] { val2.AddComponent<VisibilityController>() };
					val3.NetworkGuid = NetworkObjectGuid.Parse(Guid.NewGuid().ToString());
					NetworkPrefabSourceStatic val4 = new NetworkPrefabSourceStatic
					{
						PrefabReference = val3
					};
					NetworkProjectConfig.Global.PrefabTable.TryAdd(val3.NetworkGuid, (INetworkPrefabSource)(object)val4, ref _id);
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			GameManager.Start += (hook_Start)obj;
		}
	}
}
namespace VisibilityControlPlugin.domain
{
	public class Settings
	{
		private readonly ConfigEntry<float> _pointLightIntensity = config.Bind<float>("General", "PointLightIntensity", 0.4f, "Intensity of the point lights");

		private readonly List<Action<float>> _pointLightIntensityListeners = new List<Action<float>>();

		private readonly ConfigEntry<float> _ambientIntensity = config.Bind<float>("General", "AmbientIntensity", 0.5f, "Intensity of the ambient light during nighttime");

		private readonly List<Action<float>> _ambientIntensityListeners = new List<Action<float>>();

		private readonly ConfigEntry<bool> _fogDisabled = config.Bind<bool>("General", "FogDisabled", false, "Is fog disabled");

		private readonly List<Action<bool>> _fogDisabledListeners = new List<Action<bool>>();

		public Settings(ConfigFile config)
		{
		}

		public float GetDefaultPointLightIntensity()
		{
			return (float)((ConfigEntryBase)_pointLightIntensity).DefaultValue;
		}

		public float GetPointLightIntensity()
		{
			return _pointLightIntensity.Value;
		}

		public void SetPointLightIntensity(float value)
		{
			_pointLightIntensity.Value = value;
			_pointLightIntensityListeners.ForEach(delegate(Action<float> listener)
			{
				listener(value);
			});
		}

		public void AddPointLightIntensityListener(Action<float> listener)
		{
			_pointLightIntensityListeners.Add(listener);
		}

		public float GetDefaultAmbientIntensity()
		{
			return (float)((ConfigEntryBase)_ambientIntensity).DefaultValue;
		}

		public float GetAmbientIntensity()
		{
			return _ambientIntensity.Value;
		}

		public void SetAmbientIntensity(float value)
		{
			_ambientIntensity.Value = value;
			_ambientIntensityListeners.ForEach(delegate(Action<float> listener)
			{
				listener(value);
			});
		}

		public void AddAmbientIntensityListener(Action<float> listener)
		{
			_ambientIntensityListeners.Add(listener);
		}

		public bool GetDefaultFogDisabled()
		{
			return (bool)((ConfigEntryBase)_fogDisabled).DefaultValue;
		}

		public bool GetFogDisabled()
		{
			return _fogDisabled.Value;
		}

		public void SetFogDisabled(bool value)
		{
			_fogDisabled.Value = value;
			_fogDisabledListeners.ForEach(delegate(Action<bool> listener)
			{
				listener(value);
			});
		}

		public void AddForDisabledListener(Action<bool> listener)
		{
			_fogDisabledListeners.Add(listener);
		}

		public void ClearListeners()
		{
			_pointLightIntensityListeners.Clear();
			_ambientIntensityListeners.Clear();
			_fogDisabledListeners.Clear();
		}
	}
	[NetworkBehaviourWeaved(3)]
	public class VisibilityController : NetworkBehaviour
	{
		private float _initialPointLightIntensity;

		private float _initialAmbientIntensity;

		private bool _initialFogDisabled;

		private float _pointLightIntensity;

		private float _ambientIntensity;

		private bool _fogDisabled;

		[Networked(OnChanged = "PointLightIntensityChanged")]
		[NetworkedWeaved(0, 1)]
		public unsafe float PointLightIntensity
		{
			get
			{
				return ReadWriteUtilsForWeaver.ReadFloat(base.Ptr, 0.01f);
			}
			set
			{
				ReadWriteUtilsForWeaver.WriteFloat(base.Ptr, 99.99f, value);
			}
		}

		[Networked(OnChanged = "AmbientIntensityChanged")]
		[NetworkedWeaved(1, 1)]
		public unsafe float AmbientIntensity
		{
			get
			{
				return ReadWriteUtilsForWeaver.ReadFloat(base.Ptr + 1, 0.01f);
			}
			set
			{
				ReadWriteUtilsForWeaver.WriteFloat(base.Ptr + 1, 99.99f, value);
			}
		}

		[Networked(OnChanged = "FogDisabledChanged")]
		[NetworkedWeaved(2, 1)]
		public unsafe bool FogDisabled
		{
			get
			{
				return ReadWriteUtilsForWeaver.ReadBoolean(base.Ptr + 2);
			}
			set
			{
				ReadWriteUtilsForWeaver.WriteBoolean(base.Ptr + 2, value);
			}
		}

		public static void PointLightIntensityChanged(Changed<VisibilityController> changed)
		{
			changed.Behaviour._pointLightIntensity = changed.Behaviour.PointLightIntensity;
			Log.Info("PointLightIntensity: " + changed.Behaviour._pointLightIntensity);
		}

		public static void AmbientIntensityChanged(Changed<VisibilityController> changed)
		{
			changed.Behaviour._ambientIntensity = changed.Behaviour.AmbientIntensity;
			Log.Info("AmbientIntensity: " + changed.Behaviour._ambientIntensity);
		}

		public static void FogDisabledChanged(Changed<VisibilityController> changed)
		{
			changed.Behaviour._fogDisabled = changed.Behaviour.FogDisabled;
			Log.Info("FogDisabled: " + changed.Behaviour._fogDisabled);
		}

		public override void Spawned()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			BindToSettings();
			GameManager.Rpc_Transition += (hook_Rpc_Transition)delegate(orig_Rpc_Transition orig, NetworkRunner self)
			{
				orig.Invoke(self);
				ApplyVisibilitySettings();
			};
		}

		public override void Despawned(NetworkRunner runner, bool hasState)
		{
			VisibilityControlPlugin.Settings.ClearListeners();
		}

		private void BindToSettings()
		{
			Settings settings = VisibilityControlPlugin.Settings;
			if (((SimulationBehaviour)this).Runner.IsServer)
			{
				settings.AddPointLightIntensityListener(delegate(float value)
				{
					PointLightIntensity = value;
				});
				settings.AddAmbientIntensityListener(delegate(float value)
				{
					AmbientIntensity = value;
				});
				settings.AddForDisabledListener(delegate(bool value)
				{
					FogDisabled = value;
				});
			}
			PointLightIntensity = settings.GetPointLightIntensity();
			AmbientIntensity = settings.GetAmbientIntensity();
			FogDisabled = settings.GetFogDisabled();
		}

		private void ApplyVisibilitySettings()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameManager.LocalGameState != 2)
			{
				return;
			}
			LightingManager component = ((Component)GameManager.Instance).GetComponent<LightingManager>();
			if (!NetworkBool.op_Implicit(component.IsNight))
			{
				Log.Info("Changing visibility settings");
				_initialPointLightIntensity = component._sceneLights.First().intensity;
				_initialAmbientIntensity = RenderSettings.ambientIntensity;
				_initialFogDisabled = !RenderSettings.fog;
				CollectionsUtil.ForEach<Light>(component._sceneLights, (Action<Light>)delegate(Light light)
				{
					light.intensity = _pointLightIntensity;
				});
				RenderSettings.ambientIntensity = _ambientIntensity;
				RenderSettings.fog = !_fogDisabled;
			}
			else
			{
				Log.Info("Reverting visibility settings");
				CollectionsUtil.ForEach<Light>(component._sceneLights, (Action<Light>)delegate(Light light)
				{
					light.intensity = _initialPointLightIntensity;
				});
				RenderSettings.ambientIntensity = _initialAmbientIntensity;
				RenderSettings.fog = !_initialFogDisabled;
			}
		}
	}
}