Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DropItem v2.2.6
dropitem.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; 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.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using HG; using HG.GeneralSerializer; using HG.Reflection; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using Rewired.Integration.UnityUI; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Networking; using RoR2.Orbs; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace Dolso { internal static class log { private static readonly ManualLogSource logger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); [Conditional("DEBUG")] internal static void debug(object data) { logger.LogDebug(data); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } internal static void LogError(this ILCursor c, object data) { logger.LogError((object)$"ILCursor failure, skipping: {data}\n{c}"); } internal static void LogErrorCaller(this ILCursor c, object data) { logger.LogError((object)$"ILCursor failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}"); } } internal static class HookManager { internal delegate bool ConfigEnabled<T>(T configValue); internal class HookedConfig<T> { private readonly ConfigEnabled<T> enabled; private readonly IDetour detour; internal HookedConfig(ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour) { this.enabled = enabled; this.detour = detour; if (configEntry != null) { configEntry.SettingChanged += ConfigChanged; ConfigChanged(configEntry, null); } else { detour.Apply(); } } private void ConfigChanged(object sender, EventArgs args) { if (!detour.IsValid) { return; } if (enabled(((ConfigEntry<T>)sender).Value)) { if (!detour.IsApplied) { detour.Apply(); } } else if (detour.IsApplied) { detour.Undo(); } } } internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly List<IDisposable> detours = new List<IDisposable>(); private static readonly ConfigEnabled<bool> boolConfigEnabled = BoolEnabled; private static ILHookConfig ilHookConfig = new ILHookConfig { ManualApply = true }; private static HookConfig onHookConfig = new HookConfig { ManualApply = true }; internal static int Hook(Type typeFrom, string fromMethod, Manipulator ilHook) { return Hook(GetMethod(typeFrom, fromMethod), ilHook); } internal static int Hook(Delegate fromMethod, Manipulator ilHook) { return Hook(fromMethod.Method, ilHook); } internal static int Hook(MethodBase fromMethod, Manipulator ilHook) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown try { ILHook val = new ILHook(fromMethod, ilHook, ref ilHookConfig); detours.Add((IDisposable)val); val.Apply(); } catch (Exception e) { e.LogHookError(fromMethod, ((Delegate)(object)ilHook).Method); return 8; } return 0; } internal static int Hook(Type typeFrom, string fromMethod, Delegate onHook) { return Hook(GetMethod(typeFrom, fromMethod), onHook.Method, onHook.Target); } internal static int Hook(Delegate fromMethod, Delegate onHook) { return Hook(fromMethod.Method, onHook.Method, onHook.Target); } internal static int Hook(MethodBase fromMethod, Delegate onHook) { return Hook(fromMethod, onHook.Method, onHook.Target); } internal static int Hook(MethodBase fromMethod, MethodInfo onHook, object target = null) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown try { Hook val = new Hook(fromMethod, onHook, target, ref onHookConfig); detours.Add((IDisposable)val); val.Apply(); } catch (Exception e) { e.LogHookError(fromMethod, onHook); return 8; } return 0; } internal static int HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string fromMethod, Delegate hook) { return configEntry.HookConfig(boolConfigEnabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static int HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, Delegate hook) { return configEntry.HookConfig(boolConfigEnabled, fromMethod, hook.Method, hook.Target); } internal static int HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, MethodInfo hook) { return configEntry.HookConfig(boolConfigEnabled, fromMethod, hook); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string fromMethod, Delegate hook) { return configEntry.HookConfig(enabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, Delegate hook) { return configEntry.HookConfig(enabled, fromMethod, hook.Method, hook.Target); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, MethodInfo hook, object target = null) { try { IDetour val = ManualDetour(fromMethod, hook, target); if (val == null) { return 8; } new HookedConfig<T>(configEntry, enabled, val); return 0; } catch (Exception e) { e.LogHookError(fromMethod, hook); return 8; } } internal static IDetour ManualDetour(Type typeFrom, string fromMethod, Delegate hook) { return ManualDetour(GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static IDetour ManualDetour(MethodBase fromMethod, Delegate hook) { return ManualDetour(fromMethod, hook.Method, hook.Target); } internal static IDetour ManualDetour(MethodBase fromMethod, MethodInfo hook, object target = null) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown try { ParameterInfo[] parameters = hook.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext)) { return (IDetour)new ILHook(fromMethod, (Manipulator)hook.CreateDelegate(typeof(Manipulator)), ref ilHookConfig); } return (IDetour)new Hook(fromMethod, hook, target, ref onHookConfig); } catch (Exception e) { e.LogHookError(fromMethod, hook); return null; } } internal static MethodInfo GetMethod(Type typeFrom, string methodName) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo[] array = (from a in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where a.Name == methodName select a).ToArray(); switch (array.Length) { case 1: return array[0]; case 0: log.error($"Failed to find method: {typeFrom}::{methodName}"); return null; default: { string text = $"{array.Length} ambiguous matches found for {typeFrom}::{methodName}, may be incorrect"; MethodInfo[] array2 = array; for (int num = 0; num < array2.Length; num++) { text = text + "\n" + array2[num]; } log.warning(text); return array[0]; } } } internal static MethodInfo GetMethod(Type typeFrom, string methodName, params Type[] parameters) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo? method = typeFrom.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null); if (method == null) { log.error($"Failed to find method: {typeFrom}::{methodName}_{parameters.Length}"); } return method; } internal static void SetPriority(string[] before_il = null, string[] before_on = null, string[] after_il = null, string[] after_on = null) { ilHookConfig.Before = before_il; onHookConfig.Before = before_on; ilHookConfig.After = after_il; onHookConfig.After = after_on; } internal static void DisposeAll() { for (int num = detours.Count - 1; num >= 0; num--) { try { IDisposable disposable = detours[num]; detours.RemoveAt(num); disposable.Dispose(); } catch (Exception) { } } } internal static void LogHookError(this Exception e, MethodBase fromMethod, MethodInfo hook) { log.error((fromMethod == null) ? $"null from-method for hook: {hook.Name}\n{e}" : $"Failed to hook: {fromMethod.DeclaringType}::{fromMethod.Name} - {hook.Name}\n{e}"); } private static bool BoolEnabled(bool configValue) { return configValue; } } internal static class Utilities { internal struct AsyncHandle<T> : IDisposable { private AsyncOperationHandle<T> handle; public T result => handle.Result; public Task<T> task => handle.Task; internal AsyncHandle(AsyncOperationHandle<T> handle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) this.handle = handle; } public TaskAwaiter<T> GetAwaiter() { return handle.Task.GetAwaiter(); } public void Dispose() { handle.Release(); } public static implicit operator AsyncOperationHandle<T>(AsyncHandle<T> handle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return handle.handle; } } private static GameObject _prefabParent; internal static GameObject CreatePrefab(GameObject gameObject, string name = null) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_prefabParent)) { _prefabParent = new GameObject("DolsoPrefabs"); Object.DontDestroyOnLoad((Object)(object)_prefabParent); ((Object)_prefabParent).hideFlags = (HideFlags)61; _prefabParent.SetActive(false); } GameObject val = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); if (name != null) { ((Object)val).name = name; } return val; } internal static AsyncHandle<T> GetAddressableAsync<T>(string addressable) where T : Object { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new AsyncHandle<T>(Addressables.LoadAssetAsync<T>((object)addressable)); } internal static AsyncHandle<GameObject> GetAddressableAsync(string addressable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new AsyncHandle<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)addressable)); } internal static void DoAddressable<T>(string addressable, Action<T> callback, bool release = false) where T : Object { //IL_0016: 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) AsyncOperationHandle<T> handle = Addressables.LoadAssetAsync<T>((object)addressable); handle.Completed += delegate(AsyncOperationHandle<T> a) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)a.Status == 1) { callback(a.Result); if (release) { handle.Release(); } } }; } internal static void DoAddressable(string addressable, Action<GameObject> callback, bool release = false) { //IL_0016: 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) AsyncOperationHandle<GameObject> handle = Addressables.LoadAssetAsync<GameObject>((object)addressable); handle.Completed += delegate(AsyncOperationHandle<GameObject> a) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)a.Status == 1) { callback(a.Result); if (release) { handle.Release(); } } }; } internal static void AddressableAddComp<TComp>(string addressable, Action<TComp> callback = null) where TComp : Component { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)a.Status == 1) { TComp obj = a.Result.AddComponent<TComp>(); callback?.Invoke(obj); } }; } internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)a.Status == 1 && !Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>())) { a.Result.AddComponent<Comp>(); } }; } internal static void ModifyStateConfig(this EntityStateConfiguration stateConfig, string fieldName, object newValue) { SerializedField[] serializedFields = stateConfig.serializedFieldsCollection.serializedFields; for (int i = 0; i < serializedFields.Length; i++) { if (serializedFields[i].fieldName == fieldName) { Object val = (Object)((newValue is Object) ? newValue : null); if (val != null) { serializedFields[i].fieldValue.objectValue = val; } else if (newValue != null && StringSerializer.CanSerializeType(newValue.GetType())) { serializedFields[i].fieldValue.stringValue = StringSerializer.Serialize(newValue.GetType(), newValue); } else { log.error("Invalid value for SerializedField: " + newValue); } return; } } log.error("Failed to find " + fieldName + " for " + ((Object)stateConfig).name); } internal static bool IsKeyDown(this KeyboardShortcut key, bool onlyJustPressed) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (onlyJustPressed) { if (!Input.GetKeyDown(((KeyboardShortcut)(ref key)).MainKey)) { return false; } } else if (!Input.GetKey(((KeyboardShortcut)(ref key)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref key)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } } [MeansImplicitUse] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] internal class HookAttribute : Attribute { private readonly Type? target_type; private readonly string? target_method; private readonly Type[]? parameters; internal byte flags; internal HookAttribute(Type target_type, string target_method) { this.target_type = target_type; this.target_method = target_method; } internal HookAttribute(Type target_type, string target_method, params Type[] parameters) { this.target_type = target_type; this.target_method = target_method; this.parameters = parameters; } internal HookAttribute() { } internal static int ScanAndApply() { Type[] array = null; try { array = Assembly.GetCallingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { array = ex.Types.Where((Type t) => t != null).ToArray(); log.warning("Failed to load certain types: " + ex); } return ScanAndApply(array.Where((Type a) => a.GetCustomAttribute<HookAttribute>() != null).ToArray()); } internal static int ScanAndApply(params Type[] types) { int num = 0; for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { HookAttribute[] array = (HookAttribute[])Attribute.GetCustomAttributes(methodInfo, typeof(HookAttribute), inherit: false); foreach (HookAttribute hookAttribute in array) { num |= hookAttribute.ApplyHook(methodInfo); } } } return num; } internal int ApplyHook(MethodInfo member) { MethodInfo methodInfo = null; try { methodInfo = get_target(); if (methodInfo != null) { return Hook(methodInfo, member); } if (member.GetParameters().Length == 0 && GetType() == typeof(HookAttribute)) { member.Invoke(null, null); return 0; } log.error("null target method for hook " + member.Name); return 4; } catch (Exception e) { e.LogHookError(methodInfo, member); return 64; } } protected virtual int Hook(MethodInfo target, MethodInfo member) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown ParameterInfo[] array = member.GetParameters(); if (array.Length == 1 && array[0].ParameterType == typeof(ILContext)) { StateMachineAttribute customAttribute; if ((flags & 1) == 0 && (customAttribute = target.GetCustomAttribute<StateMachineAttribute>()) != null) { target = customAttribute.StateMachineType.GetMethod("MoveNext", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } return HookManager.Hook(target, (Manipulator)member.CreateDelegate(typeof(Manipulator))); } return HookManager.Hook(target, member); } protected MethodInfo? get_target() { if ((object)target_type != null) { if (parameters != null) { return HookManager.GetMethod(target_type, target_method, parameters); } return HookManager.GetMethod(target_type, target_method); } return null; } } internal static class RiskofOptions { internal const string RooGuid = "com.rune580.riskofoptions"; internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining)] internal static void SetSprite(Sprite sprite) { ModSettingsManager.SetModIcon(sprite); } internal static void SetSpriteDefaultIcon() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) try { string fullName = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName; Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "icon.png")))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } else { log.error("Failed to load icon.png"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } internal static void AddOption(ConfigEntryBase entry) { AddOption(entry, string.Empty, string.Empty); } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddOption(ConfigEntryBase entry, string categoryName = "", string name = "", bool restartRequired = false) { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) Type settingType = entry.SettingType; object obj; if (!(settingType == typeof(float))) { obj = ((!(settingType == typeof(string))) ? ((!(settingType == typeof(bool))) ? ((!(settingType == typeof(int))) ? ((!(settingType == typeof(Color))) ? ((!(settingType == typeof(KeyboardShortcut))) ? ((object)((!settingType.IsEnum) ? ((ChoiceOption)null) : new ChoiceOption(entry, new ChoiceConfig()))) : ((object)new KeyBindOption((ConfigEntry<KeyboardShortcut>)(object)entry, new KeyBindConfig()))) : ((object)new ColorOption((ConfigEntry<Color>)(object)entry, new ColorOptionConfig()))) : ((object)new IntFieldOption((ConfigEntry<int>)(object)entry, new IntFieldConfig()))) : ((object)new CheckBoxOption((ConfigEntry<bool>)(object)entry, new CheckBoxConfig()))) : ((object)new StringInputFieldOption((ConfigEntry<string>)(object)entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0 }))); } else if (entry.Description.AcceptableValues is AcceptableValueRange<float>) { obj = (object)new SliderOption((ConfigEntry<float>)(object)entry, new SliderConfig { min = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MinValue, max = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MaxValue, FormatString = "{0:f2}", description = entry.DescWithDefault("{0:f2}") }); } else { ConfigEntry<float> obj2 = (ConfigEntry<float>)(object)entry; FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).FormatString = "{0:f2}"; ((BaseOptionConfig)val).description = entry.DescWithDefault("{0:f2}"); obj = (object)new FloatFieldOption(obj2, val); } BaseOption val2 = (BaseOption)obj; if (val2 == null) { return; } BaseOptionConfig config = val2.GetConfig(); config.category = categoryName; config.name = name; config.restartRequired = restartRequired; if (config.description == "") { config.description = entry.DescWithDefault(); } try { ModSettingsManager.AddOption(val2); } catch (Exception arg) { log.error($"AddOption {entry.Definition} failed\n{arg}"); } } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}", string categoryName = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max, string categoryName = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } private static string DescWithDefault(this ConfigEntryBase entry, string format = "{0}") { return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description); } } } namespace Dropitem { internal static class ChatCommands { internal class Command { internal Func<NetworkUser, string[], string> method; internal string helpText; internal byte minArgs; internal Command(Func<NetworkUser, string[], string> method, byte minArgs, string helpText) { this.method = method; this.minArgs = minArgs; this.helpText = helpText; } } internal static Dictionary<string, Command> chatCommands; static ChatCommands() { Command value = new Command(Drop.Drop_item, 1, "<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapgre</color>"); Command value2 = new Command(Give.Give_Item, 2, "<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory</color>"); Command value3 = new Command(Users.Block_User, 1, "<color=#AAE6F0>/block playername\nPrevents the targeted player from dropping items</color>"); Command value4 = new Command(Users.Lock_Inventory, 0, "<color=#AAE6F0>/lock 0 or 1\n Prevents other players from accessing your inventory</color>"); chatCommands = new Dictionary<string, Command> { ["d"] = value, ["drop"] = value, ["dropitem"] = value, ["g"] = value2, ["give"] = value2, ["giveitem"] = value2, ["b"] = value3, ["block"] = value3, ["blockuser"] = value3, ["ub"] = value3, ["unblock"] = value3, ["unblockuser"] = value3, ["lock"] = value4, ["lockinventory"] = value4 }; } } internal static class Config { internal enum PrinterDisableFlags { Off, Printers, Scrappers, PrintersAndScrappers } internal enum DropPermission { None, SelfOnly, HostAny, SelfOnlyAndHostAny, Any } private static ConfigFile configFile; internal static ConfigEntry<bool> lockInventory; internal static ConfigEntry<bool> allowVoidDrop; internal static ConfigEntry<bool> allowLunarDrop; internal static ConfigEntry<bool> allowHexDrop; internal static ConfigEntry<InputButton> dropButton; internal static ConfigEntry<KeyboardShortcut> dropSingleButton; internal static ConfigEntry<string> dropBlacklist; internal static ConfigEntry<bool> applyBlacklistToAll; internal static ConfigEntry<bool> applyAllowToGive; internal static ConfigEntry<bool> allowRecycle; internal static ConfigEntry<bool> dropFromDisconnected; internal static ConfigEntry<bool> dropAsPrinter; internal static ConfigEntry<DropPermission> drop_permission_mode; internal static ConfigEntry<PrinterDisableFlags> disable_printers_when_drop_exists; internal static ConfigEntry<float> disable_printers_distance; internal static void DoConfig(ConfigFile bepConfigFile) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) configFile = bepConfigFile; lockInventory = configFile.Bind<bool>("", "Lock Inventory", false, "Prevent other players from dropping items from your inventory"); allowVoidDrop = configFile.Bind<bool>("", "Allow Void Drops", false, "Allow dropping of void corrupted items"); allowLunarDrop = configFile.Bind<bool>("", "Allow Lunar Drops", true, "Allow dropping of lunar items"); allowHexDrop = configFile.Bind<bool>("", "Allow Hex Drops", false, "Allow dropping of hex items"); dropButton = configFile.Bind<InputButton>("", "Drop button", (InputButton)0, "Mouse button to drop the currently hovered item"); dropSingleButton = configFile.Bind<KeyboardShortcut>("", "Drop single key", new KeyboardShortcut((KeyCode)323, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Key to drop a single of the currently hovered item"); dropBlacklist = configFile.Bind<string>("", "Drop blacklist", "ExtraStatsOnLevelUp, OnLevelUpFreeUnlock, CloverVoid", "Items and equipment listed here will not be dropped. Enable 'Apply Blacklist To dropall' if you want it to apply to that\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use debugtoolkit's list_item or list_equip command to view them."); applyBlacklistToAll = configFile.Bind<bool>("", "Apply blacklist to dropall", false, "If '/drop all' should respect 'Drop blacklist', 'Allow Void Drops', and 'Allow Lunar Drops'"); applyAllowToGive = configFile.Bind<bool>("", "Apply allow toggle to give", false, "If '/give' should use 'Allow Void Drops' and 'Allow Lunar Drops'. When disabled, will allow directly giving void and lunars to other players"); allowRecycle = configFile.Bind<bool>("", "Allow recycle", false, "Allow recycling of dropped items"); dropFromDisconnected = configFile.Bind<bool>("", "Drop from disconnected", true, "Allow dropping from disconnected players"); dropAsPrinter = configFile.Bind<bool>("", "Drop as printer", true, "Treats dropped items as if they were from a printer, to prevent an item duplication exploit with Drifter's Tinker skill"); drop_permission_mode = configFile.Bind<DropPermission>("", "Drop permission mode", DropPermission.SelfOnlyAndHostAny, "Sets who can drop from which inventories:\n'SelfOnly': can only drop from own inventory\n'HostAny': only host can drop items, and can drop from any inventory\n'SelfOnlyAndHostAny': clients can only drop from own inventory, while host can drop from any'Any': anyone can drop from any inventory\n"); disable_printers_when_drop_exists = configFile.Bind<PrinterDisableFlags>("", "Disable printers when drops exist", PrinterDisableFlags.Off, "Disable printers and/or scrappers for users when they have pickups they own created by dropitem within 'Disable printers radius'"); disable_printers_distance = configFile.Bind<float>("", "Disable printers radius", 200f, "When 'Disable printers when drops exist' is enabled, and the player has dropitem drops in range that they have dropped, prevent the action"); if (RiskofOptions.enabled) { DoRiskofOptions(); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void DoRiskofOptions() { RiskofOptions.SetSpriteDefaultIcon(); RiskofOptions.AddOption((ConfigEntryBase)(object)allowVoidDrop); RiskofOptions.AddOption((ConfigEntryBase)(object)allowLunarDrop); RiskofOptions.AddOption((ConfigEntryBase)(object)allowHexDrop); RiskofOptions.AddOption((ConfigEntryBase)(object)lockInventory); RiskofOptions.AddOption((ConfigEntryBase)(object)applyBlacklistToAll); RiskofOptions.AddOption((ConfigEntryBase)(object)applyAllowToGive); RiskofOptions.AddOption((ConfigEntryBase)(object)allowRecycle); RiskofOptions.AddOption((ConfigEntryBase)(object)dropAsPrinter); RiskofOptions.AddOption((ConfigEntryBase)(object)dropFromDisconnected); RiskofOptions.AddOption((ConfigEntryBase)(object)drop_permission_mode); RiskofOptions.AddOption((ConfigEntryBase)(object)disable_printers_when_drop_exists); RiskofOptions.AddOption((ConfigEntryBase)(object)disable_printers_distance); RiskofOptions.AddOption((ConfigEntryBase)(object)dropButton); RiskofOptions.AddOption((ConfigEntryBase)(object)dropSingleButton); RiskofOptions.AddOption((ConfigEntryBase)(object)dropBlacklist); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void ReloadConfig(ConCommandArgs args) { configFile.Reload(); Debug.Log((object)"DropItem config reloaded"); } internal static KeyCode ToKey(this InputButton button) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((int)button switch { 0 => 323, 1 => 324, 2 => 325, _ => 324, }); } } internal class DragItem : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IInitializePotentialDragHandler, IPointerClickHandler { public enum ItemType : byte { None, Item, Equipment } public ItemType type; private GameObject draggedIcon; private RectTransform m_DraggingPlane; public static bool InvalidButton(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (eventData.button == Config.dropButton.Value) { return Main.singlePressed > 0; } return true; } public void OnBeginDrag(PointerEventData eventData) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_00ce: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (!InvalidButton(eventData)) { HUD val = HUD.instancesList[0]; if (Object.op_Implicit((Object)(object)draggedIcon)) { Object.Destroy((Object)(object)draggedIcon); } draggedIcon = new GameObject("dragged icon"); draggedIcon.transform.SetParent(val.mainContainer.transform); draggedIcon.transform.SetAsLastSibling(); RawImage val2 = draggedIcon.AddComponent<RawImage>(); if (type == ItemType.Item) { val2.texture = ((Component)this).GetComponent<ItemIcon>().image.texture; } if (type == ItemType.Equipment) { val2.texture = ((Component)this).GetComponent<EquipmentIcon>().iconImage.texture; } ((Graphic)val2).raycastTarget = false; ((Graphic)val2).color = new Color(1f, 1f, 1f, 0.6f); RectTransform component = draggedIcon.GetComponent<RectTransform>(); ((Transform)component).localScale = ((Transform)component).localScale / 128f; ref RectTransform draggingPlane = ref m_DraggingPlane; Transform transform = ((Component)val.canvas).transform; draggingPlane = (RectTransform)(object)((transform is RectTransform) ? transform : null); } } public void OnDrag(PointerEventData data) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)draggedIcon) && Object.op_Implicit((Object)(object)m_DraggingPlane)) { RectTransform component = draggedIcon.GetComponent<RectTransform>(); Vector3 position = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, data.pressEventCamera, ref position)) { ((Transform)component).position = position; ((Transform)component).rotation = ((Transform)m_DraggingPlane).rotation; } } } public void OnEndDrag(PointerEventData eventData) { if (Object.op_Implicit((Object)(object)draggedIcon)) { Object.Destroy((Object)(object)draggedIcon); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)draggedIcon)) { Object.Destroy((Object)(object)draggedIcon); } } public void OnInitializePotentialDrag(PointerEventData eventData) { eventData.useDragThreshold = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!InvalidButton(eventData) && GetPlayerAndItem(out var player, out var args)) { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null); if ((Object)(object)player.networkUser != (Object)(object)val) { Users.AddPlayerStringArg(player, args); } Console.instance.RunCmd(new CmdSender(val), "dropitem", args); } } public bool GetPlayerAndItem(out PlayerCharacterMasterController player, out List<string> args) { switch (type) { case ItemType.Item: return FromItem(out player, out args); case ItemType.Equipment: return FromEquip(out player, out args); default: log.warning("unknown type of clicked object"); player = null; args = null; return false; } } private bool FromItem(out PlayerCharacterMasterController player, out List<string> args) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) args = new List<string>(); ItemInventoryDisplay componentInParent = ((Component)this).GetComponentInParent<ItemInventoryDisplay>(); object obj; if (componentInParent == null) { obj = null; } else { Inventory inventory = componentInParent.inventory; obj = ((inventory != null) ? ((Component)inventory).GetComponent<PlayerCharacterMasterController>() : null); } player = (PlayerCharacterMasterController)obj; if (!Object.op_Implicit((Object)(object)player)) { log.warning("null player item"); return false; } List<ItemIndex> itemAcquisitionOrder = player.master.inventory.itemAcquisitionOrder; args.Add((itemAcquisitionOrder.Count - itemAcquisitionOrder.IndexOf(((Component)this).GetComponent<ItemIcon>().itemIndex)).ToString()); return true; } private bool FromEquip(out PlayerCharacterMasterController player, out List<string> args) { args = new List<string> { "e" }; Inventory targetInventory = ((Component)this).GetComponent<EquipmentIcon>().targetInventory; player = ((targetInventory != null) ? ((Component)targetInventory).GetComponent<PlayerCharacterMasterController>() : null); if (!Object.op_Implicit((Object)(object)player)) { log.warning("null player equip"); return false; } return true; } } internal static class Drop { public const string green = "<color=#96EBAA>"; public const string player = "<color=#AAE6F0>"; public const string error = "<color=#FF8282>"; public const string bold = "<color=#ff4646>"; private static bool isNegative; public static string Drop_item(NetworkUser sender, string[] args) { //IL_0146: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Invalid comparison between Unknown and I4 //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Invalid comparison between Unknown and I4 //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Invalid comparison between Unknown and I4 //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Invalid comparison between Unknown and I4 //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) PlayerCharacterMasterController val = sender.masterController; Inventory inventory = sender.master.inventory; if (args.Length >= 2) { val = StringParsers.GetNetUserFromString(args[1]); if (!Object.op_Implicit((Object)(object)val)) { return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>"; } inventory = val.master.inventory; } if (!Object.op_Implicit((Object)(object)inventory)) { return "<color=#ff4646>ERROR: null inventory</color>"; } if (!Users.CheckUserPerms(sender, val.networkUser, out var errorMessage)) { return errorMessage; } CharacterBody currentBody = sender.GetCurrentBody(); Transform val2 = ((currentBody != null) ? currentBody.coreTransform : null); if (!Object.op_Implicit((Object)(object)val2)) { return "<color=#FF8282>Must be alive to drop items</color>"; } string value; if (Object.op_Implicit((Object)(object)val.networkUser)) { value = val.networkUser.userName; } else { if (!Config.dropFromDisconnected.Value) { return "<color=#FF8282>Dropping from disconnected players is disabled</color>"; } Users.cachedPlayerNames.TryGetValue(val, out value); } value = "<color=#AAE6F0>" + value + "</color>"; string text = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>"; if (Object.op_Implicit((Object)(object)val.networkUser) && (Object)(object)val.networkUser != (Object)(object)sender && Users.lockedUserIds.Contains(val.networkUser.id)) { return "<color=#FF8282>" + value + " has their inventory locked</color>"; } Vector3 velocity = sender.GetCurrentBody().inputBank.aimDirection; velocity.y = 0f; velocity = ((Vector3)(ref velocity)).normalized * 8f + Vector3.up * 15f; EquipmentIndex val3 = (EquipmentIndex)(-1); ItemIndex val4 = (ItemIndex)(-1); if (args[0].Equals("all", StringComparison.InvariantCultureIgnoreCase)) { new GameObject("DropAll").AddComponent<DropAll>().Assign(inventory, sender, val2); if ((Object)(object)val.networkUser == (Object)(object)sender) { return "<color=#96EBAA>Dropping all items from </color>" + value; } return "<color=#96EBAA>" + text + " is dropping all items from </color>" + value; } if (args[0].Equals("e", StringComparison.InvariantCultureIgnoreCase) || args[0].Equals("equip", StringComparison.InvariantCultureIgnoreCase) || args[0].Equals("equipment", StringComparison.InvariantCultureIgnoreCase)) { val3 = inventory.GetEquipmentIndex(); if ((int)val3 == -1) { return "<color=#FF8282>Target does not have an </color><color=#ff7d00>equipment</color>"; } } else { val4 = StringParsers.FindItemInInventroy(args[0], inventory); } PickupIndex val5; string text2; if ((int)val4 == -1) { if ((int)val3 == -1) { val3 = inventory.GetEquipmentIndex(); if ((int)val3 == -1 || !StringParsers.ContainsString(StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken)), StringParsers.ReformatString(args[0]))) { return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + value + "<color=#AAE6F0>'s</color> inventory</color>"; } } val5 = PickupCatalog.FindPickupIndex(val3); text2 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor)); if (val3 != inventory.GetEquipmentIndex()) { return "<color=#FF8282>Target does not have </color><color=#ff4646>" + text2 + "</color>"; } if (IsBlacklisted(EquipmentCatalog.GetEquipmentDef(val3), ignoreLunar: false, isFromAll: false)) { return text2 + "<color=#FF8282> is not dropable</color>"; } MakePickupDroplets(val5, val2.position, velocity, inventory); inventory.SetEquipmentIndex((EquipmentIndex)(-1), true); if ((Object)(object)val.networkUser == (Object)(object)sender) { return "<color=#96EBAA>Dropped " + text2 + " from </color>" + value; } return "<color=#96EBAA>" + text + " is dropping " + text2 + " from </color>" + value; } ItemDef itemDef = ItemCatalog.GetItemDef(val4); val5 = PickupCatalog.FindPickupIndex(val4); text2 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor)); if (IsBlacklisted(itemDef, ignoreVoidAndLunarAllow: false, allowTrash: true, isFromAll: false)) { return text2 + "<color=#FF8282> is not dropable</color>"; } int num = Math.Min(inventory.GetItemCountPermanent(val4), 20); if (args.Length > 2 && int.TryParse(args[2], out var result)) { num = Math.Min(num, result); } if (num == 0) { return "<color=#FF8282>Target does not have </color>" + text2; } if (num > 1) { text2 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor)); } MakePickupDroplets(val5, val2.position, velocity, inventory, num); inventory.RemoveItemPermanent(val4, num); if ((Object)(object)val.networkUser == (Object)(object)sender) { return string.Format("{0}{1} dropped {2} {3}</color>", "<color=#96EBAA>", value, num, text2); } return string.Format("{0}{1} is dropping {2} {3} from </color>{4}", "<color=#96EBAA>", text, num, text2, value); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCDropItem(ConCommandArgs args) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0078: 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_0089: Expected O, but got Unknown if (((ConCommandArgs)(ref args)).Count == 0) { Debug.LogError((object)"Requires at least 1 argument: dropitem {itemname} ({PlayerID:self}|{Playername})"); return; } if ((Object)(object)args.sender == (Object)null && ((ConCommandArgs)(ref args)).Count < 2) { Debug.LogError((object)"Command must be fully qualified on dedicated servers."); return; } if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP") { Debug.Log((object)"<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapg</color>"); return; } string text = Drop_item(args.sender, args.userArgs.ToArray()); Debug.Log((object)text); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = text }); } internal static void MakePickupDroplets(PickupIndex pickupIndex, Vector3 position, Vector3 velocity, Inventory inventory, int amount = 1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) CreatePickupInfo val = new CreatePickupInfo { position = position, artifactFlag = (PickupArtifactFlag)2 }; ((CreatePickupInfo)(ref val)).pickup = new UniquePickup(pickupIndex); val.prefabOverride = Main.pickupPrefab; val.recycled = !Config.allowRecycle.Value; val.duplicated = Config.dropAsPrinter.Value; CreatePickupInfo val2 = val; CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>(); DropItemTag.OwnerContext ownerContext = new DropItemTag.OwnerContext((component != null) ? component.bodyInstanceObject : null); try { for (int i = 0; i < amount; i++) { val2.rotation = Quaternion.Euler(0f, 180f * (float)i / (float)amount + DoIsNegative(), 0f); PickupDropletController.CreatePickupDroplet(val2, position, velocity * (1f + (float)i / 60f)); } } finally { ((IDisposable)ownerContext/*cast due to .constrained prefix*/).Dispose(); } } private static float DoIsNegative() { isNegative = !isNegative; return isNegative ? 180 : 0; } internal static bool IsBlacklisted(ItemDef itemDef, bool ignoreVoidAndLunarAllow, bool allowTrash, bool isFromAll) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected I4, but got Unknown //IL_002f: 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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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) ItemIndex itemIndex = itemDef.itemIndex; if (itemIndex == Items.CaptainDefenseMatrix.itemIndex) { return true; } if ((int)itemDef.tier == 5 && (!allowTrash || (itemIndex != Items.ExtraLifeConsumed.itemIndex && itemIndex != Items.ExtraLifeVoidConsumed.itemIndex && itemIndex != Items.FragileDamageBonusConsumed.itemIndex && itemIndex != Items.HealingPotionConsumed.itemIndex && itemIndex != Items.RegeneratingScrapConsumed.itemIndex))) { return true; } if (isFromAll && !Config.applyBlacklistToAll.Value) { return false; } ItemTier tier = itemDef.tier; if (!ignoreVoidAndLunarAllow) { switch (tier - 3) { case 3: case 4: case 5: case 6: return !Config.allowVoidDrop.Value; case 0: return !Config.allowLunarDrop.Value; case 10: return !Config.allowHexDrop.Value; } } if (Main.dropBlacklist.Contains(PickupCatalog.FindPickupIndex(itemIndex))) { return true; } return false; } internal static bool IsBlacklisted(EquipmentDef equipDef, bool ignoreLunar, bool isFromAll) { //IL_0030: 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) if (isFromAll && !Config.applyBlacklistToAll.Value) { return false; } if (!ignoreLunar && !Config.allowLunarDrop.Value && equipDef.isLunar) { return true; } if (Main.dropBlacklist.Contains(PickupCatalog.FindPickupIndex(equipDef.equipmentIndex))) { return true; } return false; } } internal class DropAll : MonoBehaviour { private const float period = 0.15f; private Transform targetTransform; private NetworkUser sender; private Inventory inventory; private List<ItemIndex> items; private float timer = 0.15f - Time.fixedDeltaTime; private Vector3 currentDirection; private Quaternion rotation; public void Assign(Inventory inventory, NetworkUser sender, Transform transform) { //IL_005b: 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) //IL_0065: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) this.inventory = inventory; this.sender = sender; targetTransform = transform; items = inventory.itemAcquisitionOrder; int num = items.Count + inventory.GetEquipmentSlotCount(); if (num <= 0) { log.warning("Empty inventory"); Object.Destroy((Object)(object)((Component)this).gameObject); } else { currentDirection = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 15f + Vector3.forward * 8f * (0.8f + (float)num / 80f)); rotation = Quaternion.AngleAxis(360f / (float)num, Vector3.up); } } private void FixedUpdate() { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.GetCurrentBody()) || !Object.op_Implicit((Object)(object)inventory) || !Object.op_Implicit((Object)(object)targetTransform)) { log.warning("Lost sender, aborting drop all"); Object.Destroy((Object)(object)((Component)this).gameObject); return; } timer += Time.fixedDeltaTime; if (!(timer >= 0.15f)) { return; } timer -= 0.15f; for (int num = items.Count - 1; num >= -1; num--) { if (num == -1) { for (uint num2 = 0u; num2 < inventory.equipmentSlotCount; num2++) { for (uint num3 = 0u; num3 < inventory.equipmentSetCount; num3++) { EquipmentLocation val = new EquipmentLocation { slot = num2, set = num3 }; EquipmentIndex equipmentIndex = inventory.GetEquipment(ref val).equipmentIndex; if ((int)equipmentIndex != -1 && !Drop.IsBlacklisted(EquipmentCatalog.GetEquipmentDef(equipmentIndex), ignoreLunar: false, isFromAll: true)) { Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(equipmentIndex), targetTransform.position, currentDirection, inventory); inventory.SetEquipmentIndex((EquipmentIndex)(-1), ref val); currentDirection = rotation * currentDirection; return; } } } log.info("Drop all complete"); Object.Destroy((Object)(object)((Component)this).gameObject); break; } ItemDef itemDef = ItemCatalog.GetItemDef(items[num]); if (!Drop.IsBlacklisted(itemDef, ignoreVoidAndLunarAllow: false, allowTrash: false, isFromAll: true)) { int num4 = inventory.GetItemCountPermanent(items[num]); if (num4 > 15) { num4 = 15; } timer -= (float)num4 * 0.02f; Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(items[num]), targetTransform.position, currentDirection, inventory, num4); inventory.RemoveItemPermanent(items[num], num4); if (inventory.GetItemCountPermanent(itemDef) == 0) { currentDirection = rotation * currentDirection; } break; } } } } internal class DropItemTag : MonoBehaviour { internal readonly struct OwnerContext : IDisposable { internal static GameObject current; private readonly GameObject prev; internal OwnerContext(GameObject owner) { prev = current; current = owner; } public void Dispose() { current = prev; } } internal static readonly List<DropItemTag> active_list = new List<DropItemTag>(); internal GameObject owner; private void OnEnable() { if (OwnerContext.current != null) { SetOwner(OwnerContext.current); } } internal void SetOwner(GameObject new_owner) { if (!Object.op_Implicit((Object)(object)new_owner)) { log.warning("tried to assign a null drop owner"); return; } if (owner != null) { log.error("Overwriting drop's owner " + (Object.op_Implicit((Object)(object)owner) ? ((Object)owner).name : "null") + " with " + (Object.op_Implicit((Object)(object)new_owner) ? ((Object)new_owner).name : "null")); } else { active_list.Add(this); } owner = new_owner; } private void OnDisable() { if (owner != null) { active_list.Remove(this); if (active_list.Count == 0 && active_list.Capacity > 4) { active_list.Capacity = 0; } } } } internal class DropNetworkComponent : NetworkBehaviour { private static int kCmdCmdLockInventory; static DropNetworkComponent() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown Config.lockInventory.SettingChanged += delegate { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null); DropNetworkComponent dropNetworkComponent = default(DropNetworkComponent); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<DropNetworkComponent>(ref dropNetworkComponent) && Util.HasEffectiveAuthority(((NetworkBehaviour)dropNetworkComponent).netIdentity)) { dropNetworkComponent.CallCmdLockInventory(Config.lockInventory.Value); } }; kCmdCmdLockInventory = -1225425357; NetworkBehaviour.RegisterCommandDelegate(typeof(DropNetworkComponent), kCmdCmdLockInventory, new CmdDelegate(InvokeCmdCmdLockInventory)); NetworkCRC.RegisterBehaviour("DropNetworkComponent", 0); } private void Start() { if (Config.lockInventory.Value && Util.HasEffectiveAuthority(((NetworkBehaviour)this).netIdentity)) { CallCmdLockInventory(enable: true); } } [Command] public void CmdLockInventory(bool enable) { Debug.Log((object)Users.Lock_Inventory(((Component)this).GetComponent<NetworkUser>(), enable)); } private void UNetVersion() { } protected static void InvokeCmdCmdLockInventory(NetworkBehaviour obj, NetworkReader reader) { if (!NetworkServer.active) { Debug.LogError((object)"Command CmdLockInventory called on client."); } else { ((DropNetworkComponent)(object)obj).CmdLockInventory(reader.ReadBoolean()); } } public void CallCmdLockInventory(bool enable) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!NetworkClient.active) { Debug.LogError((object)"Command function CmdLockInventory called on server."); return; } if (((NetworkBehaviour)this).isServer) { CmdLockInventory(enable); return; } NetworkWriter val = new NetworkWriter(); val.Write((short)0); val.Write((short)5); val.WritePackedUInt32((uint)kCmdCmdLockInventory); val.Write(((Component)this).GetComponent<NetworkIdentity>().netId); val.Write(enable); ((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdLockInventory"); } public override bool OnSerialize(NetworkWriter writer, bool forceAll) { bool result = default(bool); return result; } public override void OnDeserialize(NetworkReader reader, bool initialState) { } } internal static class Give { public const string green = "<color=#96EBAA>"; public const string player = "<color=#AAE6F0>"; public const string error = "<color=#FF8282>"; public const string bold = "<color=#ff4646>"; public static string Give_Item(NetworkUser sender, string[] args) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Invalid comparison between Unknown and I4 //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Invalid comparison between Unknown and I4 //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Invalid comparison between Unknown and I4 //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Invalid comparison between Unknown and I4 //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Invalid comparison between Unknown and I4 //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) if (!Users.CheckUserPerms(sender, null, out var errorMessage)) { return errorMessage; } Inventory inventory = sender.master.inventory; PlayerCharacterMasterController netUserFromString = StringParsers.GetNetUserFromString(args[1]); if (!Object.op_Implicit((Object)(object)netUserFromString)) { return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>"; } Inventory inventory2 = netUserFromString.master.inventory; if (!Object.op_Implicit((Object)(object)inventory) || !Object.op_Implicit((Object)(object)inventory2)) { return "<color=#ff4646>ERROR: null inventory</color>"; } if ((Object)(object)inventory == (Object)(object)inventory2) { return "<color=#FF8282>Target can not be the sender</color>"; } string value; if (Object.op_Implicit((Object)(object)netUserFromString.networkUser)) { value = netUserFromString.networkUser.userName; } else { if (!Config.dropFromDisconnected.Value) { return "<color=#FF8282>Giving to disconnected players is disabled</color>"; } Users.cachedPlayerNames.TryGetValue(netUserFromString, out value); } value = "<color=#AAE6F0>" + value + "</color>"; string text = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>"; if (Object.op_Implicit((Object)(object)netUserFromString.networkUser) && Users.lockedUserIds.Contains(netUserFromString.networkUser.id)) { return "<color=#FF8282>" + value + " has their inventory locked, failed to give item</color>"; } EquipmentIndex val = (EquipmentIndex)(-1); ItemIndex val2 = (ItemIndex)(-1); if (args[0].ToLower() == "e" || args[0].ToLower() == "equip" || args[0].ToLower() == "equipment") { val = inventory.GetEquipmentIndex(); if ((int)val == -1) { return "<color=#FF8282>Sender does not have an </color><color=#ff7d00>equipment</color>"; } } else { val2 = StringParsers.FindItemInInventroy(args[0], inventory); } PickupIndex val3; string text2; if ((int)val2 == -1) { if ((int)val == -1) { val = inventory.GetEquipmentIndex(); if ((int)val == -1 || !StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val).nameToken)).Contains(StringParsers.ReformatString(args[0]))) { return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + text + "<color=#AAE6F0>'s</color> inventory</color>"; } } if ((int)inventory2.GetEquipmentIndex() != -1) { return "<color=#FF8282>Target already has an equipment</color>"; } val3 = PickupCatalog.FindPickupIndex(val); text2 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val3).baseColor)); if (val != inventory.GetEquipmentIndex()) { return "<color=#FF8282>Sender does not have </color><color=#ff4646>" + text2 + "</color>"; } if (Drop.IsBlacklisted(EquipmentCatalog.GetEquipmentDef(val), !Config.applyAllowToGive.Value, isFromAll: false)) { return text2 + "<color=#FF8282> is not dropable</color>"; } inventory2.SetEquipmentIndex(val, false); inventory.SetEquipmentIndex((EquipmentIndex)(-1), true); return "<color=#96EBAA>" + text + " gave " + text2 + " to </color>" + value; } ItemDef itemDef = ItemCatalog.GetItemDef(val2); val3 = PickupCatalog.FindPickupIndex(val2); text2 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val3).baseColor)); if (Drop.IsBlacklisted(itemDef, !Config.applyAllowToGive.Value, allowTrash: true, isFromAll: false)) { return text2 + "<color=#FF8282> is not dropable</color>"; } int num = inventory.GetItemCountPermanent(val2); if (num == 0) { return "<color=#FF8282>Sender does not have </color>" + text2; } if (num > 1) { text2 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val3).baseColor)); } if (num > 30) { num = 30; } CharacterBody currentBody = sender.GetCurrentBody(); ItemTransferOrb.DispatchItemTransferOrb(new DispatchArgs { origin = (((Object)(object)((currentBody != null) ? currentBody.coreTransform : null) != (Object)null) ? currentBody.coreTransform.position : sender.master.deathFootPosition), inventoryToGrantTo = inventory2, itemIndex = val2, permanentCount = num, isPickup = true, travelDuration = 0.75f, onArrivalBehavior = delegate(ItemTransferOrb orb) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)orb.inventoryToGrantTo) && orb.stack > 0) { orb.inventoryToGrantTo.GiveItemPermanent(orb.itemIndex, orb.stack); CharacterMaster val4 = default(CharacterMaster); if (((Component)orb.inventoryToGrantTo).TryGetComponent<CharacterMaster>(ref val4)) { GenericPickupController.SendPickupMessage(val4, new UniquePickup(PickupCatalog.FindPickupIndex(orb.itemIndex)), orb.stack); } } } }); inventory.RemoveItemPermanent(val2, num); return string.Format("{0}{1} gave {2} {3} to </color>{4}", "<color=#96EBAA>", text, num, text2, value); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCGiveItem(ConCommandArgs args) { //IL_0015: 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) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (((ConCommandArgs)(ref args)).Count < 2) { Debug.LogError((object)"Requires at least 2 arguments: giveitem {Itemname} {Playername}"); return; } if ((Object)(object)args.sender == (Object)null) { Debug.LogError((object)"Command cannot be used by dedicated servers."); return; } string[] args2 = new string[2] { ((ConCommandArgs)(ref args))[0], ((ConCommandArgs)(ref args))[1] }; if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP") { Debug.Log((object)"<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory"); return; } string text = Give_Item(args.sender, args2); Debug.Log((object)text); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = text }); } } [Hook] internal static class Hooks { [Hook] private static void Appy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown NetworkUser.onNetworkUserLost += new NetworkUserGenericDelegate(CacherUsername_NetworkUser_onNetworkUserLost); PlayerCharacterMasterController.onPlayerRemoved += PlayerCMC_onPlayerRemoved; if (Chainloader.PluginInfos.TryGetValue("com.niwith.DropInMultiplayer", out var value)) { HookManager.Hook(((object)value.Instance).GetType(), "Console_RunCmd", new Manipulator(FixNullAndMute_IL_DropInMultiplayer_Console_RunCmd)); } } [Hook(typeof(Chat), "CCSay")] private static void CheckForCommands_On_Chat_CCSay(Action<ConCommandArgs> orig, ConCommandArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00e5: Expected O, but got Unknown orig(args); string text = args.userArgs.FirstOrDefault(); if (!NetworkServer.active || string.IsNullOrWhiteSpace(text) || !text.StartsWith("/")) { return; } string[] source = text.Split(new char[1] { ' ' }); string text2 = source.First(); string key = text2.Substring(1, text2.Length - 1).ToLower(); string[] array = source.Skip(1).ToArray(); if (ChatCommands.chatCommands.TryGetValue(key, out var value)) { string text3 = ((array.Length >= value.minArgs && (array.Length == 0 || (!(array[0] == "") && !array[0].Equals("help", StringComparison.InvariantCultureIgnoreCase)))) ? value.method(args.sender, array) : value.helpText); if (text3 == null) { text3 = "<color=#ff4646>ERROR: null output</color>"; } Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = text3 }); } } [Hook(typeof(NetworkManagerSystem), "Init")] private static void AddComponent_On_NetworkManagerSystem_Init(Action<NetworkManagerSystem, NetworkManagerConfiguration> orig, NetworkManagerSystem self, NetworkManagerConfiguration config) { config.PlayerPrefab.AddComponent<DropNetworkComponent>(); orig(self, config); } [Hook(typeof(ItemIcon), "ItemClicked")] private static void BlockDropKey_On_ItemIcon_ItemClicked(Action<ItemIcon> orig, ItemIcon self) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) KeyCode val = Config.dropButton.Value.ToKey(); if (!Input.GetKey(val) && !Input.GetKeyUp(val) && !Config.dropSingleButton.Value.IsKeyDown(onlyJustPressed: false) && Main.singlePressed == 0) { orig(self); } } [Hook(typeof(MPInputModule), "GetMousePointerEventData")] private static MouseState CheckResetKey_On_MPInputModule_GetMousePointerEventData(Func<MPInputModule, int, int, MouseState> orig, MPInputModule self, int playerid, int mouseIndex) { //IL_0015: 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_003b: 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) MouseState val = orig(self, playerid, mouseIndex); if (val != null && Config.dropSingleButton.Value.IsKeyDown(onlyJustPressed: true)) { RaycastResult pointerCurrentRaycast = ((PointerEventData)val.GetButtonState(0).eventData.buttonData).pointerCurrentRaycast; ExecuteEvents.GetEventChain(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (IList<Transform>)ExecuteEvents.s_InternalTransformList); foreach (Transform s_InternalTransform in ExecuteEvents.s_InternalTransformList) { DragItem component = ((Component)s_InternalTransform).gameObject.GetComponent<DragItem>(); if (Object.op_Implicit((Object)(object)component) && component.GetPlayerAndItem(out var player, out var args)) { Users.AddPlayerStringArg(player, args); args.Add("1"); Console.instance.RunCmd(new CmdSender(LocalUserManager.GetFirstLocalUser().currentNetworkUser), "dropitem", args); } } } return val; } private static void CacherUsername_NetworkUser_onNetworkUserLost(NetworkUser self) { if (Object.op_Implicit((Object)(object)self.masterController) && !string.IsNullOrWhiteSpace(self.userName)) { Users.cachedPlayerNames[self.masterController] = self.userName; } } private static void PlayerCMC_onPlayerRemoved(PlayerCharacterMasterController self) { Users.cachedPlayerNames.Remove(self); } private static void FixNullAndMute_IL_DropInMultiplayer_Console_RunCmd(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdstr(a, "Unable to find command, try /help") })) { val.Emit(OpCodes.Ret); } else { log.warning("Failed DropInMultiplayer chat compatibility"); } } [Hook(typeof(Interactor), "PerformInteraction")] private static void PreventInteractables_On_Interactor_PerformInteraction(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); VariableDefinition val2 = ((IEnumerable<VariableDefinition>)il.Body.Variables).First((VariableDefinition a) => ((MemberReference)((VariableReference)a).VariableType).Name == "IInteractable"); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallvirt<IInteractable>(a, "GetInteractability") })) { val.LogErrorCaller("printer prevention"); return; } val.Emit(OpCodes.Ldloc, val2); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<Interactability, IInteractable, Interactor, Interactability>>((Func<Interactability, IInteractable, Interactor, Interactability>)CheckIfShouldPrevent); } private static Interactability CheckIfShouldPrevent(Interactability interactability, IInteractable interactable, Interactor interactor) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_003d: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Invalid comparison between Unknown and I4 //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Invalid comparison between Unknown and I4 int count; float closest; if (Config.disable_printers_when_drop_exists.Value != Config.PrinterDisableFlags.Off && (int)interactability == 2 && NetworkServer.active && DropItemTag.active_list.Count != 0) { Component val = (Component)(object)((interactable is Component) ? interactable : null); if (val != null) { Vector3 position = val.transform.position; float num = Config.disable_printers_distance.Value * Config.disable_printers_distance.Value; count = 0; closest = float.PositiveInfinity; for (int i = 0; i < DropItemTag.active_list.Count; i++) { if (!((Object)(object)DropItemTag.active_list[i].owner == (Object)(object)((Component)interactor).gameObject)) { continue; } Vector3 val2 = position - ((Component)DropItemTag.active_list[i]).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { count++; if (sqrMagnitude < closest) { closest = sqrMagnitude; } } } if (count == 0) { return (Interactability)2; } if ((Config.disable_printers_when_drop_exists.Value & Config.PrinterDisableFlags.Printers) != Config.PrinterDisableFlags.Off) { PurchaseInteraction val3 = (PurchaseInteraction)(object)((interactable is PurchaseInteraction) ? interactable : null); if (val3 != null) { CostTypeIndex costType = val3.costType; if ((costType - 4 <= 2 || costType - 9 <= 1) ? true : false) { BroadcastError("Printing"); return (Interactability)1; } goto IL_018a; } } if ((Config.disable_printers_when_drop_exists.Value & Config.PrinterDisableFlags.Scrappers) != Config.PrinterDisableFlags.Off) { PickupPickerController val4 = (PickupPickerController)(object)((interactable is PickupPickerController) ? interactable : null); if (val4 != null && Object.op_Implicit((Object)(object)((Component)val4).GetComponent<ScrapperController>())) { BroadcastError("Scrapping"); return (Interactability)1; } } goto IL_018a; } } return interactability; IL_018a: return (Interactability)2; void BroadcastError(string action) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown SimpleChatMessage val5 = new SimpleChatMessage(); val5.baseToken = "<color=#FF8282>" + action + " for <color=#AAE6F0>" + ((Component)interactor).GetComponent<CharacterBody>().GetUserName() + "</color> is disabled as they have " + string.Format("{0} dropped pickup{1} active, closest being {2:0}m away.</color>", count.ToString(), (count > 1) ? "s" : "", MathF.Sqrt(closest)); Chat.SendBroadcastChat((ChatMessageBase)(object)val5); } } [Hook(typeof(PickupDropletController), "CreatePickup")] private static void TransferOwner_On_PickupDropletController_CreatePickup(Action<PickupDropletController> orig, PickupDropletController self) { DropItemTag dropItemTag = default(DropItemTag); if ((Object)(object)self.createPickupInfo.prefabOverride != (Object)(object)Main.pickupPrefab || !((Component)self).TryGetComponent<DropItemTag>(ref dropItemTag) || !Object.op_Implicit((Object)(object)dropItemTag.owner)) { orig(self); return; } using (new DropItemTag.OwnerContext(dropItemTag.owner)) { orig(self); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.dropitem", "Dropitem", "2.2.6")] public class Main : BaseUnityPlugin { internal const string DropInMultiplayerGuid = "com.niwith.DropInMultiplayer"; internal static GameObject pickupPrefab; internal static int singlePressed; internal static readonly List<PickupIndex> dropBlacklist = new List<PickupIndex>(); private void Awake() { Config.DoConfig(((BaseUnityPlugin)this).Config); HookAttribute.ScanAndApply(typeof(Hooks)); Config.dropBlacklist.SettingChanged += DropBlacklist_SettingChanged; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyConfig)); Utilities.DoAddressable("RoR2/Base/UI/ScoreboardStrip.prefab", delegate(GameObject scoreboard) { scoreboard.AddComponent<ScoreboardDrop>(); ((Component)scoreboard.GetComponentInChildren<EquipmentIcon>()).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment; }); Utilities.DoAddressable("RoR2/Base/UI/HUDSimple.prefab", delegate(GameObject hudSimple) { Transform val = hudSimple.transform.Find("MainContainer/MainUIArea/SpringCanvas/TopCenterCluster/ItemInventoryDisplayRoot/ItemInventoryDisplay"); if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.AddComponent<ScoreboardDrop>(); } else { log.error("failed to find ItemInventoryDisplay"); } EquipmentIcon[] componentsInChildren = hudSimple.GetComponentsInChildren<EquipmentIcon>(); foreach (EquipmentIcon val2 in componentsInChildren) { if (((Object)val2).name == "EquipmentSlot") { ((Component)val2).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment; } } }); Utilities.AddressableAddComp<DragItem>("RoR2/Base/UI/ItemIcon.prefab", (Action<DragItem>)delegate(DragItem a) { a.type = DragItem.ItemType.Item; }); Utilities.AddressableAddComp<DragItem>("RoR2/Base/UI/ItemIconScoreboard_InGame.prefab", (Action<DragItem>)delegate(DragItem a) { a.type = DragItem.ItemType.Item; }); Utilities.DoAddressable("RoR2/Base/Common/GenericPickup.prefab", delegate(GameObject a) { pickupPrefab = Utilities.CreatePrefab(a, "DropItemPickup"); pickupPrefab.AddComponent<DropItemTag>(); }); Utilities.AddressableAddComp<DropItemTag>("RoR2/Base/Common/PickupDroplet.prefab", (Action<DropItemTag>)null); } private static void SetBlacklisted() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) string[] array = Config.dropBlacklist.Value.Split(new string[2] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { array[i] = StringParsers.ReformatString(array[i]); } dropBlacklist.Clear(); bool flag = false; for (int j = 0; j < array.Length; j++) { if (string.IsNullOrEmpty(array[j])) { continue; } ScriptableObject def; PickupIndex item = StringParsers.FindPickup(array[j], out def); if (!((PickupIndex)(ref item)).isValid) { log.error("Failed to find a match \"" + array[j] + "\""); continue; } dropBlacklist.Add(item); if (!string.IsNullOrEmpty((def != null) ? ((Object)def).name : null)) { log.info("Renaming \"" + array[j] + "\" to its internal name \"" + ((Object)def).name + "\""); array[j] = ((Object)def).name; flag = true; } } if (flag) { Config.dropBlacklist.SettingChanged -= DropBlacklist_SettingChanged; Config.dropBlacklist.Value = string.Join(", ", array); Config.dropBlacklist.SettingChanged += DropBlacklist_SettingChanged; } } private static void DropBlacklist_SettingChanged(object sender, EventArgs e) { SetBlacklisted(); } private static void ApplyConfig() { try { SetBlacklisted(); } catch (Exception data) { log.error(data); } } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Config.dropSingleButton.Value.IsKeyDown(onlyJustPressed: false)) { singlePressed = 2; } else if (singlePressed > 0) { singlePressed--; } } } internal class ScoreboardDrop : MonoBehaviour, IDropHandler, IEventSystemHandler { public void OnDrop(PointerEventData eventData) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown if (DragItem.InvalidButton(eventData)) { return; } object obj; if (eventData == null) { obj = null; } else { GameObject pointerDrag = eventData.pointerDrag; obj = ((pointerDrag != null) ? pointerDrag.GetComponent<DragItem>() : null); } DragItem dragItem = (DragItem)obj; if (!Object.op_Implicit((Object)(object)dragItem)) { log.warning("Dragged object does not have DragItem component"); } else { if (!dragItem.GetPlayerAndItem(out var player, out var args)) { return; } Playe