Decompiled source of SpawnPrefab v1.0.0

SpawnPrefab.dll

Decompiled 3 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SpawnPrefab")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8f9a700c2dc332104c262344c532fc8f8d927420")]
[assembly: AssemblyProduct("SpawnPrefab")]
[assembly: AssemblyTitle("SpawnPrefab")]
[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;
		}
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class IsExternalInit
	{
	}
}
namespace SpawnPrefab
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Lawlzee.SpawnPrefab", "SpawnPrefab", "1.0.0")]
	public class SpawnPrefabPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Lawlzee.SpawnPrefab";

		public const string PluginAuthor = "Lawlzee";

		public const string PluginName = "SpawnPrefab";

		public const string PluginVersion = "1.0.0";

		private const string _description = "`spawn_prefab <prefab_key> <pos_x> <pos_y> <pos_z> <rotation_x> <rotation_y> <rotation_z>`: Use the '~' prefix before a position value to make it relative to the player's position. Similarly, use the '~' prefix before a rotation value to make it relative to the prefab's base rotation. For a list of available prefabs, refer to https://xiaoxiao921.github.io/GithubActionCacheTest/assetPathsDump.html";

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			Lexer.IsIdentifierCharacter += new hook_IsIdentifierCharacter(Lexer_IsIdentifierCharacter);
		}

		private bool Lexer_IsIdentifierCharacter(orig_IsIdentifierCharacter orig, char character)
		{
			if (character != '~')
			{
				return orig.Invoke(character);
			}
			return true;
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		public static void SpawnPrefab(ConCommandArgs args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((ConCommandArgs)(ref args)).GetSenderBody().transform.position;
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)"spawn_prefab must have at least 1 argument. `spawn_prefab <prefab_key> <pos_x> <pos_y> <pos_z> <rotation_x> <rotation_y> <rotation_z>`: Use the '~' prefix before a position value to make it relative to the player's position. Similarly, use the '~' prefix before a rotation value to make it relative to the prefab's base rotation. For a list of available prefabs, refer to https://xiaoxiao921.github.io/GithubActionCacheTest/assetPathsDump.html");
				return;
			}
			string argString = ((ConCommandArgs)(ref args)).GetArgString(0);
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)argString).WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Debug.Log((object)("Prefab '" + argString + "' not found"));
				return;
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(GetValue(1).Apply(position.x), GetValue(2).Apply(position.y), GetValue(3).Apply(position.z));
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(GetValue(4).Apply(val.transform.rotation.x), GetValue(5).Apply(val.transform.rotation.y), GetValue(6).Apply(val.transform.rotation.z));
			Object.Instantiate<GameObject>(val, val2, Quaternion.Euler(val3));
			Debug.Log((object)$"Prefab '{argString}' spawned at {val2}");
			RelativeFloat GetValue(int index)
			{
				RelativeFloat result;
				if (index < ((ConCommandArgs)(ref args)).Count)
				{
					string argString2 = ((ConCommandArgs)(ref args)).GetArgString(index);
					float value = default(float);
					if (argString2.StartsWith("~") && TextSerialization.TryParseInvariant(argString2.Substring(1), ref value))
					{
						result = default(RelativeFloat);
						result.relative = true;
						result.value = value;
						return result;
					}
					float? num = ((ConCommandArgs)(ref args)).TryGetArgFloat(index);
					if (num.HasValue)
					{
						result = default(RelativeFloat);
						result.relative = false;
						result.value = num.Value;
						return result;
					}
				}
				result = default(RelativeFloat);
				result.relative = true;
				result.value = 0f;
				return result;
			}
		}
	}
	public struct RelativeFloat
	{
		public bool relative;

		public float value;

		public float Apply(float number)
		{
			if (!relative)
			{
				return value;
			}
			return number + value;
		}
	}
}