using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using PressureDrop.Commands;
using Rewired;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("PressureDrop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1d2d532ddf13e7bd2a9163ba7b2f1ee428360cb8")]
[assembly: AssemblyProduct("PressureDrop")]
[assembly: AssemblyTitle("PressureDrop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PressureDrop
{
public static class ChatCommander
{
[CompilerGenerated]
private static class <>O
{
public static hook_RunCmd <0>__Console_RunCmd;
}
private static readonly Dictionary<string, Action<NetworkUser, string[]>> Commands = new Dictionary<string, Action<NetworkUser, string[]>>();
private static bool _hooked = false;
internal static void Hook()
{
//IL_001e: 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_0029: Expected O, but got Unknown
if (!_hooked)
{
_hooked = true;
object obj = <>O.<0>__Console_RunCmd;
if (obj == null)
{
hook_RunCmd val = Console_RunCmd;
<>O.<0>__Console_RunCmd = val;
obj = (object)val;
}
Console.RunCmd += (hook_RunCmd)obj;
}
}
private static void Console_RunCmd(orig_RunCmd orig, Console self, CmdSender sender, string concommandName, List<string> userArgs)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
string text = userArgs.FirstOrDefault();
string[] array = text?.Split(new char[1] { ' ' });
if (!NetworkServer.active || !concommandName.Equals("say", StringComparison.InvariantCultureIgnoreCase) || string.IsNullOrWhiteSpace(text) || array == null || array.Length == 0 || !Commands.TryGetValue(array[0], out var value) || value == null)
{
orig.Invoke(self, sender, concommandName, userArgs);
return;
}
Chat.SendBroadcastChat((ChatMessageBase)new UserChatMessage
{
sender = ((Component)sender.networkUser).gameObject,
text = text
});
value(sender.networkUser, array);
}
public static bool Register(string token, Action<NetworkUser, string[]> action, bool replace = false)
{
if (Commands.ContainsKey(token))
{
if (!replace)
{
Log.Warning("ChatCommander> A chat command is already registered under '" + token + "'");
return false;
}
Log.Warning("ChatCommander> '" + token + "' is replacing a previously registered chat command.");
}
Commands[token] = action;
string name = action.Method.DeclaringType.Assembly.GetName().Name;
name = ((name != typeof(ChatCommander).Assembly.GetName().Name) ? (" [from " + name + ".dll]") : "");
Log.Info("ChatCommander> Registering a chat command under '" + token + "'" + name);
return true;
}
public static bool Unregister(string token, Action<NetworkUser, string[]> action)
{
if (Commands.TryGetValue(token, out var value))
{
if (value == action)
{
Log.Info("ChatCommander> Unregistered '" + token + "' chat command.");
Commands.Remove(token);
return true;
}
Log.Warning("ChatCommander> Could not unregister chat command '" + token + "' as the action does not match.");
}
else
{
Log.Info("ChatCommander> Could not unregister chat command '" + token + "' (not registered).");
}
return false;
}
public static void Output(string message)
{
//IL_0000: 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_0020: Expected O, but got Unknown
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<style=cIsUtility>" + message + "</style>"
});
}
public static void OutputFail(string cmd, string message)
{
Output("<style=cDeath>Failed:</style> <color=#ffffff>" + cmd + "</color> " + message);
}
public static string GetColoredPickupLanguageString(ItemIndex itemIndex)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return GetColoredPickupLanguageString(PickupCatalog.FindPickupIndex(itemIndex));
}
public static string GetColoredPickupLanguageString(EquipmentIndex equipmentIndex)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return GetColoredPickupLanguageString(PickupCatalog.FindPickupIndex(equipmentIndex));
}
public static string GetColoredPickupLanguageString(PickupIndex pickupIndex)
{
//IL_0000: 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_0018: Unknown result type (might be due to invalid IL or missing references)
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
return Util.GenerateColoredString(Language.GetString(pickupDef.nameToken), Color32.op_Implicit(pickupDef.baseColor));
}
}
public sealed class Config
{
private readonly ConfigEntry<float> pressurePlateTimer;
private readonly ConfigEntry<bool> dropEnabled;
private readonly ConfigEntry<bool> dropTeleporterEnabled;
private readonly ConfigEntry<bool> dropDeadEnabled;
private readonly ConfigEntry<bool> dropInvertDirection;
private readonly ConfigEntry<bool> dropVoidAllowed;
private readonly ConfigEntry<int> maxItemsToDropAtATime;
private readonly ConfigEntry<bool> dropRecyclableWhite;
private readonly ConfigEntry<bool> dropRecyclableGreen;
private readonly ConfigEntry<bool> dropRecyclableRed;
private readonly ConfigEntry<bool> dropRecyclableYellow;
private readonly ConfigEntry<bool> dropRecyclableLunar;
private readonly ConfigEntry<bool> dropRecyclableVoid;
private readonly ConfigEntry<bool> dropRecyclableEquipment;
private readonly ConfigEntry<bool> dropRecyclableEquipmentLunar;
private readonly ConfigEntry<bool> scoreboardShowChat;
private readonly ConfigEntry<bool> voidPickupConfirmAll;
public float PressurePlateTimer => pressurePlateTimer.Value;
public bool DropEnabled => dropEnabled.Value;
public bool DropTeleporterEnabled => dropTeleporterEnabled.Value;
public bool DropDeadEnabled => dropDeadEnabled.Value;
public bool DropInvertDirection => dropInvertDirection.Value;
public bool DropVoidAllowed => dropVoidAllowed.Value;
public int MaxItemsToDropAtATime
{
get
{
if (maxItemsToDropAtATime.Value <= 0)
{
return 1;
}
return maxItemsToDropAtATime.Value;
}
}
public bool DropRecyclableWhite => dropRecyclableWhite.Value;
public bool DropRecyclableGreen => dropRecyclableGreen.Value;
public bool DropRecyclableRed => dropRecyclableRed.Value;
public bool DropRecyclableYellow => dropRecyclableYellow.Value;
public bool DropRecyclableLunar => dropRecyclableLunar.Value;
public bool DropRecyclableVoid => dropRecyclableVoid.Value;
public bool DropRecyclableEquipment => dropRecyclableEquipment.Value;
public bool DropRecyclableEquipmentLunar => dropRecyclableEquipmentLunar.Value;
public bool ScoreboardShowChat => scoreboardShowChat.Value;
public bool VoidPickupConfirmAll => voidPickupConfirmAll.Value;
public Config(ConfigFile config)
{
pressurePlateTimer = config.Bind<float>("> Timed Pressure Plates", "pressurePlateTimer", 30f, "The length of time (seconds) a pressure plate will remain pressed after being activated.\nZero disables time functionality (reverts to vanilla behaviour). Negative values prevent pressure plates from releasing once activated.");
dropEnabled = config.Bind<bool>("Drop Command", "dropEnabled", true, "Whether the /drop command should be enabled or not.");
dropTeleporterEnabled = config.Bind<bool>("Drop Command", "dropTeleporterEnabled", true, "Whether players should be able to send their drops to the Teleporter or not.");
dropDeadEnabled = config.Bind<bool>("Drop Command", "dropDeadEnabled", true, "Whether dead players should be able to drop items or not.\nRequires dropTeleporterEnabled to be true.");
dropInvertDirection = config.Bind<bool>("Drop Command", "dropInvertDirection", false, "Whether items should be dropped opposite the aim direction or not.");
dropVoidAllowed = config.Bind<bool>("Drop Command", "dropVoidAllowed", false, "Whether void items are allowed to be dropped or not.");
maxItemsToDropAtATime = config.Bind<int>("Drop Command", "maxItemsToDropAtATime", 10, "The maximum amount of items to drop from the player at a time (similar to Scrappers).\nMinimum value is 1.");
dropRecyclableWhite = config.Bind<bool>("Drop Recyclable", "dropRecyclableWhite", true, "Whether dropped white tier items should be recyclable.");
dropRecyclableGreen = config.Bind<bool>("Drop Recyclable", "dropRecyclableGreen", true, "Whether dropped green tier items should be recyclable.");
dropRecyclableRed = config.Bind<bool>("Drop Recyclable", "dropRecyclableRed", false, "Whether dropped red tier items should be recyclable.");
dropRecyclableYellow = config.Bind<bool>("Drop Recyclable", "dropRecyclableYellow", false, "Whether dropped yellow tier items should be recyclable.");
dropRecyclableLunar = config.Bind<bool>("Drop Recyclable", "dropRecyclableLunar", false, "Whether dropped lunar items should be recyclable.");
dropRecyclableVoid = config.Bind<bool>("Drop Recyclable", "dropRecyclableVoid", false, "Whether dropped void items should be recyclable.");
dropRecyclableEquipment = config.Bind<bool>("Drop Recyclable", "dropRecyclableEquipment", true, "Whether dropped equipment should be recyclable.");
dropRecyclableEquipmentLunar = config.Bind<bool>("Drop Recyclable", "dropRecyclableEquipmentLunar", false, "Whether dropped lunar equipment should be recyclable.");
scoreboardShowChat = config.Bind<bool>("Tweaks", "scoreboardShowChat", false, "Show chat history when the scoreboard is open.");
voidPickupConfirmAll = config.Bind<bool>("Tweaks", "voidPickupConfirmAll", false, "Always require confirmation to pick up void items.");
}
}
public static class Drop
{
[CompilerGenerated]
private static class <>O
{
public static hook_CreatePickup <0>__GenericPickupController_CreatePickup;
}
private static readonly Quaternion identifier = new Quaternion(-2f, -4f, -8f, -16f);
private static bool _hooked = false;
internal static void Hook()
{
//IL_001e: 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_0029: Expected O, but got Unknown
if (!_hooked)
{
_hooked = true;
object obj = <>O.<0>__GenericPickupController_CreatePickup;
if (obj == null)
{
hook_CreatePickup val = GenericPickupController_CreatePickup;
<>O.<0>__GenericPickupController_CreatePickup = val;
obj = (object)val;
}
GenericPickupController.CreatePickup += (hook_CreatePickup)obj;
PressureDrop.Commands.Drop.Enable();
}
}
internal static void Unhook()
{
//IL_001e: 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_0029: Expected O, but got Unknown
if (_hooked)
{
_hooked = false;
object obj = <>O.<0>__GenericPickupController_CreatePickup;
if (obj == null)
{
hook_CreatePickup val = GenericPickupController_CreatePickup;
<>O.<0>__GenericPickupController_CreatePickup = val;
obj = (object)val;
}
GenericPickupController.CreatePickup -= (hook_CreatePickup)obj;
PressureDrop.Commands.Drop.Disable();
}
}
private static GenericPickupController GenericPickupController_CreatePickup(orig_CreatePickup orig, ref CreatePickupInfo createPickupInfo)
{
//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_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references)
if (createPickupInfo.rotation == identifier)
{
createPickupInfo.rotation = Quaternion.identity;
GenericPickupController val = orig.Invoke(ref createPickupInfo);
if (!GetDropRecyclable(PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref createPickupInfo)).pickupIndex)))
{
val.Recycled = true;
}
return val;
}
return orig.Invoke(ref createPickupInfo);
}
public static bool IsVoidTier(ItemTier tier)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if ((int)tier != 6 && (int)tier != 7 && (int)tier != 8)
{
return (int)tier == 9;
}
return true;
}
public static bool GetDropRecyclable(PickupDef def)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Invalid comparison between Unknown and I4
//IL_000f: 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_0029: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
bool result = true;
if ((int)def.itemIndex != -1)
{
if (((int)def.itemTier == 0 && !Plugin.Config.DropRecyclableWhite) || ((int)def.itemTier == 1 && !Plugin.Config.DropRecyclableGreen) || ((int)def.itemTier == 2 && !Plugin.Config.DropRecyclableRed) || ((int)def.itemTier == 4 && !Plugin.Config.DropRecyclableYellow) || ((int)def.itemTier == 3 && !Plugin.Config.DropRecyclableLunar) || (!Plugin.Config.DropRecyclableVoid && IsVoidTier(def.itemTier)))
{
result = false;
}
}
else if ((int)def.equipmentIndex != -1)
{
if (def.isLunar)
{
if (!Plugin.Config.DropRecyclableEquipmentLunar)
{
result = false;
}
}
else if (!Plugin.Config.DropRecyclableEquipment)
{
result = false;
}
}
return result;
}
public static ItemIndex FindItemInInventory(this Inventory inventory, string query)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
List<ItemIndex> itemAcquisitionOrder = inventory.itemAcquisitionOrder;
if (itemAcquisitionOrder != null && itemAcquisitionOrder.Count > 0)
{
query = FormatStringForQuerying(query);
for (int num = itemAcquisitionOrder.Count - 1; num >= 0; num--)
{
ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num]);
if (!itemDef.hidden && itemDef.canRemove && FormatStringForQuerying(Language.GetString(itemDef.nameToken)).Contains(query))
{
return itemDef.itemIndex;
}
}
return (ItemIndex)(-1);
}
return (ItemIndex)(-1);
}
public static string FormatStringForQuerying(string input)
{
return Regex.Replace(input, "[ '_.,-]", string.Empty).ToLowerInvariant();
}
public static Vector3? GetAimDirection(CharacterBody body)
{
//IL_0021: 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_0035: Unknown result type (might be due to invalid IL or missing references)
InputBankTest val = ((body != null) ? body.inputBank : null);
if ((Object)(object)val == (Object)null)
{
return null;
}
Vector3 aimDirection = val.aimDirection;
aimDirection.y = 0f;
return ((Vector3)(ref aimDirection)).normalized;
}
public static void DropStyleChest(Transform target, PickupIndex dropPickup, int dropCount, float forwardVelocity = 2f, float upVelocity = 20f, Vector3? forwardOverride = null)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_004e: 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_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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
if (dropPickup != PickupIndex.none && dropCount >= 1)
{
float num = 360f / (float)dropCount;
Vector3 val = (Vector3)(((??)forwardOverride) ?? target.forward);
Vector3 val2 = Vector3.up * upVelocity + val * forwardVelocity;
Quaternion val3 = Quaternion.AngleAxis(num, Vector3.up);
for (int i = 0; i < dropCount; i++)
{
CreatePickupInfo val4 = default(CreatePickupInfo);
val4.rotation = identifier;
((CreatePickupInfo)(ref val4)).pickupIndex = dropPickup;
PickupDropletController.CreatePickupDroplet(val4, target.position + Vector3.up * 1.5f, val2);
val2 = val3 * val2;
}
}
}
public static void DropStyleChest(Transform target, PickupIndex[] drops, float forwardVelocity = 2f, float upVelocity = 20f, Vector3? forwardOverride = null)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_008e: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
if (drops.Length < 1)
{
return;
}
float num = 360f / (float)drops.Length;
Vector3 val = (Vector3)(((??)forwardOverride) ?? target.forward);
Vector3 val2 = Vector3.up * upVelocity + val * forwardVelocity;
Quaternion val3 = Quaternion.AngleAxis(num, Vector3.up);
for (int i = 0; i < drops.Length; i++)
{
if (!(drops[i] == PickupIndex.none))
{
CreatePickupInfo val4 = default(CreatePickupInfo);
val4.rotation = identifier;
((CreatePickupInfo)(ref val4)).pickupIndex = drops[i];
PickupDropletController.CreatePickupDroplet(val4, target.position + Vector3.up * 1.5f, val2);
val2 = val3 * val2;
}
}
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource baseLogger)
{
Logger.Sources.Remove((ILogSource)(object)baseLogger);
_logSource = Logger.CreateLogSource("itsschwer.PressureDrop");
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("itsschwer.PressureDrop", "PressureDrop", "1.3.0")]
public sealed class Plugin : BaseUnityPlugin
{
public const string GUID = "itsschwer.PressureDrop";
public const string Author = "itsschwer";
public const string Name = "PressureDrop";
public const string Version = "1.3.0";
private PressurePlateTimer pressure;
public static Config Config { get; private set; }
private void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Config = new Config(((BaseUnityPlugin)this).Config);
ChatCommander.Hook();
Run.onRunStartGlobal += SetPluginActiveState;
Run.onRunDestroyGlobal += SetPluginActiveState;
SetPluginActiveState();
Log.Message("~awake.");
}
private void OnEnable()
{
ManageHooks();
ChatCommander.Register("/reload", ReloadConfig, replace: true);
Log.Message("~enabled.");
}
private void OnDisable()
{
ManageHooks();
ChatCommander.Unregister("/reload", ReloadConfig);
Log.Message("~disabled.");
}
private void SetPluginActiveState(Run _ = null)
{
SetActive(NetworkServer.active);
}
private void SetActive(bool value)
{
((Behaviour)this).enabled = value;
if (Object.op_Implicit((Object)(object)pressure))
{
((Behaviour)pressure).enabled = value;
}
Log.Message("~" + (value ? "active" : "inactive") + ".");
}
private void ReloadConfig(NetworkUser user, string[] args)
{
//IL_0024: 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_0039: Expected O, but got Unknown
if (!((Object)(object)user != (Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser))
{
((BaseUnityPlugin)this).Config.Reload();
ManageHooks();
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "Reloaded configuration for <style=cWorldEvent>itsschwer.PressureDrop</style>"
});
}
}
private void ManageHooks()
{
ManagePressurePlateTimer();
ManageDropCommand();
ManageTweaks();
}
private void ManagePressurePlateTimer()
{
if (((Behaviour)this).enabled && Config.PressurePlateTimer != 0f)
{
if (!Object.op_Implicit((Object)(object)pressure))
{
pressure = ((Component)this).gameObject.AddComponent<PressurePlateTimer>();
}
}
else
{
Object.Destroy((Object)(object)pressure);
}
}
private void ManageDropCommand()
{
Drop.Unhook();
if (((Behaviour)this).enabled && Config.DropEnabled)
{
Drop.Hook();
}
}
private void ManageTweaks()
{
ScoreboardShowChat.Unhook();
if (Config.ScoreboardShowChat)
{
ScoreboardShowChat.Hook();
}
VoidPickupTweak.SetActive(((Behaviour)this).enabled && Config.VoidPickupConfirmAll);
}
}
internal sealed class PressurePlateTimer : MonoBehaviour
{
[CompilerGenerated]
private static class <>O
{
public static hook_SetSwitch <0>__PressurePlateController_SetSwitch;
}
private static readonly Dictionary<PressurePlateController, float> timers = new Dictionary<PressurePlateController, float>(2);
private void OnEnable()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
object obj = <>O.<0>__PressurePlateController_SetSwitch;
if (obj == null)
{
hook_SetSwitch val = PressurePlateController_SetSwitch;
<>O.<0>__PressurePlateController_SetSwitch = val;
obj = (object)val;
}
PressurePlateController.SetSwitch += (hook_SetSwitch)obj;
}
private void OnDisable()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
object obj = <>O.<0>__PressurePlateController_SetSwitch;
if (obj == null)
{
hook_SetSwitch val = PressurePlateController_SetSwitch;
<>O.<0>__PressurePlateController_SetSwitch = val;
obj = (object)val;
}
PressurePlateController.SetSwitch -= (hook_SetSwitch)obj;
}
private void Update()
{
foreach (PressurePlateController item in timers.Keys.ToList())
{
timers[item] -= Time.deltaTime;
if (timers[item] <= 0f)
{
timers.Remove(item);
}
}
}
private static void PressurePlateController_SetSwitch(orig_SetSwitch orig, PressurePlateController self, bool switchIsDown)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
float pressurePlateTimer = Plugin.Config.PressurePlateTimer;
if (switchIsDown)
{
if (switchIsDown != self.switchDown)
{
string text = (((double)Random.value <= 0.2) ? "Press your plate!" : "A pressure plate is pressed..");
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<style=cEvent>" + text + "</style>"
});
}
orig.Invoke(self, switchIsDown);
timers[self] = pressurePlateTimer;
}
else if (pressurePlateTimer > 0f && !timers.ContainsKey(self))
{
if (switchIsDown != self.switchDown)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<style=cEvent>A pressure plate releases...</style>"
});
}
orig.Invoke(self, switchIsDown);
}
}
}
internal static class ScoreboardShowChat
{
[CompilerGenerated]
private static class <>O
{
public static hook_UpdateFade <0>__ChatBox_UpdateFade;
}
private static bool _hooked;
internal static void Hook()
{
//IL_001e: 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_0029: Expected O, but got Unknown
if (!_hooked)
{
_hooked = true;
object obj = <>O.<0>__ChatBox_UpdateFade;
if (obj == null)
{
hook_UpdateFade val = ChatBox_UpdateFade;
<>O.<0>__ChatBox_UpdateFade = val;
obj = (object)val;
}
ChatBox.UpdateFade += (hook_UpdateFade)obj;
}
}
internal static void Unhook()
{
//IL_001e: 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_0029: Expected O, but got Unknown
if (_hooked)
{
_hooked = false;
object obj = <>O.<0>__ChatBox_UpdateFade;
if (obj == null)
{
hook_UpdateFade val = ChatBox_UpdateFade;
<>O.<0>__ChatBox_UpdateFade = val;
obj = (object)val;
}
ChatBox.UpdateFade -= (hook_UpdateFade)obj;
}
}
private static void ChatBox_UpdateFade(orig_UpdateFade orig, ChatBox self, float deltaTime)
{
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
Player val = ((firstLocalUser != null) ? firstLocalUser.inputPlayer : null);
if (val != null && val.GetButton("info"))
{
self.ResetFadeTimer();
}
orig.Invoke(self, deltaTime);
}
}
internal static class VoidPickupTweak
{
private static readonly Dictionary<ItemTier, PickupRules> originalRules = new Dictionary<ItemTier, PickupRules>();
public static void SetActive(bool value)
{
if (originalRules.Count > 0)
{
Revert();
originalRules.Clear();
}
if (value)
{
Apply();
}
}
private static void Apply()
{
//IL_0000: 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_0008: 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_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ItemTierDef current = enumerator.Current;
if (Drop.IsVoidTier(current.tier))
{
originalRules[current.tier] = current.pickupRules;
current.pickupRules = (PickupRules)2;
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
Log.Message("Void Pickup Rule> applied.");
}
private static void Revert()
{
//IL_0000: 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_0008: 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_001e: 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_002e: Unknown result type (might be due to invalid IL or missing references)
Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ItemTierDef current = enumerator.Current;
if (originalRules.TryGetValue(current.tier, out var value))
{
current.pickupRules = value;
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
Log.Message("Void Pickup Rule> reverted.");
}
}
}
namespace PressureDrop.Commands
{
internal static class Drop
{
public static void Enable()
{
ChatCommander.Register("/d", DropCommand);
ChatCommander.Register("/drop", DropCommand);
}
public static void Disable()
{
ChatCommander.Unregister("/d", DropCommand);
ChatCommander.Unregister("/drop", DropCommand);
}
private static void DropCommand(NetworkUser user, string[] args)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
if ((Object)(object)Run.instance == (Object)null)
{
return;
}
if (args.Length < 2)
{
ShowHelp(args);
return;
}
bool dropAtTeleporter = false;
if (args.Length > 2)
{
if (!(args[2] == "@"))
{
ShowHelp(args);
return;
}
dropAtTeleporter = true;
}
ItemIndex val = user.master.inventory.FindItemInInventory(args[1]);
if ((int)val == -1)
{
Feedback("Could not match '<color=#e5eefc>" + args[1] + "</color>' to an item in " + user.masterController.GetDisplayName() + "'s inventory.");
}
else
{
ItemDef itemDef = ItemCatalog.GetItemDef(val);
if ((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix || (!Plugin.Config.DropVoidAllowed && PressureDrop.Drop.IsVoidTier(itemDef.tier)))
{
Feedback(ChatCommander.GetColoredPickupLanguageString(itemDef.itemIndex) + " can not be dropped.");
}
else
{
DropExecute(user, itemDef, dropAtTeleporter);
}
}
}
private static void DropExecute(NetworkUser user, ItemDef itemDef, bool dropAtTeleporter)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: 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_0122: Unknown result type (might be due to invalid IL or missing references)
int num = user.master.inventory.GetItemCount(itemDef.itemIndex);
if (num > Plugin.Config.MaxItemsToDropAtATime)
{
num = Plugin.Config.MaxItemsToDropAtATime;
}
CharacterBody currentBody = user.GetCurrentBody();
Transform val = ((currentBody != null) ? ((Component)currentBody).gameObject.transform : null);
if ((Object)(object)val == (Object)null)
{
if (!Plugin.Config.DropDeadEnabled || !Plugin.Config.DropTeleporterEnabled)
{
Feedback("Dead players can't drop items <sprite name=\"Skull\" tint=1>");
return;
}
dropAtTeleporter = true;
}
if (dropAtTeleporter)
{
if (!Plugin.Config.DropTeleporterEnabled)
{
Feedback("Dropping at the Teleporter is disabled <sprite name=\"Skull\" tint=1>");
return;
}
TeleporterInteraction instance = TeleporterInteraction.instance;
Transform val2 = ((instance != null) ? ((Component)instance).transform : null);
if (!((Object)(object)val2 != (Object)null))
{
Feedback("There is no Teleporter to drop at <sprite name=\"Skull\" tint=1>");
return;
}
val = val2;
}
if ((Object)(object)val == (Object)null)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<style=cUtility>No drop target <sprite name=\"Skull\" tint=1></style>"
});
return;
}
user.master.inventory.RemoveItem(itemDef.itemIndex, num);
Vector3? forwardOverride = PressureDrop.Drop.GetAimDirection((user != null) ? user.GetCurrentBody() : null);
if (Plugin.Config.DropInvertDirection && forwardOverride.HasValue)
{
forwardOverride = -forwardOverride.Value;
}
PressureDrop.Drop.DropStyleChest(val, PickupCatalog.FindPickupIndex(itemDef.itemIndex), num, 3.4f, 14f, forwardOverride);
Feedback(user, itemDef, num, dropAtTeleporter);
}
private static void Feedback(NetworkUser user, ItemDef item, int count, bool dropAtTeleporter)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
string displayName = user.masterController.GetDisplayName();
string coloredPickupLanguageString = ChatCommander.GetColoredPickupLanguageString(item.itemIndex);
string text = ((count != 1) ? $"({count})" : "");
string text2 = (dropAtTeleporter ? " at the Teleporter" : "");
Feedback(displayName + " dropped " + coloredPickupLanguageString + text + text2);
}
private static void Feedback(string message)
{
//IL_0000: 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_0020: Expected O, but got Unknown
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<style=cEvent>" + message + "</color>"
});
}
private static void ShowHelp(string[] args)
{
ChatCommander.OutputFail(args[0], "expects an item name (without spaces).");
}
}
}