using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoCart")]
[assembly: AssemblyTitle("NoCart")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CartTouchKaboom
{
[BepInPlugin("Empress.CartTouchKaboom", "CartTouchKaboom", "1.0.2")]
public class CartTouchKaboomPlugin : BaseUnityPlugin
{
public const string PluginGuid = "Empress.CartTouchKaboom";
public const string PluginName = "CartTouchKaboom";
public const string PluginVersion = "1.0.2";
private ConfigEntry<bool> _enabled = null;
private ConfigEntry<int> _damage = null;
private ConfigEntry<bool> _onlyOnLocalGrabber = null;
private ConfigEntry<float> _cooldownSeconds = null;
private float _lastExplodeTime;
internal static CartTouchKaboomPlugin Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; private set; }
internal bool Enabled => _enabled.Value;
internal int Damage => Math.Max(1, _damage.Value);
internal bool OnlyLocal => _onlyOnLocalGrabber.Value;
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master toggle.");
_damage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Damage", 9999, "Damage applied to the grabber. Keep it lethal.");
_onlyOnLocalGrabber = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OnlyOnLocalGrabber", false, "If true, only detonate when the local player grabs.");
_cooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CooldownSeconds", 0.15f, "Minimum time between detonations.");
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} armed. Touch a cart and find out.");
}
private void OnDestroy()
{
Unpatch();
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Harmony = null;
}
internal bool ShouldExplodeNow()
{
if (Time.realtimeSinceStartup - _lastExplodeTime < _cooldownSeconds.Value)
{
return false;
}
_lastExplodeTime = Time.realtimeSinceStartup;
return true;
}
}
[HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")]
internal static class CartTouchKaboom_GrabStarted_Patch
{
private static void Postfix(PhysGrabObject __instance, PhysGrabber player)
{
//IL_0112: 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_0121: Unknown result type (might be due to invalid IL or missing references)
CartTouchKaboomPlugin instance = CartTouchKaboomPlugin.Instance;
if ((Object)(object)instance == (Object)null || !instance.Enabled || (Object)(object)__instance == (Object)null || (Object)(object)player == (Object)null || (Object)(object)((Component)__instance).GetComponent<PhysGrabCart>() == (Object)null)
{
return;
}
if (instance.OnlyLocal)
{
PlayerAvatar playerAvatar = player.playerAvatar;
if ((Object)(object)playerAvatar == (Object)null)
{
return;
}
PhotonView photonView = playerAvatar.photonView;
if ((Object)(object)photonView == (Object)null || !photonView.IsMine)
{
return;
}
}
if (!instance.ShouldExplodeNow())
{
return;
}
try
{
PlayerAvatar playerAvatar2 = player.playerAvatar;
PlayerHealth val = (((Object)(object)playerAvatar2 != (Object)null) ? playerAvatar2.playerHealth : null);
if ((Object)(object)playerAvatar2 == (Object)null || (Object)(object)val == (Object)null)
{
CartTouchKaboomPlugin.Logger.LogWarning((object)"Grabber missing PlayerAvatar/PlayerHealth. No detonation.");
return;
}
Vector3 position = ((Component)__instance).transform.position;
val.HurtOther(instance.Damage, position, false, -1);
CartTouchKaboomPlugin.Logger.LogDebug((object)$"KABOOM: {((Object)playerAvatar2).name} grabbed cart '{((Object)__instance).name}' -> dealt {instance.Damage}");
}
catch (Exception arg)
{
CartTouchKaboomPlugin.Logger.LogError((object)$"Detonation on cart-grab failed: {arg}");
}
}
}
}