Decompiled source of BeachPieces v1.0.0

plugins/BeachPieces.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BeachPieces")]
[assembly: AssemblyDescription("https://discord.gg/zRucjV8rqc")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MagicMike")]
[assembly: AssemblyProduct("BeachPieces")]
[assembly: AssemblyCopyright("Copyright © MagicMike 2025BeachPieces")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BeachPieces
{
	internal class Inflatable : MonoBehaviour, Hoverable, Interactable
	{
		public string m_name = "Inflatable";

		public float m_useDistance = 1.5f;

		public Transform m_attachPoint;

		public Vector3 m_detachOffset = new Vector3(0f, 0f, 0f);

		private static string m_attachAnimation = "attach_bed";

		private static float m_lastAttachTime;

		public string GetHoverText()
		{
			if (Time.time - m_lastAttachTime < 2f)
			{
				return "";
			}
			if (!InUseDistance((Humanoid)(object)Player.m_localPlayer))
			{
				return Localization.instance.Localize("<color=#888888>$piece_toofar</color>");
			}
			return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use");
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public bool Interact(Humanoid human, bool hold, bool alt)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (hold)
			{
				return false;
			}
			if (Time.time - m_lastAttachTime < 2f)
			{
				return false;
			}
			Player val = (Player)(object)((human is Player) ? human : null);
			if (!InUseDistance((Humanoid)(object)val))
			{
				return false;
			}
			if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Wet")))
			{
				((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Wet"), true);
			}
			((Character)val).AttachStart(m_attachPoint, ((Component)this).gameObject, true, false, false, m_attachAnimation, m_detachOffset, (Transform)null);
			m_lastAttachTime = Time.time;
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		private bool InUseDistance(Humanoid human)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Vector3.Distance(((Component)human).transform.position, m_attachPoint.position) < m_useDistance;
		}
	}
	internal class FileWatcher
	{
		public static void WatchFileChanges(string path, Action onChanged)
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
			string directoryName = Path.GetDirectoryName(path);
			string fileName = Path.GetFileName(path);
			fileSystemWatcher.Path = directoryName;
			fileSystemWatcher.Filter = fileName;
			fileSystemWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
			fileSystemWatcher.Changed += delegate
			{
				onChanged?.Invoke();
			};
			fileSystemWatcher.Deleted += delegate
			{
				onChanged?.Invoke();
			};
			fileSystemWatcher.Created += delegate
			{
				onChanged?.Invoke();
			};
			fileSystemWatcher.Renamed += delegate
			{
				onChanged?.Invoke();
			};
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		public static void WatchTranslationChanges(string path, Action onChanged)
		{
			if (!Directory.Exists(BeachPiecesPlugin.TranslationFilePath))
			{
				return;
			}
			try
			{
				WatchFileChanges(Path.Combine(path, "*.*"), onChanged);
			}
			catch
			{
				Logger.LogError((object)"There was an issue loading Translation files!");
			}
		}
	}
	internal class LocalisedText
	{
		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		public static void AddLocalisations()
		{
			CustomLocalization localization = Localization;
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "piece_bp_beach_bar", "Beach Bar" },
				{ "piece_bp_sandcastle_large", "Large Sand Castle" },
				{ "piece_bp_beach_chair", "Beach Chair" },
				{ "piece_bp_lifeguard_chair", "Lifeguard Chair" },
				{ "piece_bp_surfboard", "Surfboard" },
				{ "piece_bp_shell_01", "Shell 01" },
				{ "piece_bp_shell_02", "Shell 02" },
				{ "piece_bp_shell_03", "Shell 03" },
				{ "piece_bp_starfish", "Starfish" },
				{ "piece_bp_palm", "Palm Tree" },
				{ "piece_bp_inflatable", "Inflatable" },
				{ "piece_bp_parasol", "Parasol" }
			});
			CustomLocalization localization2 = Localization;
			text = "English";
			localization2.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_bp_beachball", "Beach Ball" },
				{ "item_bp_wilsonball", "Wilson Ball" },
				{ "item_bp_coconut_drink", "Coconut Drink" }
			});
		}
	}
	internal class AddPieces
	{
		public static EffectList buildWood;

		public static EffectList breakWood;

		public static EffectList hitWood;

		public static EffectList breakGlass;

		public static EffectList buildMetal;

		public static EffectList breakMetal;

		public static EffectList hitMetal;

		public static EffectList buildStone;

		public static EffectList breakStone;

		public static EffectList hitStone;

		public static void LoadPieces()
		{
			AddFX();
			AddBeachBar();
			AddSandCastleLarge();
			AddBeachChair();
			AddLifeguardChair();
			AddSurfboard();
			AddShell01();
			AddShell02();
			AddShell03();
			AddStarfish();
			AddPalmTree();
			AddInflatable();
			AddParasol();
		}

		public static void AddFX()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cd: 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_00da: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00f7: 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_0104: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_01f8: 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_0206: Expected O, but got Unknown
			GameObject prefab = Cache.GetPrefab<GameObject>("sfx_build_hammer_wood");
			GameObject prefab2 = Cache.GetPrefab<GameObject>("sfx_wood_break");
			GameObject prefab3 = Cache.GetPrefab<GameObject>("sfx_wood_hit");
			GameObject prefab4 = Cache.GetPrefab<GameObject>("sfx_break_glass_mm");
			GameObject prefab5 = Cache.GetPrefab<GameObject>("sfx_build_hammer_metal");
			GameObject prefab6 = Cache.GetPrefab<GameObject>("sfx_metal_blocked");
			GameObject prefab7 = Cache.GetPrefab<GameObject>("sfx_build_hammer_stone");
			GameObject prefab8 = Cache.GetPrefab<GameObject>("sfx_rock_destroyed");
			GameObject prefab9 = Cache.GetPrefab<GameObject>("sfx_rock_hit");
			EffectList val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab
				}
			};
			buildWood = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab2
				}
			};
			breakWood = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab3
				}
			};
			hitWood = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab4
				}
			};
			breakGlass = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab5
				}
			};
			buildMetal = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab6
				}
			};
			breakMetal = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab6
				}
			};
			hitMetal = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab7
				}
			};
			buildStone = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab8
				}
			};
			breakStone = val;
			val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = prefab9
				}
			};
			hitStone = val;
		}

		public static void AddBeachBar()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0062: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_beach_bar");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 50,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddSandCastleLarge()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_sandcastle_large");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddBeachChair()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_beach_chair");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddLifeguardChair()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_lifeguard_chair");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddSurfboard()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_surfboard");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddShell01()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_shell_01");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddShell02()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_shell_02");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddShell03()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_shell_03");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddStarfish()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_starfish");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddPalmTree()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_palm_tree");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddInflatable()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_inflatable");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}

		public static void AddParasol()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_parasol");
			PieceConfig val2 = new PieceConfig();
			val2.CraftingStation = "piece_workbench";
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "BeachParty";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomPiece val3 = new CustomPiece(val, false, val2);
			val.GetComponent<Piece>().m_placeEffect = buildWood;
			WearNTear component = val.GetComponent<WearNTear>();
			component.m_destroyedEffect = breakWood;
			component.m_hitEffect = hitWood;
			PieceManager.Instance.AddPiece(val3);
		}
	}
	internal class AddItems
	{
		public static void LoadItems()
		{
			AddCoconutDrink();
			AddBeachBall();
			AddWilsonBall();
		}

		public static void AddCoconutDrink()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			GameObject obj = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_coconut_drink");
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.CraftingStation = "piece_workbench";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomItem val2 = new CustomItem(obj, false, val);
			ItemManager.Instance.AddItem(val2);
		}

		public static void AddBeachBall()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			GameObject obj = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_beach_ball");
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.CraftingStation = "piece_workbench";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomItem val2 = new CustomItem(obj, false, val);
			ItemManager.Instance.AddItem(val2);
		}

		public static void AddWilsonBall()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			GameObject obj = BeachPiecesPlugin.bpieces.LoadAsset<GameObject>("bp_wilson_ball");
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.CraftingStation = "piece_workbench";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Coins",
					Amount = 1,
					Recover = true
				}
			};
			CustomItem val2 = new CustomItem(obj, false, val);
			ItemManager.Instance.AddItem(val2);
		}
	}
	[BepInPlugin("MagicMike.BeachPieces", "BeachPieces", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class BeachPiecesPlugin : BaseUnityPlugin
	{
		public const string PluginName = "BeachPieces";

		public const string PluginVersion = "1.0.0";

		public const string PluginAuthor = "MagicMike";

		internal const string PluginGUID = "MagicMike.BeachPieces";

		internal const string PluginCopy = "Copyright © MagicMike 2025BeachPieces";

		public const string PluginLink = "https://discord.gg/zRucjV8rqc";

		private static char pds = Path.DirectorySeparatorChar;

		public static readonly string _basePath = Paths.ConfigPath + pds + "BeachPieces";

		public static readonly string TranslationFilePath = _basePath + pds + "Translations";

		private CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		public static BeachPiecesPlugin plugininstance;

		public static AssetBundle bpieces;

		public static string beachBundle = "beachpieces";

		public void Awake()
		{
			plugininstance = this;
			MainConfig.InitConfigs(((BaseUnityPlugin)this).Config);
			if (MainConfig.modEnabled.Value)
			{
				LoadAssetBundle();
				CheckForFolders();
				LocalisedText.AddLocalisations();
				LoadLocalisationData(TranslationFilePath);
				FileWatcher.WatchTranslationChanges(TranslationFilePath, delegate
				{
					LoadLocalisationData(TranslationFilePath);
				});
				PrefabManager.OnVanillaPrefabsAvailable += LoadBeachItems;
				PrefabManager.OnVanillaPrefabsAvailable += LoadBeachPieces;
				Game.isModded = true;
			}
		}

		public void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		public static void LoadAssetBundle()
		{
			bpieces = AssetUtils.LoadAssetBundleFromResources(beachBundle, Assembly.GetExecutingAssembly());
			if ((Object)(object)bpieces == (Object)null)
			{
				Logger.LogError((object)("Failed to load asset bundle with name: " + beachBundle));
			}
		}

		public static void CheckForFolders()
		{
			if (!Directory.Exists(_basePath))
			{
				Logger.LogInfo((object)"Creating CoreWoodExtras Directory");
				Directory.CreateDirectory(_basePath);
			}
			if (!Directory.Exists(TranslationFilePath))
			{
				Logger.LogInfo((object)"Creating Translations folder");
				Directory.CreateDirectory(TranslationFilePath);
			}
		}

		public void LoadLocalisationData(string directory)
		{
			string[] fileSystemEntries = Directory.GetFileSystemEntries(directory, "*.json", SearchOption.AllDirectories);
			foreach (string path in fileSystemEntries)
			{
				string name = new DirectoryInfo(Path.GetDirectoryName(path)).Name;
				Path.GetFileNameWithoutExtension(path);
				Localization.AddJsonFile(name, File.ReadAllText(path));
			}
		}

		private void LoadBeachItems()
		{
			try
			{
				AddItems.LoadItems();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Exception caught while loading Beach Items: " + ex.Message));
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= LoadBeachItems;
			}
		}

		private void LoadBeachPieces()
		{
			try
			{
				AddPieces.LoadPieces();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Exception caught while loading Beach Pieces: " + ex.Message));
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= LoadBeachPieces;
			}
		}
	}
	internal static class MainConfig
	{
		internal const string GeneralSection = "General Settings";

		public static ConfigEntry<bool> modEnabled;

		public static void InitConfigs(ConfigFile config)
		{
			modEnabled = ConfigFileExtensions.BindConfigInOrder<bool>(config, "General Settings", "Enable Plugin", true, "Enable this plugin.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null);
		}
	}
}