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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using RichEnergy.Configuration;
using RichEnergy.NetcodePatcher;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RichEnergy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Rich Energy Drink Item for Lethal Company.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RichEnergy")]
[assembly: AssemblyTitle("RichEnergy")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class RichEnergyItem : GrabbableObject
{
private const string LOGPrefix = "RichEnergy";
private AudioSource audioSource;
public float drinkTimer;
public float runTimer;
private void OnEnable()
{
}
private void OnDisable()
{
}
public override void OnDestroy()
{
((NetworkBehaviour)this).OnDestroy();
}
public override void Start()
{
drinkTimer = 2f;
runTimer = 0f;
((GrabbableObject)this).Start();
}
public override void LateUpdate()
{
if ((base.isHeld || base.isPocketed) && base.isBeingUsed)
{
drinkTimer -= Time.deltaTime;
if (drinkTimer < 41f)
{
base.playerHeldBy.movementSpeed = 20f;
}
if (drinkTimer < 0f)
{
base.playerHeldBy.movementSpeed = 7f;
((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(base.itemProperties.grabSFX, 1f);
((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
}
}
((GrabbableObject)this).LateUpdate();
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
base.isBeingUsed = true;
((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(base.itemProperties.throwSFX, 1f);
drinkTimer = 43f;
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
}
public override void EquipItem()
{
((GrabbableObject)this).EquipItem();
}
public override void PocketItem()
{
((GrabbableObject)this).PocketItem();
}
protected override void __initializeVariables()
{
((GrabbableObject)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "RichEnergyItem";
}
}
namespace RichEnergy
{
[BepInPlugin("hamunii.RichEnergy", "RichEnergy", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "hamunii.RichEnergy";
internal static ManualLogSource Logger;
public static AssetBundle ModAssets;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
BoundConfig = new PluginConfig((BaseUnityPlugin)(object)this);
InitializeNetworkBehaviours();
string path = "richassets";
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
if ((Object)(object)ModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets.");
return;
}
int num = 30;
Item val = ModAssets.LoadAsset<Item>("RichEnergy");
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, num, (LevelTypes)(-1));
Logger.LogInfo((object)"Plugin RichEnergy is loaded!");
}
private static void InitializeNetworkBehaviours()
{
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);
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "RichEnergy";
public const string PLUGIN_NAME = "RichEnergy";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace RichEnergy.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> SpawnWeight;
public PluginConfig(BaseUnityPlugin plugin)
{
SpawnWeight = plugin.Config.Bind<int>("RichEnergy", "Spawn weight", 1000, "The spawn chance weight for RichEnergy, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
ClearUnusedEntries(plugin);
}
private void ClearUnusedEntries(BaseUnityPlugin plugin)
{
PropertyInfo property = ((object)plugin.Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(plugin.Config, null);
dictionary.Clear();
plugin.Config.Save();
}
}
}
namespace RichEnergy.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}