using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 StaticNetcodeLib;
using Unity.Netcode;
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("EliteMasterEric")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Rebalances scrap properties to be more fair.")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("Ceva's Scrap Rebalance")]
[assembly: AssemblyTitle("Ceva's Scrap Rebalance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 CevaScrapRebalance
{
[StaticNetcode]
internal class NetworkRPC
{
[ServerRpc(RequireOwnership = false)]
public static void BroadcastApparatusValueServerRpc(NetworkObjectReference gameObjectRef)
{
//IL_0010: 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)
Plugin.Instance.PluginLogger.LogDebug((object)$"Server received Apparatus sync request: ({gameObjectRef})");
if (Plugin.Instance.PluginConfig.ShouldApplyAnyChanges())
{
int value = ScrapValueCalculator.CalculateApparatusScrapValue();
float weight = ScrapValueCalculator.CalculateApparatusScrapWeight();
ScrapHandedness twoHanded = ScrapValueCalculator.CalculateApparatusTwoHanded();
ScrapConductivity conductive = ScrapValueCalculator.CalculateApparatusConductive();
BroadcastApparatusValueClientRpc(gameObjectRef, value, weight, twoHanded, conductive);
}
}
[ClientRpc]
public static void BroadcastApparatusValueClientRpc(NetworkObjectReference gameObjectRef, int value, float weight, ScrapHandedness twoHanded, ScrapConductivity conductive)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
Plugin.Instance.PluginLogger.LogDebug((object)$"Client received Apparatus sync request: ({gameObjectRef}) ({value}, {weight}, {twoHanded}, {conductive})");
NetworkObject val = default(NetworkObject);
if (!((NetworkObjectReference)(ref gameObjectRef)).TryGet(ref val, (NetworkManager)null))
{
Plugin.Instance.PluginLogger.LogError((object)$"Could not retrieve Apparatus from NetworkObjectReference: ({gameObjectRef})");
}
LungProp component = ((Component)val).GetComponent<LungProp>();
if (weight > 0f && Plugin.Instance.PluginConfig.ShouldApplyScrapWeightChanges())
{
Plugin.Instance.PluginLogger.LogInfo((object)("Setting Apparatus weight to " + weight));
((GrabbableObject)component).itemProperties.weight = weight;
}
else
{
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus weight as default");
}
if (value > 0 && Plugin.Instance.PluginConfig.ShouldApplyScrapValueChanges())
{
Plugin.Instance.PluginLogger.LogInfo((object)("Setting Apparatus scrap value to " + value));
((GrabbableObject)component).SetScrapValue(value);
}
else
{
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus scrap value as default");
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapHandednessChanges())
{
switch (twoHanded)
{
case ScrapHandedness.OneHanded:
Plugin.Instance.PluginLogger.LogInfo((object)"Setting Apparatus to two-handed...");
ScrapValueCalculator.DisableItemTwoHanded(((GrabbableObject)component).itemProperties);
break;
case ScrapHandedness.TwoHanded:
Plugin.Instance.PluginLogger.LogInfo((object)"Setting Apparatus to one-handed...");
ScrapValueCalculator.EnableItemTwoHanded(((GrabbableObject)component).itemProperties);
break;
case ScrapHandedness.Default:
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus handedness as default");
break;
default:
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus handedness as default");
break;
}
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapConductivityChanges())
{
switch (conductive)
{
case ScrapConductivity.NonConductive:
Plugin.Instance.PluginLogger.LogInfo((object)"Enabling Apparatus conductivity...");
((GrabbableObject)component).itemProperties.isConductiveMetal = false;
break;
case ScrapConductivity.Conductive:
Plugin.Instance.PluginLogger.LogInfo((object)"Disabling Apparatus conductivity...");
((GrabbableObject)component).itemProperties.isConductiveMetal = true;
break;
case ScrapConductivity.Default:
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus conductivity as default");
break;
default:
Plugin.Instance.PluginLogger.LogInfo((object)"Leaving Apparatus conductivity as default");
break;
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_ID = "cevascraprebalance";
public const string PLUGIN_NAME = "CevaScrapRebalance";
public const string PLUGIN_VERSION = "1.2.0";
public const string PLUGIN_GUID = "com.elitemastereric.cevascraprebalance";
}
[BepInPlugin("com.elitemastereric.cevascraprebalance", "CevaScrapRebalance", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public ManualLogSource PluginLogger;
internal PluginConfig PluginConfig;
public static Plugin Instance { get; private set; }
private void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
Instance = this;
PluginLogger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.elitemastereric.cevascraprebalance");
val.PatchAll();
PluginLogger.LogInfo((object)"Plugin CevaScrapRebalance (com.elitemastereric.cevascraprebalance) is loaded!");
LoadConfig();
}
private void LoadConfig()
{
PluginConfig = new PluginConfig();
PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
}
}
internal class PluginConfig
{
public readonly string[] LEVELS = new string[11]
{
"Level1Experimentation", "Level2Assurance", "Level3Vow", "Level4March", "Level5Rend", "Level6Dine", "Level7Offense", "Level8Titan", "Level9Artifice", "Level10Adamance",
"Level11Embrion"
};
public readonly string[] SCRAPS = new string[56]
{
"Airhorn", "Bell", "BigBolt", "Bottles", "Brush", "Candy", "CashRegister", "ChemicalJug", "Clock", "ClownHorn",
"Comedy", "ControlPad", "CookieMoldPan", "DustPan", "EasterEgg", "EggBeater", "FancyLamp", "Flask", "GarbageLid", "Gift",
"GoldBar", "GoldenCup", "Hairdryer", "HomemadeFlashbang", "JarOfPickles", "LargeAxle", "LaserPointer", "Magic7Ball", "MagnifyingGlass", "MetalSheet",
"Mug", "OldPhone", "Painting", "PerfumeBottle", "PillBottle", "PlasticCup", "PlasticFish", "RedSoda", "Remote", "Ring",
"RubberDucky", "SoccerBall", "SteeringWheel", "StopSign", "TeaKettle", "Teeth", "ToiletPaper", "Toothpaste", "ToyCube", "ToyRobot",
"ToyTrain", "Tragedy", "VTypeEngine", "WhoopieCushion", "YieldSign", "ZedDog"
};
private Dictionary<string, ScrapConfig> ScrapConfigs;
private ConfigEntry<bool> EnableScrapValueChanges;
private ConfigEntry<bool> EnableScrapWeightChanges;
private ConfigEntry<bool> EnableScrapRarityChanges;
private ConfigEntry<bool> EnableScrapHandednessChanges;
private ConfigEntry<bool> EnableScrapConductivityChanges;
private ConfigEntry<int> MeteorShowerChance;
public PluginConfig()
{
ScrapConfigs = new Dictionary<string, ScrapConfig>();
}
public void BindConfig(ConfigFile config)
{
EnableScrapValueChanges = config.Bind<bool>("General", "EnableScrapValueChanges", true, "Whether to apply scrap value changes, false to disable for all items");
EnableScrapWeightChanges = config.Bind<bool>("General", "EnableScrapWeightChanges", true, "Whether to apply scrap weight changes, false to disable for all items");
EnableScrapRarityChanges = config.Bind<bool>("General", "EnableScrapRarityChanges", true, "Whether to apply scrap rarity changes, false to disable for all items");
EnableScrapHandednessChanges = config.Bind<bool>("General", "EnableScrapHandednessChanges", true, "Whether to apply scrap handedness changes, false to disable for all items");
EnableScrapConductivityChanges = config.Bind<bool>("General", "EnableScrapConductivityChanges", true, "Whether to apply scrap conductivity changes, false to disable for all items");
MeteorShowerChance = config.Bind<int>("Weather and Events", "MeteorShowerChance", -1, "The chance of a meteor shower (-1 = default, 0 = never, 7 = 0.7%, 1000 = 100%)");
BuildAndStoreScrapConfig(config, "Apparatus", "Apparatus Properties", useRarities: false);
BuildAndStoreScrapConfig(config, "Key", "Key Properties", useRarities: false, usePriceRange: false);
string[] sCRAPS = SCRAPS;
foreach (string item in sCRAPS)
{
BuildAndStoreScrapConfig(config, item);
}
}
private void BuildAndStoreScrapConfig(ConfigFile config, string item, string category = null, bool useRarities = true, bool usePriceRange = true)
{
ScrapConfigs[item] = BuildScrapConfig(config, item, category, useRarities, usePriceRange);
}
private ScrapConfig BuildScrapConfig(ConfigFile config, string item, string category = null, bool useRarities = true, bool usePriceRange = true)
{
if (category == null)
{
category = item + " Properties";
}
return new ScrapConfig(usePriceRange ? config.Bind<int>(category, item + "MinScrapValue", -1, "The minimum scrap value of " + item) : config.Bind<int>(category, item + "ScrapValue", -1, "The scrap value of " + item), usePriceRange ? config.Bind<int>(category, item + "MaxScrapValue", -1, "The maximum scrap value of " + item) : null, config.Bind<float>(category, item + "ScrapWeight", -1f, "The weight scrap value of " + item), useRarities ? BuildScrapConfigRarities(config, item, category) : null, config.Bind<ScrapHandedness>(category, item + "ScrapTwoHanded", ScrapHandedness.Default, "Whether the item " + item + " is two handed"), config.Bind<ScrapConductivity>(category, item + "ScrapConductivity", ScrapConductivity.Default, "Whether the item " + item + " is conductive"));
}
public Dictionary<string, ConfigEntry<int>> BuildScrapConfigRarities(ConfigFile config, string item, string category)
{
Dictionary<string, ConfigEntry<int>> dictionary = new Dictionary<string, ConfigEntry<int>>();
string[] lEVELS = LEVELS;
foreach (string text in lEVELS)
{
dictionary[text] = config.Bind<int>(category, item + "ScrapRarity" + text, -1, "The scrap rarity of " + item + " on " + text + "(-1 to use default)");
}
return dictionary;
}
public int CalculateMeteorShowerChance()
{
return MeteorShowerChance.Value;
}
public bool ShouldApplyScrapValueChanges()
{
return EnableScrapValueChanges.Value;
}
public bool ShouldApplyScrapWeightChanges()
{
return EnableScrapWeightChanges.Value;
}
public bool ShouldApplyScrapRarityChanges()
{
return EnableScrapRarityChanges.Value;
}
public bool ShouldApplyScrapHandednessChanges()
{
return EnableScrapHandednessChanges.Value;
}
public bool ShouldApplyScrapConductivityChanges()
{
return EnableScrapConductivityChanges.Value;
}
public bool ShouldApplyAnyChanges()
{
return ShouldApplyScrapValueChanges() || ShouldApplyScrapWeightChanges() || ShouldApplyScrapRarityChanges() || ShouldApplyScrapHandednessChanges() || ShouldApplyScrapConductivityChanges();
}
public ScrapConfig FetchScrapConfig(string item)
{
return ScrapConfigs[item];
}
public bool HasScrapConfig(string item)
{
return ScrapConfigs.ContainsKey(item);
}
public static string SanitizeScrapKey(string key)
{
return new CultureInfo("en-US", useUserOverride: false).TextInfo.ToTitleCase(key.Replace("-", " ").ToLower()).Replace(" ", "");
}
}
internal readonly record struct ScrapConfig(ConfigEntry<int> minValue, ConfigEntry<int> maxValue, ConfigEntry<float> weight, Dictionary<string, ConfigEntry<int>> rarities, ConfigEntry<ScrapHandedness> twoHanded, ConfigEntry<ScrapConductivity> conductive);
internal enum ScrapHandedness
{
Default,
OneHanded,
TwoHanded
}
internal enum ScrapConductivity
{
Default,
Conductive,
NonConductive
}
internal class ScrapValueCalculator
{
public const double BASE_SCRAP_MULTIPLIER = 2.5;
public const float WEIGHT_MULTIPLIER = 105f;
internal static void ApplyForItem(string sceneName, SpawnableItemWithRarity item)
{
Item spawnableItem = item.spawnableItem;
string text = PluginConfig.SanitizeScrapKey(spawnableItem.itemName);
if (!HasScrapConfig(text) || !Plugin.Instance.PluginConfig.ShouldApplyAnyChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)("Item " + text + " has no scrap config, leaving numbers as default."));
return;
}
Plugin.Instance.PluginLogger.LogDebug((object)("Item " + text + " has a scrap config, applying custom values..."));
int num = CalculateScrapMinValue(text);
int num2 = CalculateScrapMaxValue(text);
if (num > num2 && num2 >= 0)
{
Plugin.Instance.PluginLogger.LogWarning((object)" - Item min value is greater than max value. Swapping...");
int num3 = num2;
num = num2;
num2 = num3;
}
if (num >= 0 && Plugin.Instance.PluginConfig.ShouldApplyScrapValueChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Min Value: " + num));
spawnableItem.minValue = num;
}
else
{
Plugin.Instance.PluginLogger.LogDebug((object)" - Min Value: DEFAULT");
}
if (num2 >= 0 && Plugin.Instance.PluginConfig.ShouldApplyScrapValueChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Max Value: " + num2));
spawnableItem.maxValue = num2;
}
else
{
Plugin.Instance.PluginLogger.LogDebug((object)" - Max Value: DEFAULT");
}
float num4 = CalculateScrapWeight(text);
float weight = CalculateScrapInternalWeight(text);
if (num4 >= 0f && Plugin.Instance.PluginConfig.ShouldApplyScrapWeightChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Weight: " + num4 + " (" + weight + ")"));
spawnableItem.weight = weight;
}
else
{
Plugin.Instance.PluginLogger.LogDebug((object)" - Weight: DEFAULT");
}
int num5 = CalculateScrapRarity(text, sceneName);
if (num5 >= 0 && Plugin.Instance.PluginConfig.ShouldApplyScrapRarityChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Rarity (" + sceneName + "): " + num5));
item.rarity = num5;
}
else
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Rarity (" + sceneName + "): DEFAULT"));
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapHandednessChanges())
{
ApplyItemTwoHanded(text, spawnableItem);
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapConductivityChanges())
{
ApplyItemConductive(text, spawnableItem);
}
}
internal static int CalculateApparatusScrapValue()
{
ScrapConfig scrapConfig = Plugin.Instance.PluginConfig.FetchScrapConfig("Apparatus");
int num = scrapConfig.minValue.Value;
int num2 = scrapConfig.maxValue.Value;
if (num < 0 && num2 < 0)
{
return -1;
}
if (num < 0)
{
num = 80;
}
if (num2 < 0)
{
num2 = 80;
}
if (num == num2)
{
return num;
}
if (num > num2)
{
Plugin.Instance.PluginLogger.LogWarning((object)" - Item min value is greater than max value. Swapping...");
int num3 = num2;
num = num2;
num2 = num3;
}
return RoundManager.Instance.AnomalyRandom.Next(num, num2);
}
internal static float CalculateApparatusScrapWeight()
{
ScrapConfig scrapConfig = Plugin.Instance.PluginConfig.FetchScrapConfig("Apparatus");
if (scrapConfig.weight.Value < 0f)
{
return -1f;
}
return CalculateInternalWeight(scrapConfig.weight.Value);
}
internal static ScrapHandedness CalculateApparatusTwoHanded()
{
return Plugin.Instance.PluginConfig.FetchScrapConfig("Apparatus").twoHanded.Value;
}
internal static void ApplyApparatusTwoHanded(Item properties)
{
switch (CalculateApparatusTwoHanded())
{
case ScrapHandedness.OneHanded:
DisableItemTwoHanded(properties);
break;
case ScrapHandedness.TwoHanded:
EnableItemTwoHanded(properties);
break;
case ScrapHandedness.Default:
break;
}
}
internal static ScrapConductivity CalculateApparatusConductive()
{
return Plugin.Instance.PluginConfig.FetchScrapConfig("Apparatus").conductive.Value;
}
internal static void ApplyApparatusConductive(Item properties)
{
switch (CalculateApparatusConductive())
{
case ScrapConductivity.NonConductive:
properties.isConductiveMetal = false;
break;
case ScrapConductivity.Conductive:
properties.isConductiveMetal = true;
break;
case ScrapConductivity.Default:
break;
}
}
internal static bool HasScrapConfig(string item)
{
return Plugin.Instance.PluginConfig.HasScrapConfig(item);
}
internal static int CalculateScrapMinValue(string item)
{
return (int)Math.Floor((double)Plugin.Instance.PluginConfig.FetchScrapConfig(item).minValue.Value * 2.5);
}
internal static int CalculateScrapMaxValue(string item)
{
return (int)Math.Floor((double)Plugin.Instance.PluginConfig.FetchScrapConfig(item).maxValue.Value * 2.5);
}
internal static float CalculateScrapWeight(string item)
{
return Plugin.Instance.PluginConfig.FetchScrapConfig(item).weight.Value;
}
internal static float CalculateScrapInternalWeight(string item)
{
return CalculateInternalWeight(CalculateScrapWeight(item));
}
internal static int CalculateScrapRarity(string item, string scene)
{
ScrapConfig scrapConfig = Plugin.Instance.PluginConfig.FetchScrapConfig(item);
if (!scrapConfig.rarities.ContainsKey(scene))
{
return -1;
}
return scrapConfig.rarities[scene]?.Value ?? (-1);
}
internal static void ApplyItemTwoHanded(string item, Item properties)
{
if (HasScrapConfig(item))
{
switch (Plugin.Instance.PluginConfig.FetchScrapConfig(item).twoHanded.Value)
{
case ScrapHandedness.OneHanded:
DisableItemTwoHanded(properties);
break;
case ScrapHandedness.TwoHanded:
EnableItemTwoHanded(properties);
break;
case ScrapHandedness.Default:
break;
}
}
}
internal static void ApplyItemConductive(string item, Item properties)
{
if (HasScrapConfig(item))
{
switch (Plugin.Instance.PluginConfig.FetchScrapConfig(item).conductive.Value)
{
case ScrapConductivity.NonConductive:
properties.isConductiveMetal = false;
break;
case ScrapConductivity.Conductive:
properties.isConductiveMetal = true;
break;
case ScrapConductivity.Default:
break;
}
}
}
internal static void EnableItemTwoHanded(Item properties)
{
properties.twoHanded = true;
properties.twoHandedAnimation = true;
properties.grabAnim = "HoldLung";
}
internal static void DisableItemTwoHanded(Item properties)
{
properties.twoHanded = false;
properties.twoHandedAnimation = false;
properties.grabAnim = "";
}
internal static float CalculateInternalWeight(float weight)
{
return weight / 105f + 1f;
}
internal static void ApplyForClipboard(ClipboardItem item)
{
((GrabbableObject)item).itemProperties.isScrap = false;
((GrabbableObject)item).itemProperties.minValue = 0;
((GrabbableObject)item).itemProperties.maxValue = 0;
((GrabbableObject)item).SetScrapValue(0);
}
internal static void ApplyForKey(KeyItem item)
{
Item itemProperties = ((GrabbableObject)item).itemProperties;
Plugin.Instance.PluginLogger.LogDebug((object)"Item Key has a scrap config, applying custom values...");
itemProperties.isScrap = true;
int value = Plugin.Instance.PluginConfig.FetchScrapConfig("Key").minValue.Value;
if (value >= 0 && Plugin.Instance.PluginConfig.ShouldApplyScrapValueChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Value: " + value));
itemProperties.minValue = value;
itemProperties.maxValue = value;
((GrabbableObject)item).SetScrapValue(value);
}
float num = CalculateScrapWeight("Key");
float weight = CalculateScrapInternalWeight("Key");
if (num >= 0f && Plugin.Instance.PluginConfig.ShouldApplyScrapWeightChanges())
{
Plugin.Instance.PluginLogger.LogDebug((object)(" - Weight: " + num + " (" + weight + ")"));
itemProperties.weight = weight;
}
else
{
Plugin.Instance.PluginLogger.LogDebug((object)" - Weight: DEFAULT");
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapHandednessChanges())
{
ApplyItemTwoHanded("Key", itemProperties);
}
if (Plugin.Instance.PluginConfig.ShouldApplyScrapConductivityChanges())
{
ApplyItemConductive("Key", itemProperties);
}
}
}
}
namespace CevaScrapRebalance.Patch
{
[HarmonyPatch(typeof(LungProp))]
[HarmonyPatch("DisconnectFromMachinery")]
internal class LungPropDisconnectFromMachineryPatch
{
public static void Postfix(LungProp __instance, ref IEnumerator __result)
{
try
{
Action prefixAction = delegate
{
Console.WriteLine("--> beginning");
};
Action postfixAction = delegate
{
Console.WriteLine("--> end");
HandleApparatusGrab(__instance);
};
Action<object> preItemAction = delegate(object item)
{
Console.WriteLine($"--> before {item}");
};
Action<object> postItemAction = delegate(object item)
{
Console.WriteLine($"--> after {item}");
};
Func<object, object> itemAction = delegate(object item)
{
string text = item?.ToString() + "+";
Console.WriteLine($"--> item {item} => {text}");
return text;
};
SimpleEnumerator simpleEnumerator = new SimpleEnumerator
{
enumerator = __result,
prefixAction = prefixAction,
postfixAction = postfixAction,
preItemAction = preItemAction,
postItemAction = postItemAction,
itemAction = itemAction
};
__result = simpleEnumerator.GetEnumerator();
}
catch (Exception ex)
{
Plugin.Instance.PluginLogger.LogError((object)("Error in MimicDoorAttackPatch.Postfix: " + ex));
Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace);
}
}
private static void HandleApparatusGrab(LungProp apparatus)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
Plugin.Instance.PluginLogger.LogInfo((object)"Apparatus retrieved, fixing properties...");
NetworkRPC.BroadcastApparatusValueServerRpc(NetworkObjectReference.op_Implicit(((Component)apparatus).gameObject));
}
}
internal class SimpleEnumerator : IEnumerable
{
public IEnumerator enumerator;
public Action prefixAction;
public Action postfixAction;
public Action<object> preItemAction;
public Action<object> postItemAction;
public Func<object, object> itemAction;
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public IEnumerator GetEnumerator()
{
prefixAction();
while (enumerator.MoveNext())
{
object item = enumerator.Current;
preItemAction(item);
yield return itemAction(item);
postItemAction(item);
}
postfixAction();
}
}
[HarmonyPatch(typeof(GrabbableObject))]
[HarmonyPatch("Start")]
internal class GrabbableObjectStartPatch2
{
public static void Postfix(GrabbableObject __instance)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
if (__instance is ClipboardItem)
{
Plugin.Instance.PluginLogger.LogInfo((object)"Clipboard spawned, applying Clipboard values...");
ScrapValueCalculator.ApplyForClipboard((ClipboardItem)__instance);
}
}
}
[HarmonyPatch(typeof(RoundManager))]
[HarmonyPatch("Start")]
internal class RoundManagerStartPatch
{
public static void Postfix(RoundManager __instance)
{
if (Plugin.Instance.PluginConfig.ShouldApplyAnyChanges())
{
Plugin.Instance.PluginLogger.LogInfo((object)"Game initialized, applying custom Key values...");
ApplyForKey(__instance);
}
}
private static void ApplyForKey(RoundManager instance)
{
KeyItem component = instance.keyPrefab.GetComponent<KeyItem>();
if ((Object)(object)component == (Object)null)
{
Plugin.Instance.PluginLogger.LogError((object)"Could not retrieve key prefab from RoundManager!");
}
else
{
ScrapValueCalculator.ApplyForKey(component);
}
}
}
[HarmonyPatch(typeof(GrabbableObject))]
[HarmonyPatch("Start")]
internal class GrabbableObjectStartPatch1
{
public static void Postfix(GrabbableObject __instance)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
if (Plugin.Instance.PluginConfig.ShouldApplyAnyChanges() && __instance is KeyItem)
{
Plugin.Instance.PluginLogger.LogInfo((object)"Key spawned, applying custom Key values...");
ScrapValueCalculator.ApplyForKey((KeyItem)__instance);
}
}
}
[HarmonyPatch(typeof(TimeOfDay))]
[HarmonyPatch("Start")]
internal class TimeOfDayStartPatch
{
public static void Postfix(TimeOfDay __instance)
{
int num = Plugin.Instance.PluginConfig.CalculateMeteorShowerChance();
if (num >= 0)
{
Plugin.Instance.PluginLogger.LogInfo((object)"Game initialized, applying Meteor Shower values...");
__instance.overrideMeteorChance = num;
}
else
{
Plugin.Instance.PluginLogger.LogInfo((object)"Game initialized, leaving Meteor Shower values at default...");
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("Start")]
internal class StartOfRoundStartPatch
{
public static void Postfix(StartOfRound __instance)
{
if (Plugin.Instance.PluginConfig.ShouldApplyAnyChanges())
{
Plugin.Instance.PluginLogger.LogInfo((object)"Game initialized, applying custom scrap values...");
ApplyForLevels(__instance.levels);
}
}
private static void ApplyForLevels(SelectableLevel[] levels)
{
if (!Plugin.Instance.PluginConfig.ShouldApplyAnyChanges())
{
return;
}
foreach (SelectableLevel val in levels)
{
foreach (SpawnableItemWithRarity item in val.spawnableScrap)
{
ScrapValueCalculator.ApplyForItem(val.sceneName, item);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit
{
}
}