Decompiled source of Starmageddon Stuff v1.0.1

BepInEx/plugins/StarmageddonScrap.dll

Decompiled 10 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("StarmageddonScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StarmageddonScrap")]
[assembly: AssemblyTitle("StarmageddonScrap")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Vulfox.StarmageddonScrap
{
	[BepInPlugin("vulfox.starmageddon", "Starmageddon Scrap", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "vulfox.starmageddon";

		public const string ModName = "Starmageddon Scrap";

		public const string ModVersion = "1.0.0";

		private const string BundleFileName = "starscrap";

		private AssetBundle _assetBundle;

		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if (string.IsNullOrEmpty(directoryName))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not determine the plugin directory.");
				return;
			}
			string text = Path.Combine(directoryName, "starscrap");
			_assetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_assetBundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not load asset bundle: " + text));
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded asset bundle: starscrap");
			RegisterScrap("Assets/SittingRoxyPlushScrap/SittingRoxyPlushItem.asset", 30);
			RegisterScrap("Assets/SittingRoxyPlushScrap/DelphoxPlushItem.asset", 30);
			RegisterScrap("Assets/SittingRoxyPlushScrap/SerperiorPlushItem.asset", 30);
			RegisterScrap("Assets/SittingRoxyPlushScrap/BugDiverPlushItem.asset", 30);
			RegisterScrap("Assets/SittingRoxyPlushScrap/CarPlushItem.asset", 30);
			RegisterScrap("Assets/SittingRoxyPlushScrap/PlushtrapItem.asset", 30);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Finished registering all Starmageddon scrap items.");
		}

		private void RegisterScrap(string itemAssetPath, int rarity)
		{
			Item val = _assetBundle.LoadAsset<Item>(itemAssetPath);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not load Item asset: " + itemAssetPath));
				return;
			}
			if ((Object)(object)val.spawnPrefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(val.itemName + " does not have a Spawn Prefab."));
				return;
			}
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Registered scrap item: " + val.itemName + " " + $"with rarity {rarity}"));
		}
	}
}