Decompiled source of HiveSpawner v1.0.1

HiveSpawner.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HiveSpawner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HiveSpawner")]
[assembly: AssemblyTitle("HiveSpawner")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace HiveSpawner
{
	[BepInPlugin("com.github.toonu.hivespawner", "HiveSpawner", "1.0.0")]
	public class HiveSpawnerMod : BaseUnityPlugin
	{
		public const string pluginGuid = "com.github.toonu.hivespawner";

		public const string pluginName = "HiveSpawner";

		public const string pluginVersion = "1.0.0";

		private ConfigEntry<string> configSpawnStarName;

		private ConfigEntry<bool> configSpawnNewHive;

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"HiveSpawnerMod loaded");
			configSpawnStarName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StarName", "", "Name of the star next to which new hive is spawned. If not found, nearest star is used.");
			configSpawnNewHive = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "SpawnNewHive", true, "Spawn new hive on loading new game? Disable after first load or you will get more hives!");
		}

		public void Update()
		{
			if (DSPGame.IsMenuDemo || GameMain.localPlanet == null)
			{
				return;
			}
			StarData val = GameMain.localStar;
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"HiveSpawnerMod: Config variables: {configSpawnNewHive.Value}");
			if (!configSpawnNewHive.Value)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			StarData[] stars = GameMain.galaxy.stars;
			foreach (StarData val2 in stars)
			{
				if (val2.name.ToLower() == configSpawnStarName.Value.ToLower())
				{
					val = val2;
				}
			}
			EnemyDFHiveSystem val3 = GameMain.data.spaceSector.TryCreateNewHive(val);
			val3.SetForNewGame();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"HiveSpawnerMod: Creating new hive at {val.displayName} with {val3.orbitRadius} orbit.");
			((Behaviour)this).enabled = false;
		}
	}
}