Decompiled source of FloodedOnly v1.0.0

GiftMod.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Logging;
using GiftMod.Patches;
using HarmonyLib;
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("GiftMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Make Christmas Special")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GiftMod")]
[assembly: AssemblyTitle("GiftMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 GiftMod
{
	[BepInPlugin("GiftWrap", "GiftWrap", "1.0.0")]
	public class GiftMod : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "GiftWrap";

		private const string PLUGIN_NAME = "GiftWrap";

		private const string PLUGIN_VERSION = "1.0.0";

		private readonly Harmony harmony = new Harmony("GiftWrap");

		public SelectableLevel loadedSelectableLevel;

		private List<SelectableLevel> selectableLevels = new List<SelectableLevel>();

		private List<SpawnableEnemyWithRarity> loadedEnemies = new List<SpawnableEnemyWithRarity>();

		private List<SpawnableItemWithRarity> grabbableObjects = new List<SpawnableItemWithRarity>();

		private AnimationCurve outsideEnemySpawn = new AnimationCurve();

		internal ManualLogSource mls;

		public static GiftMod Instance { get; private set; }

		public static SelectableLevel LoadedSelectableLevel { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			SelectableLevel val = LoadTitanLevelAsset();
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)$"Loaded asset - Type: {((object)val).GetType()}, PlanetName: {val.PlanetName}");
				selectableLevels.Add(val);
				loadedEnemies.AddRange(val.Enemies);
				loadedEnemies.Add(val.OutsideEnemies[1]);
				Debug.Log((object)loadedEnemies.Count);
				foreach (SpawnableEnemyWithRarity loadedEnemy in loadedEnemies)
				{
					Debug.Log((object)loadedEnemy.enemyType.enemyName);
				}
				grabbableObjects = val.spawnableScrap;
				outsideEnemySpawn = val.outsideEnemySpawnChanceThroughDay;
			}
			else
			{
				Debug.LogError((object)"Failed to load TitanLevel asset.");
			}
			mls = Logger.CreateLogSource("GiftWrap");
			mls.LogInfo((object)"Why are you looking at this Austin");
			harmony.PatchAll(typeof(GiftMod));
			harmony.PatchAll(typeof(changeWeatherType));
		}

		private SelectableLevel LoadTitanLevelAsset()
		{
			string text = Paths.PluginPath + "/gift/assetbundle/titanlevel";
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val != (Object)null)
			{
				Object val2 = val.LoadAsset("TitanLevel");
				if (val2 != (Object)null)
				{
					SelectableLevel val3 = (SelectableLevel)(object)((val2 is SelectableLevel) ? val2 : null);
					if ((Object)(object)val3 != (Object)null)
					{
						return val3;
					}
					Debug.LogError((object)"Failed to cast loaded asset to SelectableLevel.");
				}
				else
				{
					Debug.LogError((object)"Failed to load asset with name: TitanLevel from AssetBundle.");
				}
				val.Unload(false);
			}
			else
			{
				Debug.LogError((object)"Failed to load AssetBundle.");
			}
			return null;
		}

		public List<SelectableLevel> GetSelectableLevels()
		{
			return selectableLevels;
		}

		public List<SpawnableEnemyWithRarity> GetLoadedEnemies()
		{
			return loadedEnemies;
		}

		public List<SpawnableItemWithRarity> GetLoadedItems()
		{
			return grabbableObjects;
		}

		public AnimationCurve GetAnimationCurve()
		{
			return outsideEnemySpawn;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "GiftMod";

		public const string PLUGIN_NAME = "GiftMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace GiftMod.Patches
{
	public class changeWeatherType
	{
		[HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")]
		[HarmonyPrefix]
		private static bool prefixweather(StartOfRound __instance)
		{
			changeWeather(__instance);
			return false;
		}

		public static void changeWeather(StartOfRound __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < __instance.levels.Length; i++)
			{
				__instance.levels[i].currentWeather = (LevelWeatherType)4;
			}
			Random random = new Random(__instance.randomMapSeed + 31);
			List<SelectableLevel> list = __instance.levels.ToList();
			float num = 1f;
			int num2 = Mathf.Clamp((int)(Mathf.Clamp(__instance.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * num, 0f, 1f) * (float)__instance.levels.Length), 0, __instance.levels.Length);
			for (int j = 0; j < num2; j++)
			{
				SelectableLevel val = list[random.Next(0, list.Count)];
				if (val.randomWeathers != null && val.randomWeathers.Length != 0)
				{
					val.currentWeather = (LevelWeatherType)4;
				}
				list.Remove(val);
			}
		}
	}
}