using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 LethalLib.Modules;
using LobbyCompatibility.Attributes;
using MeguminScrap.Behaviour;
using MeguminScrap.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MeguminScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MeguminScrap")]
[assembly: AssemblyTitle("MeguminScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 MeguminScrap
{
public class MeguminConfig
{
public readonly ConfigEntry<float> MinTriggerTime;
public readonly ConfigEntry<float> CooldownTime;
public readonly ConfigEntry<int> Rarity;
public readonly ConfigEntry<int> AverageValue;
public MeguminConfig(ConfigFile _Config)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
_Config.SaveOnConfigSet = false;
ConfigDescription val = new ConfigDescription("Server side : Minimum amount of time that must pass before she can start chanting (in seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 300f), Array.Empty<object>());
MinTriggerTime = _Config.Bind<float>("Behaviour", "MinTriggerTime", 30f, val);
ConfigDescription val2 = new ConfigDescription("Server side : Time before countdown can start again afet an explosion (in seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 300f), Array.Empty<object>());
CooldownTime = _Config.Bind<float>("Behaviour", "CooldownTime", 30f, val2);
ConfigDescription val3 = new ConfigDescription("Server side : How likely the scrap is to spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>());
Rarity = _Config.Bind<int>("Defaults", "Rarity", 30, val3);
AverageValue = _Config.Bind<int>("Defaults", "AverageValue", 165, "Server side : Average value of the item without any multiplier.");
ClearOrphanedEntries(_Config);
_Config.Save();
_Config.SaveOnConfigSet = true;
}
private static void ClearOrphanedEntries(ConfigFile _Config)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(_Config);
dictionary.Clear();
}
}
[BepInPlugin("MeguminScrap", "MeguminScrap", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class MeguminScrap : BaseUnityPlugin
{
public static AssetBundle MegAssetBundle;
public static MeguminScrap Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
MegAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "meguminscrap"));
Item val = MegAssetBundle.LoadAsset<Item>("Assets/PoulpeSoyeux/MeguminScrap/I_MeguminScrap.asset");
AudioClip val2 = MegAssetBundle.LoadAsset<AudioClip>("Assets/PoulpeSoyeux/MeguminScrap/Megplosion.wav");
AudioClip val3 = MegAssetBundle.LoadAsset<AudioClip>("Assets/PoulpeSoyeux/MeguminScrap/MegPickup.wav");
AudioClip val4 = MegAssetBundle.LoadAsset<AudioClip>("Assets/PoulpeSoyeux/MeguminScrap/MegPocket.wav");
if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
{
Logger.LogError((object)"MeguminScrap : Failed to load at least one audio clip.");
return;
}
MeguminScrapBehaviour meguminScrapBehaviour = val.spawnPrefab.AddComponent<MeguminScrapBehaviour>();
((GrabbableObject)meguminScrapBehaviour).grabbable = true;
((GrabbableObject)meguminScrapBehaviour).grabbableToEnemies = true;
((GrabbableObject)meguminScrapBehaviour).itemProperties = val;
meguminScrapBehaviour.MegplosionClip = val2;
meguminScrapBehaviour.MegPickupClip = val3;
meguminScrapBehaviour.MegPocketClip = val4;
MeguminConfig meguminConfig = new MeguminConfig(((BaseUnityPlugin)this).Config);
float value = meguminConfig.MinTriggerTime.Value;
if (value >= 0f && meguminConfig.CooldownTime.Value >= 0f)
{
meguminScrapBehaviour.TimerRange = new Vector2(value, value * 2f);
meguminScrapBehaviour.CooldownTime = meguminConfig.CooldownTime.Value;
}
else
{
Logger.LogWarning((object)"MeguminScrap : Timing config invalid, default value will be used.");
}
if (meguminConfig.AverageValue.Value > 0)
{
int minValue = meguminConfig.AverageValue.Value - 35;
int maxValue = meguminConfig.AverageValue.Value + 35;
val.minValue = minValue;
val.maxValue = maxValue;
}
int value2 = meguminConfig.Rarity.Value;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, value2, (LevelTypes)(-1));
Logger.LogInfo((object)"MeguminScrap v1.0.0 has loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MeguminScrap";
public const string PLUGIN_NAME = "MeguminScrap";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace MeguminScrap.Patches
{
[HarmonyPatch(typeof(TVScript))]
public class ExampleTVPatch
{
[HarmonyPatch("SwitchTVLocalClient")]
[HarmonyPrefix]
private static void SwitchTVPrefix(TVScript __instance)
{
StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
}
}
}
namespace MeguminScrap.Behaviour
{
internal class MeguminScrapBehaviour : PhysicsProp
{
public AudioClip MegplosionClip;
public AudioClip MegPickupClip;
public AudioClip MegPocketClip;
public Vector2 TimerRange = new Vector2(30f, 60f);
public float CooldownTime = 30f;
private readonly float ChantingDuration = 22.202744f;
private readonly float IntroDuration = 5f;
private readonly float UnpocketDuration = 1f;
private AudioSource ParentAudioSource;
private float HeldTimer;
private float ChantingStartTime;
private float SoundUntilTimestamp;
private float ExplosionTimestamp;
private float CooldownTimestamp;
private bool bChanting;
public void PlaySoundEverywhere(AudioClip _AudioClip)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
ParentAudioSource.Stop();
ParentAudioSource.PlayOneShot(_AudioClip);
WalkieTalkie.TransmitOneShotAudio(ParentAudioSource, _AudioClip, 1f);
if (((NetworkBehaviour)this).IsOwner)
{
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.5f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
}
((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
}
public override void Start()
{
((GrabbableObject)this).Start();
ParentAudioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
ChantingStartTime = 0f;
ExplosionTimestamp = 0f;
bChanting = false;
ChantingStartTime = Random.Range(TimerRange.x, TimerRange.y);
}
public override void Update()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).Update();
float time = Time.time;
if (time <= CooldownTimestamp)
{
return;
}
if (bChanting)
{
if (((NetworkBehaviour)this).IsOwner)
{
if (time >= ExplosionTimestamp)
{
Explode();
ExplodeServerRpc();
}
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.5f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
if (((GrabbableObject)this).isHeld)
{
((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
}
}
}
else
{
if (!((GrabbableObject)this).isHeld)
{
return;
}
HeldTimer += Time.deltaTime;
if (((NetworkBehaviour)this).IsOwner)
{
if (HeldTimer >= ChantingStartTime)
{
BeginChanting();
BeginChantingServerRpc();
}
if (time <= SoundUntilTimestamp)
{
((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
}
}
}
}
public override void GrabItem()
{
if (!bChanting)
{
PlaySoundEverywhere(MegPickupClip);
SoundUntilTimestamp = Time.time + IntroDuration;
}
((GrabbableObject)this).GrabItem();
}
public override void EquipItem()
{
if (!bChanting && ((GrabbableObject)this).isPocketed)
{
PlaySoundEverywhere(MegPocketClip);
SoundUntilTimestamp = Time.time + UnpocketDuration;
}
((PhysicsProp)this).EquipItem();
}
[ServerRpc(RequireOwnership = false)]
public void BeginChantingServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4234283393u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4234283393u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
BeginChantingClientRpc();
}
}
}
[ClientRpc]
public void BeginChantingClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(825525745u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 825525745u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
{
BeginChanting();
}
}
}
private void BeginChanting()
{
bChanting = true;
ExplosionTimestamp = Time.time + ChantingDuration;
PlaySoundEverywhere(MegplosionClip);
}
[ServerRpc(RequireOwnership = false)]
public void ExplodeServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(160503248u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 160503248u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
ExplodeClientRpc();
}
}
}
[ClientRpc]
public void ExplodeClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1332957831u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1332957831u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
{
Explode();
}
}
}
private void Explode()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Landmine.SpawnExplosion(((Component)this).transform.position, true, 5.7f, 6f, 50, 0f, (GameObject)null, false);
bChanting = false;
ChantingStartTime = Random.Range(TimerRange.x, TimerRange.y);
CooldownTimestamp = Time.time + CooldownTime;
HeldTimer = 0f;
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_MeguminScrapBehaviour()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(4234283393u, new RpcReceiveHandler(__rpc_handler_4234283393));
NetworkManager.__rpc_func_table.Add(825525745u, new RpcReceiveHandler(__rpc_handler_825525745));
NetworkManager.__rpc_func_table.Add(160503248u, new RpcReceiveHandler(__rpc_handler_160503248));
NetworkManager.__rpc_func_table.Add(1332957831u, new RpcReceiveHandler(__rpc_handler_1332957831));
}
private static void __rpc_handler_4234283393(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((MeguminScrapBehaviour)(object)target).BeginChantingServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_825525745(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((MeguminScrapBehaviour)(object)target).BeginChantingClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_160503248(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((MeguminScrapBehaviour)(object)target).ExplodeServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1332957831(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((MeguminScrapBehaviour)(object)target).ExplodeClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "MeguminScrapBehaviour";
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace MeguminScrap.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}