Decompiled source of RepoSandboxMod v1.0.4

BepInEx\plugins\RepoSandboxMod.dll

Decompiled 4 minutes ago
using System;
using System.Collections;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[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("RepoSandboxMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("RepoSandboxMod")]
[assembly: AssemblyTitle("RepoSandboxMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[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 RepoSandboxMod
{
	[BepInPlugin("com.custom.reposandbox", "R.E.P.O. Sandbox & Testing Mod", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.custom.reposandbox";

		public const string PluginName = "R.E.P.O. Sandbox & Testing Mod";

		public const string PluginVersion = "1.0.4";

		internal static ManualLogSource Log;

		internal static ConfigEntry<KeyCode> ToggleMenuKey;

		internal static ConfigEntry<KeyCode> DeleteTargetKey;

		private void Awake()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ToggleMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleMenuKey", (KeyCode)282, "Key to open/close the Sandbox Menu");
			DeleteTargetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "DeleteTargetKey", (KeyCode)127, "Key to delete the entity or item you are looking at");
			GameObject val = new GameObject("RepoSandboxController");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<SandboxController>();
			Log.LogInfo((object)"R.E.P.O. Sandbox & Testing Mod v1.0.4 loaded!");
		}
	}
	public class SandboxController : MonoBehaviour
	{
		private class SpawnableEntry
		{
			public string DisplayName;

			public List<GameObject> Prefabs = new List<GameObject>();

			public List<string> ResourcePaths = new List<string>();
		}

		private bool _menuOpen;

		private int _selectedTab;

		private readonly string[] _tabs = new string[3] { "Items", "Entities", "Arena & Light" };

		private Rect _windowRect = new Rect(30f, 30f, 520f, 670f);

		private Vector2 _scrollPos = Vector2.zero;

		private Vector2 _activeEnemyScroll = Vector2.zero;

		private string _searchQuery = "";

		private string _statusMessage = "Ready. Press 'Reload All DB' if lists are empty.";

		private List<SpawnableEntry> _itemEntries = new List<SpawnableEntry>();

		private List<SpawnableEntry> _enemyEntries = new List<SpawnableEntry>();

		private List<GameObject> _spawnedObjects = new List<GameObject>();

		private GameObject _arenaRoot;

		private NavMeshDataInstance _arenaNavMeshInstance;

		private Light _fullbrightLight;

		private bool _isFullbright;

		private bool _freezeEnemies;

		private Vector3 _savedPosition = Vector3.zero;

		private bool _hasSavedPosition;

		private const float ArenaFloorY = 500f;

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(Plugin.ToggleMenuKey.Value))
			{
				_menuOpen = !_menuOpen;
				if (_menuOpen && (_itemEntries.Count == 0 || _enemyEntries.Count == 0))
				{
					RefreshDatabase();
				}
			}
			if (_menuOpen)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
			if (Input.GetKeyDown(Plugin.DeleteTargetKey.Value))
			{
				DeleteLookAtTarget();
			}
			MaintainArenaEntities();
		}

		private void MaintainArenaEntities()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = default(Vector3);
			foreach (GameObject item in FindActiveEnemies())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				Rigidbody[] componentsInChildren2;
				if (_freezeEnemies)
				{
					NavMeshAgent[] componentsInChildren = item.GetComponentsInChildren<NavMeshAgent>();
					foreach (NavMeshAgent val in componentsInChildren)
					{
						if (val.isOnNavMesh)
						{
							val.isStopped = true;
						}
					}
					componentsInChildren2 = item.GetComponentsInChildren<Rigidbody>();
					for (int i = 0; i < componentsInChildren2.Length; i++)
					{
						componentsInChildren2[i].velocity = Vector3.zero;
					}
				}
				if (!((Object)(object)_arenaRoot != (Object)null) || !(Mathf.Abs(item.transform.position.x) < 60f) || !(Mathf.Abs(item.transform.position.z) < 60f))
				{
					continue;
				}
				if (item.transform.position.y > 470f && item.transform.position.y < 499.5f)
				{
					((Vector3)(ref position))..ctor(item.transform.position.x, 500.8f, item.transform.position.z);
					item.transform.position = position;
				}
				componentsInChildren2 = item.GetComponentsInChildren<Rigidbody>();
				foreach (Rigidbody val2 in componentsInChildren2)
				{
					if ((Object)(object)val2 != (Object)null && ((Component)val2).transform.position.y > 470f && ((Component)val2).transform.position.y < 499.5f)
					{
						val2.velocity = Vector3.zero;
						val2.position = new Vector3(val2.position.x, 500.8f, val2.position.z);
					}
				}
			}
		}

		private void OnGUI()
		{
			//IL_001d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if (_menuOpen)
			{
				GUI.backgroundColor = new Color(0.12f, 0.14f, 0.18f, 0.96f);
				_windowRect = GUI.Window(88421, _windowRect, new WindowFunction(DrawWindow), $"R.E.P.O. Sandbox v1.0.4 [{Plugin.ToggleMenuKey.Value}: Menu | {Plugin.DeleteTargetKey.Value}: Delete]");
			}
		}

		private void DrawWindow(int windowId)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			_selectedTab = GUILayout.Toolbar(_selectedTab, _tabs, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
			GUILayout.Space(6f);
			if (_selectedTab == 0)
			{
				DrawItemsTab();
			}
			else if (_selectedTab == 1)
			{
				DrawEntitiesTab();
			}
			else if (_selectedTab == 2)
			{
				DrawArenaTab();
			}
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.Label("Status: " + _statusMessage, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 25f));
		}

		private void DrawItemsTab()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
			_searchQuery = GUILayout.TextField(_searchQuery, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Reload All DB", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				RefreshDatabase();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(5f);
			GUILayout.Label($"Loaded Items & Weapons: {_itemEntries.Count}", Array.Empty<GUILayoutOption>());
			_scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(460f) });
			foreach (SpawnableEntry itemEntry in _itemEntries)
			{
				if (string.IsNullOrEmpty(_searchQuery) || itemEntry.DisplayName.IndexOf(_searchQuery, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
					GUILayout.Label(itemEntry.DisplayName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					if (GUILayout.Button("Spawn", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
					{
						SpawnItem(itemEntry);
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Space(5f);
			if (GUILayout.Button("Clear All Spawned Items & Dummies", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				ClearSpawnedObjects();
			}
		}

		private void DrawEntitiesTab()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) });
			_searchQuery = GUILayout.TextField(_searchQuery, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Reload All DB", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				RefreshDatabase();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button($"Delete Aimed [{Plugin.DeleteTargetKey.Value}]", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				DeleteLookAtTarget();
			}
			if (GUILayout.Button("Destroy All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				DestroyAllEnemies();
			}
			if (GUILayout.Button(_freezeEnemies ? "AI Freeze: ON" : "AI Freeze: OFF", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				ToggleFreezeEnemies(!_freezeEnemies);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			GUILayout.Label($"Available Entities: {_enemyEntries.Count}", Array.Empty<GUILayoutOption>());
			_scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(250f) });
			foreach (SpawnableEntry enemyEntry in _enemyEntries)
			{
				if (string.IsNullOrEmpty(_searchQuery) || enemyEntry.DisplayName.IndexOf(_searchQuery, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
					GUILayout.Label(enemyEntry.DisplayName ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					if (GUILayout.Button("Spawn", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
					{
						SpawnEntity(enemyEntry);
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Space(6f);
			GUILayout.Label("Active Entities in Scene:", Array.Empty<GUILayoutOption>());
			_activeEnemyScroll = GUILayout.BeginScrollView(_activeEnemyScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(140f) });
			foreach (GameObject item in FindActiveEnemies())
			{
				if (!((Object)(object)item == (Object)null))
				{
					GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
					GUILayout.Label(((Object)item).name.Replace("(Clone)", ""), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					if (GUILayout.Button("Destroy", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(75f) }))
					{
						DestroyNetworkOrLocal(item);
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.EndScrollView();
		}

		private void DrawArenaTab()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("<b>1. Training & Testing Arena (100m x 100m + Ground Layer Sync)</b>", new GUIStyle(GUI.skin.label)
			{
				richText = true
			}, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Creates a solid 10m-thick floor matching the game's ground collision layer so entities never sink.", Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			if (GUILayout.Button("Build & Teleport to Testing Arena", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
			{
				BuildAndTeleportToArena();
			}
			GUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Spawn Dummy Target Box", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				SpawnDummyTarget();
			}
			if (_hasSavedPosition && GUILayout.Button("Return to Original Map", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				TeleportPlayer(_savedPosition);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(15f);
			GUILayout.Label("<b>2. Lighting & Environment</b>", new GUIStyle(GUI.skin.label)
			{
				richText = true
			}, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			if (GUILayout.Button(_isFullbright ? "Fullbright Mode: ON (Click to Disable)" : "Fullbright Mode: OFF (Click to Enable)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
			{
				ToggleFullbright(!_isFullbright);
			}
		}

		public void RefreshDatabase()
		{
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			_itemEntries.Clear();
			_enemyEntries.Clear();
			try
			{
				Resources.LoadAll<ScriptableObject>("");
				Resources.LoadAll<GameObject>("Items");
				Resources.LoadAll<GameObject>("Enemies");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Resources.LoadAll warning: " + ex.Message));
			}
			List<object> list = new List<object>();
			list.AddRange(Resources.FindObjectsOfTypeAll<ScriptableObject>());
			MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
			foreach (MonoBehaviour val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					switch (((object)val).GetType().Name)
					{
					case "StatsManager":
					case "EnemyDirector":
					case "ShopManager":
					case "PunManager":
						ExtractNestedObjects(val, list);
						break;
					}
				}
			}
			foreach (object item in list)
			{
				ScriptableObject val2 = (ScriptableObject)((item is ScriptableObject) ? item : null);
				if (val2 == null || (Object)(object)val2 == (Object)null)
				{
					continue;
				}
				string name = ((object)val2).GetType().Name;
				if (name == "Item")
				{
					GameObject val3 = FindAnyGameObjectField(val2);
					string displayName = FindAnyStringField(val2, new string[3] { "itemName", "displayName", "name" }) ?? ((Object)val2).name;
					if ((Object)(object)val3 != (Object)null)
					{
						AddItemEntry(displayName, val3);
					}
				}
				else
				{
					if (!(name == "EnemySetup"))
					{
						continue;
					}
					List<GameObject> list2 = FindAllGameObjectsInLists(val2);
					if (list2.Count == 0)
					{
						GameObject val4 = FindAnyGameObjectField(val2);
						if ((Object)(object)val4 != (Object)null)
						{
							list2.Add(val4);
						}
					}
					if (list2.Count > 0)
					{
						string text = ((Object)val2).name.Replace("Enemy - ", "").Replace("Setup", "").Trim();
						if (string.IsNullOrEmpty(text))
						{
							text = ((Object)list2[0]).name;
						}
						AddEnemyEntry(text, list2);
					}
				}
			}
			GameObject[] array2 = Resources.FindObjectsOfTypeAll<GameObject>();
			foreach (GameObject val5 in array2)
			{
				if ((Object)(object)val5 == (Object)null)
				{
					continue;
				}
				Scene scene = val5.scene;
				if (!((Scene)(ref scene)).IsValid())
				{
					if ((Object)(object)val5.GetComponent("ItemAttributes") != (Object)null || (Object)(object)val5.GetComponent("ItemEquippable") != (Object)null || (Object)(object)val5.GetComponent("ItemGun") != (Object)null || (Object)(object)val5.GetComponent("ItemMelee") != (Object)null)
					{
						AddItemEntry(((Object)val5).name, val5);
					}
					else if ((Object)(object)val5.GetComponent("EnemyParent") != (Object)null)
					{
						string displayName2 = ((Object)val5).name.Replace("Enemy - ", "").Trim();
						AddEnemyEntry(displayName2, new List<GameObject> { val5 });
					}
				}
			}
			_itemEntries = _itemEntries.OrderBy((SpawnableEntry x) => x.DisplayName).ToList();
			_enemyEntries = _enemyEntries.OrderBy((SpawnableEntry x) => x.DisplayName).ToList();
			_statusMessage = $"Loaded {_itemEntries.Count} items & {_enemyEntries.Count} entities.";
		}

		private void AddItemEntry(string displayName, GameObject prefab)
		{
			if (!((Object)(object)prefab == (Object)null) && !_itemEntries.Any((SpawnableEntry x) => x.Prefabs.Contains(prefab) || x.DisplayName == displayName))
			{
				string item = ResolveResourcePath(prefab, "Items/");
				_itemEntries.Add(new SpawnableEntry
				{
					DisplayName = displayName,
					Prefabs = new List<GameObject> { prefab },
					ResourcePaths = new List<string> { item }
				});
			}
		}

		private void AddEnemyEntry(string displayName, List<GameObject> prefabs)
		{
			if (prefabs != null && prefabs.Count != 0 && !_enemyEntries.Any((SpawnableEntry x) => x.DisplayName == displayName))
			{
				List<string> resourcePaths = prefabs.Select((GameObject p) => ResolveResourcePath(p, "Enemies/")).ToList();
				_enemyEntries.Add(new SpawnableEntry
				{
					DisplayName = displayName,
					Prefabs = prefabs,
					ResourcePaths = resourcePaths
				});
			}
		}

		private string ResolveResourcePath(GameObject prefab, string defaultFolder)
		{
			string text = defaultFolder + ((Object)prefab).name;
			if ((Object)(object)Resources.Load<GameObject>(text) != (Object)null)
			{
				return text;
			}
			if ((Object)(object)Resources.Load<GameObject>(((Object)prefab).name) != (Object)null)
			{
				return ((Object)prefab).name;
			}
			IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool;
			DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null);
			if (val != null && !val.ResourceCache.ContainsKey(((Object)prefab).name))
			{
				val.ResourceCache[((Object)prefab).name] = prefab;
			}
			return ((Object)prefab).name;
		}

		private void SpawnItem(SpawnableEntry entry)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 pos = GetGroundedSpawnPosition(2.5f) + Vector3.up * 0.6f;
			GameObject val = InstantiateNetworkOrLocal(entry.Prefabs[0], entry.ResourcePaths[0], pos, Quaternion.identity);
			if ((Object)(object)val != (Object)null)
			{
				_spawnedObjects.Add(val);
				_statusMessage = "Spawned Item: " + entry.DisplayName;
			}
		}

		private void SpawnEntity(SpawnableEntry entry)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = GetGroundedSpawnPosition(4.5f);
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val, ref val2, 6f, -1))
			{
				val = ((NavMeshHit)(ref val2)).position;
			}
			Vector3 val3 = val + Vector3.up * 1f;
			List<GameObject> list = new List<GameObject>();
			for (int i = 0; i < entry.Prefabs.Count; i++)
			{
				GameObject val4 = entry.Prefabs[i];
				string resPath = entry.ResourcePaths[i];
				if (!((Object)(object)val4 == (Object)null))
				{
					GameObject val5 = InstantiateNetworkOrLocal(val4, resPath, val3, Quaternion.identity);
					if ((Object)(object)val5 != (Object)null)
					{
						list.Add(val5);
					}
				}
			}
			if (list.Count > 0)
			{
				((MonoBehaviour)this).StartCoroutine(StabilizeSpawnedEntity(list, val, val3));
				_statusMessage = "Spawned Entity: " + entry.DisplayName;
			}
		}

		private GameObject InstantiateNetworkOrLocal(GameObject prefab, string resPath, Vector3 pos, Quaternion rot)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			GameObject val = null;
			try
			{
				if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
				{
					IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool;
					DefaultPool val2 = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null);
					if (val2 != null && !val2.ResourceCache.ContainsKey(resPath))
					{
						val2.ResourceCache[resPath] = prefab;
					}
					val = PhotonNetwork.Instantiate(resPath, pos, rot, (byte)0, (object[])null);
				}
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Object.Instantiate<GameObject>(prefab, pos, rot);
			}
			return val;
		}

		private IEnumerator StabilizeSpawnedEntity(List<GameObject> group, Vector3 groundPos, Vector3 elevatedPos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val3 = default(NavMeshHit);
			for (int frame = 0; frame < 30; frame++)
			{
				foreach (GameObject item in group)
				{
					if ((Object)(object)item == (Object)null)
					{
						continue;
					}
					item.SetActive(true);
					Transform[] componentsInChildren = item.GetComponentsInChildren<Transform>(true);
					foreach (Transform val in componentsInChildren)
					{
						if ((Object)(object)val != (Object)null && !((Component)val).gameObject.activeSelf)
						{
							((Component)val).gameObject.SetActive(true);
						}
					}
					Component component = item.GetComponent("EnemyParent");
					if ((Object)(object)component != (Object)null)
					{
						Type type = ((object)component).GetType();
						FieldInfo fieldInfo = AccessTools.Field(type, "Spawned");
						if (fieldInfo != null && fieldInfo.FieldType == typeof(bool))
						{
							fieldInfo.SetValue(component, true);
						}
						FieldInfo fieldInfo2 = AccessTools.Field(type, "SpawnTimer");
						if (fieldInfo2 != null && fieldInfo2.FieldType == typeof(float))
						{
							fieldInfo2.SetValue(component, 0f);
						}
						FieldInfo fieldInfo3 = AccessTools.Field(type, "DespawnedTimer");
						if (fieldInfo3 != null && fieldInfo3.FieldType == typeof(float))
						{
							fieldInfo3.SetValue(component, 0f);
						}
						if (frame == 1)
						{
							MethodInfo methodInfo = AccessTools.Method(type, "Spawn", (Type[])null, (Type[])null);
							if (methodInfo != null && methodInfo.GetParameters().Length == 0)
							{
								try
								{
									methodInfo.Invoke(component, null);
								}
								catch
								{
								}
							}
						}
					}
					if (frame >= 8)
					{
						continue;
					}
					item.transform.position = elevatedPos;
					Rigidbody[] componentsInChildren2 = item.GetComponentsInChildren<Rigidbody>(true);
					foreach (Rigidbody obj2 in componentsInChildren2)
					{
						obj2.velocity = Vector3.zero;
						obj2.useGravity = true;
					}
					NavMeshAgent[] componentsInChildren3 = item.GetComponentsInChildren<NavMeshAgent>(true);
					foreach (NavMeshAgent val2 in componentsInChildren3)
					{
						((Behaviour)val2).enabled = true;
						if (NavMesh.SamplePosition(groundPos, ref val3, 6f, -1))
						{
							val2.Warp(((NavMeshHit)(ref val3)).position);
						}
						val2.isStopped = _freezeEnemies;
					}
				}
				yield return null;
			}
		}

		private Vector3 GetGroundedSpawnPosition(float forwardDistance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return Vector3.zero;
			}
			Vector3 forward = ((Component)main).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val = ((Component)main).transform.position + forward * forwardDistance;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(new Vector3(val.x, ((Component)main).transform.position.y + 3f, val.z), Vector3.down, ref val2, 30f))
			{
				return ((RaycastHit)(ref val2)).point;
			}
			GameObject val3 = FindLocalPlayerObject();
			float num = (((Object)(object)val3 != (Object)null) ? val3.transform.position.y : (((Component)main).transform.position.y - 1.5f));
			return new Vector3(val.x, num, val.z);
		}

		private void ToggleFreezeEnemies(bool freeze)
		{
			_freezeEnemies = freeze;
			foreach (GameObject item in FindActiveEnemies())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				NavMeshAgent[] componentsInChildren = item.GetComponentsInChildren<NavMeshAgent>();
				foreach (NavMeshAgent val in componentsInChildren)
				{
					if (val.isOnNavMesh)
					{
						val.isStopped = freeze;
					}
				}
			}
		}

		private void DeleteLookAtTarget()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			RaycastHit val = default(RaycastHit);
			if ((Object)(object)main == (Object)null || !Physics.Raycast(new Ray(((Component)main).transform.position, ((Component)main).transform.forward), ref val, 25f))
			{
				return;
			}
			Transform val2 = ((RaycastHit)(ref val)).transform;
			while ((Object)(object)val2 != (Object)null)
			{
				if ((Object)(object)((Component)val2).GetComponent("EnemyParent") != (Object)null || (Object)(object)((Component)val2).GetComponent("Enemy") != (Object)null || (Object)(object)((Component)val2).GetComponent("ItemAttributes") != (Object)null || (Object)(object)((Component)val2).GetComponent("PhysGrabObject") != (Object)null || ((Object)val2).name.StartsWith("DummyTarget"))
				{
					_statusMessage = "Deleted: " + ((Object)val2).name;
					DestroyNetworkOrLocal(((Component)val2).gameObject);
					break;
				}
				val2 = val2.parent;
			}
		}

		private List<GameObject> FindActiveEnemies()
		{
			List<GameObject> list = new List<GameObject>();
			MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
			foreach (MonoBehaviour val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string name = ((object)val).GetType().Name;
					if ((name == "EnemyParent" || (name == "Enemy" && (Object)(object)((Component)val).transform.parent == (Object)null)) && !list.Contains(((Component)val).gameObject))
					{
						list.Add(((Component)val).gameObject);
					}
				}
			}
			return list;
		}

		private void DestroyAllEnemies()
		{
			List<GameObject> list = FindActiveEnemies();
			foreach (GameObject item in list)
			{
				DestroyNetworkOrLocal(item);
			}
			_statusMessage = $"Destroyed {list.Count} entities.";
		}

		private void ClearSpawnedObjects()
		{
			foreach (GameObject spawnedObject in _spawnedObjects)
			{
				if ((Object)(object)spawnedObject != (Object)null)
				{
					DestroyNetworkOrLocal(spawnedObject);
				}
			}
			_spawnedObjects.Clear();
			_statusMessage = "Cleared spawned items & dummies.";
		}

		private void DestroyNetworkOrLocal(GameObject target)
		{
			if (!((Object)(object)target == (Object)null))
			{
				PhotonView component = target.GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null && PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
				{
					PhotonNetwork.Destroy(component);
				}
				else
				{
					Object.Destroy((Object)(object)target);
				}
			}
		}

		private int DetectGameGroundLayer()
		{
			//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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindLocalPlayerObject();
			RaycastHit val2 = default(RaycastHit);
			if ((Object)(object)val != (Object)null && Physics.Raycast(val.transform.position + Vector3.up * 1f, Vector3.down, ref val2, 10f) && (Object)(object)((RaycastHit)(ref val2)).collider != (Object)null && !((RaycastHit)(ref val2)).collider.isTrigger)
			{
				Transform root = ((Component)((RaycastHit)(ref val2)).collider).transform.root;
				GameObject arenaRoot = _arenaRoot;
				if ((Object)(object)root != (Object)(object)((arenaRoot != null) ? arenaRoot.transform : null))
				{
					return ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer;
				}
			}
			Collider[] array = Object.FindObjectsOfType<Collider>();
			foreach (Collider val3 in array)
			{
				if (!((Object)(object)val3 != (Object)null) || val3.isTrigger || ((Component)val3).gameObject.layer == 2 || ((Component)val3).gameObject.layer == 5)
				{
					continue;
				}
				Bounds bounds = val3.bounds;
				if (((Bounds)(ref bounds)).size.x > 4f)
				{
					bounds = val3.bounds;
					if (((Bounds)(ref bounds)).size.z > 4f)
					{
						return ((Component)val3).gameObject.layer;
					}
				}
			}
			return 0;
		}

		private void BuildAndTeleportToArena()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 500f, 0f);
			int num = DetectGameGroundLayer();
			if ((Object)(object)_arenaRoot == (Object)null)
			{
				_arenaRoot = new GameObject("RepoSandbox_TestingArena");
				_arenaRoot.layer = num;
				Object.DontDestroyOnLoad((Object)(object)_arenaRoot);
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)obj).name = "ArenaFloor";
				obj.layer = num;
				obj.transform.SetParent(_arenaRoot.transform);
				obj.transform.position = val + new Vector3(0f, -5f, 0f);
				obj.transform.localScale = new Vector3(100f, 10f, 100f);
				obj.GetComponent<Renderer>().material.color = new Color(0.78f, 0.8f, 0.82f);
				CreateWall("Wall_North", val + new Vector3(0f, 5f, 50f), new Vector3(100f, 10f, 1f), num);
				CreateWall("Wall_South", val + new Vector3(0f, 5f, -50f), new Vector3(100f, 10f, 1f), num);
				CreateWall("Wall_East", val + new Vector3(50f, 5f, 0f), new Vector3(1f, 10f, 100f), num);
				CreateWall("Wall_West", val + new Vector3(-50f, 5f, 0f), new Vector3(1f, 10f, 100f), num);
				float[] array = new float[4] { 10f, 20f, 30f, 40f };
				foreach (float num2 in array)
				{
					CreateMarker(val + new Vector3(5f, 1.5f, num2), new Color(0.2f, 0.6f, 0.9f), num);
					CreateMarker(val + new Vector3(-5f, 1.5f, num2), new Color(0.2f, 0.6f, 0.9f), num);
				}
				for (int j = -2; j <= 2; j++)
				{
					CreateDummyCube(val + new Vector3((float)j * 3f, 1.2f, 12f), num);
				}
				BuildStandardUnityNavMesh(val);
			}
			ToggleFullbright(enable: true);
			GameObject val2 = FindLocalPlayerObject();
			if ((Object)(object)val2 != (Object)null)
			{
				if (!_hasSavedPosition)
				{
					_savedPosition = val2.transform.position;
					_hasSavedPosition = true;
				}
				TeleportPlayer(val + new Vector3(0f, 1.5f, 0f));
				_statusMessage = $"Arena ready (Layer {num}, 10m thick floor).";
			}
		}

		private void BuildStandardUnityNavMesh(Vector3 arenaCenter)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NavMeshBuildSettings settingsByID = NavMesh.GetSettingsByID(0);
				List<NavMeshBuildSource> list = new List<NavMeshBuildSource>();
				NavMeshBuildSource item = default(NavMeshBuildSource);
				((NavMeshBuildSource)(ref item)).shape = (NavMeshBuildSourceShape)2;
				((NavMeshBuildSource)(ref item)).size = new Vector3(100f, 10f, 100f);
				((NavMeshBuildSource)(ref item)).transform = Matrix4x4.TRS(arenaCenter + new Vector3(0f, -5f, 0f), Quaternion.identity, Vector3.one);
				((NavMeshBuildSource)(ref item)).area = 0;
				list.Add(item);
				List<NavMeshBuildSource> list2 = list;
				Bounds val = default(Bounds);
				((Bounds)(ref val))..ctor(arenaCenter, new Vector3(120f, 30f, 120f));
				NavMeshData val2 = NavMeshBuilder.BuildNavMeshData(settingsByID, list2, val, arenaCenter, Quaternion.identity);
				if ((Object)(object)val2 != (Object)null)
				{
					_arenaNavMeshInstance = NavMesh.AddNavMeshData(val2);
				}
			}
			catch
			{
			}
		}

		private void CreateWall(string name, Vector3 pos, Vector3 scale, int layer)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.layer = layer;
			obj.transform.SetParent(_arenaRoot.transform);
			obj.transform.position = pos;
			obj.transform.localScale = scale;
			obj.GetComponent<Renderer>().material.color = new Color(0.45f, 0.48f, 0.52f);
		}

		private void CreateMarker(Vector3 pos, Color color, int layer)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			obj.layer = layer;
			obj.transform.SetParent(_arenaRoot.transform);
			obj.transform.position = pos;
			obj.transform.localScale = new Vector3(0.4f, 1.5f, 0.4f);
			obj.GetComponent<Renderer>().material.color = color;
		}

		private void SpawnDummyTarget()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			int layer = (((Object)(object)_arenaRoot != (Object)null) ? _arenaRoot.layer : 0);
			CreateDummyCube(GetGroundedSpawnPosition(3.5f) + Vector3.up * 1.1f, layer);
		}

		private void CreateDummyCube(Vector3 pos, int layer)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "DummyTarget";
			val.layer = layer;
			val.transform.position = pos;
			val.transform.localScale = new Vector3(1.2f, 1.8f, 1.2f);
			val.GetComponent<Renderer>().material.color = new Color(0.9f, 0.35f, 0.25f);
			val.AddComponent<Rigidbody>().mass = 15f;
			_spawnedObjects.Add(val);
		}

		private void ToggleFullbright(bool enable)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			_isFullbright = enable;
			if (enable)
			{
				RenderSettings.fog = false;
				RenderSettings.ambientMode = (AmbientMode)3;
				RenderSettings.ambientLight = new Color(0.85f, 0.85f, 0.85f);
				if ((Object)(object)_fullbrightLight == (Object)null)
				{
					GameObject val = new GameObject("RepoSandbox_SunLight");
					Object.DontDestroyOnLoad((Object)(object)val);
					_fullbrightLight = val.AddComponent<Light>();
					_fullbrightLight.type = (LightType)1;
					_fullbrightLight.intensity = 1.4f;
					_fullbrightLight.color = Color.white;
					val.transform.rotation = Quaternion.Euler(50f, -30f, 0f);
				}
				((Behaviour)_fullbrightLight).enabled = true;
			}
			else
			{
				if ((Object)(object)_fullbrightLight != (Object)null)
				{
					((Behaviour)_fullbrightLight).enabled = false;
				}
				RenderSettings.ambientLight = new Color(0.1f, 0.1f, 0.1f);
			}
		}

		private GameObject FindLocalPlayerObject()
		{
			MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
			foreach (MonoBehaviour val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string name = ((object)val).GetType().Name;
				if (name == "PlayerAvatar" || name == "PlayerController")
				{
					PhotonView component = ((Component)val).GetComponent<PhotonView>();
					if ((Object)(object)component == (Object)null || component.IsMine)
					{
						return ((Component)val).gameObject;
					}
				}
			}
			if (!((Object)(object)Camera.main != (Object)null))
			{
				return null;
			}
			return ((Component)((Component)Camera.main).transform.root).gameObject;
		}

		private void TeleportPlayer(Vector3 targetPos)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindLocalPlayerObject();
			if (!((Object)(object)val == (Object)null))
			{
				CharacterController component = val.GetComponent<CharacterController>();
				if ((Object)(object)component != (Object)null)
				{
					((Collider)component).enabled = false;
				}
				Rigidbody component2 = val.GetComponent<Rigidbody>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.velocity = Vector3.zero;
					component2.position = targetPos;
				}
				val.transform.position = targetPos;
				if ((Object)(object)component != (Object)null)
				{
					((Collider)component).enabled = true;
				}
			}
		}

		private void ExtractNestedObjects(object target, List<object> results)
		{
			if (target == null)
			{
				return;
			}
			FieldInfo[] fields = target.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				try
				{
					object value = fieldInfo.GetValue(target);
					if (value is IDictionary dictionary)
					{
						foreach (object value2 in dictionary.Values)
						{
							if (value2 != null)
							{
								results.Add(value2);
							}
						}
					}
					else
					{
						if (!(value is IEnumerable enumerable) || value is string)
						{
							continue;
						}
						foreach (object item in enumerable)
						{
							if (item != null)
							{
								results.Add(item);
							}
						}
						continue;
					}
				}
				catch
				{
				}
			}
		}

		private GameObject FindAnyGameObjectField(object obj)
		{
			FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.FieldType == typeof(GameObject))
				{
					object? value = fieldInfo.GetValue(obj);
					GameObject val = (GameObject)((value is GameObject) ? value : null);
					if (val != null && (Object)(object)val != (Object)null)
					{
						return val;
					}
				}
			}
			return null;
		}

		private List<GameObject> FindAllGameObjectsInLists(object obj)
		{
			List<GameObject> list = new List<GameObject>();
			FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!typeof(IEnumerable).IsAssignableFrom(fieldInfo.FieldType) || !(fieldInfo.FieldType != typeof(string)) || !(fieldInfo.GetValue(obj) is IEnumerable enumerable))
				{
					continue;
				}
				foreach (object item in enumerable)
				{
					GameObject val = (GameObject)((item is GameObject) ? item : null);
					if (val != null && (Object)(object)val != (Object)null && !list.Contains(val))
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		private string FindAnyStringField(object obj, string[] preferredNames)
		{
			Type type = obj.GetType();
			foreach (string text in preferredNames)
			{
				FieldInfo fieldInfo = AccessTools.Field(type, text);
				if (fieldInfo != null && fieldInfo.GetValue(obj) is string text2 && !string.IsNullOrEmpty(text2))
				{
					return text2;
				}
			}
			return null;
		}
	}
}