using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
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.Configuration;
using BepInEx.Logging;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("TungstenCubeMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Yeah :D")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+e26360f7c96fa668bb8320c512c7b0f93350c8c4")]
[assembly: AssemblyProduct("TungstenCubeMod")]
[assembly: AssemblyTitle("TungstenCubeMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TungstenCubeMod
{
public static class ConfigSettings
{
private enum ConfigSections
{
[Description("1: Item Customization")]
Customization
}
public enum ConfigIndexes
{
SpawnWeight,
CarryWeight,
ValueMin,
ValueMax
}
public struct ConfigurableSetting
{
public Enum Index;
public string Section;
public string Key;
public object DefaultValue;
public ConfigDescription Description;
}
public static readonly ConfigurableSetting[] AllConfigSettings = new ConfigurableSetting[4]
{
new ConfigurableSetting
{
Index = ConfigIndexes.SpawnWeight,
Section = ConfigSections.Customization.GetDescription(),
Key = "Spawn weight",
DefaultValue = 6,
Description = new ConfigDescription("The spawn weight for the Tungsten Cube. Higher numbers mean it spawns more often.", (AcceptableValueBase)null, Array.Empty<object>())
},
new ConfigurableSetting
{
Index = ConfigIndexes.CarryWeight,
Section = ConfigSections.Customization.GetDescription(),
Key = "Carry weight",
DefaultValue = 41,
Description = new ConfigDescription("The carry weight of the Tungsten Cube. Higher numbers will weigh you down more when carrying it.", (AcceptableValueBase)null, Array.Empty<object>())
},
new ConfigurableSetting
{
Index = ConfigIndexes.ValueMin,
Section = ConfigSections.Customization.GetDescription(),
Key = "Minimum value",
DefaultValue = 90,
Description = new ConfigDescription("The minimum value of the Tungsten cube. This is the lowest random value it can be given.", (AcceptableValueBase)null, Array.Empty<object>())
},
new ConfigurableSetting
{
Index = ConfigIndexes.ValueMax,
Section = ConfigSections.Customization.GetDescription(),
Key = "Maximum value",
DefaultValue = 125,
Description = new ConfigDescription("The maximum value of the Tungsten cube. This is the highest random value it can be given.", (AcceptableValueBase)null, Array.Empty<object>())
}
};
public static ConfigEntryBase[] ConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[AllConfigSettings.Length];
private static string GetDescription(this Enum value)
{
FieldInfo field = value.GetType().GetField(value.ToString());
if (field.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false) is DescriptionAttribute[] source && source.Any())
{
return source.First().Description;
}
return value.ToString();
}
public static void BindConfigSettings()
{
for (int i = 0; i < AllConfigSettings.Length; i++)
{
TungstenCubeMod._logger.LogInfo((object)$"[{i}] Binding - {AllConfigSettings[i].Key}");
BindAnyObject(AllConfigSettings[i], i);
}
}
private static void BindAnyObject(ConfigurableSetting setting, int index)
{
if (setting.DefaultValue is int || setting.DefaultValue is Enum)
{
ConfigEntryBase[] configEntries = ConfigEntries;
string section = setting.Section;
string key = setting.Key;
int defaultValue = (int)setting.DefaultValue;
ConfigDescription description = setting.Description;
configEntries[index] = (ConfigEntryBase)(object)Bind(section, key, defaultValue, (description != null) ? description.Description : null);
}
else if (setting.DefaultValue is bool)
{
ConfigEntryBase[] configEntries2 = ConfigEntries;
string section2 = setting.Section;
string key2 = setting.Key;
bool defaultValue2 = (bool)setting.DefaultValue;
ConfigDescription description2 = setting.Description;
configEntries2[index] = (ConfigEntryBase)(object)Bind(section2, key2, defaultValue2, (description2 != null) ? description2.Description : null);
}
}
private static ConfigEntry<T> Bind<T>(string section, string key, T DefaultValue, string Description = null)
{
return ((BaseUnityPlugin)TungstenCubeMod._instance).Config.Bind<T>(section, key, DefaultValue, Description);
}
}
[BepInPlugin("TungstenCubeMod", "TungstenCubeMod", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class TungstenCubeMod : BaseUnityPlugin
{
public static AssetBundle CustomAssets;
public static TungstenCubeMod _instance;
public static ManualLogSource _logger;
private void Awake()
{
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TungstenCubeMod is loaded!");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
CustomAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "tungstencubebundle"));
if ((Object)(object)CustomAssets == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
return;
}
Item val = CustomAssets.LoadAsset<Item>("Assets/TungstenCube.asset");
_logger = ((BaseUnityPlugin)this).Logger;
ConfigSettings.BindConfigSettings();
int num = (int)ConfigSettings.ConfigEntries[0].BoxedValue;
val.minValue = (int)((float)(int)ConfigSettings.ConfigEntries[2].BoxedValue / 0.4f);
val.maxValue = (int)((float)(int)ConfigSettings.ConfigEntries[3].BoxedValue / 0.4f);
val.weight = 1.0001f + (float)(int)ConfigSettings.ConfigEntries[1].BoxedValue / 105f;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, num, (LevelTypes)(-1));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TungstenCubeMod";
public const string PLUGIN_NAME = "TungstenCubeMod";
public const string PLUGIN_VERSION = "1.2.0";
}
}