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 MeguminScrap.Behaviour;
using MeguminScrap.Config;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MeguminScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("MeguminScrap")]
[assembly: AssemblyTitle("MeguminScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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
{
[BepInPlugin("MeguminScrap", "MeguminScrap", "1.0.3")]
public class MeguminScrapPlugin : BaseUnityPlugin
{
public static AssetBundle MegAssetBundle;
public static MeguminScrapPlugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
NetcodePatcher();
InitMeguminScrap();
Patch();
Logger.LogInfo((object)"MeguminScrap v1.0.3 has loaded!");
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("MeguminScrap");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
private void NetcodePatcher()
{
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);
}
}
}
}
private void InitMeguminScrap()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
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;
MeguminScrapConfig meguminScrapConfig = new MeguminScrapConfig(((BaseUnityPlugin)this).Config);
float value = meguminScrapConfig.MinTriggerTime.Value;
if (value >= 0f && meguminScrapConfig.CooldownTime.Value >= 0f)
{
meguminScrapBehaviour.TimerRange = new Vector2(value, value * 2f);
meguminScrapBehaviour.CooldownTime = meguminScrapConfig.CooldownTime.Value;
}
else
{
Logger.LogWarning((object)"MeguminScrap : Timing config invalid, default value will be used.");
}
if (meguminScrapConfig.AverageValue.Value > 0)
{
int minValue = meguminScrapConfig.AverageValue.Value - 35;
int maxValue = meguminScrapConfig.AverageValue.Value + 35;
val.minValue = minValue;
val.maxValue = maxValue;
}
int value2 = meguminScrapConfig.Rarity.Value;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, value2, (LevelTypes)(-1));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MeguminScrap";
public const string PLUGIN_NAME = "MeguminScrap";
public const string PLUGIN_VERSION = "1.0.3";
}
}
namespace MeguminScrap.Config
{
public class MeguminScrapConfig
{
public readonly ConfigEntry<float> MinTriggerTime;
public readonly ConfigEntry<float> CooldownTime;
public readonly ConfigEntry<int> Rarity;
public readonly ConfigEntry<int> AverageValue;
public MeguminScrapConfig(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 after 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();
}
}
}
namespace MeguminScrap.Behaviour
{
public 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_0043: 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)
{
CH_ExplodeRpc();
}
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 7f, 0.3f, 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)
{
CH_BeginChantingRpc();
}
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();
}
[Rpc(/*Could not decode attribute arguments.*/)]
public void CH_BeginChantingRpc()
{
//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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
{
RpcAttributeParams val = default(RpcAttributeParams);
RpcParams val2 = default(RpcParams);
FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2801125603u, val2, val, (SendTo)7, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendRpc(ref val3, 2801125603u, val2, val, (SendTo)7, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
bChanting = true;
ExplosionTimestamp = Time.time + ChantingDuration;
PlaySoundEverywhere(MegplosionClip);
}
}
}
[Rpc(/*Could not decode attribute arguments.*/)]
public void CH_ExplodeRpc()
{
//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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_00b0: 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)
{
RpcAttributeParams val = default(RpcAttributeParams);
RpcParams val2 = default(RpcParams);
FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3925870932u, val2, val, (SendTo)7, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendRpc(ref val3, 3925870932u, val2, val, (SendTo)7, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
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();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(2801125603u, new RpcReceiveHandler(__rpc_handler_2801125603), "CH_BeginChantingRpc");
((NetworkBehaviour)this).__registerRpc(3925870932u, new RpcReceiveHandler(__rpc_handler_3925870932), "CH_ExplodeRpc");
((PhysicsProp)this).__initializeRpcs();
}
private static void __rpc_handler_2801125603(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).CH_BeginChantingRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3925870932(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).CH_ExplodeRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "MeguminScrapBehaviour";
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace MeguminScrap.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}