Decompiled source of MoonforgedGatesAndFences v1.0.3

MoonforgedGatesAndFences.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoonforgedGatesAndFences")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoonforgedGatesAndFences")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ad799d2-7e36-4098-b363-92c0f7924b6a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Moonforged.GatesAndFences;

public class LocalizeKey : MonoBehaviour
{
	public string Key;

	public void Awake()
	{
		if (!string.IsNullOrEmpty(Key))
		{
			string text = LocalizationCache.Get(Key);
		}
	}
}
public static class Localizer
{
	public static void Add(string key, string value)
	{
		LocalizationCache.Add(key, value);
	}

	public static void Register()
	{
		LocalizationCache.RegisterToJotunnLocalization();
	}
}
public class PlacementWatcher : MonoBehaviour
{
	public List<GameObject> RegisterList;

	private void Start()
	{
		if (RegisterList != null && !RegisterList.Contains(((Component)this).gameObject))
		{
			RegisterList.Add(((Component)this).gameObject);
		}
	}

	private void OnDestroy()
	{
		if (RegisterList != null)
		{
			RegisterList.Remove(((Component)this).gameObject);
		}
	}
}
public static class LocalizationCache
{
	private static Dictionary<string, string> translations = new Dictionary<string, string>();

	public static void Add(string key, string value)
	{
		translations[key] = value;
	}

	public static string Get(string key, string fallback = null)
	{
		if (translations.TryGetValue(key, out var value))
		{
			return value;
		}
		return fallback ?? key;
	}

	public static void RegisterToJotunnLocalization()
	{
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		foreach (KeyValuePair<string, string> translation in translations)
		{
			string text = "English";
			string key = translation.Key;
			localization.AddTranslation(ref text, ref key, translation.Value);
		}
	}
}
public class RelicRegistration
{
	public string PrefabName;

	public string DisplayName;

	public RequirementConfig[] Requirements;

	public string Description;

	public string Category;

	public int Comfort;

	public string CraftingStation;

	public RelicRegistration(string prefab, string display, RequirementConfig[] reqs, string desc, string cat, int comfort = 0, string craftingStation = "Workbench")
	{
		PrefabName = prefab;
		DisplayName = display;
		Requirements = reqs;
		Description = desc;
		Category = cat;
		Comfort = comfort;
		CraftingStation = craftingStation;
	}
}
public static class RelicRegistrar
{
	private static bool wasAlreadyRegistered = false;

	public static readonly List<RelicRegistration> AllRegistrations = new List<RelicRegistration>
	{
		new RelicRegistration("v1_SilverGate", "Silver Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Silver", 5, 0, true),
			new RequirementConfig("Crystal", 2, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_DvergrForgedGate", "Dvergr Forged Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("BlackMetal", 5, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_DvergrForgedGate3m", "Dvergr Forged Gate 3m Tall", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("BlackMetal", 4, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_DvergrForgedGate4m", "Dvergr Forged Gate 4m Tall", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("BlackMetal", 5, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_EmberlightGate", "Moonforged Emberlight Gate", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("BlackMetal", 5, 0, true),
			new RequirementConfig("Bronze", 1, 0, true),
			new RequirementConfig("Stone", 5, 0, true),
			new RequirementConfig("Resin", 2, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_ValkyriesGate", "Valkyrie's Gate", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 3, 0, true),
			new RequirementConfig("Bronze", 1, 0, true),
			new RequirementConfig("Silver", 2, 0, true)
		}, "A side gate to Valhalla.", "building", 0, "Forge"),
		new RelicRegistration("v1_NeoWall", "Valkyrie's New Wall", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("BlackMetal", 2, 0, true),
			new RequirementConfig("Tar", 3, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_SilverFence", "Silver Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Silver", 2, 0, true),
			new RequirementConfig("Crystal", 2, 0, true)
		}, "Silver Fence of the Howling Cavern.", "building", 0, "Forge"),
		new RelicRegistration("v1_IroncrestWardenFenceBK", "Ironcrest Warden Fence Black", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("BlackMetal", 2, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_IroncrestWardenFenceSilver", "Ironcrest Warden Fence Silver", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Silver", 2, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_Stonewatch_Palisade", "Stonewatch Palisade", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("BlackMetal", 2, 0, true),
			new RequirementConfig("Stone", 4, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_GildedRingwatchFence", "Gilded Ringwatch Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_chain_fence", "Golden Chain Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("BlackMetal", 1, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_VikingArchGate", "Viking Arch Gate", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Stone", 5, 0, true),
			new RequirementConfig("Wood", 5, 0, true),
			new RequirementConfig("Iron", 2, 0, true)
		}, "", "building", 0, "piece_stonecutter"),
		new RelicRegistration("v1_CurvedWoodFence", "Curved Wood Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("FineWood", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("v1_BlackFence", "Black Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "BlackForge"),
		new RelicRegistration("v1_Wrought_iron_fence_1", "Wrought Iron Fence I", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Bronze", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_StoneBlackFence", "Stone Black Fence", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Bronze", 1, 0, true),
			new RequirementConfig("Stone", 1, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_VikingGate", "Viking Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("coal", 4, 0, true),
			new RequirementConfig("Wood", 10, 0, true)
		}, "Old Viking Gate.", "building"),
		new RelicRegistration("v1_GardenGate", "Moonforged Garden Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Coal", 2, 0, true),
			new RequirementConfig("Wood", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("v1_GardenFence", "Moonforged Garden Fence", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Coal", 2, 0, true),
			new RequirementConfig("Wood", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("v1_Element03", "Moonforged Ivy Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("FineWood", 5, 0, true),
			new RequirementConfig("Wood", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("v1_Element04", "Moonforged Twinleaf Gate", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("FineWood", 5, 0, true),
			new RequirementConfig("Wood", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("v1_Element0", "Moonforged Castle Gate", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 5, 0, true),
			new RequirementConfig("Wood", 20, 0, true),
			new RequirementConfig("Tar", 10, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_Element01", "Moonforged Archgate", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Iron", 2, 0, true)
		}, "", "building", 0, "piece_stonecutter"),
		new RelicRegistration("v1_MoonforgedIronboundGate", "Moonforged Ironbound Gate", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 10, 0, true),
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Coal", 2, 0, true)
		}, "", "building", 0, "Forge"),
		new RelicRegistration("v1_BlackFenceStonePillar", "Stone Black Fence Pillar", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("Iron", 1, 0, true),
			new RequirementConfig("Bronze", 1, 0, true),
			new RequirementConfig("Stone", 2, 0, true),
			new RequirementConfig("Resin", 1, 0, true)
		}, "", "building", 0, "piece_stonecutter"),
		new RelicRegistration("v1_BlackFenceStonePillar3m", "Stone Black Fence Pillar 3m", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("Iron", 1, 0, true),
			new RequirementConfig("Bronze", 1, 0, true),
			new RequirementConfig("Stone", 2, 0, true),
			new RequirementConfig("Resin", 1, 0, true)
		}, "", "building", 0, "piece_stonecutter")
	};

	public static IEnumerable<string> GetAllCategories()
	{
		return AllRegistrations.Select((RelicRegistration r) => CategoryToTab(r.Category)).Distinct();
	}

	private static string CategoryToTab(string category)
	{
		string text = category.ToLower();
		string text2 = text;
		string text3 = text2;
		if (text3 == "building")
		{
			return MoonforgedGates.PlayerPreferredCategory.Value;
		}
		return category;
	}

	public static void RegisterAllRelics(AssetBundle bundle)
	{
		if (wasAlreadyRegistered)
		{
			return;
		}
		foreach (RelicRegistration allRegistration in AllRegistrations)
		{
			RegisterRelic(bundle, allRegistration);
		}
		wasAlreadyRegistered = true;
	}

	private static void RegisterRelic(AssetBundle bundle, RelicRegistration reg)
	{
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Expected O, but got Unknown
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Expected O, but got Unknown
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Expected O, but got Unknown
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_0479: Unknown result type (might be due to invalid IL or missing references)
		//IL_0485: Expected O, but got Unknown
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b7: Expected O, but got Unknown
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_049b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Expected O, but got Unknown
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fe: Expected O, but got Unknown
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Expected O, but got Unknown
		if ((Object)(object)bundle == (Object)null)
		{
			return;
		}
		GameObject val = bundle.LoadAsset<GameObject>(reg.PrefabName);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		((Object)val).name = reg.PrefabName;
		ZNetView val2 = val.GetComponent<ZNetView>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<ZNetView>();
		}
		val2.m_persistent = true;
		val2.m_syncInitialScale = true;
		if (!Object.op_Implicit((Object)(object)val.GetComponent<ZSyncTransform>()))
		{
			val.AddComponent<ZSyncTransform>();
		}
		Piece val3 = val.GetComponent<Piece>();
		if ((Object)(object)val3 == (Object)null)
		{
			val3 = val.AddComponent<Piece>();
		}
		val3.m_name = reg.DisplayName;
		val3.m_description = reg.Description;
		val3.m_groundOnly = false;
		GameObject val4 = null;
		GameObject val5 = null;
		GameObject val6 = null;
		GameObject val7 = null;
		if (reg.PrefabName == "v1_CurvedWoodFence" || reg.PrefabName == "v1_GardenGate" || reg.PrefabName == "v1_Element04" || reg.PrefabName == "v1_Element01" || reg.PrefabName == "v1_Element0" || reg.PrefabName == "v1_Element03" || reg.PrefabName == "v1_GardenFence" || reg.PrefabName == "v1_Element02a" || reg.PrefabName == "v1_MoonforgedIronboundGate" || reg.PrefabName == "v1_VikingGate")
		{
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				val4 = ZNetScene.instance.GetPrefab("vfx_Place_wood");
				val5 = ZNetScene.instance.GetPrefab("sfx_build_hammer_wood");
				val6 = ZNetScene.instance.GetPrefab("vfx_destroyed_wood");
				val7 = ZNetScene.instance.GetPrefab("sfx_wood_break");
			}
		}
		else if (reg.PrefabName == "v1_SilverGate" || reg.PrefabName == "v1_DvergrForgedGate" || reg.PrefabName == "v1_DvergrForgedGate3m" || reg.PrefabName == "v1_DvergrForgedGate4m" || reg.PrefabName == "v1_EmberlightGate" || reg.PrefabName == "v1_ValkyriesGate" || reg.PrefabName == "v1_GildedRingwatchFence" || reg.PrefabName == "v1_SilverFence" || reg.PrefabName == "v1_IroncrestWardenFenceBK" || reg.PrefabName == "v1_IroncrestWardenFenceSilver" || reg.PrefabName == "v1_VikingArchGate" || reg.PrefabName == "v1_BlackFence" || reg.PrefabName == "v1_Wrought_iron_fence_1" || reg.PrefabName == "v1_chain_fence")
		{
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				val4 = ZNetScene.instance.GetPrefab("vfx_Place_stone");
				val5 = ZNetScene.instance.GetPrefab("sfx_build_hammer_metal");
				val6 = ZNetScene.instance.GetPrefab("vfx_destroyed");
				val7 = ZNetScene.instance.GetPrefab("sfx_metal_blocked");
			}
		}
		else if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			val4 = ZNetScene.instance.GetPrefab("vfx_Place_stone");
			val5 = ZNetScene.instance.GetPrefab("sfx_build_hammer_stone");
			val6 = ZNetScene.instance.GetPrefab("vfx_destroyed");
			val7 = ZNetScene.instance.GetPrefab("sfx_rock_destroyed");
		}
		List<EffectData> list = new List<EffectData>();
		if ((Object)(object)val4 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val4,
				m_enabled = true
			});
		}
		if ((Object)(object)val5 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val5,
				m_enabled = true
			});
		}
		EffectList val8 = new EffectList();
		val8.m_effectPrefabs = list.ToArray();
		val3.m_placeEffect = val8;
		WearNTear val9 = val.GetComponent<WearNTear>();
		if ((Object)(object)val9 == (Object)null)
		{
			val9 = val.AddComponent<WearNTear>();
		}
		val9.m_health = 1000f;
		val9.m_noRoofWear = true;
		List<EffectData> list2 = new List<EffectData>();
		if ((Object)(object)val6 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val6,
				m_enabled = true
			});
		}
		if ((Object)(object)val7 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val7,
				m_enabled = true
			});
		}
		EffectList val10 = new EffectList();
		val10.m_effectPrefabs = list2.ToArray();
		val9.m_destroyedEffect = val10;
		Sprite val11 = bundle.LoadAsset<Sprite>(reg.PrefabName.ToLowerInvariant());
		if ((Object)(object)val11 != (Object)null)
		{
			val3.m_icon = val11;
		}
		PieceConfig val12 = new PieceConfig();
		val12.PieceTable = "Hammer";
		val12.Category = CategoryToTab(reg.Category);
		val12.CraftingStation = reg.CraftingStation;
		val12.Requirements = reg.Requirements;
		PieceManager.Instance.AddPiece(new CustomPiece(val, true, val12));
	}
}
[BepInPlugin("Moonforged.GatesAndFences", "Moonforged Gates & Fences", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MoonforgedGates : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <DelayedRegister>d__7 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AssetBundle bundle;

		public MoonforgedGates <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DelayedRegister>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			RelicRegistrar.RegisterAllRelics(bundle);
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string PluginGUID = "Moonforged.GatesAndFences";

	public const string PluginName = "Moonforged Gates & Fences";

	public const string PluginVersion = "1.0.3";

	private AssetBundle gatesBundle;

	private static readonly List<GameObject> placedObjects = new List<GameObject>();

	public static ConfigEntry<string> PlayerPreferredCategory;

	private void Awake()
	{
		//IL_0006: 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)
		new Harmony("moonforged.gates.scalingdebug").PatchAll();
		string resourcePath = "MoonforgedGatesAndFences.gatesandfences";
		gatesBundle = EmbeddedAssetBundleLoader.LoadBundle(resourcePath);
		if ((Object)(object)gatesBundle == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load embedded AssetBundle.");
			return;
		}
		TrackAllPrefabsInBundle(gatesBundle);
		PlayerPreferredCategory = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomHammerTab", "Moonforged Structures", "Set the hammer tab where this mod's pieces should appear (e.g., Building, Furniture, Moonforged Structures)");
		foreach (string allCategory in RelicRegistrar.GetAllCategories())
		{
			PieceManager.Instance.AddPieceCategory(allCategory);
		}
		PrefabManager.OnPrefabsRegistered += delegate
		{
			((MonoBehaviour)this).StartCoroutine(DelayedRegister(gatesBundle));
		};
	}

	[IteratorStateMachine(typeof(<DelayedRegister>d__7))]
	private IEnumerator DelayedRegister(AssetBundle bundle)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedRegister>d__7(0)
		{
			<>4__this = this,
			bundle = bundle
		};
	}

	public static void TrackAllPrefabsInBundle(AssetBundle bundle)
	{
		GameObject[] array = bundle.LoadAllAssets<GameObject>();
		foreach (GameObject val in array)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<PlacementWatcher>() == (Object)null)
			{
				val.AddComponent<PlacementWatcher>().RegisterList = placedObjects;
			}
		}
	}
}
public static class EmbeddedAssetBundleLoader
{
	public static AssetBundle LoadBundle(string resourcePath)
	{
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath);
		if (stream == null)
		{
			Debug.LogError((object)("AssetBundle resource not found: " + resourcePath));
			return null;
		}
		byte[] array = new byte[stream.Length];
		stream.Read(array, 0, array.Length);
		return AssetBundle.LoadFromMemory(array);
	}
}