

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using ShipInventoryUpdated.Configurations;
using ShipInventoryUpdated.Helpers.API;
using ShipInventoryUpdated.Objects;
using ShipInventoryUpdated.Scripts;
using Steamworks;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
using com.github.zehsteam.SellMyScrap.Commands;
using com.github.zehsteam.SellMyScrap.Data;
using com.github.zehsteam.SellMyScrap.Dependencies;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Extensions;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Objects;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Patches;
using com.github.zehsteam.SellMyScrap.Dependencies.Vanilla;
using com.github.zehsteam.SellMyScrap.Extensions;
using com.github.zehsteam.SellMyScrap.Helpers;
using com.github.zehsteam.SellMyScrap.Helpers.ScrapMatchAlgorithms;
using com.github.zehsteam.SellMyScrap.Managers;
using com.github.zehsteam.SellMyScrap.MonoBehaviours;
using com.github.zehsteam.SellMyScrap.NetcodePatcher;
using com.github.zehsteam.SellMyScrap.Objects;
using com.github.zehsteam.SellMyScrap.Patches;
using com.github.zehsteam.SellMyScrap.ScrapEaters;
using com.github.zehsteam.TakeyPlush.Managers;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("ShipInventoryUpdated")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2026 Zehs")]
[assembly: AssemblyDescription("[v73+] Adds a few terminal commands to sell your scrap from the ship or cruiser. Highly Configurable. Compatible with the ShipInventoryUpdated mod. SellFromTerminal +")]
[assembly: AssemblyFileVersion("1.15.3.0")]
[assembly: AssemblyInformationalVersion("1.15.3+ce02e090196b7cde0bc9863c7c029afde99ae47e")]
[assembly: AssemblyProduct("SellMyScrap v73+")]
[assembly: AssemblyTitle("com.github.zehsteam.SellMyScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.15.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
{
object IEnumerator.Current => _item;
T IEnumerator<T>.Current => _item;
public Enumerator(T item)
{
_item = item;
}
bool IEnumerator.MoveNext()
{
if (!_moveNextCalled)
{
return _moveNextCalled = true;
}
return false;
}
void IEnumerator.Reset()
{
_moveNextCalled = false;
}
void IDisposable.Dispose()
{
}
}
int ICollection.Count => 1;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => 1;
T IReadOnlyList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
}
int ICollection<T>.Count => 1;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlySingleElementList(T item)
{
_item = item;
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection.CopyTo(Array array, int index)
{
array.SetValue(_item, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return EqualityComparer<T>.Default.Equals(_item, (T)value);
}
int IList.IndexOf(object value)
{
if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
{
return -1;
}
return 0;
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return EqualityComparer<T>.Default.Equals(_item, item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
array[arrayIndex] = _item;
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
if (!EqualityComparer<T>.Default.Equals(_item, item))
{
return -1;
}
return 0;
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
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 com.github.zehsteam.SellMyScrap
{
internal static class Assets
{
public static GameObject NetworkHandlerPrefab { get; private set; }
public static GameObject OctolarScrapEaterPrefab { get; private set; }
public static GameObject TakeyScrapEaterPrefab { get; private set; }
public static GameObject MaxwellScrapEaterPrefab { get; private set; }
public static GameObject YippeeScrapEaterPrefab { get; private set; }
public static GameObject CookieFumoScrapEaterPrefab { get; private set; }
public static GameObject PsychoScrapEaterPrefab { get; private set; }
public static GameObject ZombiesScrapEaterPrefab { get; private set; }
public static GameObject WolfyScrapEaterPrefab { get; private set; }
public static GameObject GlitchScrapEaterPrefab { get; private set; }
public static AudioClip BrainRotIntroSpeechSFX { get; private set; }
public static void Load()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = "sellmyscrap_assets";
string text2 = Path.Combine(directoryName, text);
if (!File.Exists(text2))
{
Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file.");
}
else
{
AssetBundle val = AssetBundle.LoadFromFile(text2);
if ((Object)(object)val == (Object)null)
{
Logger.LogFatal("Failed to load assets. AssetBundle is null.");
}
else
{
HandleAssetBundleLoaded(val);
}
}
}
private static void HandleAssetBundleLoaded(AssetBundle assetBundle)
{
NetworkHandlerPrefab = LoadAsset<GameObject>("NetworkHandler", assetBundle);
NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
OctolarScrapEaterPrefab = LoadAsset<GameObject>("OctolarScrapEater", assetBundle);
TakeyScrapEaterPrefab = LoadAsset<GameObject>("TakeyScrapEater", assetBundle);
MaxwellScrapEaterPrefab = LoadAsset<GameObject>("MaxwellScrapEater", assetBundle);
YippeeScrapEaterPrefab = LoadAsset<GameObject>("YippeeScrapEater", assetBundle);
CookieFumoScrapEaterPrefab = LoadAsset<GameObject>("CookieFumoScrapEater", assetBundle);
PsychoScrapEaterPrefab = LoadAsset<GameObject>("PsychoScrapEater", assetBundle);
ZombiesScrapEaterPrefab = LoadAsset<GameObject>("ZombiesScrapEater", assetBundle);
WolfyScrapEaterPrefab = LoadAsset<GameObject>("WolfyScrapEater", assetBundle);
GlitchScrapEaterPrefab = LoadAsset<GameObject>("GlitchScrapEater", assetBundle);
BrainRotIntroSpeechSFX = LoadAsset<AudioClip>("BrainRotIntroSpeechSFX", assetBundle);
}
private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
{
if (string.IsNullOrWhiteSpace(name))
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace.");
return default(T);
}
if ((Object)(object)assetBundle == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null.");
return default(T);
}
T val = assetBundle.LoadAsset<T>(name);
if ((Object)(object)val == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name.");
return default(T);
}
return val;
}
private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
{
asset = LoadAsset<T>(name, assetBundle);
return (Object)(object)asset != (Object)null;
}
}
internal static class Logger
{
public static ManualLogSource ManualLogSource { get; private set; }
public static void Initialize(ManualLogSource manualLogSource)
{
ManualLogSource = manualLogSource;
}
public static void LogDebug(object data)
{
Log((LogLevel)32, data);
}
public static void LogInfo(object data, bool extended = false)
{
Log((LogLevel)16, data, extended);
}
public static void LogMessage(object data, bool extended = false)
{
Log((LogLevel)8, data, extended);
}
public static void LogWarning(object data, bool extended = false)
{
Log((LogLevel)4, data, extended);
}
public static void LogError(object data, bool extended = false)
{
Log((LogLevel)2, data, extended);
}
public static void LogFatal(object data, bool extended = false)
{
Log((LogLevel)1, data, extended);
}
public static void Log(LogLevel logLevel, object data, bool extended = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!extended || IsExtendedLoggingEnabled())
{
ManualLogSource manualLogSource = ManualLogSource;
if (manualLogSource != null)
{
manualLogSource.Log(logLevel, data);
}
}
}
public static bool IsExtendedLoggingEnabled()
{
if (ConfigManager.ExtendedLogging == null)
{
return false;
}
return ConfigManager.ExtendedLogging.Value;
}
}
internal static class ConfigManager
{
public static ConfigFile ConfigFile { get; private set; }
public static ConfigEntry<bool> ExtendedLogging { get; private set; }
public static SyncedConfigEntry<bool> SellGifts { get; private set; }
public static SyncedConfigEntry<bool> SellShotguns { get; private set; }
public static SyncedConfigEntry<bool> SellAmmo { get; private set; }
public static SyncedConfigEntry<bool> SellKnives { get; private set; }
public static SyncedConfigEntry<bool> SellPickles { get; private set; }
public static SyncedConfigEntry<bool> SellScrapWorthZero { get; private set; }
public static SyncedConfigEntry<bool> OnlySellScrapOnFloor { get; private set; }
public static SyncedConfigEntry<string> PrioritySellList { get; private set; }
public static SyncedConfigEntry<string> DontSellList { get; private set; }
public static SyncedConfigEntry<string> SellList { get; private set; }
public static string[] PrioritySellListArray
{
get
{
return PrioritySellList.Value.StringToCollection<string>().ToArray();
}
set
{
PrioritySellList.Value = value.CollectionToString();
}
}
public static string[] DontSellListArray
{
get
{
return DontSellList.Value.StringToCollection<string>().ToArray();
}
set
{
DontSellList.Value = value.CollectionToString();
}
}
public static string[] SellListArray
{
get
{
return SellList.Value.StringToCollection<string>().ToArray();
}
set
{
SellList.Value = value.CollectionToString();
}
}
public static ConfigEntry<bool> OverrideWelcomeMessage { get; private set; }
public static ConfigEntry<bool> OverrideHelpMessage { get; private set; }
public static ConfigEntry<bool> ShowFoundItems { get; private set; }
public static ConfigEntry<bool> SortFoundItemsPrice { get; private set; }
public static ConfigEntry<bool> AlignFoundItemsPrice { get; private set; }
public static ConfigEntry<bool> SpeakInShip { get; private set; }
public static ConfigEntry<float> RareVoiceLineChance { get; private set; }
public static ConfigEntry<bool> ShowQuotaWarning { get; private set; }
public static ConfigEntry<int> ScrapEaterChance { get; private set; }
public static ConfigEntry<int> OctolarSpawnWeight { get; private set; }
public static ConfigEntry<int> TakeySpawnWeight { get; private set; }
public static ConfigEntry<int> MaxwellSpawnWeight { get; private set; }
public static ConfigEntry<int> YippeeSpawnWeight { get; private set; }
public static ConfigEntry<int> CookieFumoSpawnWeight { get; private set; }
public static ConfigEntry<int> PsychoSpawnWeight { get; private set; }
public static ConfigEntry<int> ZombiesSpawnWeight { get; private set; }
public static ConfigEntry<int> WolfySpawnWeight { get; private set; }
public static ConfigEntry<int> GlitchSpawnWeight { get; private set; }
public static void Initialize(ConfigFile configFile)
{
ConfigFile = configFile;
BindConfigs();
}
private static void BindConfigs()
{
ConfigHelper.SkipAutoGen();
ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
SellGifts = ConfigHelper.BindSynced("Sell", "SellGifts", defaultValue: false, "Do you want to sell Gifts?");
SellShotguns = ConfigHelper.BindSynced("Sell", "SellShotguns", defaultValue: false, "Do you want to sell Shotguns?");
SellAmmo = ConfigHelper.BindSynced("Sell", "SellAmmo", defaultValue: false, "Do you want to sell Ammo?");
SellKnives = ConfigHelper.BindSynced("Sell", "SellKnives", defaultValue: false, "Do you want to sell Kitchen knives?");
SellPickles = ConfigHelper.BindSynced("Sell", "SellPickles", defaultValue: true, "Do you want to sell Jar of pickles?");
SellScrapWorthZero = ConfigHelper.BindSynced("Advanced Sell", "SellScrapWorthZero", defaultValue: false, "Do you want to sell scrap worth zero?");
OnlySellScrapOnFloor = ConfigHelper.BindSynced("Advanced Sell", "OnlySellScrapOnFloor", defaultValue: false, "Do you want to sell scrap that is only on the floor?");
PrioritySellList = ConfigHelper.BindSynced("Advanced Sell", "PrioritySellList", "Tragedy, Comedy, Whoopie cushion, Easter egg, Clock, Soccer ball", GetPrioritySellListDescription());
DontSellList = ConfigHelper.BindSynced("Advanced Sell", "DontSellList", "", GetDontSellListDescription());
SellList = ConfigHelper.BindSynced("Advanced Sell", "SellList", "Whoopie cushion, Easter egg, Tragedy, Comedy", GetSellListDescription());
OverrideWelcomeMessage = ConfigHelper.Bind("Terminal", "OverrideWelcomeMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal welcome message to add additional info.");
OverrideHelpMessage = ConfigHelper.Bind("Terminal", "OverrideHelpMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal help message to add additional info.");
ShowFoundItems = ConfigHelper.Bind("Terminal", "ShowFoundItems", defaultValue: true, requiresRestart: false, "Show found items on the confirmation screen.");
SortFoundItemsPrice = ConfigHelper.Bind("Terminal", "SortFoundItemsPrice", defaultValue: true, requiresRestart: false, "Sorts found items from most to least expensive.");
AlignFoundItemsPrice = ConfigHelper.Bind("Terminal", "AlignFoundItemsPrice", defaultValue: true, requiresRestart: false, "Align all prices of found items.");
SpeakInShip = ConfigHelper.Bind("Misc", "SpeakInShip", defaultValue: true, requiresRestart: false, "The Company will speak inside your ship after selling from the terminal.");
RareVoiceLineChance = ConfigHelper.Bind("Misc", "RareVoiceLineChance", 5f, requiresRestart: false, "The percent chance the Company will say a rare microphone voice line after selling.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
ShowQuotaWarning = ConfigHelper.Bind("Misc", "ShowQuotaWarning", defaultValue: true, requiresRestart: false, "If enabled, will show a warning when you try to pull the ship's lever when the quota hasn't been fulfilled at the Company building with 0 days left.");
ScrapEaterChance = ConfigHelper.Bind("Scrap Eater", "ScrapEaterChance", 0, requiresRestart: false, "The percent chance a scrap eater will spawn?!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
OctolarSpawnWeight = ConfigHelper.Bind("Scrap Eater", "OctolarSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Octolar will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
TakeySpawnWeight = ConfigHelper.Bind("Scrap Eater", "TakeySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Takey will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
MaxwellSpawnWeight = ConfigHelper.Bind("Scrap Eater", "MaxwellSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Maxwell will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
YippeeSpawnWeight = ConfigHelper.Bind("Scrap Eater", "YippeeSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Yippee will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
CookieFumoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "CookieFumoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Cookie Fumo will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
PsychoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "PsychoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Psycho will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
ZombiesSpawnWeight = ConfigHelper.Bind("Scrap Eater", "ZombiesSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Zombies will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
WolfySpawnWeight = ConfigHelper.Bind("Scrap Eater", "WolfySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Wolfy will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
GlitchSpawnWeight = ConfigHelper.Bind("Scrap Eater", "GlitchSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Glitch will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
}
private static string GetPrioritySellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to prioritize when selling.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
private static string GetDontSellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to not sell.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
private static string GetSellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to sell when using the `sell list` command.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
}
[BepInPlugin("com.github.zehsteam.SellMyScrap", "SellMyScrap v73+", "1.15.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.SellMyScrap");
private const string TargetUnityVersion = "2022.3.62";
internal static Plugin Instance { get; private set; }
private void Awake()
{
Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.SellMyScrap"));
if (!Utils.IsUnityVersion("2022.3.62"))
{
Logger.LogWarning("Skipping SellMyScrap v73+ because it targets a different version of Unity (2022.3.62)");
return;
}
Instance = this;
Logger.LogInfo("SellMyScrap v73+ has awoken!");
_harmony.PatchAll(typeof(GameNetworkManagerPatch));
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(TimeOfDayPatch));
_harmony.PatchAll(typeof(HUDManagerPatch));
_harmony.PatchAll(typeof(TerminalPatch));
_harmony.PatchAll(typeof(DepositItemsDeskPatch));
_harmony.PatchAll(typeof(StartMatchLeverPatch));
_harmony.PatchAll(typeof(InteractTriggerPatch));
if (ShipInventoryProxy.Enabled)
{
ShipInventoryProxy.PatchAll(_harmony);
}
Assets.Load();
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
ScrapEaterManager.Initialize();
NetcodePatcherAwake();
}
private void NetcodePatcherAwake()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type[] types = executingAssembly.GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
try
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
try
{
methodInfo.Invoke(null, null);
}
catch (TargetInvocationException ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message));
}
}
}
catch (Exception ex2)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message));
}
}
}
}
catch (Exception ex3)
{
((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message));
}
}
public static void HandleLocalDisconnect()
{
CommandManager.OnLocalDisconnect();
SellManager.CancelSellRequest();
}
public static void HandleTerminalQuit()
{
CommandManager.OnTerminalQuit();
SellManager.CancelSellRequest();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.SellMyScrap";
public const string PLUGIN_NAME = "SellMyScrap v73+";
public const string PLUGIN_VERSION = "1.15.3";
}
}
namespace com.github.zehsteam.SellMyScrap.ScrapEaters
{
public class ScrapEater
{
public GameObject SpawnPrefab;
public Func<int> GetSpawnWeight;
public ScrapEater(GameObject spawnPrefab, Func<int> getSpawnWeight)
{
SpawnPrefab = spawnPrefab;
GetSpawnWeight = getSpawnWeight;
}
}
public static class ScrapEaterManager
{
public static List<ScrapEater> ScrapEaters { get; private set; } = new List<ScrapEater>();
internal static void Initialize()
{
ScrapEaters = new List<ScrapEater>(9)
{
new ScrapEater(Assets.OctolarScrapEaterPrefab, () => ConfigManager.OctolarSpawnWeight.Value),
new ScrapEater(Assets.TakeyScrapEaterPrefab, () => ConfigManager.TakeySpawnWeight.Value),
new ScrapEater(Assets.MaxwellScrapEaterPrefab, () => ConfigManager.MaxwellSpawnWeight.Value),
new ScrapEater(Assets.YippeeScrapEaterPrefab, () => ConfigManager.YippeeSpawnWeight.Value),
new ScrapEater(Assets.CookieFumoScrapEaterPrefab, () => ConfigManager.CookieFumoSpawnWeight.Value),
new ScrapEater(Assets.PsychoScrapEaterPrefab, () => ConfigManager.PsychoSpawnWeight.Value),
new ScrapEater(Assets.ZombiesScrapEaterPrefab, () => ConfigManager.ZombiesSpawnWeight.Value),
new ScrapEater(Assets.WolfyScrapEaterPrefab, () => ConfigManager.WolfySpawnWeight.Value),
new ScrapEater(Assets.GlitchScrapEaterPrefab, () => ConfigManager.GlitchSpawnWeight.Value)
};
}
internal static bool CanUseScrapEater()
{
int value = ConfigManager.ScrapEaterChance.Value;
return Utils.RollPercentChance(value);
}
internal static bool HasScrapEater(int index)
{
if (ScrapEaters.Count == 0)
{
return false;
}
if (index < 0 || index > ScrapEaters.Count - 1)
{
return false;
}
return true;
}
public static void AddScrapEater(GameObject spawnPrefab, Func<int> GetSpawnWeight)
{
ScrapEaters.Add(new ScrapEater(spawnPrefab, GetSpawnWeight));
}
internal static void StartRandomScrapEaterOnServer(List<GrabbableObject> scrap, int variantIndex = -1)
{
if (NetworkUtils.IsServer)
{
int randomScrapEaterIndex = GetRandomScrapEaterIndex();
if (randomScrapEaterIndex != -1)
{
StartScrapEaterOnServer(randomScrapEaterIndex, scrap, variantIndex);
}
}
}
internal static void StartScrapEaterOnServer(int index, List<GrabbableObject> scrap, int variantIndex = -1)
{
//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)
if (NetworkUtils.IsServer)
{
GameObject spawnPrefab = ScrapEaters[index].SpawnPrefab;
GameObject val = Object.Instantiate<GameObject>(spawnPrefab, Vector3.zero, Quaternion.identity);
NetworkObject component = val.GetComponent<NetworkObject>();
component.Spawn(true);
ScrapEaterBehaviour component2 = val.GetComponent<ScrapEaterBehaviour>();
component2.SetData(scrap, variantIndex);
Logger.LogInfo($"Spawned scrap eater #{index + 1}");
}
}
private static int GetRandomScrapEaterIndex()
{
return Utils.GetRandomIndexFromWeightList(ScrapEaters.Select((ScrapEater x) => x.GetSpawnWeight()).ToList());
}
}
}
namespace com.github.zehsteam.SellMyScrap.Patches
{
[HarmonyPatch(typeof(DepositItemsDesk))]
internal static class DepositItemsDeskPatch
{
public static int ClipIndex = -1;
public static bool SpeakInShip = false;
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(ref DepositItemsDesk __instance)
{
DepositItemsDeskHelper.SetInstance(__instance);
}
[HarmonyPatch("SellItemsOnServer")]
[HarmonyPrefix]
private static bool SellItemsOnServerPatch(ref DepositItemsDesk __instance)
{
if (__instance.itemsOnCounter.Count == 0)
{
return false;
}
if (NetworkUtils.IsServer)
{
SetMicrophoneSpeakData_Server(SpeakInShip);
}
return true;
}
[HarmonyPatch("MicrophoneSpeak")]
[HarmonyPrefix]
private static bool MicrophoneSpeakPatch(ref DepositItemsDesk __instance)
{
AudioClip[] microphoneAudios = __instance.microphoneAudios;
AudioClip[] rareMicrophoneAudios = __instance.rareMicrophoneAudios;
List<AudioClip> list = new List<AudioClip>(microphoneAudios.Length + rareMicrophoneAudios.Length);
list.AddRange(microphoneAudios);
list.AddRange(rareMicrophoneAudios);
List<AudioClip> list2 = list;
if (ClipIndex == -1)
{
ClipIndex = GetRandomAudioClipIndex();
}
AudioClip val = list2[ClipIndex];
__instance.speakerAudio.PlayOneShot(val, 1f);
if (SpeakInShip && ConfigManager.SpeakInShip.Value)
{
StartOfRound.Instance.speakerAudioSource.PlayOneShot(val, 1f);
}
SpeakInShip = false;
ClipIndex = -1;
return false;
}
private static int GetRandomAudioClipIndex()
{
if (Utils.RollPercentChance(ConfigManager.RareVoiceLineChance.Value))
{
return Random.Range(0, DepositItemsDeskHelper.Instance.rareMicrophoneAudios.Length) + DepositItemsDeskHelper.Instance.microphoneAudios.Length;
}
return Random.Range(0, DepositItemsDeskHelper.Instance.microphoneAudios.Length);
}
public static void SetMicrophoneSpeakData_LocalClient(bool speakInShip, int clipIndex)
{
SpeakInShip = speakInShip;
ClipIndex = clipIndex;
}
private static void SetMicrophoneSpeakData_Server(bool speakInShip)
{
SpeakInShip = speakInShip;
ClipIndex = GetRandomAudioClipIndex();
PluginNetworkBehaviour.Instance.SetMicrophoneSpeakDataClientRpc(speakInShip, ClipIndex);
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
AddNetworkPrefabs();
}
private static void AddNetworkPrefabs()
{
AddNetworkPrefab(Assets.NetworkHandlerPrefab);
foreach (ScrapEater scrapEater in ScrapEaterManager.ScrapEaters)
{
AddNetworkPrefab(scrapEater.SpawnPrefab);
}
}
private static void AddNetworkPrefab(GameObject prefab)
{
if ((Object)(object)prefab == (Object)null)
{
Logger.LogError("Failed to register network prefab. GameObject is null.");
return;
}
NetworkManager.Singleton.AddNetworkPrefab(prefab);
Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab.");
}
}
[HarmonyPatch(typeof(HUDManager))]
internal static class HUDManagerPatch
{
[CompilerGenerated]
private sealed class <ScrollRewardsListText>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Scrollbar rewardsScrollbar;
public float duration;
private float <timer>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ScrollRewardsListText>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<timer>5__2 = 0f;
rewardsScrollbar.value = 1f;
break;
case 2:
<>1__state = -1;
<timer>5__2 += Time.deltaTime;
break;
}
if (<timer>5__2 < duration)
{
if (<timer>5__2 > duration)
{
<timer>5__2 = duration;
}
float num = 1f / duration * <timer>5__2;
rewardsScrollbar.value = 1f - num;
<>2__current = null;
<>1__state = 2;
return true;
}
rewardsScrollbar.value = 0f;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("DisplayCreditsEarning")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static bool DisplayCreditsEarningPatch(ref HUDManager __instance, int creditsEarned, GrabbableObject[] objectsSold, int newGroupCredits, ref Coroutine ___scrollRewardTextCoroutine)
{
Logger.LogInfo($"Earned ${creditsEarned}; sold {objectsSold.Length} items; new credits amount: ${newGroupCredits}");
string text = ScrapHelper.GetScrapMessage(objectsSold.ToList());
int num = text.Split('\n').Length;
int num2 = ((num < 8) ? (8 - num) : 0);
for (int i = 0; i < num2; i++)
{
text += "\n\t";
}
((TMP_Text)__instance.moneyRewardsListText).text = text;
((TMP_Text)__instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}";
__instance.moneyRewardsAnimator.SetTrigger("showRewards");
__instance.rewardsScrollbar.value = 1f;
if (num >= 9)
{
if (___scrollRewardTextCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(___scrollRewardTextCoroutine);
}
___scrollRewardTextCoroutine = ((MonoBehaviour)__instance).StartCoroutine(ScrollRewardsListText(__instance.rewardsScrollbar));
}
return false;
}
[IteratorStateMachine(typeof(<ScrollRewardsListText>d__1))]
private static IEnumerator ScrollRewardsListText(Scrollbar rewardsScrollbar, float duration = 3f)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ScrollRewardsListText>d__1(0)
{
rewardsScrollbar = rewardsScrollbar,
duration = duration
};
}
}
[HarmonyPatch(typeof(InteractTrigger))]
internal static class InteractTriggerPatch
{
[HarmonyPatch("StopInteraction")]
[HarmonyPostfix]
private static void StopInteractionPatch(ref InteractTrigger __instance)
{
if ((Object)(object)StartMatchLeverPatch.InteractTrigger == (Object)(object)__instance)
{
StartMatchLeverPatch.DisplayedSellWarning = false;
}
}
}
[HarmonyPatch(typeof(StartMatchLever))]
internal static class StartMatchLeverPatch
{
public static InteractTrigger InteractTrigger;
public static bool DisplayedSellWarning;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ref StartMatchLever __instance)
{
InteractTrigger = ((Component)__instance).GetComponent<InteractTrigger>();
DisplayedSellWarning = false;
}
[HarmonyPatch("BeginHoldingInteractOnLever")]
[HarmonyPostfix]
private static void BeginHoldingInteractOnLeverPatch(ref StartMatchLever __instance)
{
if (TimeOfDay.Instance.daysUntilDeadline > 0 || !ConfigManager.ShowQuotaWarning.Value)
{
if (__instance.triggerScript.timeToHold == 4.01f)
{
__instance.triggerScript.timeToHold = 0.7f;
}
}
else if (!((Object)(object)DepositItemsDeskHelper.Instance == (Object)null) && StartOfRound.Instance.shipHasLanded)
{
if (TimeOfDay.Instance.quotaFulfilled >= TimeOfDay.Instance.profitQuota)
{
__instance.triggerScript.timeToHold = 0.7f;
}
else if (!DisplayedSellWarning)
{
DisplayedSellWarning = true;
__instance.triggerScript.timeToHold = 4.01f;
HUDManager.Instance.DisplayTip("HALT!", "You did not sell enough scrap to fulfill the profit quota.", true, false, "LC_Tip1");
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePatch()
{
SpawnNetworkHandler();
}
private static void SpawnNetworkHandler()
{
//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)
if (NetworkUtils.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(Assets.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
RemoveMapPropsContainerForTesting();
}
private static void RemoveMapPropsContainerForTesting()
{
GameObject val = GameObject.Find("Environment/MapPropsContainerForTesting");
if (!((Object)(object)val == (Object)null))
{
val.SetActive(false);
}
}
[HarmonyPatch("firstDayAnimation")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static void FirstDayAnimationPatchPrefix()
{
if (DateTime.Today.Month == 4 && DateTime.Today.Day == 1)
{
StartOfRound.Instance.shipIntroSpeechSFX = Assets.BrainRotIntroSpeechSFX;
}
}
[HarmonyPatch("OnClientConnect")]
[HarmonyPrefix]
private static void OnClientConnectPatch(ref ulong clientId)
{
if (NetworkUtils.IsServer)
{
SyncedConfigEntryBase.SendConfigsToClient(clientId);
}
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPrefix]
private static void OnLocalDisconnectPatch()
{
Plugin.HandleLocalDisconnect();
}
}
[HarmonyPatch(typeof(Terminal))]
internal static class TerminalPatch
{
private static bool _hasOverrideTerminalNodes;
public static Terminal Instance { get; private set; }
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePatch(Terminal __instance)
{
Instance = __instance;
}
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatchPrefix(ref Terminal __instance)
{
TerminalHelper.SetInstance(__instance);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void StartPatchPostfix(ref TerminalNodesList ___terminalNodes)
{
OverrideTerminalNodes(___terminalNodes);
}
private static void OverrideTerminalNodes(TerminalNodesList terminalNodes)
{
if (!_hasOverrideTerminalNodes)
{
_hasOverrideTerminalNodes = true;
if (ConfigManager.OverrideWelcomeMessage.Value)
{
OverrideWelcomeTerminalNode(terminalNodes);
}
if (ConfigManager.OverrideHelpMessage.Value)
{
OverrideHelpTerminalNode(terminalNodes);
}
}
}
private static void OverrideWelcomeTerminalNode(TerminalNodesList terminalNodes)
{
int index = 1;
string displayText = terminalNodes.specialNodes[index].displayText;
string text = "Type \"Help\" for a list of commands.";
string displayText2 = displayText.Replace(text, text + "\n\n[SellMyScrap v73+]\nType \"Sell\" for a list of commands.");
terminalNodes.specialNodes[index].displayText = displayText2;
}
private static void OverrideHelpTerminalNode(TerminalNodesList terminalNodes)
{
int index = 13;
string displayText = terminalNodes.specialNodes[index].displayText;
string text = ">OTHER\nTo see the list of other commands";
string displayText2 = displayText.Replace(text, text + ".\n\n>SELL\nTo see the list of SellMyScrap v73+ commands.");
terminalNodes.specialNodes[index].displayText = displayText2;
}
[HarmonyPatch("QuitTerminal")]
[HarmonyPostfix]
private static void QuitTerminalPatch()
{
Plugin.HandleTerminalQuit();
}
[HarmonyPatch("ParsePlayerSentence")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static bool ParsePlayerSentencePatch(ref Terminal __instance, ref TerminalNode __result)
{
string[] array = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (CommandManager.TryExecuteCommand(array, out var terminalNode))
{
if ((Object)(object)terminalNode == (Object)null)
{
__result = TerminalHelper.CreateTerminalNode("TerminalNode is null!\n\n");
return false;
}
__result = terminalNode;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal static class TimeOfDayPatch
{
private static int _daysUntilDeadline = 3;
private static int _preDaysUntilDeadline = 3;
private static int _postDaysUntilDeadline = 3;
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPrefix]
private static void SetBuyingRateForDayPatchPrefix()
{
_preDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
}
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPostfix]
private static void SetBuyingRateForDayPatchPostfix()
{
_postDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
SetDaysUntilDeadline();
}
private static void SetDaysUntilDeadline()
{
if (_postDaysUntilDeadline == 0)
{
if (_preDaysUntilDeadline == 0)
{
_daysUntilDeadline = 0;
}
else
{
_daysUntilDeadline = -1;
}
}
else
{
_daysUntilDeadline = _postDaysUntilDeadline;
}
}
public static int GetDaysUntilDeadline()
{
return _daysUntilDeadline;
}
}
}
namespace com.github.zehsteam.SellMyScrap.Data
{
public enum SellType
{
None,
Amount,
Quota,
All,
Item,
List
}
public enum ConfirmationStatus
{
None,
AwaitingConfirmation,
Confirmed
}
public class SellRequest
{
public SellType SellType;
public int ScrapValue;
public int RequestedScrapValue;
public ConfirmationStatus ConfirmationStatus;
public int ScrapEaterIndex;
public int ScrapEaterVariantIndex;
public int RealScrapValue => ScrapHelper.GetRealValue(ScrapValue);
public SellRequest(SellType sellType, int scrapValue, int requestedScrapValue, ConfirmationStatus confirmationStatus, int scrapEaterIndex = -2, int scrapEaterVariantIndex = -1)
{
SellType = sellType;
ScrapValue = scrapValue;
RequestedScrapValue = requestedScrapValue;
ConfirmationStatus = confirmationStatus;
ScrapEaterIndex = scrapEaterIndex;
ScrapEaterVariantIndex = scrapEaterVariantIndex;
}
}
}
namespace com.github.zehsteam.SellMyScrap.Objects
{
public enum ItemLocation
{
Ship,
Vehicle,
ShipInventory
}
public class ItemData
{
public GrabbableObject GrabbableObject { get; set; }
public SI_ItemDataProxy SI_ItemDataProxy { get; set; }
public ItemLocation ItemLocation { get; set; }
public string ItemName => GetItemName();
public int ScrapValue => GetScrapValue();
public ItemData(GrabbableObject grabbableObject, ItemLocation itemLocation)
{
GrabbableObject = grabbableObject;
ItemLocation = itemLocation;
}
public ItemData(SI_ItemDataProxy si_ItemDataProxy, ItemLocation itemLocation)
{
SI_ItemDataProxy = si_ItemDataProxy;
ItemLocation = itemLocation;
}
private string GetItemName()
{
if ((Object)(object)GrabbableObject != (Object)null)
{
return GrabbableObject.itemProperties.itemName;
}
if (ShipInventoryProxy.Enabled && SI_ItemDataProxy.IsValid())
{
return SI_ItemDataProxy.ItemName;
}
return "Unknown Item";
}
private int GetScrapValue()
{
if ((Object)(object)GrabbableObject != (Object)null)
{
return GrabbableObject.scrapValue;
}
if (ShipInventoryProxy.Enabled && SI_ItemDataProxy.IsValid())
{
return SI_ItemDataProxy.ScrapValue;
}
return 0;
}
}
[Serializable]
public class ScrapToSell : INetworkSerializable
{
public NetworkObjectReference[] ShipNetworkObjectReferences = Array.Empty<NetworkObjectReference>();
public NetworkObjectReference[] VehicleNetworkObjectReferences = Array.Empty<NetworkObjectReference>();
public SI_ItemDataProxy[] ShipInventoryItems = Array.Empty<SI_ItemDataProxy>();
private List<ItemData> _itemDataList = new List<ItemData>();
private bool _setItemDataList;
private List<GrabbableObject> _shipGrabbableObjects = new List<GrabbableObject>();
private bool _setShipGrabbableObjects;
private List<GrabbableObject> _vehicleGrabbableObjects = new List<GrabbableObject>();
private bool _setVehicleGrabbableObjects;
public List<ItemData> ItemDataList
{
get
{
if (!_setItemDataList)
{
SetItemDataList();
}
return _itemDataList;
}
set
{
_itemDataList = value;
_setItemDataList = true;
}
}
public List<GrabbableObject> GrabbableObjects
{
get
{
List<GrabbableObject> shipGrabbableObjects = ShipGrabbableObjects;
List<GrabbableObject> vehicleGrabbableObjects = VehicleGrabbableObjects;
List<GrabbableObject> list = new List<GrabbableObject>(shipGrabbableObjects.Count + vehicleGrabbableObjects.Count);
list.AddRange(shipGrabbableObjects);
list.AddRange(vehicleGrabbableObjects);
return list;
}
}
public List<GrabbableObject> ShipGrabbableObjects
{
get
{
if (!_setShipGrabbableObjects)
{
SetShipGrabbableObjects();
}
return _shipGrabbableObjects;
}
set
{
_shipGrabbableObjects = value;
_setShipGrabbableObjects = true;
}
}
public List<GrabbableObject> VehicleGrabbableObjects
{
get
{
if (!_setVehicleGrabbableObjects)
{
SetVehicleGrabbableObjects();
}
return _vehicleGrabbableObjects;
}
set
{
_vehicleGrabbableObjects = value;
_setVehicleGrabbableObjects = true;
}
}
public int ItemCount => GetItemCount();
public int TotalScrapValue => GetTotalScrapValue();
public int RealTotalScrapValue => ScrapHelper.GetRealValue(TotalScrapValue);
public ScrapToSell()
{
}
public ScrapToSell(List<ItemData> items)
{
ItemDataList = items;
ShipGrabbableObjects = (from x in items
where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Ship
select x.GrabbableObject).ToList();
VehicleGrabbableObjects = (from x in items
where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Vehicle
select x.GrabbableObject).ToList();
ShipInventoryItems = (from x in items
where x.SI_ItemDataProxy.IsValid()
select x.SI_ItemDataProxy).ToArray();
SetShipNetworkObjectReferences();
SetVehicleNetworkObjectReferences();
}
private void SetShipNetworkObjectReferences()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
List<NetworkObjectReference> list = new List<NetworkObjectReference>();
NetworkObject val = default(NetworkObject);
foreach (GrabbableObject shipGrabbableObject in ShipGrabbableObjects)
{
if (((Component)shipGrabbableObject).TryGetComponent<NetworkObject>(ref val))
{
list.Add(NetworkObjectReference.op_Implicit(val));
}
}
ShipNetworkObjectReferences = list.ToArray();
}
private void SetVehicleNetworkObjectReferences()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
List<NetworkObjectReference> list = new List<NetworkObjectReference>();
NetworkObject val = default(NetworkObject);
foreach (GrabbableObject vehicleGrabbableObject in VehicleGrabbableObjects)
{
if (((Component)vehicleGrabbableObject).TryGetComponent<NetworkObject>(ref val))
{
list.Add(NetworkObjectReference.op_Implicit(val));
}
}
VehicleNetworkObjectReferences = list.ToArray();
}
private void SetItemDataList()
{
ItemDataList = ScrapHelper.GetItemDataList(ShipGrabbableObjects, VehicleGrabbableObjects, ShipInventoryItems);
}
private void SetShipGrabbableObjects()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
ShipGrabbableObjects = new List<GrabbableObject>();
NetworkObjectReference[] shipNetworkObjectReferences = ShipNetworkObjectReferences;
NetworkObject val2 = default(NetworkObject);
GrabbableObject item = default(GrabbableObject);
for (int i = 0; i < shipNetworkObjectReferences.Length; i++)
{
NetworkObjectReference val = shipNetworkObjectReferences[i];
if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
{
ShipGrabbableObjects.Add(item);
}
}
}
private void SetVehicleGrabbableObjects()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
VehicleGrabbableObjects = new List<GrabbableObject>();
NetworkObjectReference[] vehicleNetworkObjectReferences = VehicleNetworkObjectReferences;
NetworkObject val2 = default(NetworkObject);
GrabbableObject item = default(GrabbableObject);
for (int i = 0; i < vehicleNetworkObjectReferences.Length; i++)
{
NetworkObjectReference val = vehicleNetworkObjectReferences[i];
if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
{
VehicleGrabbableObjects.Add(item);
}
}
}
private int GetItemCount()
{
return GrabbableObjects.Count + ShipInventoryItems.Length;
}
private int GetTotalScrapValue()
{
return GrabbableObjects.Sum((GrabbableObject x) => x.scrapValue) + ShipInventoryItems.Sum((SI_ItemDataProxy x) => x.ScrapValue);
}
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref ShipNetworkObjectReferences, default(ForNetworkSerializable));
((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref VehicleNetworkObjectReferences, default(ForNetworkSerializable));
((BufferSerializer<SI_ItemDataProxy>*)(&serializer))->SerializeValue<SI_ItemDataProxy>(ref ShipInventoryItems, default(ForNetworkSerializable));
}
}
public class SellCommandRequest
{
[CompilerGenerated]
private int <value>P;
public int Value => <value>P;
public bool OnlyAllowedScrap { get; set; }
public bool WithOvertimeBonus { get; set; }
public bool OnlyUseShipInventory { get; set; }
public BaseScrapMatchAlgorithm ScrapMatchAlgorithm { get; set; }
public int TargetValue
{
get
{
if (!WithOvertimeBonus)
{
return GetSellValue(Value);
}
return GetSellValueWithOvertime();
}
}
public SellCommandRequest(int value)
{
<value>P = value;
OnlyAllowedScrap = true;
ScrapMatchAlgorithm = BaseScrapMatchAlgorithm.Default;
base..ctor();
}
public ScrapToSell GetScrapToSell(List<ItemData> items)
{
if (Value == int.MaxValue)
{
return new ScrapToSell(items);
}
return new ScrapToSell(ScrapMatchAlgorithm.FindMatch(items, TargetValue, ConfigManager.PrioritySellListArray));
}
private int GetSellValue(int value)
{
if (value == int.MaxValue)
{
return value;
}
return Mathf.CeilToInt((float)value / StartOfRound.Instance.companyBuyingRate);
}
private int GetSellValueWithOvertime()
{
int profitQuota = TimeOfDay.Instance.profitQuota;
int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled;
int num = quotaFulfilled + Value - profitQuota;
if (num <= 0)
{
return GetSellValue(Value);
}
int value = Value;
int num2 = Mathf.Max(profitQuota - quotaFulfilled, 0);
value -= (TimeOfDayPatch.GetDaysUntilDeadline() + 1) * 15;
int value2 = Mathf.CeilToInt((float)(5 * value + num2 + 75) / 6f);
return GetSellValue(value2);
}
}
public class SyncedConfigEntry<T> : SyncedConfigEntryBase
{
private ConfigEntry<T> _configEntry;
private T _serverValue;
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue;
public override string Section => ((ConfigEntryBase)_configEntry).Definition.Section;
public override string Key => ((ConfigEntryBase)_configEntry).Definition.Key;
public event Action<T> SettingChanged;
public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null)
{
SyncedConfigEntryBase.AddInstance(this);
_configEntry = ConfigHelper.Bind(section, key, defaultValue, requiresRestart: false, description, acceptableValues, null, configFile);
_configEntry.SettingChanged += SettingChangedInternal;
}
public T GetValue()
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
return _serverValue;
}
return _configEntry.Value;
}
public void SetValue(T value)
{
if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
{
_configEntry.Value = value;
}
}
public void ResetToDefault()
{
if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
{
_configEntry.Value = DefaultValue;
}
}
private void SettingChangedInternal(object sender, EventArgs e)
{
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
this.SettingChanged?.Invoke(Value);
SendConfigToClients();
}
}
private void SendConfigToClients()
{
//IL_003b: 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)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString());
}
}
public override void SendConfigToClient(ulong clientId)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId)
};
ClientRpcParams clientRpcParams = val;
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString(), clientRpcParams);
}
}
public override void SetValueFromServer(string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
if (!value.TryConvertTo<T>(out var result))
{
throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}");
}
_serverValue = result;
Logger.LogInfo("Set synced config entry value from server. (Section: \"" + Section + "\", Key: \"" + Key + "\", Value: \"" + value + "\")", extended: true);
this.SettingChanged?.Invoke(result);
}
}
}
public abstract class SyncedConfigEntryBase
{
private static readonly object _instancesLock = new object();
public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>();
public abstract string Section { get; }
public abstract string Key { get; }
public static void AddInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Add(instance);
}
}
public static void RemoveInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Remove(instance);
}
}
public abstract void SendConfigToClient(ulong clientId);
public abstract void SetValueFromServer(string value);
public static void SendConfigsToClient(ulong clientId)
{
if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId))
{
return;
}
foreach (SyncedConfigEntryBase instance in Instances)
{
instance.SendConfigToClient(clientId);
}
}
public static void SetValueFromServer(string section, string key, string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key);
if (syncedConfigEntryBase == null)
{
Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\"");
}
else
{
syncedConfigEntryBase.SetValueFromServer(value);
}
}
}
}
}
namespace com.github.zehsteam.SellMyScrap.MonoBehaviours
{
public class CookieFumoScrapEaterBehaviour : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <StartAnimation>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CookieFumoScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Expected O, but got Unknown
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CookieFumoScrapEaterBehaviour cookieFumoScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.fallSFX);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.spawnPosition, cookieFumoScrapEaterBehaviour.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.soundEffectsAudio);
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.landSFX, cookieFumoScrapEaterBehaviour.landIndex);
cookieFumoScrapEaterBehaviour.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.beforeEatSFX));
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.MoveTargetScrapToTargetTransform(cookieFumoScrapEaterBehaviour.mouthTransform, cookieFumoScrapEaterBehaviour.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.suckDuration);
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.eatSFX));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.voiceLineSFX, cookieFumoScrapEaterBehaviour._voiceLineIndex));
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 10;
return true;
case 10:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.movementDuration));
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 12;
return true;
case 12:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.takeOffSFX);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.spawnPosition, 2f));
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Cookie Fumo")]
[Space(5f)]
public AudioClip fallSFX;
public AudioClip beforeEatSFX;
public AudioClip[] voiceLineSFX = Array.Empty<AudioClip>();
private int _voiceLineIndex;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
_voiceLineIndex = Random.Range(0, voiceLineSFX.Length);
SetDataClientRpc(_voiceLineIndex);
}
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(int voiceLineIndex)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3160276146u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, voiceLineIndex);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3160276146u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
_voiceLineIndex = voiceLineIndex;
}
}
}
[IteratorStateMachine(typeof(<StartAnimation>d__6))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__6(0)
{
<>4__this = this
};
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(3160276146u, new RpcReceiveHandler(__rpc_handler_3160276146), "SetDataClientRpc");
base.__initializeRpcs();
}
private static void __rpc_handler_3160276146(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int dataClientRpc = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref dataClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)1;
((CookieFumoScrapEaterBehaviour)(object)target).SetDataClientRpc(dataClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "CookieFumoScrapEaterBehaviour";
}
}
internal class CoroutineRunner : MonoBehaviour
{
public static CoroutineRunner Instance { get; private set; }
public static void Spawn()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Instance != (Object)null))
{
new GameObject("SellMyScrap v73+ CoroutineRunner", new Type[1] { typeof(CoroutineRunner) });
}
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
((Object)this).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)this);
}
public static Coroutine Start(IEnumerator routine)
{
if ((Object)(object)Instance == (Object)null)
{
Spawn();
}
CoroutineRunner instance = Instance;
return ((instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null) ?? null;
}
public static void Stop(IEnumerator routine)
{
if (!((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StopCoroutine(routine);
}
}
public static void Stop(Coroutine routine)
{
if (!((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StopCoroutine(routine);
}
}
}
public class DestroyAfterTimeBehaviour : MonoBehaviour
{
[CompilerGenerated]
private sealed class <DestoryAfterTime>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DestroyAfterTimeBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DestoryAfterTime>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
int num = <>1__state;
DestroyAfterTimeBehaviour destroyAfterTimeBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(destroyAfterTimeBehaviour.duration);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Object.Destroy((Object)(object)((Component)destroyAfterTimeBehaviour).gameObject);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public float duration = 5f;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(DestoryAfterTime());
}
[IteratorStateMachine(typeof(<DestoryAfterTime>d__2))]
private IEnumerator DestoryAfterTime()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DestoryAfterTime>d__2(0)
{
<>4__this = this
};
}
}
public class GlitchScrapEater : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <StartAnimation>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GlitchScrapEater <>4__this;
private float <flashbangSFXLength>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Expected O, but got Unknown
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: 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_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Expected O, but got Unknown
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Expected O, but got Unknown
int num = <>1__state;
GlitchScrapEater glitchScrapEater = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((MonoBehaviour)glitchScrapEater).StartCoroutine(glitchScrapEater.MoveToPosition(glitchScrapEater.spawnPosition, glitchScrapEater.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
glitchScrapEater.PlayOneShotSFX(glitchScrapEater.landSFX, glitchScrapEater.landIndex);
glitchScrapEater.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
glitchScrapEater.PlayAudioSource(glitchScrapEater.movementAudio);
<>2__current = ((MonoBehaviour)glitchScrapEater).StartCoroutine(glitchScrapEater.MoveToPosition(glitchScrapEater.startPosition, glitchScrapEater.endPosition, glitchScrapEater.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
glitchScrapEater.StopAudioSource(glitchScrapEater.movementAudio);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.pauseDuration / 2f);
<>1__state = 4;
return true;
case 4:
{
<>1__state = -1;
AudioClip[] audioClips = (glitchScrapEater._playLunxaraSFX ? glitchScrapEater._beforeEatLunxaraSFX : glitchScrapEater._beforeEatSFX);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(audioClips, glitchScrapEater._beforeEatSFXIndex));
<>1__state = 5;
return true;
}
case 5:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.pauseDuration / 2f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
glitchScrapEater.MoveTargetScrapToTargetTransform(glitchScrapEater.mouthTransform, glitchScrapEater.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.suckDuration);
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(glitchScrapEater.eatSFX));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(glitchScrapEater._afterEatSFX));
<>1__state = 9;
return true;
case 9:
{
<>1__state = -1;
<flashbangSFXLength>5__2 = glitchScrapEater._flashbangExplodeSFX.length;
Vector3 position = glitchScrapEater.mouthTransform.position;
Object.Instantiate<GameObject>(glitchScrapEater._flashbangParticlePrefab, position, Quaternion.identity);
StunGrenadeItem.StunExplosion(position, true, 1f, 7.5f, 1f, false, (PlayerControllerB)null, (PlayerControllerB)null, 0f);
glitchScrapEater.PlayOneShotSFX(glitchScrapEater._flashbangExplodeSFX);
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 10;
return true;
}
case 10:
<>1__state = -1;
glitchScrapEater.modelObject.SetActive(false);
<>2__current = (object)new WaitForSeconds(<flashbangSFXLength>5__2);
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Glitch")]
[Space(5f)]
[SerializeField]
private AudioClip[] _beforeEatSFX = Array.Empty<AudioClip>();
[SerializeField]
private AudioClip[] _beforeEatLunxaraSFX = Array.Empty<AudioClip>();
[SerializeField]
private AudioClip _afterEatSFX;
private int _beforeEatSFXIndex;
private bool _playLunxaraSFX;
private AudioClip _flashbangExplodeSFX;
private GameObject _flashbangParticlePrefab;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
if (PlayerUtils.HasPlayerLunxara())
{
_playLunxaraSFX = Utils.RollPercentChance(50f);
}
if (_playLunxaraSFX)
{
_beforeEatSFXIndex = Random.Range(0, _beforeEatLunxaraSFX.Length);
}
else
{
_beforeEatSFXIndex = Random.Range(0, _beforeEatSFX.Length);
}
SetDataClientRpc(_beforeEatSFXIndex, _playLunxaraSFX);
}
FindFlashbangAssets();
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(int beforeEatSFXIndex, bool playLunxaraSFX)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2203949794u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, beforeEatSFXIndex);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref playLunxaraSFX, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2203949794u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
_beforeEatSFXIndex = beforeEatSFXIndex;
_playLunxaraSFX = playLunxaraSFX;
}
}
}
private void FindFlashbangAssets()
{
Item val = ((IEnumerable<Item>)TerminalPatch.Instance.buyableItemsList).FirstOrDefault((Func<Item, bool>)((Item x) => x.itemName.Equals("Stun grenade", StringComparison.OrdinalIgnoreCase)));
if ((Object)(object)val == (Object)null)
{
Logger.LogError("[GlitchScrapEater] Failed to find Stun Grenade item.");
return;
}
StunGrenadeItem val2 = default(StunGrenadeItem);
if (!val.spawnPrefab.TryGetComponent<StunGrenadeItem>(ref val2))
{
Logger.LogError("[GlitchScrapEater] Failed to find StunGrenadeItem component on Stun Grenade item prefab.");
return;
}
_flashbangExplodeSFX = val2.explodeSFX;
_flashbangParticlePrefab = val2.stunGrenadeExplosion;
}
[IteratorStateMachine(typeof(<StartAnimation>d__10))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__10(0)
{
<>4__this = this
};
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(2203949794u, new RpcReceiveHandler(__rpc_handler_2203949794), "SetDataClientRpc");
base.__initializeRpcs();
}
private static void __rpc_handler_2203949794(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int beforeEatSFXIndex = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref beforeEatSFXIndex);
bool playLunxaraSFX = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref playLunxaraSFX, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((GlitchScrapEater)(object)target).SetDataClientRpc(beforeEatSFXIndex, playLunxaraSFX);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "GlitchScrapEater";
}
}
public class MaxwellScrapEaterBehaviour : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <MoveLocalPlayerToMaxwell>d__13 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
public float duration;
private PlayerControllerB <localPlayerScript>5__2;
private Vector3 <startPosition>5__3;
private Vector3 <endPosition>5__4;
private float <timer>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MoveLocalPlayerToMaxwell>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<localPlayerScript>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<localPlayerScript>5__2 = PlayerUtils.GetLocalPlayerScript();
maxwellScrapEaterBehaviour._isTarget = true;
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: false);
PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: false);
<startPosition>5__3 = ((Component)<localPlayerScript>5__2).transform.position;
<endPosition>5__4 = maxwellScrapEaterBehaviour.mouthTransform.position;
<endPosition>5__4.x += 1f;
<endPosition>5__4.y = ((Component)maxwellScrapEaterBehaviour).transform.position.y;
<timer>5__5 = 0f;
break;
case 1:
<>1__state = -1;
<timer>5__5 += Time.deltaTime;
break;
}
if (<timer>5__5 < duration)
{
float num2 = 1f / duration * <timer>5__5;
Vector3 position = <startPosition>5__3 + (<endPosition>5__4 - <startPosition>5__3) * num2;
((Component)<localPlayerScript>5__2).transform.position = position;
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <StartAnimation>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Expected O, but got Unknown
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Expected O, but got Unknown
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Expected O, but got Unknown
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Expected O, but got Unknown
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Expected O, but got Unknown
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationIdle();
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.spawnPosition, maxwellScrapEaterBehaviour.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.landSFX, maxwellScrapEaterBehaviour.landIndex);
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.meowSFX, maxwellScrapEaterBehaviour._meowIndex);
maxwellScrapEaterBehaviour.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationDance();
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveLocalPlayerToMaxwell(maxwellScrapEaterBehaviour.suckDuration - 0.1f));
}
maxwellScrapEaterBehaviour.MoveTargetScrapToTargetTransform(maxwellScrapEaterBehaviour.mouthTransform, maxwellScrapEaterBehaviour.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.suckDuration);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.eatSFX));
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationIdle();
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: true);
}
if (maxwellScrapEaterBehaviour._isEvil)
{
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.StartEvilMaxwell());
<>1__state = 10;
return true;
}
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
}
maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.movementDuration));
<>1__state = 12;
return true;
case 10:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(3f);
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
return false;
case 12:
<>1__state = -1;
maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.takeOffSFX);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.spawnPosition, 2f));
<>1__state = 14;
return true;
case 14:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <StartEvilMaxwell>d__14 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartEvilMaxwell>d__14(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
maxwellScrapEaterBehaviour.bodyObject.SetActive(false);
maxwellScrapEaterBehaviour.evilObject.SetActive(true);
maxwellScrapEaterBehaviour.purrAudio.Stop();
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.evilNoise);
<>2__current = (object)new WaitForSeconds(1.25f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
}
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 2;
return true;
case 2:
{
<>1__state = -1;
Vector3 position = ((Component)maxwellScrapEaterBehaviour).transform.position;
position.y += 0.31f;
Utils.CreateExplosion(position, spawnExplosionEffect: true, 100, 0f, 6.4f, 6, (CauseOfDeath)3);
maxwellScrapEaterBehaviour.evilObject.transform.SetParent((Transform)null);
maxwellScrapEaterBehaviour.evilObject.AddComponent<DestroyAfterTimeBehaviour>().duration = 15f;
Rigidbody[] componentsInChildren = maxwellScrapEaterBehaviour.evilObject.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody val in componentsInChildren)
{
val.isKinematic = false;
val.AddExplosionForce(1000f, maxwellScrapEaterBehaviour.evilObject.transform.position, 100f);
}
PlayerUtils.ReviveDeadPlayersAfterTime(5f);
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Maxwell")]
[Space(5f)]
public GameObject bodyObject;
public GameObject evilObject;
public Animator danceAnimator;
public AudioSource purrAudio;
public AudioSource danceAudio;
public AudioClip[] meowSFX = Array.Empty<AudioClip>();
public AudioClip evilNoise;
private bool _isEvil;
private int _meowIndex;
private bool _isTarget;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
if (PlayerUtils.HasPlayerMagoroku() || PlayerUtils.HasPlayerPsychoHypnotic())
{
_isEvil = Utils.RollPercentChance(80f);
}
else
{
_isEvil = Utils.RollPercentChance(50f);
}
_meowIndex = Random.Range(0, meowSFX.Length);
SetDataClientRpc(_isEvil, _meowIndex);
}
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(bool isEvil, int meowIndex)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2957132727u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isEvil, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, meowIndex);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2957132727u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
_isEvil = isEvil;
_meowIndex = meowIndex;
if (PlayerUtils.IsLocalPlayerMagoroku() && (Utils.RollPercentChance(40f) || (isEvil && Utils.RollPercentChance(80f))))
{
_isTarget = true;
}
}
}
[IteratorStateMachine(typeof(<StartAnimation>d__12))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__12(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<MoveLocalPlayerToMaxwell>d__13))]
private IEnumerator MoveLocalPlayerToMaxwell(float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MoveLocalPlayerToMaxwell>d__13(0)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using ShipInventoryUpdated.Configurations;
using ShipInventoryUpdated.Helpers.API;
using ShipInventoryUpdated.Objects;
using ShipInventoryUpdated.Scripts;
using Steamworks;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
using com.github.zehsteam.SellMyScrap.Commands;
using com.github.zehsteam.SellMyScrap.Data;
using com.github.zehsteam.SellMyScrap.Dependencies;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Extensions;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Objects;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Patches;
using com.github.zehsteam.SellMyScrap.Dependencies.Vanilla;
using com.github.zehsteam.SellMyScrap.Extensions;
using com.github.zehsteam.SellMyScrap.Helpers;
using com.github.zehsteam.SellMyScrap.Helpers.ScrapMatchAlgorithms;
using com.github.zehsteam.SellMyScrap.Managers;
using com.github.zehsteam.SellMyScrap.MonoBehaviours;
using com.github.zehsteam.SellMyScrap.Objects;
using com.github.zehsteam.SellMyScrap.Patches;
using com.github.zehsteam.SellMyScrap.ScrapEaters;
using com.github.zehsteam.SellMyScrap.v40-v72.NetcodePatcher;
using com.github.zehsteam.TakeyPlush.Managers;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("ShipInventoryUpdated")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2026 Zehs")]
[assembly: AssemblyDescription("[v40/v72] Adds a few terminal commands to sell your scrap from the ship or cruiser. Highly Configurable. Compatible with the ShipInventoryUpdated mod. SellFromTerminal +")]
[assembly: AssemblyFileVersion("1.15.3.0")]
[assembly: AssemblyInformationalVersion("1.15.3+ce02e090196b7cde0bc9863c7c029afde99ae47e")]
[assembly: AssemblyProduct("SellMyScrap v40-v72")]
[assembly: AssemblyTitle("com.github.zehsteam.SellMyScrap.v40-v72")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.15.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
{
object IEnumerator.Current => _item;
T IEnumerator<T>.Current => _item;
public Enumerator(T item)
{
_item = item;
}
bool IEnumerator.MoveNext()
{
if (!_moveNextCalled)
{
return _moveNextCalled = true;
}
return false;
}
void IEnumerator.Reset()
{
_moveNextCalled = false;
}
void IDisposable.Dispose()
{
}
}
int ICollection.Count => 1;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => 1;
T IReadOnlyList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
}
int ICollection<T>.Count => 1;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlySingleElementList(T item)
{
_item = item;
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection.CopyTo(Array array, int index)
{
array.SetValue(_item, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return EqualityComparer<T>.Default.Equals(_item, (T)value);
}
int IList.IndexOf(object value)
{
if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
{
return -1;
}
return 0;
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return EqualityComparer<T>.Default.Equals(_item, item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
array[arrayIndex] = _item;
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
if (!EqualityComparer<T>.Default.Equals(_item, item))
{
return -1;
}
return 0;
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
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 com.github.zehsteam.SellMyScrap
{
internal static class Assets
{
public static GameObject NetworkHandlerPrefab { get; private set; }
public static GameObject OctolarScrapEaterPrefab { get; private set; }
public static GameObject TakeyScrapEaterPrefab { get; private set; }
public static GameObject MaxwellScrapEaterPrefab { get; private set; }
public static GameObject YippeeScrapEaterPrefab { get; private set; }
public static GameObject CookieFumoScrapEaterPrefab { get; private set; }
public static GameObject PsychoScrapEaterPrefab { get; private set; }
public static GameObject ZombiesScrapEaterPrefab { get; private set; }
public static GameObject WolfyScrapEaterPrefab { get; private set; }
public static GameObject GlitchScrapEaterPrefab { get; private set; }
public static AudioClip BrainRotIntroSpeechSFX { get; private set; }
public static void Load()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = "sellmyscrap_assets";
string text2 = Path.Combine(directoryName, text);
if (!File.Exists(text2))
{
Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file.");
}
else
{
AssetBundle val = AssetBundle.LoadFromFile(text2);
if ((Object)(object)val == (Object)null)
{
Logger.LogFatal("Failed to load assets. AssetBundle is null.");
}
else
{
HandleAssetBundleLoaded(val);
}
}
}
private static void HandleAssetBundleLoaded(AssetBundle assetBundle)
{
NetworkHandlerPrefab = LoadAsset<GameObject>("NetworkHandler", assetBundle);
NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
OctolarScrapEaterPrefab = LoadAsset<GameObject>("OctolarScrapEater", assetBundle);
TakeyScrapEaterPrefab = LoadAsset<GameObject>("TakeyScrapEater", assetBundle);
MaxwellScrapEaterPrefab = LoadAsset<GameObject>("MaxwellScrapEater", assetBundle);
YippeeScrapEaterPrefab = LoadAsset<GameObject>("YippeeScrapEater", assetBundle);
CookieFumoScrapEaterPrefab = LoadAsset<GameObject>("CookieFumoScrapEater", assetBundle);
PsychoScrapEaterPrefab = LoadAsset<GameObject>("PsychoScrapEater", assetBundle);
ZombiesScrapEaterPrefab = LoadAsset<GameObject>("ZombiesScrapEater", assetBundle);
WolfyScrapEaterPrefab = LoadAsset<GameObject>("WolfyScrapEater", assetBundle);
GlitchScrapEaterPrefab = LoadAsset<GameObject>("GlitchScrapEater", assetBundle);
BrainRotIntroSpeechSFX = LoadAsset<AudioClip>("BrainRotIntroSpeechSFX", assetBundle);
}
private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
{
if (string.IsNullOrWhiteSpace(name))
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace.");
return default(T);
}
if ((Object)(object)assetBundle == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null.");
return default(T);
}
T val = assetBundle.LoadAsset<T>(name);
if ((Object)(object)val == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name.");
return default(T);
}
return val;
}
private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
{
asset = LoadAsset<T>(name, assetBundle);
return (Object)(object)asset != (Object)null;
}
}
internal static class Logger
{
public static ManualLogSource ManualLogSource { get; private set; }
public static void Initialize(ManualLogSource manualLogSource)
{
ManualLogSource = manualLogSource;
}
public static void LogDebug(object data)
{
Log((LogLevel)32, data);
}
public static void LogInfo(object data, bool extended = false)
{
Log((LogLevel)16, data, extended);
}
public static void LogMessage(object data, bool extended = false)
{
Log((LogLevel)8, data, extended);
}
public static void LogWarning(object data, bool extended = false)
{
Log((LogLevel)4, data, extended);
}
public static void LogError(object data, bool extended = false)
{
Log((LogLevel)2, data, extended);
}
public static void LogFatal(object data, bool extended = false)
{
Log((LogLevel)1, data, extended);
}
public static void Log(LogLevel logLevel, object data, bool extended = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!extended || IsExtendedLoggingEnabled())
{
ManualLogSource manualLogSource = ManualLogSource;
if (manualLogSource != null)
{
manualLogSource.Log(logLevel, data);
}
}
}
public static bool IsExtendedLoggingEnabled()
{
if (ConfigManager.ExtendedLogging == null)
{
return false;
}
return ConfigManager.ExtendedLogging.Value;
}
}
internal static class ConfigManager
{
public static ConfigFile ConfigFile { get; private set; }
public static ConfigEntry<bool> ExtendedLogging { get; private set; }
public static SyncedConfigEntry<bool> SellGifts { get; private set; }
public static SyncedConfigEntry<bool> SellShotguns { get; private set; }
public static SyncedConfigEntry<bool> SellAmmo { get; private set; }
public static SyncedConfigEntry<bool> SellKnives { get; private set; }
public static SyncedConfigEntry<bool> SellPickles { get; private set; }
public static SyncedConfigEntry<bool> SellScrapWorthZero { get; private set; }
public static SyncedConfigEntry<bool> OnlySellScrapOnFloor { get; private set; }
public static SyncedConfigEntry<string> PrioritySellList { get; private set; }
public static SyncedConfigEntry<string> DontSellList { get; private set; }
public static SyncedConfigEntry<string> SellList { get; private set; }
public static string[] PrioritySellListArray
{
get
{
return PrioritySellList.Value.StringToCollection<string>().ToArray();
}
set
{
PrioritySellList.Value = value.CollectionToString();
}
}
public static string[] DontSellListArray
{
get
{
return DontSellList.Value.StringToCollection<string>().ToArray();
}
set
{
DontSellList.Value = value.CollectionToString();
}
}
public static string[] SellListArray
{
get
{
return SellList.Value.StringToCollection<string>().ToArray();
}
set
{
SellList.Value = value.CollectionToString();
}
}
public static ConfigEntry<bool> OverrideWelcomeMessage { get; private set; }
public static ConfigEntry<bool> OverrideHelpMessage { get; private set; }
public static ConfigEntry<bool> ShowFoundItems { get; private set; }
public static ConfigEntry<bool> SortFoundItemsPrice { get; private set; }
public static ConfigEntry<bool> AlignFoundItemsPrice { get; private set; }
public static ConfigEntry<bool> SpeakInShip { get; private set; }
public static ConfigEntry<float> RareVoiceLineChance { get; private set; }
public static ConfigEntry<bool> ShowQuotaWarning { get; private set; }
public static ConfigEntry<int> ScrapEaterChance { get; private set; }
public static ConfigEntry<int> OctolarSpawnWeight { get; private set; }
public static ConfigEntry<int> TakeySpawnWeight { get; private set; }
public static ConfigEntry<int> MaxwellSpawnWeight { get; private set; }
public static ConfigEntry<int> YippeeSpawnWeight { get; private set; }
public static ConfigEntry<int> CookieFumoSpawnWeight { get; private set; }
public static ConfigEntry<int> PsychoSpawnWeight { get; private set; }
public static ConfigEntry<int> ZombiesSpawnWeight { get; private set; }
public static ConfigEntry<int> WolfySpawnWeight { get; private set; }
public static ConfigEntry<int> GlitchSpawnWeight { get; private set; }
public static void Initialize(ConfigFile configFile)
{
ConfigFile = configFile;
BindConfigs();
}
private static void BindConfigs()
{
ConfigHelper.SkipAutoGen();
ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
SellGifts = ConfigHelper.BindSynced("Sell", "SellGifts", defaultValue: false, "Do you want to sell Gifts?");
SellShotguns = ConfigHelper.BindSynced("Sell", "SellShotguns", defaultValue: false, "Do you want to sell Shotguns?");
SellAmmo = ConfigHelper.BindSynced("Sell", "SellAmmo", defaultValue: false, "Do you want to sell Ammo?");
SellKnives = ConfigHelper.BindSynced("Sell", "SellKnives", defaultValue: false, "Do you want to sell Kitchen knives?");
SellPickles = ConfigHelper.BindSynced("Sell", "SellPickles", defaultValue: true, "Do you want to sell Jar of pickles?");
SellScrapWorthZero = ConfigHelper.BindSynced("Advanced Sell", "SellScrapWorthZero", defaultValue: false, "Do you want to sell scrap worth zero?");
OnlySellScrapOnFloor = ConfigHelper.BindSynced("Advanced Sell", "OnlySellScrapOnFloor", defaultValue: false, "Do you want to sell scrap that is only on the floor?");
PrioritySellList = ConfigHelper.BindSynced("Advanced Sell", "PrioritySellList", "Tragedy, Comedy, Whoopie cushion, Easter egg, Clock, Soccer ball", GetPrioritySellListDescription());
DontSellList = ConfigHelper.BindSynced("Advanced Sell", "DontSellList", "", GetDontSellListDescription());
SellList = ConfigHelper.BindSynced("Advanced Sell", "SellList", "Whoopie cushion, Easter egg, Tragedy, Comedy", GetSellListDescription());
OverrideWelcomeMessage = ConfigHelper.Bind("Terminal", "OverrideWelcomeMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal welcome message to add additional info.");
OverrideHelpMessage = ConfigHelper.Bind("Terminal", "OverrideHelpMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal help message to add additional info.");
ShowFoundItems = ConfigHelper.Bind("Terminal", "ShowFoundItems", defaultValue: true, requiresRestart: false, "Show found items on the confirmation screen.");
SortFoundItemsPrice = ConfigHelper.Bind("Terminal", "SortFoundItemsPrice", defaultValue: true, requiresRestart: false, "Sorts found items from most to least expensive.");
AlignFoundItemsPrice = ConfigHelper.Bind("Terminal", "AlignFoundItemsPrice", defaultValue: true, requiresRestart: false, "Align all prices of found items.");
SpeakInShip = ConfigHelper.Bind("Misc", "SpeakInShip", defaultValue: true, requiresRestart: false, "The Company will speak inside your ship after selling from the terminal.");
RareVoiceLineChance = ConfigHelper.Bind("Misc", "RareVoiceLineChance", 5f, requiresRestart: false, "The percent chance the Company will say a rare microphone voice line after selling.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
ShowQuotaWarning = ConfigHelper.Bind("Misc", "ShowQuotaWarning", defaultValue: true, requiresRestart: false, "If enabled, will show a warning when you try to pull the ship's lever when the quota hasn't been fulfilled at the Company building with 0 days left.");
ScrapEaterChance = ConfigHelper.Bind("Scrap Eater", "ScrapEaterChance", 0, requiresRestart: false, "The percent chance a scrap eater will spawn?!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
OctolarSpawnWeight = ConfigHelper.Bind("Scrap Eater", "OctolarSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Octolar will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
TakeySpawnWeight = ConfigHelper.Bind("Scrap Eater", "TakeySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Takey will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
MaxwellSpawnWeight = ConfigHelper.Bind("Scrap Eater", "MaxwellSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Maxwell will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
YippeeSpawnWeight = ConfigHelper.Bind("Scrap Eater", "YippeeSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Yippee will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
CookieFumoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "CookieFumoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Cookie Fumo will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
PsychoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "PsychoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Psycho will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
ZombiesSpawnWeight = ConfigHelper.Bind("Scrap Eater", "ZombiesSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Zombies will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
WolfySpawnWeight = ConfigHelper.Bind("Scrap Eater", "WolfySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Wolfy will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
GlitchSpawnWeight = ConfigHelper.Bind("Scrap Eater", "GlitchSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Glitch will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
}
private static string GetPrioritySellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to prioritize when selling.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
private static string GetDontSellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to not sell.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
private static string GetSellListDescription()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Array of item names to sell when using the `sell list` command.");
stringBuilder.AppendLine("Each entry should be separated by a comma.");
stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
return stringBuilder.ToString();
}
}
[BepInPlugin("com.github.zehsteam.SellMyScrap.v40-v72", "SellMyScrap v40-v72", "1.15.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.SellMyScrap.v40-v72");
private const string TargetUnityVersion = "2022.3.9";
internal static Plugin Instance { get; private set; }
private void Awake()
{
Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.SellMyScrap.v40-v72"));
if (!Utils.IsUnityVersion("2022.3.9"))
{
Logger.LogWarning("Skipping SellMyScrap v40-v72 because it targets a different version of Unity (2022.3.9)");
return;
}
Instance = this;
Logger.LogInfo("SellMyScrap v40-v72 has awoken!");
_harmony.PatchAll(typeof(GameNetworkManagerPatch));
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(TimeOfDayPatch));
_harmony.PatchAll(typeof(HUDManagerPatch));
_harmony.PatchAll(typeof(TerminalPatch));
_harmony.PatchAll(typeof(DepositItemsDeskPatch));
_harmony.PatchAll(typeof(StartMatchLeverPatch));
_harmony.PatchAll(typeof(InteractTriggerPatch));
if (ShipInventoryProxy.Enabled)
{
ShipInventoryProxy.PatchAll(_harmony);
}
Assets.Load();
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
ScrapEaterManager.Initialize();
NetcodePatcherAwake();
}
private void NetcodePatcherAwake()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type[] types = executingAssembly.GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
try
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
try
{
methodInfo.Invoke(null, null);
}
catch (TargetInvocationException ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message));
}
}
}
catch (Exception ex2)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message));
}
}
}
}
catch (Exception ex3)
{
((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message));
}
}
public static void HandleLocalDisconnect()
{
CommandManager.OnLocalDisconnect();
SellManager.CancelSellRequest();
}
public static void HandleTerminalQuit()
{
CommandManager.OnTerminalQuit();
SellManager.CancelSellRequest();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.SellMyScrap.v40-v72";
public const string PLUGIN_NAME = "SellMyScrap v40-v72";
public const string PLUGIN_VERSION = "1.15.3";
}
}
namespace com.github.zehsteam.SellMyScrap.ScrapEaters
{
public class ScrapEater
{
public GameObject SpawnPrefab;
public Func<int> GetSpawnWeight;
public ScrapEater(GameObject spawnPrefab, Func<int> getSpawnWeight)
{
SpawnPrefab = spawnPrefab;
GetSpawnWeight = getSpawnWeight;
}
}
public static class ScrapEaterManager
{
public static List<ScrapEater> ScrapEaters { get; private set; } = new List<ScrapEater>();
internal static void Initialize()
{
ScrapEaters = new List<ScrapEater>(9)
{
new ScrapEater(Assets.OctolarScrapEaterPrefab, () => ConfigManager.OctolarSpawnWeight.Value),
new ScrapEater(Assets.TakeyScrapEaterPrefab, () => ConfigManager.TakeySpawnWeight.Value),
new ScrapEater(Assets.MaxwellScrapEaterPrefab, () => ConfigManager.MaxwellSpawnWeight.Value),
new ScrapEater(Assets.YippeeScrapEaterPrefab, () => ConfigManager.YippeeSpawnWeight.Value),
new ScrapEater(Assets.CookieFumoScrapEaterPrefab, () => ConfigManager.CookieFumoSpawnWeight.Value),
new ScrapEater(Assets.PsychoScrapEaterPrefab, () => ConfigManager.PsychoSpawnWeight.Value),
new ScrapEater(Assets.ZombiesScrapEaterPrefab, () => ConfigManager.ZombiesSpawnWeight.Value),
new ScrapEater(Assets.WolfyScrapEaterPrefab, () => ConfigManager.WolfySpawnWeight.Value),
new ScrapEater(Assets.GlitchScrapEaterPrefab, () => ConfigManager.GlitchSpawnWeight.Value)
};
}
internal static bool CanUseScrapEater()
{
int value = ConfigManager.ScrapEaterChance.Value;
return Utils.RollPercentChance(value);
}
internal static bool HasScrapEater(int index)
{
if (ScrapEaters.Count == 0)
{
return false;
}
if (index < 0 || index > ScrapEaters.Count - 1)
{
return false;
}
return true;
}
public static void AddScrapEater(GameObject spawnPrefab, Func<int> GetSpawnWeight)
{
ScrapEaters.Add(new ScrapEater(spawnPrefab, GetSpawnWeight));
}
internal static void StartRandomScrapEaterOnServer(List<GrabbableObject> scrap, int variantIndex = -1)
{
if (NetworkUtils.IsServer)
{
int randomScrapEaterIndex = GetRandomScrapEaterIndex();
if (randomScrapEaterIndex != -1)
{
StartScrapEaterOnServer(randomScrapEaterIndex, scrap, variantIndex);
}
}
}
internal static void StartScrapEaterOnServer(int index, List<GrabbableObject> scrap, int variantIndex = -1)
{
//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)
if (NetworkUtils.IsServer)
{
GameObject spawnPrefab = ScrapEaters[index].SpawnPrefab;
GameObject val = Object.Instantiate<GameObject>(spawnPrefab, Vector3.zero, Quaternion.identity);
NetworkObject component = val.GetComponent<NetworkObject>();
component.Spawn(true);
ScrapEaterBehaviour component2 = val.GetComponent<ScrapEaterBehaviour>();
component2.SetData(scrap, variantIndex);
Logger.LogInfo($"Spawned scrap eater #{index + 1}");
}
}
private static int GetRandomScrapEaterIndex()
{
return Utils.GetRandomIndexFromWeightList(ScrapEaters.Select((ScrapEater x) => x.GetSpawnWeight()).ToList());
}
}
}
namespace com.github.zehsteam.SellMyScrap.Patches
{
[HarmonyPatch(typeof(DepositItemsDesk))]
internal static class DepositItemsDeskPatch
{
public static int ClipIndex = -1;
public static bool SpeakInShip = false;
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(ref DepositItemsDesk __instance)
{
DepositItemsDeskHelper.SetInstance(__instance);
}
[HarmonyPatch("SellItemsOnServer")]
[HarmonyPrefix]
private static bool SellItemsOnServerPatch(ref DepositItemsDesk __instance)
{
if (__instance.itemsOnCounter.Count == 0)
{
return false;
}
if (NetworkUtils.IsServer)
{
SetMicrophoneSpeakData_Server(SpeakInShip);
}
return true;
}
[HarmonyPatch("MicrophoneSpeak")]
[HarmonyPrefix]
private static bool MicrophoneSpeakPatch(ref DepositItemsDesk __instance)
{
AudioClip[] microphoneAudios = __instance.microphoneAudios;
AudioClip[] rareMicrophoneAudios = __instance.rareMicrophoneAudios;
List<AudioClip> list = new List<AudioClip>(microphoneAudios.Length + rareMicrophoneAudios.Length);
list.AddRange(microphoneAudios);
list.AddRange(rareMicrophoneAudios);
List<AudioClip> list2 = list;
if (ClipIndex == -1)
{
ClipIndex = GetRandomAudioClipIndex();
}
AudioClip val = list2[ClipIndex];
__instance.speakerAudio.PlayOneShot(val, 1f);
if (SpeakInShip && ConfigManager.SpeakInShip.Value)
{
StartOfRound.Instance.speakerAudioSource.PlayOneShot(val, 1f);
}
SpeakInShip = false;
ClipIndex = -1;
return false;
}
private static int GetRandomAudioClipIndex()
{
if (Utils.RollPercentChance(ConfigManager.RareVoiceLineChance.Value))
{
return Random.Range(0, DepositItemsDeskHelper.Instance.rareMicrophoneAudios.Length) + DepositItemsDeskHelper.Instance.microphoneAudios.Length;
}
return Random.Range(0, DepositItemsDeskHelper.Instance.microphoneAudios.Length);
}
public static void SetMicrophoneSpeakData_LocalClient(bool speakInShip, int clipIndex)
{
SpeakInShip = speakInShip;
ClipIndex = clipIndex;
}
private static void SetMicrophoneSpeakData_Server(bool speakInShip)
{
SpeakInShip = speakInShip;
ClipIndex = GetRandomAudioClipIndex();
PluginNetworkBehaviour.Instance.SetMicrophoneSpeakDataClientRpc(speakInShip, ClipIndex);
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
AddNetworkPrefabs();
}
private static void AddNetworkPrefabs()
{
AddNetworkPrefab(Assets.NetworkHandlerPrefab);
foreach (ScrapEater scrapEater in ScrapEaterManager.ScrapEaters)
{
AddNetworkPrefab(scrapEater.SpawnPrefab);
}
}
private static void AddNetworkPrefab(GameObject prefab)
{
if ((Object)(object)prefab == (Object)null)
{
Logger.LogError("Failed to register network prefab. GameObject is null.");
return;
}
NetworkManager.Singleton.AddNetworkPrefab(prefab);
Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab.");
}
}
[HarmonyPatch(typeof(HUDManager))]
internal static class HUDManagerPatch
{
[CompilerGenerated]
private sealed class <ScrollRewardsListText>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Scrollbar rewardsScrollbar;
public float duration;
private float <timer>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ScrollRewardsListText>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<timer>5__2 = 0f;
rewardsScrollbar.value = 1f;
break;
case 2:
<>1__state = -1;
<timer>5__2 += Time.deltaTime;
break;
}
if (<timer>5__2 < duration)
{
if (<timer>5__2 > duration)
{
<timer>5__2 = duration;
}
float num = 1f / duration * <timer>5__2;
rewardsScrollbar.value = 1f - num;
<>2__current = null;
<>1__state = 2;
return true;
}
rewardsScrollbar.value = 0f;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("DisplayCreditsEarning")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static bool DisplayCreditsEarningPatch(ref HUDManager __instance, int creditsEarned, GrabbableObject[] objectsSold, int newGroupCredits, ref Coroutine ___scrollRewardTextCoroutine)
{
Logger.LogInfo($"Earned ${creditsEarned}; sold {objectsSold.Length} items; new credits amount: ${newGroupCredits}");
string text = ScrapHelper.GetScrapMessage(objectsSold.ToList());
int num = text.Split('\n').Length;
int num2 = ((num < 8) ? (8 - num) : 0);
for (int i = 0; i < num2; i++)
{
text += "\n\t";
}
((TMP_Text)__instance.moneyRewardsListText).text = text;
((TMP_Text)__instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}";
__instance.moneyRewardsAnimator.SetTrigger("showRewards");
__instance.rewardsScrollbar.value = 1f;
if (num >= 9)
{
if (___scrollRewardTextCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(___scrollRewardTextCoroutine);
}
___scrollRewardTextCoroutine = ((MonoBehaviour)__instance).StartCoroutine(ScrollRewardsListText(__instance.rewardsScrollbar));
}
return false;
}
[IteratorStateMachine(typeof(<ScrollRewardsListText>d__1))]
private static IEnumerator ScrollRewardsListText(Scrollbar rewardsScrollbar, float duration = 3f)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ScrollRewardsListText>d__1(0)
{
rewardsScrollbar = rewardsScrollbar,
duration = duration
};
}
}
[HarmonyPatch(typeof(InteractTrigger))]
internal static class InteractTriggerPatch
{
[HarmonyPatch("StopInteraction")]
[HarmonyPostfix]
private static void StopInteractionPatch(ref InteractTrigger __instance)
{
if ((Object)(object)StartMatchLeverPatch.InteractTrigger == (Object)(object)__instance)
{
StartMatchLeverPatch.DisplayedSellWarning = false;
}
}
}
[HarmonyPatch(typeof(StartMatchLever))]
internal static class StartMatchLeverPatch
{
public static InteractTrigger InteractTrigger;
public static bool DisplayedSellWarning;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ref StartMatchLever __instance)
{
InteractTrigger = ((Component)__instance).GetComponent<InteractTrigger>();
DisplayedSellWarning = false;
}
[HarmonyPatch("BeginHoldingInteractOnLever")]
[HarmonyPostfix]
private static void BeginHoldingInteractOnLeverPatch(ref StartMatchLever __instance)
{
if (TimeOfDay.Instance.daysUntilDeadline > 0 || !ConfigManager.ShowQuotaWarning.Value)
{
if (__instance.triggerScript.timeToHold == 4.01f)
{
__instance.triggerScript.timeToHold = 0.7f;
}
}
else if (!((Object)(object)DepositItemsDeskHelper.Instance == (Object)null) && StartOfRound.Instance.shipHasLanded)
{
if (TimeOfDay.Instance.quotaFulfilled >= TimeOfDay.Instance.profitQuota)
{
__instance.triggerScript.timeToHold = 0.7f;
}
else if (!DisplayedSellWarning)
{
DisplayedSellWarning = true;
__instance.triggerScript.timeToHold = 4.01f;
HUDManager.Instance.DisplayTip("HALT!", "You did not sell enough scrap to fulfill the profit quota.", true, false, "LC_Tip1");
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePatch()
{
SpawnNetworkHandler();
}
private static void SpawnNetworkHandler()
{
//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)
if (NetworkUtils.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(Assets.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
RemoveMapPropsContainerForTesting();
}
private static void RemoveMapPropsContainerForTesting()
{
GameObject val = GameObject.Find("Environment/MapPropsContainerForTesting");
if (!((Object)(object)val == (Object)null))
{
val.SetActive(false);
}
}
[HarmonyPatch("firstDayAnimation")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static void FirstDayAnimationPatchPrefix()
{
if (DateTime.Today.Month == 4 && DateTime.Today.Day == 1)
{
StartOfRound.Instance.shipIntroSpeechSFX = Assets.BrainRotIntroSpeechSFX;
}
}
[HarmonyPatch("OnClientConnect")]
[HarmonyPrefix]
private static void OnClientConnectPatch(ref ulong clientId)
{
if (NetworkUtils.IsServer)
{
SyncedConfigEntryBase.SendConfigsToClient(clientId);
}
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPrefix]
private static void OnLocalDisconnectPatch()
{
Plugin.HandleLocalDisconnect();
}
}
[HarmonyPatch(typeof(Terminal))]
internal static class TerminalPatch
{
private static bool _hasOverrideTerminalNodes;
public static Terminal Instance { get; private set; }
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePatch(Terminal __instance)
{
Instance = __instance;
}
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatchPrefix(ref Terminal __instance)
{
TerminalHelper.SetInstance(__instance);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void StartPatchPostfix(ref TerminalNodesList ___terminalNodes)
{
OverrideTerminalNodes(___terminalNodes);
}
private static void OverrideTerminalNodes(TerminalNodesList terminalNodes)
{
if (!_hasOverrideTerminalNodes)
{
_hasOverrideTerminalNodes = true;
if (ConfigManager.OverrideWelcomeMessage.Value)
{
OverrideWelcomeTerminalNode(terminalNodes);
}
if (ConfigManager.OverrideHelpMessage.Value)
{
OverrideHelpTerminalNode(terminalNodes);
}
}
}
private static void OverrideWelcomeTerminalNode(TerminalNodesList terminalNodes)
{
int index = 1;
string displayText = terminalNodes.specialNodes[index].displayText;
string text = "Type \"Help\" for a list of commands.";
string displayText2 = displayText.Replace(text, text + "\n\n[SellMyScrap v40-v72]\nType \"Sell\" for a list of commands.");
terminalNodes.specialNodes[index].displayText = displayText2;
}
private static void OverrideHelpTerminalNode(TerminalNodesList terminalNodes)
{
int index = 13;
string displayText = terminalNodes.specialNodes[index].displayText;
string text = ">OTHER\nTo see the list of other commands";
string displayText2 = displayText.Replace(text, text + ".\n\n>SELL\nTo see the list of SellMyScrap v40-v72 commands.");
terminalNodes.specialNodes[index].displayText = displayText2;
}
[HarmonyPatch("QuitTerminal")]
[HarmonyPostfix]
private static void QuitTerminalPatch()
{
Plugin.HandleTerminalQuit();
}
[HarmonyPatch("ParsePlayerSentence")]
[HarmonyPrefix]
[HarmonyPriority(800)]
private static bool ParsePlayerSentencePatch(ref Terminal __instance, ref TerminalNode __result)
{
string[] array = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (CommandManager.TryExecuteCommand(array, out var terminalNode))
{
if ((Object)(object)terminalNode == (Object)null)
{
__result = TerminalHelper.CreateTerminalNode("TerminalNode is null!\n\n");
return false;
}
__result = terminalNode;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal static class TimeOfDayPatch
{
private static int _daysUntilDeadline = 3;
private static int _preDaysUntilDeadline = 3;
private static int _postDaysUntilDeadline = 3;
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPrefix]
private static void SetBuyingRateForDayPatchPrefix()
{
_preDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
}
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPostfix]
private static void SetBuyingRateForDayPatchPostfix()
{
_postDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
SetDaysUntilDeadline();
}
private static void SetDaysUntilDeadline()
{
if (_postDaysUntilDeadline == 0)
{
if (_preDaysUntilDeadline == 0)
{
_daysUntilDeadline = 0;
}
else
{
_daysUntilDeadline = -1;
}
}
else
{
_daysUntilDeadline = _postDaysUntilDeadline;
}
}
public static int GetDaysUntilDeadline()
{
return _daysUntilDeadline;
}
}
}
namespace com.github.zehsteam.SellMyScrap.Data
{
public enum SellType
{
None,
Amount,
Quota,
All,
Item,
List
}
public enum ConfirmationStatus
{
None,
AwaitingConfirmation,
Confirmed
}
public class SellRequest
{
public SellType SellType;
public int ScrapValue;
public int RequestedScrapValue;
public ConfirmationStatus ConfirmationStatus;
public int ScrapEaterIndex;
public int ScrapEaterVariantIndex;
public int RealScrapValue => ScrapHelper.GetRealValue(ScrapValue);
public SellRequest(SellType sellType, int scrapValue, int requestedScrapValue, ConfirmationStatus confirmationStatus, int scrapEaterIndex = -2, int scrapEaterVariantIndex = -1)
{
SellType = sellType;
ScrapValue = scrapValue;
RequestedScrapValue = requestedScrapValue;
ConfirmationStatus = confirmationStatus;
ScrapEaterIndex = scrapEaterIndex;
ScrapEaterVariantIndex = scrapEaterVariantIndex;
}
}
}
namespace com.github.zehsteam.SellMyScrap.Objects
{
public enum ItemLocation
{
Ship,
Vehicle,
ShipInventory
}
public class ItemData
{
public GrabbableObject GrabbableObject { get; set; }
public SI_ItemDataProxy SI_ItemDataProxy { get; set; }
public ItemLocation ItemLocation { get; set; }
public string ItemName => GetItemName();
public int ScrapValue => GetScrapValue();
public ItemData(GrabbableObject grabbableObject, ItemLocation itemLocation)
{
GrabbableObject = grabbableObject;
ItemLocation = itemLocation;
}
public ItemData(SI_ItemDataProxy si_ItemDataProxy, ItemLocation itemLocation)
{
SI_ItemDataProxy = si_ItemDataProxy;
ItemLocation = itemLocation;
}
private string GetItemName()
{
if ((Object)(object)GrabbableObject != (Object)null)
{
return GrabbableObject.itemProperties.itemName;
}
if (ShipInventoryProxy.Enabled && SI_ItemDataProxy.IsValid())
{
return SI_ItemDataProxy.ItemName;
}
return "Unknown Item";
}
private int GetScrapValue()
{
if ((Object)(object)GrabbableObject != (Object)null)
{
return GrabbableObject.scrapValue;
}
if (ShipInventoryProxy.Enabled && SI_ItemDataProxy.IsValid())
{
return SI_ItemDataProxy.ScrapValue;
}
return 0;
}
}
[Serializable]
public class ScrapToSell : INetworkSerializable
{
public NetworkObjectReference[] ShipNetworkObjectReferences = Array.Empty<NetworkObjectReference>();
public NetworkObjectReference[] VehicleNetworkObjectReferences = Array.Empty<NetworkObjectReference>();
public SI_ItemDataProxy[] ShipInventoryItems = Array.Empty<SI_ItemDataProxy>();
private List<ItemData> _itemDataList = new List<ItemData>();
private bool _setItemDataList;
private List<GrabbableObject> _shipGrabbableObjects = new List<GrabbableObject>();
private bool _setShipGrabbableObjects;
private List<GrabbableObject> _vehicleGrabbableObjects = new List<GrabbableObject>();
private bool _setVehicleGrabbableObjects;
public List<ItemData> ItemDataList
{
get
{
if (!_setItemDataList)
{
SetItemDataList();
}
return _itemDataList;
}
set
{
_itemDataList = value;
_setItemDataList = true;
}
}
public List<GrabbableObject> GrabbableObjects
{
get
{
List<GrabbableObject> shipGrabbableObjects = ShipGrabbableObjects;
List<GrabbableObject> vehicleGrabbableObjects = VehicleGrabbableObjects;
List<GrabbableObject> list = new List<GrabbableObject>(shipGrabbableObjects.Count + vehicleGrabbableObjects.Count);
list.AddRange(shipGrabbableObjects);
list.AddRange(vehicleGrabbableObjects);
return list;
}
}
public List<GrabbableObject> ShipGrabbableObjects
{
get
{
if (!_setShipGrabbableObjects)
{
SetShipGrabbableObjects();
}
return _shipGrabbableObjects;
}
set
{
_shipGrabbableObjects = value;
_setShipGrabbableObjects = true;
}
}
public List<GrabbableObject> VehicleGrabbableObjects
{
get
{
if (!_setVehicleGrabbableObjects)
{
SetVehicleGrabbableObjects();
}
return _vehicleGrabbableObjects;
}
set
{
_vehicleGrabbableObjects = value;
_setVehicleGrabbableObjects = true;
}
}
public int ItemCount => GetItemCount();
public int TotalScrapValue => GetTotalScrapValue();
public int RealTotalScrapValue => ScrapHelper.GetRealValue(TotalScrapValue);
public ScrapToSell()
{
}
public ScrapToSell(List<ItemData> items)
{
ItemDataList = items;
ShipGrabbableObjects = (from x in items
where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Ship
select x.GrabbableObject).ToList();
VehicleGrabbableObjects = (from x in items
where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Vehicle
select x.GrabbableObject).ToList();
ShipInventoryItems = (from x in items
where x.SI_ItemDataProxy.IsValid()
select x.SI_ItemDataProxy).ToArray();
SetShipNetworkObjectReferences();
SetVehicleNetworkObjectReferences();
}
private void SetShipNetworkObjectReferences()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
List<NetworkObjectReference> list = new List<NetworkObjectReference>();
NetworkObject val = default(NetworkObject);
foreach (GrabbableObject shipGrabbableObject in ShipGrabbableObjects)
{
if (((Component)shipGrabbableObject).TryGetComponent<NetworkObject>(ref val))
{
list.Add(NetworkObjectReference.op_Implicit(val));
}
}
ShipNetworkObjectReferences = list.ToArray();
}
private void SetVehicleNetworkObjectReferences()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
List<NetworkObjectReference> list = new List<NetworkObjectReference>();
NetworkObject val = default(NetworkObject);
foreach (GrabbableObject vehicleGrabbableObject in VehicleGrabbableObjects)
{
if (((Component)vehicleGrabbableObject).TryGetComponent<NetworkObject>(ref val))
{
list.Add(NetworkObjectReference.op_Implicit(val));
}
}
VehicleNetworkObjectReferences = list.ToArray();
}
private void SetItemDataList()
{
ItemDataList = ScrapHelper.GetItemDataList(ShipGrabbableObjects, VehicleGrabbableObjects, ShipInventoryItems);
}
private void SetShipGrabbableObjects()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
ShipGrabbableObjects = new List<GrabbableObject>();
NetworkObjectReference[] shipNetworkObjectReferences = ShipNetworkObjectReferences;
NetworkObject val2 = default(NetworkObject);
GrabbableObject item = default(GrabbableObject);
for (int i = 0; i < shipNetworkObjectReferences.Length; i++)
{
NetworkObjectReference val = shipNetworkObjectReferences[i];
if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
{
ShipGrabbableObjects.Add(item);
}
}
}
private void SetVehicleGrabbableObjects()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
VehicleGrabbableObjects = new List<GrabbableObject>();
NetworkObjectReference[] vehicleNetworkObjectReferences = VehicleNetworkObjectReferences;
NetworkObject val2 = default(NetworkObject);
GrabbableObject item = default(GrabbableObject);
for (int i = 0; i < vehicleNetworkObjectReferences.Length; i++)
{
NetworkObjectReference val = vehicleNetworkObjectReferences[i];
if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
{
VehicleGrabbableObjects.Add(item);
}
}
}
private int GetItemCount()
{
return GrabbableObjects.Count + ShipInventoryItems.Length;
}
private int GetTotalScrapValue()
{
return GrabbableObjects.Sum((GrabbableObject x) => x.scrapValue) + ShipInventoryItems.Sum((SI_ItemDataProxy x) => x.ScrapValue);
}
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref ShipNetworkObjectReferences, default(ForNetworkSerializable));
((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref VehicleNetworkObjectReferences, default(ForNetworkSerializable));
((BufferSerializer<SI_ItemDataProxy>*)(&serializer))->SerializeValue<SI_ItemDataProxy>(ref ShipInventoryItems, default(ForNetworkSerializable));
}
}
public class SellCommandRequest
{
[CompilerGenerated]
private int <value>P;
public int Value => <value>P;
public bool OnlyAllowedScrap { get; set; }
public bool WithOvertimeBonus { get; set; }
public bool OnlyUseShipInventory { get; set; }
public BaseScrapMatchAlgorithm ScrapMatchAlgorithm { get; set; }
public int TargetValue
{
get
{
if (!WithOvertimeBonus)
{
return GetSellValue(Value);
}
return GetSellValueWithOvertime();
}
}
public SellCommandRequest(int value)
{
<value>P = value;
OnlyAllowedScrap = true;
ScrapMatchAlgorithm = BaseScrapMatchAlgorithm.Default;
base..ctor();
}
public ScrapToSell GetScrapToSell(List<ItemData> items)
{
if (Value == int.MaxValue)
{
return new ScrapToSell(items);
}
return new ScrapToSell(ScrapMatchAlgorithm.FindMatch(items, TargetValue, ConfigManager.PrioritySellListArray));
}
private int GetSellValue(int value)
{
if (value == int.MaxValue)
{
return value;
}
return Mathf.CeilToInt((float)value / StartOfRound.Instance.companyBuyingRate);
}
private int GetSellValueWithOvertime()
{
int profitQuota = TimeOfDay.Instance.profitQuota;
int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled;
int num = quotaFulfilled + Value - profitQuota;
if (num <= 0)
{
return GetSellValue(Value);
}
int value = Value;
int num2 = Mathf.Max(profitQuota - quotaFulfilled, 0);
value -= (TimeOfDayPatch.GetDaysUntilDeadline() + 1) * 15;
int value2 = Mathf.CeilToInt((float)(5 * value + num2 + 75) / 6f);
return GetSellValue(value2);
}
}
public class SyncedConfigEntry<T> : SyncedConfigEntryBase
{
private ConfigEntry<T> _configEntry;
private T _serverValue;
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue;
public override string Section => ((ConfigEntryBase)_configEntry).Definition.Section;
public override string Key => ((ConfigEntryBase)_configEntry).Definition.Key;
public event Action<T> SettingChanged;
public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null)
{
SyncedConfigEntryBase.AddInstance(this);
_configEntry = ConfigHelper.Bind(section, key, defaultValue, requiresRestart: false, description, acceptableValues, null, configFile);
_configEntry.SettingChanged += SettingChangedInternal;
}
public T GetValue()
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
return _serverValue;
}
return _configEntry.Value;
}
public void SetValue(T value)
{
if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
{
_configEntry.Value = value;
}
}
public void ResetToDefault()
{
if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
{
_configEntry.Value = DefaultValue;
}
}
private void SettingChangedInternal(object sender, EventArgs e)
{
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
this.SettingChanged?.Invoke(Value);
SendConfigToClients();
}
}
private void SendConfigToClients()
{
//IL_003b: 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)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString());
}
}
public override void SendConfigToClient(ulong clientId)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId)
};
ClientRpcParams clientRpcParams = val;
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString(), clientRpcParams);
}
}
public override void SetValueFromServer(string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
if (!value.TryConvertTo<T>(out var result))
{
throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}");
}
_serverValue = result;
Logger.LogInfo("Set synced config entry value from server. (Section: \"" + Section + "\", Key: \"" + Key + "\", Value: \"" + value + "\")", extended: true);
this.SettingChanged?.Invoke(result);
}
}
}
public abstract class SyncedConfigEntryBase
{
private static readonly object _instancesLock = new object();
public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>();
public abstract string Section { get; }
public abstract string Key { get; }
public static void AddInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Add(instance);
}
}
public static void RemoveInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Remove(instance);
}
}
public abstract void SendConfigToClient(ulong clientId);
public abstract void SetValueFromServer(string value);
public static void SendConfigsToClient(ulong clientId)
{
if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId))
{
return;
}
foreach (SyncedConfigEntryBase instance in Instances)
{
instance.SendConfigToClient(clientId);
}
}
public static void SetValueFromServer(string section, string key, string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key);
if (syncedConfigEntryBase == null)
{
Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\"");
}
else
{
syncedConfigEntryBase.SetValueFromServer(value);
}
}
}
}
}
namespace com.github.zehsteam.SellMyScrap.MonoBehaviours
{
public class CookieFumoScrapEaterBehaviour : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <StartAnimation>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CookieFumoScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Expected O, but got Unknown
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CookieFumoScrapEaterBehaviour cookieFumoScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.fallSFX);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.spawnPosition, cookieFumoScrapEaterBehaviour.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.soundEffectsAudio);
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.landSFX, cookieFumoScrapEaterBehaviour.landIndex);
cookieFumoScrapEaterBehaviour.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.beforeEatSFX));
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.MoveTargetScrapToTargetTransform(cookieFumoScrapEaterBehaviour.mouthTransform, cookieFumoScrapEaterBehaviour.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.suckDuration);
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.eatSFX));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.voiceLineSFX, cookieFumoScrapEaterBehaviour._voiceLineIndex));
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
<>1__state = 10;
return true;
case 10:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.movementDuration));
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 12;
return true;
case 12:
<>1__state = -1;
cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.takeOffSFX);
<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.spawnPosition, 2f));
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Cookie Fumo")]
[Space(5f)]
public AudioClip fallSFX;
public AudioClip beforeEatSFX;
public AudioClip[] voiceLineSFX = Array.Empty<AudioClip>();
private int _voiceLineIndex;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
_voiceLineIndex = Random.Range(0, voiceLineSFX.Length);
SetDataClientRpc(_voiceLineIndex);
}
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(int voiceLineIndex)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3624265567u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, voiceLineIndex);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3624265567u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
_voiceLineIndex = voiceLineIndex;
}
}
}
[IteratorStateMachine(typeof(<StartAnimation>d__6))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__6(0)
{
<>4__this = this
};
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CookieFumoScrapEaterBehaviour()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3624265567u, new RpcReceiveHandler(__rpc_handler_3624265567));
}
private static void __rpc_handler_3624265567(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int dataClientRpc = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref dataClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CookieFumoScrapEaterBehaviour)(object)target).SetDataClientRpc(dataClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "CookieFumoScrapEaterBehaviour";
}
}
internal class CoroutineRunner : MonoBehaviour
{
public static CoroutineRunner Instance { get; private set; }
public static void Spawn()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Instance != (Object)null))
{
new GameObject("SellMyScrap v40-v72 CoroutineRunner", new Type[1] { typeof(CoroutineRunner) });
}
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
((Object)this).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)this);
}
public static Coroutine Start(IEnumerator routine)
{
if ((Object)(object)Instance == (Object)null)
{
Spawn();
}
CoroutineRunner instance = Instance;
return ((instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null) ?? null;
}
public static void Stop(IEnumerator routine)
{
if (!((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StopCoroutine(routine);
}
}
public static void Stop(Coroutine routine)
{
if (!((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StopCoroutine(routine);
}
}
}
public class DestroyAfterTimeBehaviour : MonoBehaviour
{
[CompilerGenerated]
private sealed class <DestoryAfterTime>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DestroyAfterTimeBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DestoryAfterTime>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
int num = <>1__state;
DestroyAfterTimeBehaviour destroyAfterTimeBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(destroyAfterTimeBehaviour.duration);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Object.Destroy((Object)(object)((Component)destroyAfterTimeBehaviour).gameObject);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public float duration = 5f;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(DestoryAfterTime());
}
[IteratorStateMachine(typeof(<DestoryAfterTime>d__2))]
private IEnumerator DestoryAfterTime()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DestoryAfterTime>d__2(0)
{
<>4__this = this
};
}
}
public class GlitchScrapEater : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <StartAnimation>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GlitchScrapEater <>4__this;
private float <flashbangSFXLength>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Expected O, but got Unknown
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: 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_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Expected O, but got Unknown
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Expected O, but got Unknown
int num = <>1__state;
GlitchScrapEater glitchScrapEater = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((MonoBehaviour)glitchScrapEater).StartCoroutine(glitchScrapEater.MoveToPosition(glitchScrapEater.spawnPosition, glitchScrapEater.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
glitchScrapEater.PlayOneShotSFX(glitchScrapEater.landSFX, glitchScrapEater.landIndex);
glitchScrapEater.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
glitchScrapEater.PlayAudioSource(glitchScrapEater.movementAudio);
<>2__current = ((MonoBehaviour)glitchScrapEater).StartCoroutine(glitchScrapEater.MoveToPosition(glitchScrapEater.startPosition, glitchScrapEater.endPosition, glitchScrapEater.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
glitchScrapEater.StopAudioSource(glitchScrapEater.movementAudio);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.pauseDuration / 2f);
<>1__state = 4;
return true;
case 4:
{
<>1__state = -1;
AudioClip[] audioClips = (glitchScrapEater._playLunxaraSFX ? glitchScrapEater._beforeEatLunxaraSFX : glitchScrapEater._beforeEatSFX);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(audioClips, glitchScrapEater._beforeEatSFXIndex));
<>1__state = 5;
return true;
}
case 5:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.pauseDuration / 2f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
glitchScrapEater.MoveTargetScrapToTargetTransform(glitchScrapEater.mouthTransform, glitchScrapEater.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(glitchScrapEater.suckDuration);
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(glitchScrapEater.eatSFX));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(glitchScrapEater.PlayOneShotSFX(glitchScrapEater._afterEatSFX));
<>1__state = 9;
return true;
case 9:
{
<>1__state = -1;
<flashbangSFXLength>5__2 = glitchScrapEater._flashbangExplodeSFX.length;
Vector3 position = glitchScrapEater.mouthTransform.position;
Object.Instantiate<GameObject>(glitchScrapEater._flashbangParticlePrefab, position, Quaternion.identity);
StunGrenadeItem.StunExplosion(position, true, 1f, 7.5f, 1f, false, (PlayerControllerB)null, (PlayerControllerB)null, 0f);
glitchScrapEater.PlayOneShotSFX(glitchScrapEater._flashbangExplodeSFX);
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 10;
return true;
}
case 10:
<>1__state = -1;
glitchScrapEater.modelObject.SetActive(false);
<>2__current = (object)new WaitForSeconds(<flashbangSFXLength>5__2);
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Glitch")]
[Space(5f)]
[SerializeField]
private AudioClip[] _beforeEatSFX = Array.Empty<AudioClip>();
[SerializeField]
private AudioClip[] _beforeEatLunxaraSFX = Array.Empty<AudioClip>();
[SerializeField]
private AudioClip _afterEatSFX;
private int _beforeEatSFXIndex;
private bool _playLunxaraSFX;
private AudioClip _flashbangExplodeSFX;
private GameObject _flashbangParticlePrefab;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
if (PlayerUtils.HasPlayerLunxara())
{
_playLunxaraSFX = Utils.RollPercentChance(50f);
}
if (_playLunxaraSFX)
{
_beforeEatSFXIndex = Random.Range(0, _beforeEatLunxaraSFX.Length);
}
else
{
_beforeEatSFXIndex = Random.Range(0, _beforeEatSFX.Length);
}
SetDataClientRpc(_beforeEatSFXIndex, _playLunxaraSFX);
}
FindFlashbangAssets();
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(int beforeEatSFXIndex, bool playLunxaraSFX)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1454171327u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, beforeEatSFXIndex);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref playLunxaraSFX, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1454171327u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
_beforeEatSFXIndex = beforeEatSFXIndex;
_playLunxaraSFX = playLunxaraSFX;
}
}
}
private void FindFlashbangAssets()
{
Item val = ((IEnumerable<Item>)TerminalPatch.Instance.buyableItemsList).FirstOrDefault((Func<Item, bool>)((Item x) => x.itemName.Equals("Stun grenade", StringComparison.OrdinalIgnoreCase)));
if ((Object)(object)val == (Object)null)
{
Logger.LogError("[GlitchScrapEater] Failed to find Stun Grenade item.");
return;
}
StunGrenadeItem val2 = default(StunGrenadeItem);
if (!val.spawnPrefab.TryGetComponent<StunGrenadeItem>(ref val2))
{
Logger.LogError("[GlitchScrapEater] Failed to find StunGrenadeItem component on Stun Grenade item prefab.");
return;
}
_flashbangExplodeSFX = val2.explodeSFX;
_flashbangParticlePrefab = val2.stunGrenadeExplosion;
}
[IteratorStateMachine(typeof(<StartAnimation>d__10))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__10(0)
{
<>4__this = this
};
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_GlitchScrapEater()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1454171327u, new RpcReceiveHandler(__rpc_handler_1454171327));
}
private static void __rpc_handler_1454171327(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int beforeEatSFXIndex = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref beforeEatSFXIndex);
bool playLunxaraSFX = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref playLunxaraSFX, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((GlitchScrapEater)(object)target).SetDataClientRpc(beforeEatSFXIndex, playLunxaraSFX);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "GlitchScrapEater";
}
}
public class MaxwellScrapEaterBehaviour : ScrapEaterExtraBehaviour
{
[CompilerGenerated]
private sealed class <MoveLocalPlayerToMaxwell>d__13 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
public float duration;
private PlayerControllerB <localPlayerScript>5__2;
private Vector3 <startPosition>5__3;
private Vector3 <endPosition>5__4;
private float <timer>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MoveLocalPlayerToMaxwell>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<localPlayerScript>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<localPlayerScript>5__2 = PlayerUtils.GetLocalPlayerScript();
maxwellScrapEaterBehaviour._isTarget = true;
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: false);
PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: false);
<startPosition>5__3 = ((Component)<localPlayerScript>5__2).transform.position;
<endPosition>5__4 = maxwellScrapEaterBehaviour.mouthTransform.position;
<endPosition>5__4.x += 1f;
<endPosition>5__4.y = ((Component)maxwellScrapEaterBehaviour).transform.position.y;
<timer>5__5 = 0f;
break;
case 1:
<>1__state = -1;
<timer>5__5 += Time.deltaTime;
break;
}
if (<timer>5__5 < duration)
{
float num2 = 1f / duration * <timer>5__5;
Vector3 position = <startPosition>5__3 + (<endPosition>5__4 - <startPosition>5__3) * num2;
((Component)<localPlayerScript>5__2).transform.position = position;
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <StartAnimation>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartAnimation>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Expected O, but got Unknown
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Expected O, but got Unknown
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Expected O, but got Unknown
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Expected O, but got Unknown
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Expected O, but got Unknown
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationIdle();
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.spawnPosition, maxwellScrapEaterBehaviour.startPosition, 2f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.landSFX, maxwellScrapEaterBehaviour.landIndex);
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.meowSFX, maxwellScrapEaterBehaviour._meowIndex);
maxwellScrapEaterBehaviour.ShakeCamera();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.movementDuration));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationDance();
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveLocalPlayerToMaxwell(maxwellScrapEaterBehaviour.suckDuration - 0.1f));
}
maxwellScrapEaterBehaviour.MoveTargetScrapToTargetTransform(maxwellScrapEaterBehaviour.mouthTransform, maxwellScrapEaterBehaviour.suckDuration - 0.1f);
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.suckDuration);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.eatSFX));
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
maxwellScrapEaterBehaviour.SetAnimationIdle();
<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: true);
}
if (maxwellScrapEaterBehaviour._isEvil)
{
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.StartEvilMaxwell());
<>1__state = 10;
return true;
}
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
}
maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.movementDuration));
<>1__state = 12;
return true;
case 10:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(3f);
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
return false;
case 12:
<>1__state = -1;
maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.takeOffSFX);
<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.spawnPosition, 2f));
<>1__state = 14;
return true;
case 14:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <StartEvilMaxwell>d__14 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MaxwellScrapEaterBehaviour <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartEvilMaxwell>d__14(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
maxwellScrapEaterBehaviour.bodyObject.SetActive(false);
maxwellScrapEaterBehaviour.evilObject.SetActive(true);
maxwellScrapEaterBehaviour.purrAudio.Stop();
maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.evilNoise);
<>2__current = (object)new WaitForSeconds(1.25f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (maxwellScrapEaterBehaviour._isTarget)
{
PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
}
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 2;
return true;
case 2:
{
<>1__state = -1;
Vector3 position = ((Component)maxwellScrapEaterBehaviour).transform.position;
position.y += 0.31f;
Utils.CreateExplosion(position, spawnExplosionEffect: true, 100, 0f, 6.4f, 6, (CauseOfDeath)3);
maxwellScrapEaterBehaviour.evilObject.transform.SetParent((Transform)null);
maxwellScrapEaterBehaviour.evilObject.AddComponent<DestroyAfterTimeBehaviour>().duration = 15f;
Rigidbody[] componentsInChildren = maxwellScrapEaterBehaviour.evilObject.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody val in componentsInChildren)
{
val.isKinematic = false;
val.AddExplosionForce(1000f, maxwellScrapEaterBehaviour.evilObject.transform.position, 100f);
}
PlayerUtils.ReviveDeadPlayersAfterTime(5f);
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Space(20f)]
[Header("Maxwell")]
[Space(5f)]
public GameObject bodyObject;
public GameObject evilObject;
public Animator danceAnimator;
public AudioSource purrAudio;
public AudioSource danceAudio;
public AudioClip[] meowSFX = Array.Empty<AudioClip>();
public AudioClip evilNoise;
private bool _isEvil;
private int _meowIndex;
private bool _isTarget;
protected override void Start()
{
if (NetworkUtils.IsServer)
{
if (PlayerUtils.HasPlayerMagoroku() || PlayerUtils.HasPlayerPsychoHypnotic())
{
_isEvil = Utils.RollPercentChance(80f);
}
else
{
_isEvil = Utils.RollPercentChance(50f);
}
_meowIndex = Random.Range(0, meowSFX.Length);
SetDataClientRpc(_isEvil, _meowIndex);
}
base.Start();
}
[ClientRpc]
private void SetDataClientRpc(bool isEvil, int meowIndex)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1025003959u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isEvil, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, meowIndex);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1025003959u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
_isEvil = isEvil;
_meowIndex = meowIndex;
if (PlayerUtils.IsLocalPlayerMagoroku() && (Utils.RollPercentChance(40f) || (isEvil && Utils.RollPercentChance(80f))))
{
_isTarget = true;
}
}
}
[IteratorStateMachine(typeof(<StartAnimation>d__12))]
protected override IEnumerator StartAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartAnimation>d__12(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<MoveLocalPlayerToMaxwell>d__13))]
private IEnumerator MoveLocalPlayerToMaxwell(float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MoveLocalPlayerToMaxwell>d__13(0)
{
<>4__this = this,
duration = duration
};
}
[IteratorStateMachine(typeof(<StartEvilMaxwell>d__14))]
private IEnumerator StartEvilMaxwell()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartEvilMaxwell>d__14(0)
{
<>4__this = this
};
}
priva