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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
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: AssemblyCompany("Rbnelr.WeatherScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WeatherScrap")]
[assembly: AssemblyTitle("Rbnelr.WeatherScrap")]
[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 WeatherScrap
{
[BepInPlugin("Rbnelr.WeatherScrap", "WeatherScrap", "1.0.0")]
public class WeatherScrap : BaseUnityPlugin
{
public Dictionary<LevelWeatherType, ConfigEntry<float>> WeatherScrapAmounts;
public Dictionary<string, ConfigEntry<float>> LevelScrapAmounts;
public static WeatherScrap Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private WeatherScrap()
{
WeatherScrapAmounts = new Dictionary<LevelWeatherType, ConfigEntry<float>>
{
{
(LevelWeatherType)(-1),
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountClear", 1f, "Scrap Amount Multiplier")
},
{
(LevelWeatherType)1,
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountRainy", 1.1f, "Scrap Amount Multiplier")
},
{
(LevelWeatherType)2,
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountStormy", 1.2f, "Scrap Amount Multiplier")
},
{
(LevelWeatherType)3,
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountFoggy", 1.2f, "Scrap Amount Multiplier")
},
{
(LevelWeatherType)4,
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountFlooded", 1.25f, "Scrap Amount Multiplier")
},
{
(LevelWeatherType)5,
((BaseUnityPlugin)this).Config.Bind<float>("Weather", "ScrapAmountEclipsed", 1.6f, "Scrap Amount Multiplier")
}
};
LevelScrapAmounts = new Dictionary<string, ConfigEntry<float>>();
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
Logger.LogInfo((object)"Rbnelr.WeatherScrap v1.0.0 has loaded!");
}
internal static void Patch()
{
//IL_000d: 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_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("Rbnelr.WeatherScrap");
}
Logger.LogInfo((object)"Patching...");
Harmony.PatchAll(typeof(StartOfRoundPatch));
Harmony.PatchAll(typeof(RoundManagerPatch));
Logger.LogInfo((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogInfo((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogInfo((object)"Finished unpatching!");
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePostfix(StartOfRound __instance)
{
WeatherScrap.Logger.LogInfo((object)"StartOfRound.Awake Prefix!");
SelectableLevel[] levels = __instance.levels;
foreach (SelectableLevel val in levels)
{
ConfigEntry<float> val2 = createEntry(((Object)val).name);
AdjustLevel(val, val2.Value);
}
}
private static ConfigEntry<float> createEntry(string levelName)
{
string text = Regex.Replace(levelName, "Level$", "");
if (text.Length > 0)
{
text = char.ToUpper(text[0]) + text.Substring(1);
}
WeatherScrap.Instance.LevelScrapAmounts[levelName] = ((BaseUnityPlugin)WeatherScrap.Instance).Config.Bind<float>("Level", "ScrapAmount" + text, 1f, "Scrap Amount Multiplier");
return WeatherScrap.Instance.LevelScrapAmounts[levelName];
}
private static void AdjustLevel(SelectableLevel level, float scrapMultiplier)
{
if (scrapMultiplier != 1f)
{
int minScrap = level.minScrap;
int maxScrap = level.maxScrap;
level.minScrap = (int)MathF.Ceiling((float)level.minScrap * scrapMultiplier);
level.maxScrap = (int)MathF.Ceiling((float)level.maxScrap * scrapMultiplier);
WeatherScrap.Logger.LogInfo((object)$"Adjusted Scrap for {((Object)level).name}: minScrap: {minScrap} -> {level.minScrap} maxScrap: {maxScrap} -> {level.maxScrap}");
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPrefix]
private static void SpawnScrapInLevelPrefix(RoundManager __instance)
{
//IL_0017: 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_0027: 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_0042: Unknown result type (might be due to invalid IL or missing references)
WeatherScrap.Logger.LogInfo((object)"RoundManager.SpawnScrapInLevel Prefix!");
LevelWeatherType currentWeather = __instance.currentLevel.currentWeather;
if (WeatherScrap.Instance.WeatherScrapAmounts.ContainsKey(currentWeather))
{
__instance.scrapAmountMultiplier *= WeatherScrap.Instance.WeatherScrapAmounts[currentWeather].Value;
}
WeatherScrap.Logger.LogInfo((object)$"Weather: {currentWeather}, scrapValueMultiplier: {__instance.scrapValueMultiplier}, scrapAmountMultiplier: {__instance.scrapAmountMultiplier}");
}
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPostfix]
private static void SpawnScrapInLevelPostfix(RoundManager __instance)
{
//IL_0017: 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_0027: 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)
WeatherScrap.Logger.LogInfo((object)"RoundManager.SpawnScrapInLevel Postfix!");
LevelWeatherType currentWeather = __instance.currentLevel.currentWeather;
if (WeatherScrap.Instance.WeatherScrapAmounts.ContainsKey(currentWeather))
{
__instance.scrapAmountMultiplier /= WeatherScrap.Instance.WeatherScrapAmounts[currentWeather].Value;
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Rbnelr.WeatherScrap";
public const string PLUGIN_NAME = "WeatherScrap";
public const string PLUGIN_VERSION = "1.0.0";
}
}