Decompiled source of Fincha Mod v1.0.2

FinchaMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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 BepInEx;
using HarmonyLib;
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("FinchaMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FinchaMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9f4ef8ae-7132-4988-b8f9-4133bad9924d")]
[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 FinchaMod;

[BepInPlugin("com.LORDAERON.fincha", "Fincha Mod", "1.0.0")]
public class FinchaPlugin : BaseUnityPlugin
{
	public static GameObject finchaPrefab;

	private void Awake()
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, "finchabundle");
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val != (Object)null)
		{
			finchaPrefab = val.LoadAsset<GameObject>("Fincha");
			finchaPrefab.AddComponent<FinchaLogic>();
			Piece val2 = finchaPrefab.GetComponent<Piece>();
			ZNetView val3 = finchaPrefab.GetComponent<ZNetView>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = finchaPrefab.AddComponent<ZNetView>();
			}
			val3.m_persistent = true;
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = finchaPrefab.AddComponent<Piece>();
			}
			val2.m_icon = val.LoadAsset<Sprite>("Finchab");
			val2.m_comfort = 2;
			val2.m_comfortGroup = (ComfortGroup)0;
			WearNTear val4 = finchaPrefab.GetComponent<WearNTear>();
			if ((Object)(object)val4 == (Object)null)
			{
				val4 = finchaPrefab.AddComponent<WearNTear>();
			}
			val4.m_health = 1000f;
			val4.m_noRoofWear = true;
			val4.m_noSupportWear = true;
			Harmony.CreateAndPatchAll(typeof(FinchaPlugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Финча-батон успешно инициализирован!");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Не удалось найти finchabundle! Убедись, что файл лежит рядом с .dll");
		}
	}

	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	[HarmonyPostfix]
	private static void ZNetSceneAwakePatch(ZNetScene __instance)
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Expected O, but got Unknown
		if ((Object)(object)finchaPrefab == (Object)null)
		{
			return;
		}
		Piece component = finchaPrefab.GetComponent<Piece>();
		if ((Object)(object)component != (Object)null)
		{
			bool flag = PlayerPrefs.GetString("language", "English") == "Russian";
			component.m_name = (flag ? "ЗаБАТОНированный Финча" : "Loafed Fincha");
			component.m_description = (flag ? "Он конечно всратыш, но смотрите какой :з." : "He is a bit derpy, but look at him :3.");
			GameObject prefab = __instance.GetPrefab("WolfPelt");
			GameObject prefab2 = __instance.GetPrefab("TrophyDragonQueen");
			if ((Object)(object)prefab != (Object)null && (Object)(object)prefab2 != (Object)null)
			{
				component.m_resources = (Requirement[])(object)new Requirement[2]
				{
					new Requirement
					{
						m_resItem = prefab.GetComponent<ItemDrop>(),
						m_amount = 5,
						m_recover = true
					},
					new Requirement
					{
						m_resItem = prefab2.GetComponent<ItemDrop>(),
						m_amount = 1,
						m_recover = true
					}
				};
				GameObject prefab3 = __instance.GetPrefab("piece_workbench");
				if ((Object)(object)prefab3 != (Object)null)
				{
					component.m_craftingStation = prefab3.GetComponent<CraftingStation>();
					Piece component2 = prefab3.GetComponent<Piece>();
					if ((Object)(object)component2 != (Object)null)
					{
						component.m_placeEffect = component2.m_placeEffect;
					}
					WearNTear component3 = prefab3.GetComponent<WearNTear>();
					WearNTear component4 = finchaPrefab.GetComponent<WearNTear>();
					if ((Object)(object)component3 != (Object)null && (Object)(object)component4 != (Object)null)
					{
						component4.m_destroyedEffect = component3.m_destroyedEffect;
						component4.m_hitEffect = component3.m_hitEffect;
					}
				}
			}
		}
		__instance.m_prefabs.Add(finchaPrefab);
		Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs").GetValue(__instance);
		dictionary[StringExtensionMethods.GetStableHashCode(((Object)finchaPrefab).name)] = finchaPrefab;
		GameObject prefab4 = __instance.GetPrefab("Hammer");
		if ((Object)(object)prefab4 != (Object)null)
		{
			PieceTable buildPieces = prefab4.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
			if (!buildPieces.m_pieces.Contains(finchaPrefab))
			{
				buildPieces.m_pieces.Add(finchaPrefab);
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	[HarmonyPostfix]
	private static void ObjectDBAwakePatch(ObjectDB __instance)
	{
		if ((Object)(object)finchaPrefab != (Object)null)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(ObjectDB), "m_itemByHash");
			if (fieldInfo != null)
			{
				Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)fieldInfo.GetValue(__instance);
				dictionary[StringExtensionMethods.GetStableHashCode(((Object)finchaPrefab).name)] = finchaPrefab;
			}
		}
	}
}
public class FinchaLogic : MonoBehaviour, Interactable, Hoverable
{
	[CompilerGenerated]
	private sealed class <HealRoutine>d__3 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public FinchaLogic <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)<>4__this.audioSource != (Object)null && <>4__this.audioSource.isPlaying)
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					((Character)Player.m_localPlayer).Heal(10f, true);
				}
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 1;
				return true;
			}
			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();
		}
	}

	private AudioSource audioSource;

	private void Awake()
	{
		audioSource = ((Component)this).GetComponent<AudioSource>();
		if ((Object)(object)audioSource != (Object)null)
		{
			audioSource.volume = 1f;
			audioSource.spatialBlend = 0.5f;
			audioSource.minDistance = 20f;
			audioSource.maxDistance = 60f;
			audioSource.rolloffMode = (AudioRolloffMode)1;
		}
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if ((Object)(object)audioSource != (Object)null && !audioSource.isPlaying)
		{
			audioSource.Play();
			((MonoBehaviour)this).StartCoroutine(HealRoutine());
		}
		return true;
	}

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

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

	public string GetHoverText()
	{
		bool flag = PlayerPrefs.GetString("language", "English") == "Russian";
		string text = (flag ? "ЗаБАТОНненный Финча" : "Loafed Fincha");
		string text2 = (flag ? "Погладить" : "Pet");
		return text + "\n[<color=#A5A5A5><b>E</b></color>] " + text2;
	}

	public string GetHoverName()
	{
		return (PlayerPrefs.GetString("language", "English") == "Russian") ? "ЗаБАТОНненный Финча" : "Loafed Fincha";
	}
}