using System;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using MrovLib;
using MrovWeathers.NetcodePatcher;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using WeatherRegistry;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("WeatherRegistry")]
[assembly: AssemblyCompany("MrovWeathers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3+6013268c5fa8e4d97976857c8cd2caa21c652cc5")]
[assembly: AssemblyProduct("MrovWeathers")]
[assembly: AssemblyTitle("MrovWeathers")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AndreyMrovol/MrovWeathers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 MrovWeathers
{
public static class InitWeathers
{
public static Weather Blackout;
public static Weather Cloudy;
public static void Init()
{
InitCloudy();
InitBlackout();
}
public static void InitCloudy()
{
//IL_0007: 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_001c: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0032: 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_0052: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
Weather val = new Weather("Cloudy", new ImprovedWeatherEffect((GameObject)null, (GameObject)null)
{
SunAnimatorBool = "overcast"
});
val.Color = new Color(0f, 1f, 0.55f, 1f);
val.Config.ScrapAmountMultiplier = new FloatConfigHandler(1.6f, true);
val.Config.ScrapValueMultiplier = new FloatConfigHandler(0.8f, true);
val.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(new string[2] { "Eclipsed@50", "Stormy@80" }, true);
val.Config.DefaultWeight = new IntegerConfigHandler(25, true);
Cloudy = val;
WeatherManager.RegisterWeather(Cloudy);
}
public static void InitBlackout()
{
//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_0015: Expected O, but got Unknown
//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_0072: Expected O, but got Unknown
//IL_006d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_00a7: Expected O, but got Unknown
//IL_00a7: 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_00bd: Expected O, but got Unknown
//IL_00bd: 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)
//IL_00d0: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_00e6: 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_00fc: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(new GameObject
{
name = "BlackoutWeather"
});
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<Blackout>();
Object.DontDestroyOnLoad((Object)(object)val);
AssetBundle val2 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Plugin.PluginInformation.Location), "blackout"));
AnimationClip animationClip = val2.LoadAsset<AnimationClip>("BlackoutSunClip");
Blackout = new Weather("Blackout", new ImprovedWeatherEffect((GameObject)null, val)
{
SunAnimatorBool = "eclipse"
})
{
Color = new Color(0.5f, 0.4f, 0.5f, 1f),
Config =
{
ScrapAmountMultiplier = new FloatConfigHandler(0.65f, true)
},
Config =
{
ScrapValueMultiplier = new FloatConfigHandler(1.7f, true)
},
Config =
{
DefaultWeight = new IntegerConfigHandler(35, true)
},
Config =
{
LevelWeights = new LevelWeightsConfigHandler("Rend@200; Dine@200; Titan@200", true)
},
Config =
{
WeatherToWeatherWeights = new WeatherWeightsConfigHandler("None@200; Cloudy@250", true)
},
AnimationClip = animationClip
};
WeatherManager.RegisterWeather(Blackout);
}
}
[BepInPlugin("MrovWeathers", "MrovWeathers", "0.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource logger;
internal static Logger DebugLogger = new Logger("MrovWeathers", (ConfigEntry<bool>)null);
internal static Harmony harmony = new Harmony("MrovWeathers");
internal static PluginInfo PluginInformation;
private void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll();
PluginInformation = ((BaseUnityPlugin)this).Info;
InitWeathers.Init();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MrovWeathers is loaded!");
}
}
public class Blackout : MonoBehaviour
{
public class LightUtils
{
public static List<Light> GetLightsInScene(string sceneName)
{
//IL_0007: 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)
List<Light> list = new List<Light>();
Scene sceneByName = SceneManager.GetSceneByName(sceneName);
if (!((Scene)(ref sceneByName)).isLoaded)
{
Plugin.DebugLogger.LogWarning((object)("Scene " + sceneName + " is not loaded!"));
return list;
}
GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
GameObject[] array = rootGameObjects;
foreach (GameObject val in array)
{
Light[] componentsInChildren = val.GetComponentsInChildren<Light>(true);
list.AddRange(componentsInChildren);
}
return list;
}
public static List<Light> GetLightsUnderParent(Transform parent, bool includeInactive = true)
{
List<Light> list = new List<Light>();
if ((Object)(object)parent == (Object)null)
{
return list;
}
Light[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Light>(includeInactive);
list.AddRange(componentsInChildren);
return list;
}
public static List<Light> GetLightsInSceneUnderParent(string sceneName, string parentName, bool includeInactive = true)
{
//IL_0007: 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)
List<Light> list = new List<Light>();
Scene sceneByName = SceneManager.GetSceneByName(sceneName);
if (!((Scene)(ref sceneByName)).isLoaded)
{
Plugin.DebugLogger.LogWarning((object)("Scene " + sceneName + " is not loaded!"));
return list;
}
GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
GameObject[] array = rootGameObjects;
foreach (GameObject val in array)
{
if (((Object)val).name == parentName)
{
list.AddRange(GetLightsUnderParent(val.transform, includeInactive));
break;
}
Transform val2 = val.transform.Find(parentName);
if ((Object)(object)val2 != (Object)null)
{
list.AddRange(GetLightsUnderParent(val2, includeInactive));
break;
}
}
return list;
}
public static Dictionary<string, List<Light>> GetLightsInScenes(string[] sceneNames)
{
Dictionary<string, List<Light>> dictionary = new Dictionary<string, List<Light>>();
foreach (string text in sceneNames)
{
dictionary[text] = GetLightsInScene(text);
}
return dictionary;
}
public static Light[] GetAllLightsInScene(bool includeInactive = true)
{
return Resources.FindObjectsOfTypeAll<Light>();
}
public static Light[] GetActiveLightsInScene()
{
return Object.FindObjectsOfType<Light>();
}
public static List<Light> GetLightsByType(LightType lightType)
{
//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)
Light[] allLightsInScene = GetAllLightsInScene();
List<Light> list = new List<Light>();
Light[] array = allLightsInScene;
foreach (Light val in array)
{
if (val.type == lightType)
{
list.Add(val);
}
}
return list;
}
}
private Logger Logger = new Logger("Blackout", (ConfigEntry<bool>)null);
private List<Light> AllPoweredLights = new List<Light>();
private List<HDAdditionalLightData> Floodlights = new List<HDAdditionalLightData>();
private float FloodlightRange = 44f;
private float FloodlightAngle = 116.7f;
private float FloodlightIntensity = 762f;
private void OnEnable()
{
if (!WeatherManager.IsSetupFinished)
{
return;
}
LungProp val = Object.FindObjectOfType<LungProp>();
ItemDropship val2 = Object.FindObjectOfType<ItemDropship>();
List<Light> lightsUnderParent = LightUtils.GetLightsUnderParent(((Component)val2).transform);
AllPoweredLights = LightUtils.GetLightsInScene(StartOfRound.Instance.currentLevel.sceneName);
Logger.LogInfo((object)$"Found {AllPoweredLights.Count} lights in scene {StartOfRound.Instance.currentLevel.sceneName}");
HDAdditionalLightData val3 = default(HDAdditionalLightData);
foreach (Light allPoweredLight in AllPoweredLights)
{
if ((Object)(object)val != (Object)null && (Object)(object)((Component)allPoweredLight).transform.parent == (Object)(object)((Component)val).gameObject.transform)
{
Logger.LogDebug((object)("Skipping light " + ((Object)allPoweredLight).name + " (parent " + ((Object)((Component)allPoweredLight).transform.parent).name + ")"));
((Component)allPoweredLight).gameObject.TryGetComponent<HDAdditionalLightData>(ref val3);
if ((Object)(object)val3 != (Object)null)
{
val3.SetIntensity(900f);
val3.SetRange(80f);
}
}
else if (lightsUnderParent.Contains(allPoweredLight))
{
Logger.LogDebug((object)("Skipping light " + ((Object)allPoweredLight).name + " (parent " + ((Object)((Component)allPoweredLight).transform.parent).name + ")"));
}
else
{
Logger.LogDebug((object)("Disabling light " + ((Object)allPoweredLight).name + " (parent " + ((Object)((Component)allPoweredLight).transform.parent).name + ")"));
((Component)allPoweredLight).gameObject.SetActive(false);
}
}
RoundManager.Instance.SwitchPower(true);
RoundManager.Instance.TurnOnAllLights(false);
BreakerBox val4 = Object.FindObjectOfType<BreakerBox>();
if ((Object)(object)val4 != (Object)null)
{
((Component)val4).gameObject.SetActive(false);
}
GameObject val5 = GameObject.Find("Sun");
if ((Object)(object)val5 != (Object)null)
{
val5.SetActive(false);
}
try
{
Transform component = GameObject.Find("ShipLightsPost").GetComponent<Transform>();
List<Light> lightsUnderParent2 = LightUtils.GetLightsUnderParent(component);
Logger.LogInfo((object)$"Found {lightsUnderParent2.Count} floodlights in scene SampleSceneRelay");
HDAdditionalLightData val6 = default(HDAdditionalLightData);
foreach (Light item in lightsUnderParent2)
{
((Component)item).gameObject.TryGetComponent<HDAdditionalLightData>(ref val6);
if ((Object)(object)val6 != (Object)null)
{
val6.SetIntensity(30000f);
val6.SetSpotAngle(120f, 0f);
val6.SetRange(600f);
Floodlights.Add(val6);
}
}
}
catch (Exception arg)
{
Logger.LogWarning((object)$"Error while trying to modify floodlights: {arg}");
}
}
private void OnDisable()
{
if (!WeatherManager.IsSetupFinished)
{
return;
}
foreach (HDAdditionalLightData floodlight in Floodlights)
{
floodlight.SetIntensity(FloodlightIntensity);
floodlight.SetSpotAngle(FloodlightAngle, 0f);
floodlight.SetRange(FloodlightRange);
}
AllPoweredLights.Clear();
Floodlights.Clear();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MrovWeathers";
public const string PLUGIN_NAME = "MrovWeathers";
public const string PLUGIN_VERSION = "0.0.3";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace MrovWeathers.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}