using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GrindersMod.NetcodePatcher;
using LethalCompanyTemplate.Extensions;
using LethalCompanyTemplate.MonoBehaviour;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using Unity.Netcode.Components;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("GrindersMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod for some true grinders")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("GrindersMod")]
[assembly: AssemblyTitle("GrindersMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
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 LethalCompanyTemplate
{
[BepInPlugin("GrindersMod", "GrindersMod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static AssetBundle GrinderAssets;
internal static ManualLogSource logger = Logger.CreateLogSource("GrindersMod");
private List<Item> registeredItems = new List<Item>();
private void Awake()
{
logger.LogInfo((object)"Plugin loading...");
string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
logger.LogInfo((object)("Assembly location: " + Paths.PluginPath));
GrinderAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modassets"));
if ((Object)(object)GrinderAssets == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
return;
}
Item val = GrinderAssets.LoadAsset<Item>("Assets/Items/GrindersJukebox/GrindersJukebox.asset");
if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null)
{
NetworkTransform obj = val.spawnPrefab.AddComponent<NetworkTransform>();
obj.SlerpPosition = false;
obj.Interpolate = false;
obj.SyncPositionX = false;
obj.SyncPositionY = false;
obj.SyncPositionZ = false;
obj.SyncScaleX = false;
obj.SyncScaleY = false;
obj.SyncScaleZ = false;
obj.UseHalfFloatPrecision = true;
}
JukeboxItem jukeboxItem = val.spawnPrefab.AddComponent<JukeboxItem>();
jukeboxItem.musicSource = val.spawnPrefab.GetComponent<AudioSource>();
AudioClip val2 = GrinderAssets.LoadAsset<AudioClip>("Assets/Items/GrindersJukebox/grinders.mp3");
if ((Object)(object)val2 == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load grinders song.");
}
((GrabbableObject)jukeboxItem).grabbable = true;
((GrabbableObject)jukeboxItem).itemProperties = val;
jukeboxItem.grindersSong = val2;
Utilities.FixMixerGroups(val.spawnPrefab);
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
val3.clearPreviousText = true;
val3.displayText = "GRIND. GRIND. GRIND\n\n";
registeredItems.Add(val);
Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val3, 30);
logger.LogInfo((object)"Registered Grinder's jukebox");
logger.LogInfo((object)"Plugin loaded!");
try
{
foreach (Type loadableType in Assembly.GetExecutingAssembly().GetLoadableTypes())
{
MethodInfo[] methods = loadableType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
catch (Exception)
{
}
}
private void Start()
{
logger.LogInfo((object)"Plugin started!");
}
private void Update()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<KeyboardShortcut, Action> keyboardShortcut in Utils.keyboardShortcuts)
{
KeyboardShortcut key = keyboardShortcut.Key;
if (((KeyboardShortcut)(ref key)).IsDown())
{
keyboardShortcut.Value();
}
}
}
}
internal class Utils
{
public static Dictionary<KeyboardShortcut, Action> keyboardShortcuts = new Dictionary<KeyboardShortcut, Action>();
public static void RegisterShortcut(KeyboardShortcut shortcut, Action action)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)$"Registering shortcut {((KeyboardShortcut)(ref shortcut)).MainKey}");
keyboardShortcuts.Add(shortcut, action);
}
public static GameObject LoadPrefab(GameObject prefab, Vector3 position)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)("Loading prefab " + ((Object)prefab).name));
GameObject obj = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
obj.GetComponent<NetworkObject>().Spawn(false);
return obj;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "GrindersMod";
public const string PLUGIN_NAME = "GrindersMod";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace LethalCompanyTemplate.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("LethalCompanyTemplate.Properties.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}
namespace LethalCompanyTemplate.MonoBehaviour
{
internal class JukeboxItem : PhysicsProp
{
public AudioSource musicSource;
public AudioClip grindersSong;
public NetworkVariable<bool> isPlayingMusic = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);
private ManualLogSource logger;
private void Awake()
{
logger = Logger.CreateLogSource("GrindersMod");
musicSource = ((Component)this).GetComponent<AudioSource>();
if ((Object)(object)musicSource == (Object)null)
{
logger.LogError((object)"No audio source found");
}
musicSource.clip = grindersSong;
musicSource.loop = true;
musicSource.Play();
musicSource.Pause();
}
public override void EquipItem()
{
((PhysicsProp)this).EquipItem();
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
logger.LogError((object)"Starting music");
}
public override void ItemInteractLeftRight(bool right)
{
((GrabbableObject)this).ItemInteractLeftRight(right);
logger.LogInfo((object)"Interacting with item");
if (!right && ((NetworkBehaviour)this).IsOwner)
{
isPlayingMusic.Value = !isPlayingMusic.Value;
}
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
if (((NetworkBehaviour)this).IsOwner)
{
isPlayingMusic.Value = false;
}
logger.LogInfo((object)"Networkspawn");
}
public override void Update()
{
((GrabbableObject)this).Update();
if (isPlayingMusic.Value)
{
if (!musicSource.isPlaying)
{
musicSource.Play();
}
musicSource.UnPause();
}
else
{
musicSource.Pause();
}
}
protected override void __initializeVariables()
{
if (isPlayingMusic == null)
{
throw new Exception("JukeboxItem.isPlayingMusic cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)isPlayingMusic).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isPlayingMusic, "isPlayingMusic");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isPlayingMusic);
((PhysicsProp)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "JukeboxItem";
}
}
}
namespace LethalCompanyTemplate.Extensions
{
public static class AssemblyExtensions
{
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
return ex.Types.Where((Type t) => t != null);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace GrindersMod.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}