Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ArcadeStoneGenerator v1.0.2
ArcadeStoneGenerator.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using ArcadeStoneGenerator.Visuals; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SoftReferenceableAssets; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.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 ArcadeStoneGenerator { [BepInPlugin("arcade.valheim.arcadestonegenerator", "ArcadeStoneGenerator", "1.0.2")] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class ArcadeStoneGeneratorPlugin : BaseUnityPlugin { public const string PluginGuid = "arcade.valheim.arcadestonegenerator"; public const string PluginName = "ArcadeStoneGenerator"; public const string PluginVersion = "1.0.2"; private Harmony _harmony; public static ConfigEntry<float> GenerationIntervalSeconds; public static ConfigEntry<int> MaxStorage; public static ConfigEntry<int> ReqPlaceableHardRock; public static ConfigEntry<int> ReqThunderstone; public static ConfigEntry<int> ReqCoal; public static ConfigEntry<int> ReqStone; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; InitConfig(); _harmony = new Harmony("arcade.valheim.arcadestonegenerator"); try { _harmony.PatchAll(typeof(ArcadeStoneGeneratorPlugin).Assembly); Log.LogInfo((object)"ArcadeStoneGenerator v1.0.0 loaded and patches applied!"); } catch (Exception arg) { Log.LogError((object)$"ArcadeStoneGenerator failed to patch: {arg}"); } } private void InitConfig() { GenerationIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "GenerationIntervalSeconds", 20f, "Time in seconds required to passively extract 1 stone from the earth."); MaxStorage = ((BaseUnityPlugin)this).Config.Bind<int>("Generation", "MaxStorage", 50, "Maximum amount of stone the structure can store before generation pauses."); ReqPlaceableHardRock = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "ReqPlaceableHardRock", 1, "Amount of Placeable_HardRock (Mysterious Rock) required to build the generator."); ReqThunderstone = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "ReqThunderstone", 1, "Amount of Thunderstone required to build the generator."); ReqCoal = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "ReqCoal", 10, "Amount of Coal required to build the generator."); ReqStone = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "ReqStone", 25, "Amount of Stone required to build the generator."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class StoneGenerator : MonoBehaviour, Hoverable, Interactable { private ZNetView m_nview; private Piece m_piece; private const string ZdoCountKey = "ArcadeStoneGen_Count"; private const string ZdoLastTimeKey = "ArcadeStoneGen_LastTime"; private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_piece = ((Component)this).GetComponent<Piece>(); if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { m_nview.Register("RPC_OnCollectStone", (Action<long>)RPC_OnCollectStone); ((MonoBehaviour)this).InvokeRepeating("UpdateGeneration", 2f, 2f); } } private void Start() { if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid() && m_nview.IsOwner() && (Object)(object)ZNet.instance != (Object)null) { long num = m_nview.GetZDO().GetLong("ArcadeStoneGen_LastTime", 0L); if (num <= 0) { m_nview.GetZDO().Set("ArcadeStoneGen_LastTime", (long)ZNet.instance.GetTimeSeconds()); } } } private void UpdateGeneration() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid() || !m_nview.IsOwner() || (Object)(object)ZNet.instance == (Object)null) { return; } float num = ArcadeStoneGeneratorPlugin.GenerationIntervalSeconds.Value; if (num < 0.5f) { num = 0.5f; } int value = ArcadeStoneGeneratorPlugin.MaxStorage.Value; int num2 = m_nview.GetZDO().GetInt("ArcadeStoneGen_Count", 0); long num3 = (long)ZNet.instance.GetTimeSeconds(); long num4 = m_nview.GetZDO().GetLong("ArcadeStoneGen_LastTime", 0L); if (num4 <= 0) { m_nview.GetZDO().Set("ArcadeStoneGen_LastTime", num3); return; } if (num2 >= value) { m_nview.GetZDO().Set("ArcadeStoneGen_LastTime", num3); return; } long num5 = num3 - num4; if (num5 >= (long)num) { int num6 = (int)((float)num5 / num); if (num6 > 0) { int num7 = Mathf.Min(num2 + num6, value); m_nview.GetZDO().Set("ArcadeStoneGen_Count", num7); long num8 = (long)((float)num6 * num); m_nview.GetZDO().Set("ArcadeStoneGen_LastTime", num4 + num8); } } } public string GetHoverText() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return ""; } int num = m_nview.GetZDO().GetInt("ArcadeStoneGen_Count", 0); int value = ArcadeStoneGeneratorPlugin.MaxStorage.Value; string text = $"Stone Generator [{num} / {value}]\n[<color=yellow><b>$KEY_Use</b></color>] Take stone"; return Localization.instance.Localize(text); } public string GetHoverName() { return "Stone Generator"; } public float GetHoverOffset() { return 0f; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null || (Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return false; } int num = m_nview.GetZDO().GetInt("ArcadeStoneGen_Count", 0); if (num <= 0) { ((Character)user).Message((MessageType)2, "Generator is empty.", 0, (Sprite)null, false); return false; } ObjectDB instance = ObjectDB.instance; GameObject val2 = ((instance != null) ? instance.GetItemPrefab("Stone") : null); if ((Object)(object)val2 == (Object)null) { return false; } ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { return false; } int maxStackSize = component.m_itemData.m_shared.m_maxStackSize; int num2 = 0; int num3 = num; while (num2 < num3) { int num4 = Mathf.Min(num3 - num2, maxStackSize); if (((Humanoid)val).GetInventory().AddItem(val2, num4)) { num2 += num4; continue; } bool flag = false; while (num2 < num3 && ((Humanoid)val).GetInventory().AddItem(val2, 1)) { num2++; flag = true; } if (flag) { continue; } break; } if (num2 > 0) { int num5 = num - num2; m_nview.GetZDO().Set("ArcadeStoneGen_Count", num5); ((Character)user).Message((MessageType)1, $"Took {num2} stone ({num5}/{ArcadeStoneGeneratorPlugin.MaxStorage.Value})", 0, (Sprite)null, false); m_nview.InvokeRPC(ZNetView.Everybody, "RPC_OnCollectStone", Array.Empty<object>()); return true; } ((Character)user).Message((MessageType)2, "Your inventory is full!", 0, (Sprite)null, false); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } private void RPC_OnCollectStone(long sender) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) ZNetScene instance = ZNetScene.instance; object obj = ((instance != null) ? instance.GetPrefab("vfx_stone_destroyed") : null); if (obj == null) { ZNetScene instance2 = ZNetScene.instance; obj = ((instance2 != null) ? instance2.GetPrefab("vfx_rock_destroyed") : null); } GameObject val = (GameObject)obj; if ((Object)(object)val != (Object)null) { Object.Instantiate<GameObject>(val, ((Component)this).transform.position + Vector3.up * 1.3f, Quaternion.identity); } } private void OnDestroy() { //IL_008e: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid() || !m_nview.IsOwner()) { return; } int num = m_nview.GetZDO().GetInt("ArcadeStoneGen_Count", 0); if (num <= 0) { return; } ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab("Stone") : null); if (!((Object)(object)val != (Object)null)) { return; } while (num > 0) { int num2 = Mathf.Min(num, 50); GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position + Vector3.up * 0.8f, Quaternion.identity); ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_stack = num2; } num -= num2; } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { [HarmonyPostfix] private static void Postfix(ZNetScene __instance) { if ((Object)(object)__instance == (Object)null) { return; } try { StoneGeneratorPrefabs.Init(__instance); } catch (Exception arg) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogError((object)$"Failed to init Stone Generator prefab in ZNetScene: {arg}"); } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDB_Awake_Patch { [HarmonyPostfix] private static void Postfix(ObjectDB __instance) { if ((Object)(object)__instance == (Object)null || __instance.m_items.Count == 0) { return; } try { StoneGeneratorPrefabs.TryFinalize(); } catch (Exception arg) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogError((object)$"Failed to finalize Stone Generator in ObjectDB.Awake: {arg}"); } } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDB_CopyOtherDB_Patch { [HarmonyPostfix] private static void Postfix() { try { StoneGeneratorPrefabs.TryFinalize(); } catch (Exception arg) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogError((object)$"Failed in ObjectDB.CopyOtherDB: {arg}"); } } } } public static class StoneGeneratorPrefabs { public const string PrefabName = "arcade_stone_generator"; private static GameObject _holder; private static Sprite _customPieceIcon; private const string EmbeddedPieceIconBase64 = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAJP0lEQVR4nO2dT2gcVRzHJ+kWpPSQoxQtIlTS4kEQJEdbJeChOUQPaS9CKdKAtJZIj3vYY+nWJBZapAhe3F7sITkUQm08hoLgQdqgIBJD8dhDWIRSIr91futvX96/efNm5r23vw9sdnZndubN+37f7/2bmWQZwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMw6TAzI//3IBXNuZMNp0Aplla2Rgw/fY7+5Kvu5p1A7Z//WUiS5wkDSATdfHzyyOfe4rvkdu3Vg/sJ0VDRGsAXclt4pjbkZqjlaLYYqmG0uzCYoH9yNIYgykmYhVcFbpVgHj0N70T5wdtgHO/f79k2tZ2/yZCNEQrBtGLitEEi5I0iqag5xiKGVoxNNhiZVFTheB5N22EVijCFxUdQrgsfIfMIjlHNEPTRphsWnzIFBfx6XuT9BzTIJ53E72aRgyAJ+oiPOKj5OM+eiVM5MOINB+aMEEtBoATw5fvOt428+GYNi312w49AB+GpCageZVcG8CX+JDptARuffDKl3T9xrOXgwycPXZoWLfaZuqVSxeM9XEVE0m2Jo3WAC7i68W4IBUCxcfly7PvFjrmtKG7Ro8JxtvKshHzUVbufLsfsgka7wa6lD4ZIMrzKzPGUEwzd2rl/IHvRMSosbrx83CZRhfb8ylqiKqppeuBmXj6w9lseno6297eHlm/+XAjK9oVosJMrWwN2wFoAhRKJ9JMXpLF6kN1HCo+gtHFJe1Q2sW8cM2PZCKADlUdDqKjCTD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tPq4RqGU2sCipmmHXU4j3ORsYxfUAsRpit4I6PbjrAeo0Qsim2K24Aedb+FquCWxqzqAqc+w20EqnwldxTWClVwWL3/EEkpvoVQhf21PCZEYA2Axm0asUHqn10aVshjBEpzT27FqVGVKNEH2F2E2ITgnm4cUmQ8Rkir5B7CYFFwkiEa6GaMIkfQtxQxZcJMhE+TZF3ewEKraMaBIaikl2IhKXYRiGYRiGYRiGYRiGYRiGYRiGYRiGYRiGGUP+BdOZ0+TjhAPbAAAAAElFTkSuQmCC"; public static GameObject GeneratorPrefab { get; private set; } public static void Init(ZNetScene scene) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scene == (Object)null) { return; } GameObject val = ResolvePlaceableHardRock(scene); if ((Object)(object)val != (Object)null) { RegisterInScene(scene, val); } GameObject val2 = ResolveStoneRockItem(scene); if ((Object)(object)val2 != (Object)null) { RegisterInScene(scene, val2); } GameObject val3 = scene.GetPrefab("piece_stonefloor2x2") ?? scene.GetPrefab("piece_stonewall1x1") ?? scene.GetPrefab("piece_stonecutter") ?? scene.GetPrefab("piece_chest_wood"); if ((Object)(object)val3 == (Object)null) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogError((object)"Base stone piece not found in ZNetScene!"); } return; } if ((Object)(object)_holder != (Object)null) { Object.Destroy((Object)(object)_holder); } _holder = new GameObject("ArcadeStoneGenerator_Holder"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); GeneratorPrefab = Object.Instantiate<GameObject>(val3, _holder.transform, false); ((Object)GeneratorPrefab).name = "arcade_stone_generator"; MonoBehaviour[] components = GeneratorPrefab.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val4 in components) { if (!(val4 is ZNetView) && !(val4 is Piece) && !(val4 is WearNTear)) { Object.DestroyImmediate((Object)(object)val4); } } for (int num = GeneratorPrefab.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)GeneratorPrefab.transform.GetChild(num)).gameObject); } Collider[] components2 = GeneratorPrefab.GetComponents<Collider>(); foreach (Collider val5 in components2) { Object.DestroyImmediate((Object)(object)val5); } WearNTear component = GeneratorPrefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_new = null; component.m_worn = null; component.m_broken = null; component.m_wet = null; component.m_snow = null; component.m_snowWorn = null; component.m_snowBroken = null; component.m_fragmentRoots = null; component.m_nonSolidRenderers?.Clear(); component.m_health = 1500f; component.m_materialType = (MaterialType)1; } Piece val6 = GeneratorPrefab.GetComponent<Piece>(); if ((Object)(object)val6 == (Object)null) { val6 = GeneratorPrefab.AddComponent<Piece>(); } val6.m_enabled = true; val6.m_name = "Stone Generator"; val6.m_description = "Ancient mystic well drawing mineral essence from deep within the earth to continuously generate raw stone."; val6.m_category = (PieceCategory)1; val6.m_canBeRemoved = true; ((StaticTarget)val6).m_primaryTarget = false; val6.m_groundOnly = false; val6.m_waterPiece = false; val6.m_noClipping = false; val6.m_clipGround = true; val6.m_icon = val3.GetComponent<Piece>()?.m_icon; GeneratorPrefab.AddComponent<StoneGenerator>(); StoneGeneratorModel.Build(GeneratorPrefab, scene); if ((Object)(object)component != (Object)null) { component.m_noSupportWear = true; component.m_noRoofWear = true; component.m_health = 1500f; component.m_materialType = (MaterialType)1; } try { Sprite val7 = GetCustomPieceIcon() ?? IconRenderer.Render(GeneratorPrefab); if ((Object)(object)val7 != (Object)null) { val6.m_icon = val7; } } catch (Exception ex) { ManualLogSource log2 = ArcadeStoneGeneratorPlugin.Log; if (log2 != null) { log2.LogWarning((object)("Icon loading skipped: " + ex.Message)); } } RegisterInScene(scene, GeneratorPrefab); ManualLogSource log3 = ArcadeStoneGeneratorPlugin.Log; if (log3 != null) { log3.LogInfo((object)"Stone Generator prefab created and registered!"); } TryFinalize(); } public static GameObject ResolveRunestonePrefab(ZNetScene scene) { GameObject val = ResolveSoftRefPrefab("Assets/world/Locations/BlackForest/Runestone_BlackForest.prefab", "fe867d16af763e2428b13c784d0b5a84"); if ((Object)(object)val != (Object)null) { return val; } val = ResolveSoftRefPrefab("Assets/world/Locations/Meadows/Runestone_Meadows.prefab", "86a97041cd76c664d82d24f8149d4f5d"); if ((Object)(object)val != (Object)null) { return val; } val = ((scene != null) ? scene.GetPrefab("PT_BlankRunestone") : null) ?? ((scene != null) ? scene.GetPrefab("PT_BlueRunestone") : null) ?? ((scene != null) ? scene.GetPrefab("Runestone_BlackForest") : null) ?? ((scene != null) ? scene.GetPrefab("Runestone_Meadows") : null) ?? ((scene != null) ? scene.GetPrefab("Runestone") : null); if ((Object)(object)val != (Object)null) { return val; } val = ResolvePlaceableHardRock(scene); if ((Object)(object)val != (Object)null) { return val; } return null; } public static GameObject ResolvePlaceableHardRock(ZNetScene scene) { GameObject val = ((scene != null) ? scene.GetPrefab("Placeable_HardRock") : null); if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = ResolveSoftRefPrefab("Assets/GameElements/Items/pickables/Placeable_HardRock.prefab", "f5042c7f7b27cb342af58a21fdf1638e"); if ((Object)(object)val2 != (Object)null) { return val2; } return null; } public static GameObject ResolveStoneRockItem(ZNetScene scene) { ObjectDB instance = ObjectDB.instance; object obj = ((instance != null) ? instance.GetItemPrefab("StoneRock") : null); if (obj == null) { ObjectDB instance2 = ObjectDB.instance; obj = ((instance2 != null) ? instance2.GetItemPrefab("Placeable_HardRock") : null); if (obj == null) { ObjectDB instance3 = ObjectDB.instance; obj = ((instance3 != null) ? instance3.GetItemPrefab("Stonerock") : null) ?? ((scene != null) ? scene.GetPrefab("StoneRock") : null) ?? ((scene != null) ? scene.GetPrefab("Placeable_HardRock") : null) ?? ((scene != null) ? scene.GetPrefab("Stonerock") : null); } } GameObject val = (GameObject)obj; if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = ResolveSoftRefPrefab("Assets/GameElements/Items/materials/StoneRock.prefab", "e7521d35685a45f4d9cb8c5a8ba24bba") ?? ResolveSoftRefPrefab("Assets/GameElements/Items/pickables/Pickable_StoneRock.prefab", "5031e97dd4fbf39418459f5545371ee4"); if ((Object)(object)val2 != (Object)null) { return val2; } return null; } private static GameObject ResolveSoftRefPrefab(string bundlePath, string assetIdHex) { //IL_00d5: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) try { Dictionary<string, AssetID> allAssetPathsInBundleMappedToAssetID = Runtime.GetAllAssetPathsInBundleMappedToAssetID(); if (allAssetPathsInBundleMappedToAssetID != null) { SoftReference<GameObject> val = default(SoftReference<GameObject>); foreach (KeyValuePair<string, AssetID> item in allAssetPathsInBundleMappedToAssetID) { if (item.Key.IndexOf(bundlePath, StringComparison.OrdinalIgnoreCase) >= 0) { val..ctor(item.Value); val.Load(); if ((Object)(object)val.Asset != (Object)null) { return val.Asset; } } } } } catch (Exception ex) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogWarning((object)("SoftRef map resolution: " + ex.Message)); } } try { AssetID val2 = default(AssetID); if (AssetID.TryParse(assetIdHex, ref val2)) { SoftReference<GameObject> val3 = default(SoftReference<GameObject>); val3..ctor(val2); val3.Load(); if ((Object)(object)val3.Asset != (Object)null) { return val3.Asset; } } } catch (Exception ex2) { ManualLogSource log2 = ArcadeStoneGeneratorPlugin.Log; if (log2 != null) { log2.LogWarning((object)("SoftRef AssetID resolution: " + ex2.Message)); } } return null; } private static void RegisterInScene(ZNetScene scene, GameObject prefab) { if (!((Object)(object)scene == (Object)null) && !((Object)(object)prefab == (Object)null)) { scene.m_prefabs.RemoveAll((GameObject p) => (Object)(object)p == (Object)null || ((Object)(object)p != (Object)(object)prefab && ((Object)p).name == ((Object)prefab).name)); if (!scene.m_prefabs.Contains(prefab)) { scene.m_prefabs.Add(prefab); } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (typeof(ZNetScene).GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(scene) is Dictionary<int, GameObject> dictionary) { dictionary[stableHashCode] = prefab; } } } private static void RegisterInObjectDB(GameObject itemPrefab) { if (!((Object)(object)itemPrefab == (Object)null) && !((Object)(object)ObjectDB.instance == (Object)null)) { if (!ObjectDB.instance.m_items.Contains(itemPrefab)) { ObjectDB.instance.m_items.Add(itemPrefab); } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)itemPrefab).name); if (typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(ObjectDB.instance) is Dictionary<int, GameObject> dictionary) { dictionary[stableHashCode] = itemPrefab; } } } public static void TryFinalize() { //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown if ((Object)(object)GeneratorPrefab == (Object)null || (Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hammer"); if ((Object)(object)itemPrefab == (Object)null) { return; } ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null || component.m_itemData.m_shared == null) { return; } PieceTable buildPieces = component.m_itemData.m_shared.m_buildPieces; if ((Object)(object)buildPieces == (Object)null) { return; } Piece component2 = GeneratorPrefab.GetComponent<Piece>(); if ((Object)(object)component2 != (Object)null) { List<Requirement> list = new List<Requirement>(); GameObject val = ResolveStoneRockItem(ZNetScene.instance) ?? ResolvePlaceableHardRock(ZNetScene.instance); if ((Object)(object)val != (Object)null) { RegisterInObjectDB(val); } object obj = ((val != null) ? val.GetComponent<ItemDrop>() : null); if (obj == null) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("StoneRock"); obj = ((itemPrefab2 != null) ? itemPrefab2.GetComponent<ItemDrop>() : null); if (obj == null) { GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab("Placeable_HardRock"); obj = ((itemPrefab3 != null) ? itemPrefab3.GetComponent<ItemDrop>() : null); if (obj == null) { GameObject itemPrefab4 = ObjectDB.instance.GetItemPrefab("Stonerock"); obj = ((itemPrefab4 != null) ? itemPrefab4.GetComponent<ItemDrop>() : null); } } } ItemDrop val2 = (ItemDrop)obj; if ((Object)(object)val2 == (Object)null) { GameObject val3 = ObjectDB.instance.GetItemPrefab("StoneRock") ?? ResolveSoftRefPrefab("Assets/GameElements/Items/materials/StoneRock.prefab", "e7521d35685a45f4d9cb8c5a8ba24bba"); if ((Object)(object)val3 != (Object)null) { RegisterInObjectDB(val3); val2 = val3.GetComponent<ItemDrop>(); } } GameObject itemPrefab5 = ObjectDB.instance.GetItemPrefab("Thunderstone"); ItemDrop val4 = ((itemPrefab5 != null) ? itemPrefab5.GetComponent<ItemDrop>() : null); GameObject itemPrefab6 = ObjectDB.instance.GetItemPrefab("Coal"); ItemDrop val5 = ((itemPrefab6 != null) ? itemPrefab6.GetComponent<ItemDrop>() : null); GameObject itemPrefab7 = ObjectDB.instance.GetItemPrefab("Stone"); ItemDrop val6 = ((itemPrefab7 != null) ? itemPrefab7.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 != (Object)null) { list.Add(new Requirement { m_resItem = val2, m_amount = Mathf.Max(1, ArcadeStoneGeneratorPlugin.ReqPlaceableHardRock.Value), m_recover = true }); ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogInfo((object)$"Registered {((Object)((Component)val2).gameObject).name} in generator recipe ({ArcadeStoneGeneratorPlugin.ReqPlaceableHardRock.Value}x)."); } } else { ManualLogSource log2 = ArcadeStoneGeneratorPlugin.Log; if (log2 != null) { log2.LogError((object)"Failed to resolve Mysterious Rock / Placeable_HardRock item for the recipe!"); } } if ((Object)(object)val4 != (Object)null) { list.Add(new Requirement { m_resItem = val4, m_amount = Mathf.Max(1, ArcadeStoneGeneratorPlugin.ReqThunderstone.Value), m_recover = true }); } if ((Object)(object)val5 != (Object)null) { list.Add(new Requirement { m_resItem = val5, m_amount = Mathf.Max(1, ArcadeStoneGeneratorPlugin.ReqCoal.Value), m_recover = true }); } if ((Object)(object)val6 != (Object)null) { list.Add(new Requirement { m_resItem = val6, m_amount = Mathf.Max(1, ArcadeStoneGeneratorPlugin.ReqStone.Value), m_recover = true }); } component2.m_resources = list.ToArray(); component2.m_category = (PieceCategory)1; GameObject itemPrefab8 = ObjectDB.instance.GetItemPrefab("piece_stonecutter"); GameObject itemPrefab9 = ObjectDB.instance.GetItemPrefab("piece_workbench"); if ((Object)(object)itemPrefab8 != (Object)null) { component2.m_craftingStation = itemPrefab8.GetComponent<CraftingStation>(); } else if ((Object)(object)itemPrefab9 != (Object)null) { component2.m_craftingStation = itemPrefab9.GetComponent<CraftingStation>(); } } buildPieces.m_pieces.RemoveAll((GameObject p) => (Object)(object)p == (Object)null || ((Object)p).name == "arcade_stone_generator"); int num = buildPieces.m_pieces.FindIndex((GameObject p) => (Object)(object)p != (Object)null && (((Object)p).name == "piece_stonecutter" || ((Object)p).name == "piece_stonefloor2x2")); if (num >= 0) { buildPieces.m_pieces.Insert(num + 1, GeneratorPrefab); } else { buildPieces.m_pieces.Add(GeneratorPrefab); } ManualLogSource log3 = ArcadeStoneGeneratorPlugin.Log; if (log3 != null) { log3.LogInfo((object)"Arcade Stone Generator successfully inserted into Hammer table!"); } } public static Sprite GetCustomPieceIcon() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_customPieceIcon != (Object)null) { return _customPieceIcon; } try { byte[] array = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAJP0lEQVR4nO2dT2gcVRzHJ+kWpPSQoxQtIlTS4kEQJEdbJeChOUQPaS9CKdKAtJZIj3vYY+nWJBZapAhe3F7sITkUQm08hoLgQdqgIBJD8dhDWIRSIr91futvX96/efNm5r23vw9sdnZndubN+37f7/2bmWQZwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMw6TAzI//3IBXNuZMNp0Aplla2Rgw/fY7+5Kvu5p1A7Z//WUiS5wkDSATdfHzyyOfe4rvkdu3Vg/sJ0VDRGsAXclt4pjbkZqjlaLYYqmG0uzCYoH9yNIYgykmYhVcFbpVgHj0N70T5wdtgHO/f79k2tZ2/yZCNEQrBtGLitEEi5I0iqag5xiKGVoxNNhiZVFTheB5N22EVijCFxUdQrgsfIfMIjlHNEPTRphsWnzIFBfx6XuT9BzTIJ53E72aRgyAJ+oiPOKj5OM+eiVM5MOINB+aMEEtBoATw5fvOt428+GYNi312w49AB+GpCageZVcG8CX+JDptARuffDKl3T9xrOXgwycPXZoWLfaZuqVSxeM9XEVE0m2Jo3WAC7i68W4IBUCxcfly7PvFjrmtKG7Ro8Jxtv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6i5IfQXZMBeV/WBK3Yxa9KuM2HG96qrpBNEOR0MFMfE6mW/nGj7zhOUHkEUA3AMGHkXeVzATAAwyZww3auoQzcBhhzJlNxcmrs1pRnTn3HMg1Brg78C19moqj2KoCjQVh54zyE6KM7yNGgvPBlp4lLTST4HBMYNzPseijtPq4RqGU2sCipmmHXU4j3ORsYxfUAsRpit4I6PbjrAeo0Qsim2K24Aedb+FquCWxqzqAqc+w20EqnwldxTWClVwWL3/EEkpvoVQhf21PCZEYA2Axm0asUHqn10aVshjBEpzT27FqVGVKNEH2F2E2ITgnm4cUmQ8Rkir5B7CYFFwkiEa6GaMIkfQtxQxZcJMhE+TZF3ewEKraMaBIaikl2IhKXYRiGYRiGYRiGYRiGYRiGYRiGYRiGYRiGGUP+BdOZ0+TjhAPbAAAAAElFTkSuQmCC"); Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array)) { _customPieceIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); return _customPieceIcon; } } catch (Exception ex) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogError((object)("Failed to load custom piece icon: " + ex.Message)); } } return null; } } } namespace ArcadeStoneGenerator.Visuals { internal static class IconRenderer { private const int Size = 128; private static readonly Vector3 StudioPosition = new Vector3(0f, 9500f, 0f); internal static Sprite Render(GameObject prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_015f: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if ((int)SystemInfo.graphicsDeviceType == 4) { return null; } int num = FreeLayer(); if (num < 0) { return null; } GameObject val = null; GameObject val2 = null; GameObject val3 = null; RenderTexture val4 = null; RenderTexture active = RenderTexture.active; try { val = new GameObject("ArcadeStoneGen_IconStudio"); val.transform.position = StudioPosition; Matrix4x4 worldToLocalMatrix = prefab.transform.worldToLocalMatrix; MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val5 in array) { MeshFilter component = ((Component)val5).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && ((Renderer)val5).enabled) { string text = ((Object)val5).name.ToLowerInvariant(); if (!text.Contains("watermask") && !text.Contains("snow") && !text.Contains("worn") && !text.Contains("broken")) { Matrix4x4 val6 = worldToLocalMatrix * ((Component)val5).transform.localToWorldMatrix; GameObject val7 = new GameObject(((Object)val5).name); val7.layer = num; val7.transform.SetParent(val.transform, false); val7.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val6)).GetColumn(3)); val7.transform.localRotation = ((Matrix4x4)(ref val6)).rotation; val7.transform.localScale = ((Matrix4x4)(ref val6)).lossyScale; val7.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; ((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)val5).sharedMaterials; } } } Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(); if (componentsInChildren2.Length == 0) { return null; } Bounds bounds = componentsInChildren2[0].bounds; foreach (Renderer item in componentsInChildren2.Skip(1)) { ((Bounds)(ref bounds)).Encapsulate(item.bounds); } val4 = new RenderTexture(128, 128, 24, (RenderTextureFormat)0) { antiAliasing = 4 }; val2 = new GameObject("ArcadeStoneGen_IconCamera"); Camera val8 = val2.AddComponent<Camera>(); ((Behaviour)val8).enabled = false; val8.clearFlags = (CameraClearFlags)2; val8.backgroundColor = new Color(0f, 0f, 0f, 0f); val8.cullingMask = 1 << num; val8.fieldOfView = 30f; val8.targetTexture = val4; Vector3 val9 = Quaternion.Euler(22f, 215f, 0f) * Vector3.forward; Vector3 extents = ((Bounds)(ref bounds)).extents; float num2 = ((Vector3)(ref extents)).magnitude / Mathf.Sin((float)Math.PI / 12f); ((Component)val8).transform.position = ((Bounds)(ref bounds)).center - val9 * num2; ((Component)val8).transform.rotation = Quaternion.LookRotation(val9); extents = ((Bounds)(ref bounds)).extents; val8.nearClipPlane = Mathf.Max(0.05f, num2 - ((Vector3)(ref extents)).magnitude * 2f); extents = ((Bounds)(ref bounds)).extents; val8.farClipPlane = num2 + ((Vector3)(ref extents)).magnitude * 2f; val3 = new GameObject("ArcadeStoneGen_IconLight"); Light val10 = val3.AddComponent<Light>(); val10.type = (LightType)1; val10.intensity = 1f; val10.cullingMask = 1 << num; ((Component)val10).transform.rotation = Quaternion.Euler(35f, 160f, 0f); val8.Render(); RenderTexture.active = val4; Texture2D val11 = new Texture2D(128, 128, (TextureFormat)5, false) { name = ((Object)prefab).name + "_icon" }; val11.ReadPixels(new Rect(0f, 0f, 128f, 128f), 0, 0); val11.Apply(); return Sprite.Create(val11, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f); } catch (Exception ex) { ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogWarning((object)("Failed to render icon: " + ex.Message)); } return null; } finally { RenderTexture.active = active; if ((Object)(object)val4 != (Object)null) { val4.Release(); Object.DestroyImmediate((Object)(object)val4); } if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)val3); } } } private static int FreeLayer() { for (int i = 28; i < 32; i++) { if (string.IsNullOrEmpty(LayerMask.LayerToName(i))) { return i; } } return -1; } } public class LodestoneBobber : MonoBehaviour { private Vector3 _basePos; private float _speed = 20f; private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _basePos = ((Component)this).transform.localPosition; } private void Update() { //IL_0007: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(Vector3.up, _speed * Time.deltaTime, (Space)0); float num = Mathf.Sin(Time.time * 2.2f) * 0.035f; ((Component)this).transform.localPosition = _basePos + new Vector3(0f, num, 0f); } } public static class StoneGeneratorModel { public static void Build(GameObject root, ZNetScene scene) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Expected O, but got Unknown //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Renderer[] components = root.GetComponents<Renderer>(); foreach (Renderer val in components) { Object.DestroyImmediate((Object)(object)val); } Collider[] components2 = root.GetComponents<Collider>(); foreach (Collider val2 in components2) { Object.DestroyImmediate((Object)(object)val2); } int num = LayerMask.NameToLayer("piece"); if (num >= 0) { root.layer = num; } GameObject val3 = new GameObject("ArcadeStoneGen_VisualContainer"); val3.transform.SetParent(root.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; GameObject val4 = ((scene != null) ? scene.GetPrefab("piece_stonefloor2x2") : null) ?? ((scene != null) ? scene.GetPrefab("stone_floor_2x2") : null) ?? ((scene != null) ? scene.GetPrefab("piece_stonefloor") : null) ?? ((scene != null) ? scene.GetPrefab("piece_stonewall1x1") : null); GameObject val5 = ((scene != null) ? scene.GetPrefab("piece_stonewall1x1") : null) ?? ((scene != null) ? scene.GetPrefab("stone_wall_1x1") : null) ?? ((scene != null) ? scene.GetPrefab("piece_stonepillar") : null) ?? val4; GameObject val6 = ((scene != null) ? scene.GetPrefab("piece_stonepillar") : null) ?? ((scene != null) ? scene.GetPrefab("stone_pillar") : null) ?? val5; GameObject val7 = ((scene != null) ? scene.GetPrefab("piece_stonearch") : null) ?? ((scene != null) ? scene.GetPrefab("stone_arch") : null); GameObject val8 = ((scene != null) ? scene.GetPrefab("piece_stonepile") : null) ?? ((scene != null) ? scene.GetPrefab("stone_pile") : null); if ((Object)(object)val4 != (Object)null) { CreateVisualPart(val3, val4, new Vector3(0f, 0.04f, 0f), Quaternion.identity, new Vector3(0.85f, 0.16f, 0.85f)); } if ((Object)(object)val5 != (Object)null) { float num2 = 0.74f; Vector3 localPos = default(Vector3); Vector3 localScale = default(Vector3); for (int k = 0; k < 8; k++) { float num3 = (float)k * 45f; float num4 = num3 * ((float)Math.PI / 180f); ((Vector3)(ref localPos))..ctor(Mathf.Sin(num4) * num2, 0.34f, Mathf.Cos(num4) * num2); Quaternion localRot = Quaternion.Euler(0f, num3, 0f); ((Vector3)(ref localScale))..ctor(0.64f, 0.65f, 0.32f); CreateVisualPart(val3, val5, localPos, localRot, localScale); } } if ((Object)(object)val8 != (Object)null) { CreateVisualPart(val3, val8, new Vector3(0f, 0.12f, 0f), Quaternion.Euler(0f, 25f, 0f), new Vector3(0.72f, 0.6f, 0.72f)); } else { GameObject val9 = StoneGeneratorPrefabs.ResolveStoneRockItem(scene) ?? StoneGeneratorPrefabs.ResolvePlaceableHardRock(scene); if ((Object)(object)val9 != (Object)null) { CreateVisualPart(val3, val9, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(0.7f, 0.5f, 0.7f)); CreateVisualPart(val3, val9, new Vector3(-0.25f, 0.25f, 0.2f), Quaternion.Euler(15f, 40f, 0f), new Vector3(0.5f, 0.5f, 0.5f)); CreateVisualPart(val3, val9, new Vector3(0.25f, 0.25f, -0.2f), Quaternion.Euler(-10f, 80f, 0f), new Vector3(0.55f, 0.55f, 0.55f)); } } if ((Object)(object)val6 != (Object)null) { CreateVisualPart(val3, val6, new Vector3(-0.72f, 0.85f, 0f), Quaternion.identity, new Vector3(0.38f, 0.85f, 0.38f)); CreateVisualPart(val3, val6, new Vector3(0.72f, 0.85f, 0f), Quaternion.identity, new Vector3(0.38f, 0.85f, 0.38f)); } if ((Object)(object)val7 != (Object)null) { CreateVisualPart(val3, val7, new Vector3(0f, 1.55f, 0f), Quaternion.identity, new Vector3(0.78f, 0.65f, 0.38f)); } else if ((Object)(object)val6 != (Object)null) { CreateVisualPart(val3, val6, new Vector3(0f, 1.55f, 0f), Quaternion.Euler(0f, 0f, 90f), new Vector3(0.38f, 0.78f, 0.38f)); } GameObject val10 = StoneGeneratorPrefabs.ResolveStoneRockItem(scene) ?? StoneGeneratorPrefabs.ResolvePlaceableHardRock(scene) ?? StoneGeneratorPrefabs.ResolveRunestonePrefab(scene); if ((Object)(object)val10 != (Object)null) { GameObject val11 = CreateVisualPart(val3, val10, new Vector3(0f, 1.05f, 0f), Quaternion.identity, new Vector3(0.46f, 0.46f, 0.46f)); if ((Object)(object)val11 != (Object)null) { val11.AddComponent<LodestoneBobber>(); } ManualLogSource log = ArcadeStoneGeneratorPlugin.Log; if (log != null) { log.LogInfo((object)("Mounted floating mystic lodestone (" + ((Object)val10).name + ") in Stone Well!")); } } GameObject val12 = new GameObject("ArcadeStoneGen_CyanLight"); val12.transform.SetParent(root.transform, false); val12.transform.localPosition = new Vector3(0f, 1.05f, 0f); Light val13 = val12.AddComponent<Light>(); val13.type = (LightType)2; val13.color = new Color(0.25f, 0.85f, 1f); val13.range = 3.8f; val13.intensity = 0.75f; val13.shadows = (LightShadows)0; GameObject val14 = new GameObject("ArcadeStoneGen_AmberLight"); val14.transform.SetParent(root.transform, false); val14.transform.localPosition = new Vector3(0f, 0.28f, 0f); Light val15 = val14.AddComponent<Light>(); val15.type = (LightType)2; val15.color = new Color(1f, 0.7f, 0.2f); val15.range = 2.2f; val15.intensity = 0.5f; val15.shadows = (LightShadows)0; BoxCollider val16 = root.AddComponent<BoxCollider>(); val16.center = new Vector3(0f, 0.08f, 0f); val16.size = new Vector3(1.7f, 0.16f, 1.7f); BoxCollider val17 = root.AddComponent<BoxCollider>(); val17.center = new Vector3(0f, 0.38f, 0f); val17.size = new Vector3(1.6f, 0.6f, 1.6f); BoxCollider val18 = root.AddComponent<BoxCollider>(); val18.center = new Vector3(-0.72f, 1.1f, 0f); val18.size = new Vector3(0.4f, 1.4f, 0.4f); BoxCollider val19 = root.AddComponent<BoxCollider>(); val19.center = new Vector3(0.72f, 1.1f, 0f); val19.size = new Vector3(0.4f, 1.4f, 0.4f); WearNTear component = root.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_new = val3; } } private static GameObject CreateVisualPart(GameObject parent, GameObject prefab, Vector3 localPos, Quaternion localRot, Vector3 localScale) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) if ((Object)(object)prefab == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(prefab, parent.transform, false); ((Object)val).name = ((Object)prefab).name + "_VisualClone"; val.transform.localPosition = localPos; val.transform.localRotation = localRot; val.transform.localScale = localScale; WearNTear component = val.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)component.m_snow != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)component.m_snow).gameObject); } if ((Object)(object)component.m_snowWorn != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)component.m_snowWorn).gameObject); } if ((Object)(object)component.m_snowBroken != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)component.m_snowBroken).gameObject); } if ((Object)(object)component.m_worn != (Object)null) { Object.DestroyImmediate((Object)(object)component.m_worn); } if ((Object)(object)component.m_broken != (Object)null) { Object.DestroyImmediate((Object)(object)component.m_broken); } } for (int num = val.transform.childCount - 1; num >= 0; num--) { Transform child = val.transform.GetChild(num); string text = ((Object)child).name.ToLowerInvariant(); if (text.Contains("snow") || text.Contains("worn") || text.Contains("broken")) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val2); } Collider[] componentsInChildren2 = val.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val3); } Renderer[] componentsInChildren3 = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren3) { Material[] sharedMaterials = val4.sharedMaterials; bool flag = false; for (int l = 0; l < sharedMaterials.Length; l++) { if (((Object)(object)sharedMaterials[l] == (Object)null || (Object)(object)sharedMaterials[l].shader == (Object)null || ((Object)sharedMaterials[l].shader).name == "Hidden/InternalErrorShader") && sharedMaterials.Length != 0 && (Object)(object)sharedMaterials[0] != (Object)null && (Object)(object)sharedMaterials[0].shader != (Object)null && ((Object)sharedMaterials[0].shader).name != "Hidden/InternalErrorShader") { sharedMaterials[l] = sharedMaterials[0]; flag = true; } } if (flag) { val4.sharedMaterials = sharedMaterials; } } return val; } } }