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 DropInMultiplayer;
using HG;
using HG.GeneralSerializer;
using HG.Reflection;
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.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: OptIn]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
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)string.Format($"ILCursor failure, skipping: {data}\n{c}"));
}
internal static void LogErrorCaller(this ILCursor c, object data)
{
logger.LogError((object)string.Format($"ILCursor failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}"));
}
}
internal static class HookManager
{
internal delegate bool ConfigEnabled<T>(T configValue);
internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly ConfigEnabled<bool> boolConfigEnabled = (bool configValue) => configValue;
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
{
HookInternal(GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
{
HookInternal(methodFrom, ilHook);
}
internal static void Hook(Delegate from, Manipulator ilHook)
{
HookInternal(from.Method, ilHook);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
{
HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
{
HookInternal(methodFrom, onHook, null);
}
internal static void Hook(MethodBase methodFrom, Delegate onHook)
{
HookInternal(methodFrom, onHook.Method, onHook.Target);
}
internal static void Hook(Delegate from, Delegate onHook)
{
HookInternal(from.Method, onHook.Method, onHook.Target);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
{
HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
{
HookInternal(methodFrom, onHook, target);
}
private static void HookInternal(MethodBase methodFrom, Manipulator ilHook)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (methodFrom == null)
{
log.error("null methodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
return;
}
try
{
new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}::{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (methodFrom == null)
{
log.error("null methodFrom for hook: " + onHook.Name);
return;
}
try
{
new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
}
catch (Exception ex)
{
log.error($"Failed to apply Hook: {methodFrom.DeclaringType}::{methodFrom.Name} - {onHook.Name}\n{ex}");
}
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, (Delegate)(object)ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
{
configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, onHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.HookConfigInternal(enabled, methodFrom, (Delegate)(object)ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), onHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook)
{
configEntry.HookConfigInternal(enabled, methodFrom, onHook);
}
private static void HookConfigInternal<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate hook)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
try
{
IDetour detour = ManualDetour(methodFrom, hook);
EventHandler eventHandler = delegate(object sender, EventArgs _)
{
UpdateHook(detour, enabled((sender as ConfigEntry<T>).Value));
};
configEntry.SettingChanged += eventHandler;
eventHandler(configEntry, (EventArgs)new SettingChangedEventArgs((ConfigEntryBase)(object)configEntry));
}
catch (Exception ex)
{
log.error($"Failed to do config hook {methodFrom.DeclaringType}::{methodFrom.Name} - {hook.Method.Name}\n{ex}");
}
}
private static void UpdateHook(IDetour hook, bool enabled)
{
if (enabled)
{
if (!hook.IsApplied)
{
hook.Apply();
}
}
else if (hook.IsApplied)
{
hook.Undo();
}
}
internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate hook)
{
return ManualDetour(GetMethod(typeFrom, methodFrom), hook);
}
internal static IDetour ManualDetour(MethodBase methodFrom, Delegate hook)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null methodFrom for detour: " + hook.Method.Name);
}
else
{
try
{
Manipulator val = (Manipulator)(object)((hook is Manipulator) ? hook : null);
if (val != null)
{
return (IDetour)new ILHook(methodFrom, val, ref ilHookConfig);
}
return (IDetour)new Hook(methodFrom, hook, ref onHookConfig);
}
catch (Exception ex)
{
log.error($"Failed to create detour {methodFrom.DeclaringType}::{methodFrom} - {hook.Method.Name}\n{ex}");
}
}
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 predicate in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where predicate.Name == methodName
select predicate).ToArray();
switch (array.Length)
{
case 1:
return array[0];
case 0:
log.error($"Failed to find method: {typeFrom}::{methodName}");
return null;
default:
{
log.error($"{array.Length} ambiguous matches found for: {typeFrom}::{methodName}");
MethodInfo[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
log.error(array2[i]);
}
return null;
}
}
}
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 = null, string[] after = null)
{
ilHookConfig.Before = before;
onHookConfig.Before = before;
ilHookConfig.After = after;
onHookConfig.After = after;
}
}
internal static class Utilities
{
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 Task<Obj> GetAddressableAsync<Obj>(string addressable) where Obj : Object
{
//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)
return Addressables.LoadAssetAsync<Obj>((object)addressable).Task;
}
internal static Task<GameObject> GetAddressableAsync(string addressable)
{
//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)
return Addressables.LoadAssetAsync<GameObject>((object)addressable).Task;
}
internal static void DoAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object
{
//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<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<Obj> a)
{
callback(a.Result);
};
}
internal static void DoAddressable(string addressable, Action<GameObject> callback)
{
//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)
{
callback(a.Result);
};
}
internal static void AddressableAddComp<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)
{
a.Result.AddComponent<Comp>();
};
}
internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : 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)
{
callback(a.Result.AddComponent<Comp>());
};
}
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)
{
if (!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 ConfigEntry<KeyboardShortcut> key, bool onlyPressed)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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)
KeyboardShortcut value;
if (onlyPressed)
{
value = key.Value;
if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
{
goto IL_0030;
}
}
if (!onlyPressed)
{
value = key.Value;
if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
goto IL_0030;
}
}
value = key.Value;
foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
{
if (!Input.GetKey(modifier))
{
return false;
}
}
return true;
IL_0030:
return false;
}
}
internal static class RiskofOptions
{
internal const string rooGuid = "com.rune580.riskofoptions";
internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
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<T>(ConfigEntry<T> entry)
{
AddOption<T>(entry, "", "", restartRequired: false);
}
internal static void AddOption<T>(ConfigEntry<T> entry, string categoryName = "", string name = "", bool restartRequired = false)
{
//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_0156: Expected O, but got Unknown
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_0126: 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_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Expected O, but got Unknown
//IL_0119: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_00f5: 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_00e5: Expected O, but got Unknown
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
object obj;
if (!(typeof(T) == typeof(float)))
{
obj = ((!(typeof(T) == typeof(string))) ? ((!(typeof(T) == typeof(bool))) ? ((!(typeof(T) == typeof(int))) ? ((!(typeof(T) == typeof(Color))) ? ((!(typeof(T) == typeof(KeyboardShortcut))) ? ((object)((!typeof(T).IsEnum) ? ((ChoiceOption)null) : new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig()))) : ((object)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, new KeyBindConfig()))) : ((object)new ColorOption(entry as ConfigEntry<Color>, new ColorOptionConfig()))) : ((object)new IntFieldOption(entry as ConfigEntry<int>, new IntFieldConfig()))) : ((object)new CheckBoxOption(entry as ConfigEntry<bool>, new CheckBoxConfig()))) : ((object)new StringInputFieldOption(entry as ConfigEntry<string>, new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0
})));
}
else
{
ConfigEntry<float> obj2 = entry as ConfigEntry<float>;
FloatFieldConfig val = new FloatFieldConfig();
((NumericFieldConfig<float>)val).FormatString = "{0:f2}";
((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault("{0:f2}");
obj = (object)new FloatFieldOption(obj2, val);
}
BaseOption val2 = (BaseOption)obj;
if (val2 != null)
{
BaseOptionConfig config = val2.GetConfig();
config.category = categoryName;
config.name = name;
config.restartRequired = restartRequired;
if (config.description == "")
{
config.description = ((ConfigEntryBase)(object)entry).DescWithDefault();
}
ModSettingsManager.AddOption(val2);
}
}
internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
{
AddFloatSlider(entry, min, max, format);
}
internal static void AddFloatSlider(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)
}));
}
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_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
{
return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
}
private static string DescWithDefault(this ConfigEntryBase entry, string format)
{
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
{
private static ConfigFile configFile;
internal static ConfigEntry<bool> lockInventory;
internal static ConfigEntry<bool> allowVoidDrop;
internal static ConfigEntry<InputButton> dropButton;
internal static ConfigEntry<KeyboardShortcut> dropSingleButton;
internal static ConfigEntry<string> dropBlacklist;
internal static ConfigEntry<bool> applyBlacklistToAll;
internal static ConfigEntry<bool> allowRecycle;
internal static ConfigEntry<bool> hostOnly;
internal static ConfigEntry<bool> dropFromDisconnected;
internal static void DoConfig(ConfigFile bepConfigFile)
{
//IL_0085: 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");
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 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 the item_list command to view them.");
applyBlacklistToAll = configFile.Bind<bool>("", "Apply blacklist to dropall", false, "If '/drop all' should respect 'Drop blacklist' and 'Allow Void Drops'");
allowRecycle = configFile.Bind<bool>("", "Allow recycle", false, "Allow recycling of dropped items");
hostOnly = configFile.Bind<bool>("", "Host only", false, "If only host should be able to use the mod");
dropFromDisconnected = configFile.Bind<bool>("", "Drop from disconnected", true, "Allow dropping from disconnected players");
if (RiskofOptions.enabled)
{
DoRiskofOptions();
}
}
private static void DoRiskofOptions()
{
RiskofOptions.SetSpriteDefaultIcon();
RiskofOptions.AddOption<bool>(allowVoidDrop);
RiskofOptions.AddOption<bool>(lockInventory);
RiskofOptions.AddOption<bool>(applyBlacklistToAll);
RiskofOptions.AddOption<bool>(allowRecycle);
RiskofOptions.AddOption<bool>(hostOnly);
RiskofOptions.AddOption<bool>(dropFromDisconnected);
RiskofOptions.AddOption<InputButton>(dropButton);
RiskofOptions.AddOption<KeyboardShortcut>(dropSingleButton);
RiskofOptions.AddOption<string>(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 static GameObject draggedIcon;
private static 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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<RawImage>().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;
Transform transform = ((Component)val.canvas).transform;
m_DraggingPlane = (RectTransform)(object)((transform is RectTransform) ? transform : null);
}
}
public void OnDrag(PointerEventData data)
{
//IL_001e: 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)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)draggedIcon))
{
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);
}
}
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_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: 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_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Invalid comparison between Unknown and I4
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Invalid comparison between Unknown and I4
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Invalid comparison between Unknown and I4
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: 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_02c7: 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_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Invalid comparison between Unknown and I4
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: 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_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
if (!Users.CheckUserPerms(sender, out var errorMessage))
{
return errorMessage;
}
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>";
}
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>";
}
MakePickupDroplets(val5, val2.position, velocity);
inventory.SetEquipmentIndex((EquipmentIndex)(-1));
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, permitVoid: false, allowTrash: true, isFromAll: false))
{
return text2 + "<color=#FF8282> is not dropable</color>";
}
int num = Math.Min(inventory.GetItemCount(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, num);
inventory.RemoveItem(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 CCDIDropItem(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_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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;
}
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = Drop_item(args.sender, args.userArgs.ToArray())
});
}
internal static void MakePickupDroplets(PickupIndex pickupIndex, Vector3 position, Vector3 velocity, 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
CreatePickupInfo val = default(CreatePickupInfo);
val.position = position;
val.artifactFlag = (PickupArtifactFlag)2;
((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
val.prefabOverride = Main.pickupPrefab;
CreatePickupInfo val2 = val;
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));
}
}
private static float DoIsNegative()
{
isNegative = !isNegative;
return isNegative ? 180 : 0;
}
internal static bool IsBlacklisted(ItemDef itemDef, bool permitVoid, 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_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
//IL_0079: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Invalid comparison between Unknown and I4
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_0098: Invalid comparison between Unknown and I4
//IL_005a: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Invalid comparison between Unknown and I4
ItemIndex itemIndex = itemDef.itemIndex;
if (itemIndex != Items.CaptainDefenseMatrix.itemIndex && ((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))))
{
if (isFromAll && !Config.applyBlacklistToAll.Value)
{
return false;
}
ItemTier tier = itemDef.tier;
if ((permitVoid || Config.allowVoidDrop.Value || ((int)tier != 6 && (int)tier != 7 && (int)tier != 8 && (int)tier != 9)) && !Main.dropBlacklist.Contains(itemIndex))
{
return false;
}
}
return true;
}
}
internal class DropAll : MonoBehaviour
{
private const float period = 0.2f;
private Transform targetTransform;
private NetworkUser sender;
private Inventory inventory;
private List<ItemIndex> items;
private float timer = 0.2f - 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: 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_01a3: 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_00a5: 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_00aa: Invalid comparison between Unknown and I4
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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_00e9: 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))
{
log.warning("Lost sender, aborting drop all");
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
timer += Time.fixedDeltaTime;
if (!(timer >= 0.2f))
{
return;
}
timer -= 0.2f;
for (int num = items.Count - 1; num >= -1; num--)
{
if (num == -1)
{
for (uint num2 = 0u; num2 < inventory.GetEquipmentSlotCount(); num2++)
{
EquipmentIndex equipmentIndex = inventory.GetEquipment(num2).equipmentIndex;
if ((int)equipmentIndex != -1)
{
Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(equipmentIndex), targetTransform.position, currentDirection);
inventory.SetEquipmentIndexForSlot((EquipmentIndex)(-1), num2);
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, permitVoid: false, allowTrash: false, isFromAll: true))
{
int num3 = inventory.GetItemCount(items[num]);
if (num3 > 15)
{
num3 = 15;
}
timer -= (float)num3 * 0.02f;
Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(items[num]), targetTransform.position, currentDirection, num3);
inventory.RemoveItem(items[num], num3);
if (inventory.GetItemCount(itemDef) == 0)
{
currentDirection = rotation * currentDirection;
}
break;
}
}
}
}
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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Invalid comparison between Unknown and I4
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Invalid comparison between Unknown and I4
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: 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_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Invalid comparison between Unknown and I4
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Invalid comparison between Unknown and I4
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Invalid comparison between Unknown and I4
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: 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_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
if (!Users.CheckUserPerms(sender, 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>";
}
inventory2.SetEquipmentIndex(val);
inventory.SetEquipmentIndex((EquipmentIndex)(-1));
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, permitVoid: true, allowTrash: true, isFromAll: false))
{
return text2 + "<color=#FF8282> is not dropable</color>";
}
int num = inventory.GetItemCount(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;
}
inventory2.GiveItem(val2, num);
inventory.RemoveItem(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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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;
}
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = Give_Item(args.sender, args2)
});
}
}
internal static class Hooks
{
private delegate GenericPickupController FuncCreatePickup<T1>(in T1 a1);
internal static void DoSetup()
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
HookManager.Hook(typeof(Chat), "CCSay", (Delegate)new Action<Action<ConCommandArgs>, ConCommandArgs>(CheckForCommands_On_Chat_CCSay));
HookManager.Hook(typeof(GenericPickupController), "CreatePickup", (Delegate)new <>F{00000008}<FuncCreatePickup<CreatePickupInfo>, CreatePickupInfo, GenericPickupController>(DetectDropped_On_GenericPickupController_CreatePickup));
HookManager.Hook(typeof(NetworkManagerSystem), "Init", (Delegate)new Action<Action<NetworkManagerSystem, NetworkManagerConfiguration>, NetworkManagerSystem, NetworkManagerConfiguration>(AddComponent_On_NetworkManagerSystem_Init));
HookManager.Hook(typeof(ItemIcon), "ItemClicked", (Delegate)new Action<Action<ItemIcon>, ItemIcon>(BlockDropKey_On_ItemIcon_ItemClicked));
HookManager.Hook(typeof(MPInputModule), "GetMousePointerEventData", (Delegate)new Func<Func<MPInputModule, int, int, MouseState>, MPInputModule, int, int, MouseState>(CheckResetKey_On_MPInputModule_GetMousePointerEventData));
NetworkUser.onNetworkUserLost += new NetworkUserGenericDelegate(CacherUsername_NetworkUser_onNetworkUserLost);
PlayerCharacterMasterController.onPlayerRemoved += PlayerCMC_onPlayerRemoved;
if (Chainloader.PluginInfos.ContainsKey("com.niwith.DropInMultiplayer"))
{
try
{
DoDropInMultiplayerHook();
}
catch (Exception ex)
{
log.error("Failed DropInMultiplayer chat compatibility\n" + ex);
}
}
}
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_00bd: 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_00e8: 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 key = source.FirstOrDefault().Substring(1).ToLower();
string[] array = source.Skip(1).ToArray();
if (ChatCommands.chatCommands.TryGetValue(key, out var value))
{
string text2 = ((array.Length >= value.minArgs && (array.Length == 0 || (!(array[0] == "") && !array[0].Equals("h", StringComparison.InvariantCultureIgnoreCase) && !array[0].Equals("help", StringComparison.InvariantCultureIgnoreCase)))) ? value.method(args.sender, array) : value.helpText);
if (text2 == null)
{
text2 = "<color=#ff4646>ERROR: null output</color>";
}
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = text2
});
}
}
private static GenericPickupController DetectDropped_On_GenericPickupController_CreatePickup(FuncCreatePickup<CreatePickupInfo> orig, ref CreatePickupInfo createPickupInfo)
{
if ((Object)(object)createPickupInfo.prefabOverride == (Object)(object)Main.pickupPrefab)
{
createPickupInfo.prefabOverride = GenericPickupController.pickupPrefab;
GenericPickupController val = orig(in createPickupInfo);
if (!Config.allowRecycle.Value)
{
val.NetworkRecycled = true;
}
return val;
}
return orig(in createPickupInfo);
}
private static void AddComponent_On_NetworkManagerSystem_Init(Action<NetworkManagerSystem, NetworkManagerConfiguration> orig, NetworkManagerSystem self, NetworkManagerConfiguration config)
{
config.PlayerPrefab.AddComponent<DropNetworkComponent>();
orig(self, config);
}
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)
KeyCode val = Config.dropButton.Value.ToKey();
if (!Input.GetKey(val) && !Input.GetKeyUp(val) && !Config.dropSingleButton.IsKeyDown(onlyPressed: false) && Main.singlePressed == 0)
{
orig(self);
}
}
private static MouseState CheckResetKey_On_MPInputModule_GetMousePointerEventData(Func<MPInputModule, int, int, MouseState> orig, MPInputModule self, int playerid, int mouseIndex)
{
//IL_0031: 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_009f: Unknown result type (might be due to invalid IL or missing references)
MouseState val = orig(self, playerid, mouseIndex);
if (val != null && Config.dropSingleButton.IsKeyDown(onlyPressed: 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 DoDropInMultiplayerHook()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
HookManager.Hook(typeof(DropInMultiplayer), "Console_RunCmd", new Manipulator(RunCmd_IL_DropInMultiplayer_Console_FixNullAndMute));
}
private static void RunCmd_IL_DropInMultiplayer_Console_FixNullAndMute(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction a) => ILPatternMatchingExt.MatchLdstr(a, "Unable to find command, try /help"),
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(DropInMultiplayer), "SendChatMessage")
}))
{
val.Emit(OpCodes.Ret);
}
else
{
log.warning("Failed DropInMultiplayer chat compatibility");
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.dropitem", "Dropitem", "2.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
internal const string dropinguid = "com.niwith.DropInMultiplayer";
internal static GameObject pickupPrefab;
internal static int singlePressed;
internal static readonly HashSet<ItemIndex> dropBlacklist = new HashSet<ItemIndex>();
private void Awake()
{
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_010f: Expected O, but got Unknown
log.start(((BaseUnityPlugin)this).Logger);
Config.DoConfig(((BaseUnityPlugin)this).Config);
Hooks.DoSetup();
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 val2 = hudSimple.transform.Find("MainContainer/MainUIArea/SpringCanvas/TopCenterCluster/ItemInventoryDisplayRoot/ItemInventoryDisplay");
if (Object.op_Implicit((Object)(object)val2))
{
((Component)val2).gameObject.AddComponent<ScoreboardDrop>();
}
else
{
log.error("failed to find ItemInventoryDisplay");
}
EquipmentIcon[] componentsInChildren = hudSimple.GetComponentsInChildren<EquipmentIcon>();
foreach (EquipmentIcon val3 in componentsInChildren)
{
if (((Object)val3).name == "EquipmentSlot")
{
((Component)val3).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;
});
GameObject val = new GameObject();
pickupPrefab = Utilities.CreatePrefab(val, "DropItemPickup");
Object.Destroy((Object)val);
}
private static void SetBlacklisted()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
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;
}
if (ItemCatalog.itemNameToIndex.TryGetValue(array[j], out var value))
{
dropBlacklist.Add(value);
continue;
}
Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ItemDef current = enumerator.Current;
if (current.nameToken == null || !StringParsers.ContainsString(StringParsers.ReformatString(Language.GetString(current.nameToken, "en")), array[j]))
{
continue;
}
dropBlacklist.Add(current.itemIndex);
array[j] = ((Object)current).name;
flag = true;
goto IL_0117;
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
log.error("failed to find item '" + array[j] + "'");
IL_0117:;
}
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()
{
if (Config.dropSingleButton.IsKeyDown(onlyPressed: 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;
}
PlayerCharacterMasterController val = ((Component)this).GetComponent<ScoreboardStrip>()?.userPlayerCharacterMasterController;
if (!Object.op_Implicit((Object)(object)val))
{
ItemInventoryDisplay component = ((Component)this).GetComponent<ItemInventoryDisplay>();
object obj2;
if (component == null)
{
obj2 = null;
}
else
{
Inventory inventory = component.inventory;
obj2 = ((inventory != null) ? ((Component)inventory).GetComponent<PlayerCharacterMasterController>() : null);
}
val = (PlayerCharacterMasterController)obj2;
}
if (!Object.op_Implicit((Object)(object)val))
{
log.warning("null target player");
return;
}
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
NetworkUser val2 = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
string text;
if ((Object)(object)player != (Object)(object)val)
{
if ((Object)(object)player.networkUser != (Object)(object)val2)
{
Chat.AddMessage((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#FF8282>Can only give items from your inventory</color>"
});
return;
}
text = "giveitem";
Users.AddPlayerStringArg(val, args);
}
else
{
text = "dropitem";
if ((Object)(object)player.networkUser != (Object)(object)val2)
{
Users.AddPlayerStringArg(player, args);
}
}
Console.instance.RunCmd(new CmdSender(val2), text, args);
}
}
}
internal static class StringParsers
{
internal static ItemIndex FindItemInInventroy(string input, Inventory inventory)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
List<ItemIndex> itemAcquisitionOrder = inventory.itemAcquisitionOrder;
if (itemAcquisitionOrder.Count == 0)
{
return (ItemIndex)(-1);
}
input = ReformatString(input);
if (int.TryParse(input, out var result))
{
if (result > itemAcquisitionOrder.Count || result < 0)
{
return (ItemIndex)(-1);
}
if (result == 0)
{
return itemAcquisitionOrder[itemAcquisitionOrder.Count - 1];
}
return itemAcquisitionOrder[itemAcquisitionOrder.Count - result];
}
for (int num = itemAcquisitionOrder.Count - 1; num >= 0; num--)
{
ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num]);
if (ContainsString(ReformatString(Language.GetString(itemDef.nameToken)), input))
{
return itemDef.itemIndex;
}
}
if (Language.currentLanguageName != "en")
{
for (int num2 = itemAcquisitionOrder.Count - 1; num2 >= 0; num2--)
{
ItemDef itemDef2 = ItemCatalog.GetItemDef(itemAcquisitionOrder[num2]);
if (ContainsString(ReformatString(Language.GetString(itemDef2.nameToken, "en")), input))
{
return itemDef2.itemIndex;
}
}
}
return (ItemIndex)(-1);
}
public static EquipmentIndex GetEquipFromPartial(string name)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
name = ReformatString(name);
EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
foreach (EquipmentDef val in equipmentDefs)
{
if (ContainsString(ReformatString(Language.GetString(val.nameToken)), name))
{
return val.equipmentIndex;
}
}
return (EquipmentIndex)(-1);
}
internal static PlayerCharacterMasterController GetNetUserFromString(string name)
{
if (int.TryParse(name, out var result) && result < NetworkUser.readOnlyInstancesList.Count && result >= 0)
{
return NetworkUser.readOnlyInstancesList[result].masterController;
}
name = ReformatString(name);
foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
{
if (ReformatString(readOnlyInstances.userName).StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
{
return readOnlyInstances.masterController;
}
}
foreach (NetworkUser readOnlyInstances2 in NetworkUser.readOnlyInstancesList)
{
if (ContainsString(ReformatString(readOnlyInstances2.userName), name))
{
return readOnlyInstances2.masterController;
}
}
foreach (KeyValuePair<PlayerCharacterMasterController, string> cachedPlayerName in Users.cachedPlayerNames)
{
if (ContainsString(ReformatString(cachedPlayerName.Value), name))
{
return cachedPlayerName.Key;
}
}
return null;
}
internal static string ReformatString(string input)
{
return Regex.Replace(input, "[\n '_.,-]", string.Empty);
}
internal static bool ContainsString(string source, string value)
{
return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0;
}
}
internal static class Users
{
internal static readonly HashSet<NetworkUserId> lockedUserIds = new HashSet<NetworkUserId>();
internal static readonly HashSet<NetworkUserId> blockedUserIds = new HashSet<NetworkUserId>();
internal static readonly Dictionary<PlayerCharacterMasterController, string> cachedPlayerNames = new Dictionary<PlayerCharacterMasterController, string>();
internal static void AddPlayerStringArg(PlayerCharacterMasterController player, List<string> args)
{
int num = NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser);
string value;
if (num >= 0)
{
args.Add(num.ToString());
}
else if (cachedPlayerNames.TryGetValue(player, out value))
{
args.Add(value);
}
}
internal static bool CheckUserPerms(NetworkUser sender, out string errorMessage)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)sender))
{
errorMessage = "<color=#ff4646>ERROR: null sender</color>";
}
else
{
if (!blockedUserIds.Contains(sender.id))
{
if (Config.hostOnly.Value)
{
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
if ((Object)(object)((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null) != (Object)(object)sender)
{
errorMessage = "<color=#FF8282>Host has prohibited clients from dropping</color>";
goto IL_005f;
}
}
errorMessage = null;
return true;
}
errorMessage = "<color=#FF8282>You are blocked from dropping items</color>";
}
goto IL_005f;
IL_005f:
return false;
}
internal static string Lock_Inventory(NetworkUser user, string[] args)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
bool shouldLock = ((args.Length == 0) ? (!lockedUserIds.Contains(user.id)) : (args[0] != "0"));
return Lock_Inventory(user, shouldLock);
}
internal static string Lock_Inventory(NetworkUser user, bool shouldLock)
{
//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_0060: 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)
//IL_006d: 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)
NetworkUserId id = user.id;
string text = "<color=#AAE6F0>" + user.userName + "</color>";
if (shouldLock)
{
if (!lockedUserIds.Contains(id))
{
lockedUserIds.Add(id);
return "<color=#96EBAA>Locking " + text + "'s inventory</color>";
}
return "<color=#FF8282>Locked list already contains " + text + ", do '/lock 0' to unlock</color>";
}
if (lockedUserIds.Contains(id))
{
lockedUserIds.Remove(id);
return "<color=#96EBAA>Unlocking " + text + "'s inventory</color>";
}
return "<color=#FF8282>Locked list does not contain " + text + ", do '/lock 1' to lock</color>";
}
internal static string Block_User(NetworkUser sender, string[] args)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_00af: Unknown result type (might be due to invalid IL or missing references)
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
if ((Object)(object)((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null) != (Object)(object)sender)
{
return "<color=#FF8282>Sender is not host</color>";
}
if (!Object.op_Implicit((Object)(object)Run.instance))
{
return "<color=#FF8282>Can only be done during a run";
}
PlayerCharacterMasterController netUserFromString = StringParsers.GetNetUserFromString(args[0]);
if (!Object.op_Implicit((Object)(object)netUserFromString) || !Object.op_Implicit((Object)(object)netUserFromString.networkUser))
{
return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[0] + "</color>'</color>";
}
if ((Object)(object)netUserFromString.networkUser == (Object)(object)sender)
{
return "<color=#FF8282>Can not block self</color>";
}
NetworkUserId id = netUserFromString.networkUser.id;
if (blockedUserIds.Remove(id))
{
return "<color=#96EBAA>Unblocked <color=#AAE6F0>" + netUserFromString.networkUser.userName + "</color></color>";
}
blockedUserIds.Add(id);
return "<color=#96EBAA>Blocked <color=#AAE6F0>" + netUserFromString.networkUser.userName + "</color></color>";
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCDIBlockUser(ConCommandArgs args)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.LogError((object)"Requires at least 1 argument: blockuser {Playername}");
return;
}
Debug.Log((object)Block_User(args.sender, new string[1] { ((ConCommandArgs)(ref args))[0] }));
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCLockInventory(ConCommandArgs args)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
if (((ConCommandArgs)(ref args)).Count > 0)
{
Config.lockInventory.Value = ((ConCommandArgs)(ref args))[0] != "0";
}
else
{
Config.lockInventory.Value = !Config.lockInventory.Value;
}
Debug.Log((object)("Set Lock Inventory to: " + Config.lockInventory.Value));
if (Object.op_Implicit((Object)(object)args.sender))
{
((Component)args.sender).GetComponent<DropNetworkComponent>().CallCmdLockInventory(Config.lockInventory.Value);
}
}
}
}