using System;
using System.Collections;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using TurretHellAppy.Dependencies;
using Unity.Mathematics;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TestAccount666.TurretHellAppy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes turrets go haywire when the appy is pulled")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d4d4bdae8225aa2f6a13784b0f3787e5138493b7")]
[assembly: AssemblyProduct("TurretHellAppy")]
[assembly: AssemblyTitle("TestAccount666.TurretHellAppy")]
[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 TurretHellAppy
{
public class Config
{
private ConfigEntry<float> _minDownTime = null;
private ConfigEntry<float> _maxDownTime = null;
public FloatRange downTime = null;
public void LoadConfig(ConfigFile config)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
_minDownTime = config.Bind<float>("Turret", "MinDownTime", 1f, new ConfigDescription("How long should a turret be deactivated after berserk?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
_maxDownTime = config.Bind<float>("Turret", "MaxDownTime", 5f, new ConfigDescription("How long should a turret be deactivated after berserk?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
BindDownTime();
_minDownTime.SettingChanged += delegate
{
BindDownTime();
};
_maxDownTime.SettingChanged += delegate
{
BindDownTime();
};
}
private void BindDownTime()
{
float value = _minDownTime.Value;
float value2 = _maxDownTime.Value;
if (value2 < value)
{
TurretHellAppy.Logger.LogWarning((object)"If it hadn't been for my checks, your config probably would've exploded this mod :> You shouldn't set `MaxDownTime` to a lower value than `MinDownTime` .-.");
}
downTime = new FloatRange(_minDownTime.Value, _maxDownTime.Value);
}
}
public class FloatRange
{
public readonly float min = Math.Min(first, second);
public readonly float max = Math.Max(first, second);
public FloatRange(float first, float second)
{
}
public void Deconstruct(out float minOut, out float maxOut)
{
minOut = min;
maxOut = max;
}
}
public class TurretHaywireComponent : MonoBehaviour
{
[CompilerGenerated]
private sealed class <GoHaywire>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TurretHaywireComponent <>4__this;
private float <min>5__1;
private float <max>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GoHaywire>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)<>4__this.turret)));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
break;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.6f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<>2__current = null;
<>1__state = 4;
return true;
case 4:
{
<>1__state = -1;
<>4__this.turret.ToggleTurretClientRpc(false);
TurretHellAppy.Config.downTime.Deconstruct(out var minOut, out var maxOut);
<min>5__1 = minOut;
<max>5__2 = maxOut;
Random random = Random;
<>2__current = (object)new WaitForSeconds(((Random)(ref random)).NextFloat(<min>5__1, <max>5__2));
<>1__state = 5;
return true;
}
case 5:
<>1__state = -1;
<>4__this.turret.ToggleTurretClientRpc(true);
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
break;
}
if (Object.op_Implicit((Object)(object)<>4__this))
{
<>4__this.turret.EnterBerserkModeClientRpc(-1);
<>2__current = (object)new WaitUntil((Func<bool>)(() => !<>4__this.turret.enteringBerserkMode && (int)<>4__this.turret.turretMode != 3));
<>1__state = 2;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Random? _Random;
public Turret turret = null;
public static Random Random
{
get
{
//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_003a: 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_0037: Unknown result type (might be due to invalid IL or missing references)
Random valueOrDefault = _Random.GetValueOrDefault();
Random result;
if (!_Random.HasValue)
{
((Random)(ref valueOrDefault))..ctor((uint)DateTime.Now.Ticks);
_Random = valueOrDefault;
result = valueOrDefault;
}
else
{
result = valueOrDefault;
}
return result;
}
}
private void Awake()
{
((MonoBehaviour)this).StartCoroutine(GoHaywire());
}
[IteratorStateMachine(typeof(<GoHaywire>d__5))]
private IEnumerator GoHaywire()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GoHaywire>d__5(0)
{
<>4__this = this
};
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("TestAccount666.TurretHellAppy", "TurretHellAppy", "1.0.0")]
public class TurretHellAppy : BaseUnityPlugin
{
public static Config Config;
public static TurretHellAppy Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("TestAccount666.TurretHellAppy");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
if (DependencyChecker.IsLobbyCompatibilityInstalled())
{
Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)");
LobbyCompatibilitySupport.Initialize();
}
Patch();
Config = new Config();
Config.LoadConfig(((BaseUnityPlugin)this).Config);
Logger.LogInfo((object)"TestAccount666.TurretHellAppy v1.0.0 has loaded!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TestAccount666.TurretHellAppy";
public const string PLUGIN_NAME = "TurretHellAppy";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TurretHellAppy.Patches
{
[HarmonyPatch(typeof(RoundManager))]
public static class AppyPullPatch
{
[CompilerGenerated]
private sealed class <WaitAndCheck>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private Turret[] <turrets>5__1;
private Turret[] <>s__2;
private int <>s__3;
private Turret <turret>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitAndCheck>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<turrets>5__1 = null;
<>s__2 = null;
<turret>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (!RoundManager.Instance.powerOffPermanently)
{
return false;
}
<turrets>5__1 = Object.FindObjectsByType<Turret>((FindObjectsInactive)0, (FindObjectsSortMode)0);
<>s__2 = <turrets>5__1;
for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
{
<turret>5__4 = <>s__2[<>s__3];
if (Object.op_Implicit((Object)(object)<turret>5__4))
{
((Component)<turret>5__4).gameObject.AddComponent<TurretHaywireComponent>().turret = <turret>5__4;
<turret>5__4 = null;
}
}
<>s__2 = null;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("SwitchPower")]
[HarmonyPostfix]
public static void DisconnectFromMachinery(bool on)
{
RoundManager instance = RoundManager.Instance;
if (!on && (instance == null || ((NetworkBehaviour)instance).IsHost || ((NetworkBehaviour)instance).IsServer))
{
((MonoBehaviour)instance).StartCoroutine(WaitAndCheck());
}
}
[IteratorStateMachine(typeof(<WaitAndCheck>d__1))]
private static IEnumerator WaitAndCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitAndCheck>d__1(0);
}
}
}
namespace TurretHellAppy.Dependencies
{
internal static class DependencyChecker
{
internal static bool IsLobbyCompatibilityInstalled()
{
return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility"));
}
}
internal static class LobbyCompatibilitySupport
{
internal static void Initialize()
{
PluginHelper.RegisterPlugin("TestAccount666.TurretHellAppy", new Version("1.0.0"), (CompatibilityLevel)2, (VersionStrictness)2);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}