Decompiled source of Knusperdino v2.0.1

LC_Knusperdino.dll

Decompiled 3 months ago
using System;
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 CSync.Extensions;
using CSync.Lib;
using HarmonyLib;
using Knusperdino.ConfigSync;
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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LC_Knusperdino")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+ea5561e933df51fa53339c28f4d914e94f4e16b2")]
[assembly: AssemblyProduct("Knusperdino")]
[assembly: AssemblyTitle("LC_Knusperdino")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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.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;
		}
	}
	[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 Knusperdino
{
	[BepInPlugin("LC_Knusperdino", "Knusperdino", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.sigurd.csync", "5.0.0")]
	public class Knusperdino : BaseUnityPlugin
	{
		internal static KnusperConfig Config;

		public static Knusperdino Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Config = new KnusperConfig(((BaseUnityPlugin)this).Config);
			smallDinoScrap(Config.smallDinoMin.Value, Config.smallDinoMax.Value, Config.smallDinoSpawnWeight.Value);
			mediumDinoScrap(Config.mediumDinoMin.Value, Config.mediumDinoMax.Value, Config.mediumDinoSpawnWeight.Value);
			bigDinoScrap(Config.bigDinoMin.Value, Config.bigDinoMax.Value, Config.bigDinoSpawnWeight.Value);
			Logger.LogInfo((object)"LC_Knusperdino v2.0.0 has loaded! | LONG LIVE THE KNUSPERDINOS!!!");
			((SyncedConfig2<KnusperConfig>)(object)Config).InitialSyncCompleted += delegate
			{
				Logger.LogInfo((object)"Initial sync complete!");
			};
		}

		internal void smallDinoScrap(int min, int max, int weight)
		{
			if (max < min)
			{
				min = 35;
				max = 69;
				Logger.LogWarning((object)"[Small Dino Scrap] Custom config values are wrong! Check if the values are right. Loaded default values");
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "smallknusperdino");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets (Small Dino Scrap).");
				return;
			}
			Item val2 = val.LoadAsset<Item>("Assets/Scrap/SmallDinoItem.asset");
			val2.maxValue = Convert.ToInt32((double)max / 0.4);
			val2.minValue = Convert.ToInt32((double)min / 0.4);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterScrap(val2, weight, (LevelTypes)(-1));
		}

		internal void mediumDinoScrap(int min, int max, int weight)
		{
			if (max < min)
			{
				min = 69;
				max = 100;
				Logger.LogWarning((object)"[Medium Dino Scrap] Custom config values are wrong! Check if the values are right. Loaded default values");
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mediumknusperdino");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets (Medium Dino Scrap).");
				return;
			}
			Item val2 = val.LoadAsset<Item>("Assets/Scrap/MediumDinoItem.asset");
			val2.maxValue = Convert.ToInt32((double)max / 0.4);
			val2.minValue = Convert.ToInt32((double)min / 0.4);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterScrap(val2, weight, (LevelTypes)(-1));
		}

		internal void bigDinoScrap(int min, int max, int weight)
		{
			if (max < min)
			{
				min = 100;
				max = 130;
				Logger.LogWarning((object)"[Big Dino Scrap] Custom config values are wrong! Check if the values are right. Loaded default values");
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bigknusperdino");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets (Big Dino Scrap).");
				return;
			}
			Item val2 = val.LoadAsset<Item>("Assets/Scrap/BigDinoItem.asset");
			val2.maxValue = Convert.ToInt32((double)max / 0.4);
			val2.minValue = Convert.ToInt32((double)min / 0.4);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterScrap(val2, weight, (LevelTypes)(-1));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LC_Knusperdino";

		public const string PLUGIN_NAME = "Knusperdino";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace Knusperdino.ConfigSync
{
	public class KnusperConfig : SyncedConfig2<KnusperConfig>
	{
		[SyncedEntryField]
		public SyncedEntry<int> bigDinoMin;

		[SyncedEntryField]
		public SyncedEntry<int> bigDinoMax;

		[SyncedEntryField]
		public SyncedEntry<int> mediumDinoMin;

		[SyncedEntryField]
		public SyncedEntry<int> mediumDinoMax;

		[SyncedEntryField]
		public SyncedEntry<int> smallDinoMin;

		[SyncedEntryField]
		public SyncedEntry<int> smallDinoMax;

		[SyncedEntryField]
		public SyncedEntry<int> smallDinoSpawnWeight;

		[SyncedEntryField]
		public SyncedEntry<int> mediumDinoSpawnWeight;

		[SyncedEntryField]
		public SyncedEntry<int> bigDinoSpawnWeight;

		public KnusperConfig(ConfigFile cfg)
			: base("LC_Knusperdino")
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0065: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0092: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00bf: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00ec: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0119: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0145: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_0172: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_019f: Expected O, but got Unknown
			bigDinoMax = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Big Dino Max value"), 130, new ConfigDescription("Max value for the big dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			bigDinoMin = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Big Dino Min value"), 100, new ConfigDescription("Min value for the big dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			mediumDinoMax = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Medium Dino Max value"), 100, new ConfigDescription("Max value for the medium dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			mediumDinoMin = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Medium Dino Min value"), 69, new ConfigDescription("Min value for the medium dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			smallDinoMax = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Small Dino Max value"), 69, new ConfigDescription("Max value for the small dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			smallDinoMin = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Scrap value", "Small Dino Min value"), 35, new ConfigDescription("Min value for the small dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			bigDinoSpawnWeight = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Spawn weight", "Big Dino Spawning Weight"), 5, new ConfigDescription("Spawn weight for the big dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			mediumDinoSpawnWeight = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Spawn weight", "Medium Dino Spawning Weight"), 10, new ConfigDescription("Spawn weight for the medium dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			smallDinoSpawnWeight = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("Spawn weight", "Small Dino Spawning Weight"), 15, new ConfigDescription("Spawn weight for the small dino scrap", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigManager.Register<KnusperConfig>((SyncedConfig2<KnusperConfig>)(object)this);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}