Decompiled source of Genesis v2.6.0

Genesiss.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Genesiss")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Genesiss")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04ef0a3f-9697-441c-9a23-eb36ed9faf0d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class GenesisLines
{
	public enum LType
	{
		Arrival,
		Warning
	}

	private struct Line
	{
		public string text;

		public LType type;

		public int weight;

		public Line(string t, LType ty, int w)
		{
			text = t;
			type = ty;
			weight = w;
		}
	}

	private static readonly Line[] lines = new Line[90]
	{
		new Line("Genesis! GENESIS!!!", LType.Arrival, 10),
		new Line("Where are you, Genesis?!", LType.Arrival, 8),
		new Line("Quick! Someone find Genesis!", LType.Arrival, 9),
		new Line("Genesis is here somewhere!", LType.Arrival, 6),
		new Line("Don't let Genesis escape!", LType.Arrival, 10),
		new Line("MISSION UPDATE: GENESIS PRESENT. PET RESPONSIBLY.", LType.Arrival, 5),
		new Line("GENESIS IS IN THE BUILDING!", LType.Arrival, 10),
		new Line("Did you hear that?! That was definitely Genesis!", LType.Arrival, 4),
		new Line("Genesis has graced us with her presence.", LType.Arrival, 5),
		new Line("Scanning… Genesis signature confirmed. Approach with caution.", LType.Arrival, 8),
		new Line("GENESIS! I've detected lifeforms nearby… oh wait, that's her!", LType.Arrival, 6),
		new Line("Genesis spotted! Deploy petting protocol, but… gently.", LType.Arrival, 8),
		new Line("She's here… my sensors are overloading from her cuteness!", LType.Arrival, 5),
		new Line("Approach Genesis slowly. She may bite if over-stimulated.", LType.Arrival, 3),
		new Line("Genesis is within range. Pet to restore health… but moderation is key.", LType.Arrival, 2),
		new Line("Scan complete: Genesis is currently… judging.", LType.Arrival, 8),
		new Line("I would die for Genesis.", LType.Arrival, 4),
		new Line("My therapist said I need to stop talking about Genesis. My therapist was wrong.", LType.Arrival, 5),
		new Line("I love Genesis so much!", LType.Arrival, 9),
		new Line("I should support Genesis' creator at ko-fi.com/eberk30", LType.Arrival, 2),
		new Line("First droid out of the truck gets to pet Genesis!", LType.Arrival, 7),
		new Line("Psta Psti Psta Come here Genesis!", LType.Arrival, 3),
		new Line("VALUABLE DETECTED: GENESIS. PET FOR BENEFITS, BUT CAUTION ADVISED.", LType.Arrival, 4),
		new Line("GENESIS IS ON SITE. HANDLE WITH CARE. OVERPETTING MAY RESULT IN DAMAGE.", LType.Arrival, 6),
		new Line("Do you think I could get her pawtograph?", LType.Arrival, 7),
		new Line("Genesis. Genesis. Wherefore art thou, Genesis?", LType.Arrival, 8),
		new Line("I bet my life-savings that I will find Genesis first!", LType.Arrival, 6),
		new Line("Wait. What was my line again?", LType.Arrival, 2),
		new Line("Genesis stared at a wall for 10 minutes. The wall blinked first.", LType.Arrival, 5),
		new Line("I came here to find Genesis and chew bubblegum, and i'm all out of bubblegum", LType.Arrival, 4),
		new Line("GENESIS HAS BREACHED CONTAINMENT!", LType.Arrival, 8),
		new Line("WHO LEFT THE DOOR OPEN FOR GENESIS?!", LType.Arrival, 3),
		new Line("I REPEAT, GENESIS IS LOOSE!", LType.Arrival, 7),
		new Line("THIS IS NOT A DRILL. GENESIS IS ACTIVE.", LType.Arrival, 5),
		new Line("Stay calm. Stay calm. It's just Genesis. We're fine. We're NOT fine.", LType.Arrival, 6),
		new Line("Genesis was last seen… everywhere at once.", LType.Arrival, 10),
		new Line("Genesis blinked. That means something. I just know it.", LType.Arrival, 2),
		new Line("This facility is no longer Genesis-proof.", LType.Arrival, 8),
		new Line("Genesis has been here the whole time.", LType.Arrival, 7),
		new Line("You don't find Genesis. Genesis finds you.", LType.Arrival, 6),
		new Line("Genesis has been spotted… no wait… false alarm… keep searching!", LType.Arrival, 5),
		new Line("All sensors indicate Genesis is in the vicinity!", LType.Arrival, 7),
		new Line("Genesis is unpredictable. Treat with respect and caution.", LType.Arrival, 6),
		new Line("Genesis is here. Sensors indicate high cuteness and moderate danger.", LType.Arrival, 9),
		new Line("Approach Genesis… slowly… slowly… maybe faster? Wait.", LType.Arrival, 4),
		new Line("All units, locate Genesis immediately!", LType.Arrival, 7),
		new Line("68 different lines and I had to say this one?", LType.Arrival, 1),
		new Line("Genesis' location is unconfirmed. Search pattern initiated.", LType.Arrival, 6),
		new Line("Do you hear that? That's definitely Genesis!", LType.Arrival, 9),
		new Line("Genesis is evaluating your threat level… or maybe your snack supply.", LType.Arrival, 6),
		new Line("GENESIS HAS BEEN SPOTTED! Initiate cautious approach.", LType.Arrival, 10),
		new Line("I for one welcome our Genesis overlord.", LType.Arrival, 8),
		new Line("Genesis could be anywhere… including above you!", LType.Arrival, 5),
		new Line("Genesis is near! Visual confirmation required!", LType.Arrival, 9),
		new Line("Containment failed the moment she arrived.", LType.Arrival, 7),
		new Line("Genesis has been located… mostly… probably… maybe.", LType.Arrival, 3),
		new Line("Genesis is not a cat. Genesis is an event.", LType.Arrival, 6),
		new Line("I heard a noise… Did she knock something over?..", LType.Arrival, 5),
		new Line("The prophecy is true. Genesis walks among us.", LType.Arrival, 8),
		new Line("Genesis presence detected. Do not panic… too much.", LType.Arrival, 8),
		new Line("Please don't bite me this time...", LType.Warning, 8),
		new Line("I just want to pet her, that's all I ask.", LType.Warning, 8),
		new Line("Warning: Genesis may heal or harm depending on petting intensity.", LType.Warning, 8),
		new Line("Genesis appears to be in a playful mood… but that can change instantly.", LType.Warning, 6),
		new Line("Her presence heals… her wrath hurts. Proceed carefully.", LType.Warning, 5),
		new Line("Activating Healing protocol via Genesis interaction… but monitor her mood!", LType.Warning, 10),
		new Line("Engage with Genesis to recover health… disengage if she hisses.", LType.Warning, 4),
		new Line("She meowed. That felt like a threat.", LType.Warning, 3),
		new Line("Her tail is swishing.", LType.Warning, 7),
		new Line("I think Genesis is getting annoyed.", LType.Warning, 9),
		new Line("Wait. How many pets were left?", LType.Warning, 2),
		new Line("Hello Mr. Enemy, I'm over here!", LType.Warning, 1),
		new Line("She's staring at me. She's DEFINITELY staring at me.", LType.Warning, 4),
		new Line("That's the look. You know the look.", LType.Warning, 7),
		new Line("Genesis' ears just went flat. That's bad. That's very bad.", LType.Warning, 6),
		new Line("I may have miscounted the pets.", LType.Warning, 4),
		new Line("Her patience has a limit. I think we're close.", LType.Warning, 8),
		new Line("Okay. Okay. Last one. Easy. Don't blow it.", LType.Warning, 9),
		new Line("She just flicked her tail. Abort? Don't abort?", LType.Warning, 7),
		new Line("Tread lightly. Genesis is… considering her options.", LType.Warning, 5),
		new Line("I think she's been tolerating us, not enjoying us.", LType.Warning, 6),
		new Line("Last pet, guys.", LType.Warning, 2),
		new Line("One more and I think she snaps.", LType.Warning, 5),
		new Line("She's giving me the slow blink. That means love. Right? ...Right?", LType.Warning, 4),
		new Line("Her pupils just went huge. Run or stay? Run or stay?", LType.Warning, 6),
		new Line("Genesis has entered threat assessment mode.", LType.Warning, 8),
		new Line("I can feel her judging me from across the room.", LType.Warning, 8),
		new Line("She just knocked something over on purpose. Message received.", LType.Warning, 4),
		new Line("That was the warning meow. I know the warning meow.", LType.Warning, 7),
		new Line("Her tail is puffed up. We messed up.", LType.Warning, 8)
	};

	public static string GetRandomLine(LType type)
	{
		List<string> list = new List<string>();
		Line[] array = lines;
		for (int i = 0; i < array.Length; i++)
		{
			Line line = array[i];
			if (line.type == type)
			{
				for (int j = 0; j < line.weight; j++)
				{
					list.Add(line.text);
				}
			}
		}
		if (list.Count == 0)
		{
			return "GENESIS DETECTED.";
		}
		return list[Random.Range(0, list.Count)];
	}
}
[BepInPlugin("eberk30.genesis", "Genesis", "2.6.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("REPO.exe")]
public class GenesisPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ValuableDirector), "SetupHost")]
	internal static class SpawnPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !SpawningEnabled.Value)
			{
				return;
			}
			Level levelCurrent = RunManager.instance.levelCurrent;
			if ((Object)(object)levelCurrent == (Object)(object)RunManager.instance.levelMainMenu || (Object)(object)levelCurrent == (Object)(object)RunManager.instance.levelLobby || Random.value > SpawnChance.Value)
			{
				return;
			}
			PrefabRef val = ((IEnumerable<PrefabRef>)Valuables.RegisteredValuables).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef v) => v.PrefabName == "Genesis"));
			if (val == null)
			{
				return;
			}
			int num = 0;
			ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)((Component)array[i]).gameObject).name.StartsWith("Genesis"))
				{
					num++;
				}
			}
			if (num >= SpawnCount.Value)
			{
				return;
			}
			List<ValuableVolume> list = new List<ValuableVolume>();
			ValuableVolume[] array2 = Object.FindObjectsOfType<ValuableVolume>();
			foreach (ValuableVolume val2 in array2)
			{
				if (((Object)val2).name.Contains("Medium") || ((Object)val2).name.Contains("Big"))
				{
					list.Add(val2);
				}
			}
			if (list.Count != 0)
			{
				int num2 = Mathf.Min(SpawnCount.Value - num, list.Count);
				for (int j = 0; j < num2; j++)
				{
					int index = Random.Range(0, list.Count);
					Valuables.SpawnValuable(val, ((Component)list[index]).transform.position, Quaternion.identity);
					list.RemoveAt(index);
				}
				if (Random.value <= ChatChance.Value)
				{
					((MonoBehaviour)Instance).StartCoroutine(ChatOnSpawn());
				}
			}
		}
	}

	[HarmonyPatch(typeof(ValuableObject), "Start")]
	private static class GenesisStartPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ValuableObject __instance)
		{
			if (((Object)((Component)__instance).gameObject).name.StartsWith("Genesis") && !((Object)(object)((Component)__instance).gameObject.GetComponent<GenesisHealBehaviour>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<GenesisHealBehaviour>();
			}
		}
	}

	[HarmonyPatch(typeof(ItemToggle), "ToggleItemLogic")]
	internal static class EPressPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemToggle __instance, bool toggle)
		{
			if (toggle && ((Object)((Component)__instance).gameObject).name.StartsWith("Genesis"))
			{
				PhysGrabObject component = ((Component)__instance).gameObject.GetComponent<PhysGrabObject>();
				if (!((Object)(object)component == (Object)null) && component.grabbedLocal)
				{
					((Component)__instance).gameObject.GetComponent<GenesisHealBehaviour>()?.OnPet();
				}
			}
		}
	}

	[HarmonyPatch(typeof(ItemToggle), "Update")]
	internal static class HoldingPromptPatch
	{
		[HarmonyPostfix]
		private static void UpdatePrompt(ItemToggle __instance)
		{
			if (!((Object)((Component)__instance).gameObject).name.StartsWith("Genesis"))
			{
				return;
			}
			PhysGrabObject component = ((Component)__instance).gameObject.GetComponent<PhysGrabObject>();
			if ((Object)(object)component == (Object)null || !component.grabbedLocal)
			{
				return;
			}
			GenesisHealBehaviour component2 = ((Component)__instance).gameObject.GetComponent<GenesisHealBehaviour>();
			string text = (((Object)(object)component2 != (Object)null && component2.petsLeft > 0) ? "#00FF00" : "#FF4444");
			string text2 = InputManager.instance.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>");
			try
			{
				SemiFunc.UIItemInfoText((ItemAttributes)null, "Genesis <color=#FFFFFF>[" + text2 + "]</color> <color=" + text + ">Pet</color>");
			}
			catch
			{
			}
		}
	}

	[CompilerGenerated]
	private sealed class <ChatOnSpawn>d__18 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private float <waited>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<waited>5__2 = 0f;
				goto IL_0067;
			case 1:
				<>1__state = -1;
				<waited>5__2 += Time.deltaTime;
				if (<waited>5__2 > 60f)
				{
					return false;
				}
				goto IL_0067;
			case 2:
				{
					<>1__state = -1;
					List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
					if (list.Count == 0)
					{
						return false;
					}
					string randomLine = GenesisLines.GetRandomLine(GenesisLines.LType.Arrival);
					PlayerAvatar val = list[Random.Range(0, list.Count)];
					ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
					foreach (ValuableObject val2 in array)
					{
						if (((Object)((Component)val2).gameObject).name.StartsWith("Genesis"))
						{
							((Component)val2).GetComponent<PhotonView>().RPC("TriggerChatRPC", (RpcTarget)0, new object[2]
							{
								randomLine,
								val.photonView.ViewID
							});
							break;
						}
					}
					return false;
				}
				IL_0067:
				if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 2;
				return true;
			}
		}

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

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

	public static GenesisPlugin Instance;

	public static ManualLogSource Log;

	public static ConfigEntry<bool> SpawningEnabled;

	public static ConfigEntry<float> SpawnChance;

	public static ConfigEntry<int> SpawnCount;

	public static ConfigEntry<float> ChatChance;

	public static NetworkedEvent GenesisHealEvent;

	public static FieldInfo HpField;

	public static FieldInfo MaxHpField;

	public static FieldInfo DollarField;

	public static AudioClip PurrClip;

	public static AudioClip HissClip;

	public static AudioClip[] SpawnSounds;

	public const int healAmt = 10;

	public const int maxPets = 3;

	public const int biteDmg = 5;

	private void Awake()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Expected O, but got Unknown
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Expected O, but got Unknown
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Expected O, but got Unknown
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		SpawningEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Controlled Spawning", "Enable Controlled Spawning", false, "Turn this on to control the spawn rate");
		SpawnCount = ((BaseUnityPlugin)this).Config.Bind<int>("Controlled Spawning", "Spawn Count", 1, new ConfigDescription("How many Genesis items per level. Must enable Controlled Spawning.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
		SpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Controlled Spawning", "Spawn Chance", 0.5f, new ConfigDescription("0 = never, 1 = always. Must enable Controlled Spawning.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		ChatChance = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "Chat Line Chance", 0.25f, new ConfigDescription("Chance a player reacts when Genesis spawns", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		GenesisHealEvent = new NetworkedEvent("GenesisHeal", (Action<EventData>)HealNearby);
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "genesisbundle");
		AssetBundle val = null;
		foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
		{
			if (((Object)allLoadedAssetBundle).name.StartsWith("genesisbundle"))
			{
				val = allLoadedAssetBundle;
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			val = AssetBundle.LoadFromFile(text);
		}
		if ((Object)(object)val == (Object)null)
		{
			Log.LogError((object)"couldn't load genesisbundle");
			return;
		}
		List<AudioClip> list = new List<AudioClip>();
		AudioClip[] array = val.LoadAllAssets<AudioClip>();
		foreach (AudioClip val2 in array)
		{
			if (((Object)val2).name.ToLower() == "purr")
			{
				PurrClip = val2;
			}
			else if (((Object)val2).name.ToLower() == "hiss")
			{
				HissClip = val2;
			}
			else
			{
				list.Add(val2);
			}
		}
		SpawnSounds = list.ToArray();
		try
		{
			Upgrades.RegisterUpgrade("GenesisLove", (Item)null, (Action<PlayerAvatar, int>)null, (Action<PlayerAvatar, int>)null);
		}
		catch
		{
		}
		try
		{
			Upgrades.RegisterUpgrade("GenesisPatience", (Item)null, (Action<PlayerAvatar, int>)null, (Action<PlayerAvatar, int>)null);
		}
		catch
		{
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
		HpField = typeof(PlayerHealth).GetField("health", bindingAttr);
		MaxHpField = typeof(PlayerHealth).GetField("maxHealth", bindingAttr);
		DollarField = typeof(ValuableObject).GetField("dollarValueCurrent", bindingAttr);
		new Harmony("eberk30.genesis").PatchAll();
		Log.LogInfo((object)"Genesis has escaped");
	}

	private static void HealNearby(EventData data)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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 (!(data.CustomData is float[] array))
		{
			return;
		}
		PlayerAvatar instance = PlayerAvatar.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		int num = (int)HpField.GetValue(instance.playerHealth);
		int num2 = (int)MaxHpField.GetValue(instance.playerHealth);
		if (num < num2)
		{
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(array[0], array[1], array[2]);
			Vector3 val2 = ((Component)instance).transform.position - val;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 16f))
			{
				PlayerUpgrade upgrade = Upgrades.GetUpgrade("GenesisLove");
				instance.playerHealth.HealOther(10 + ((upgrade != null) ? (upgrade.GetLevel(instance) * 5) : 0), true);
			}
		}
	}

	[IteratorStateMachine(typeof(<ChatOnSpawn>d__18))]
	public static IEnumerator ChatOnSpawn()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ChatOnSpawn>d__18(0);
	}
}
public class GenesisHealBehaviour : MonoBehaviourPun
{
	[CompilerGenerated]
	private sealed class <>c__DisplayClass11_0
	{
		public int playerViewID;

		public string line;
	}

	[CompilerGenerated]
	private sealed class <MeowLoop>d__3 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public GenesisHealBehaviour <>4__this;

		private float <min>5__2;

		private float <max>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			int num = <>1__state;
			GenesisHealBehaviour genesisHealBehaviour = <>4__this;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				((MonoBehaviourPun)genesisHealBehaviour).photonView.RPC("PlayAmbientSoundRPC", (RpcTarget)0, new object[1] { Random.Range(0, GenesisPlugin.SpawnSounds.Length) });
			}
			else
			{
				<>1__state = -1;
				if (SemiFunc.IsMultiplayer() && !PhotonNetwork.IsMasterClient)
				{
					return false;
				}
				PlayerUpgrade upgrade = Upgrades.GetUpgrade("GenesisTreats");
				int num2 = ((upgrade != null) ? upgrade.GetLevel(PlayerAvatar.instance) : 0);
				<min>5__2 = 30f + (float)num2 * 25f;
				if (<min>5__2 > 120f)
				{
					<min>5__2 = 120f;
				}
				<max>5__3 = 90f + (float)num2 * 20f;
				if (GenesisPlugin.SpawnSounds == null || GenesisPlugin.SpawnSounds.Length == 0)
				{
					return false;
				}
			}
			<>2__current = (object)new WaitForSeconds(Random.Range(<min>5__2, <max>5__3));
			<>1__state = 1;
			return true;
		}

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

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

	public int petsLeft = 3;

	private float _valuePerPet;

	private void Start()
	{
		PlayerUpgrade upgrade = Upgrades.GetUpgrade("GenesisPatience");
		if (upgrade != null)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				petsLeft += upgrade.GetLevel(item);
			}
		}
		if (SemiFunc.IsMultiplayer() && PhotonNetwork.IsMasterClient)
		{
			((MonoBehaviourPun)this).photonView.RPC("SyncPetsRPC", (RpcTarget)1, new object[1] { petsLeft });
		}
		((MonoBehaviour)this).StartCoroutine(MeowLoop());
	}

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

	public void OnPet()
	{
		if (petsLeft <= 0)
		{
			((MonoBehaviourPun)this).photonView.RPC("PlayCatSoundRPC", (RpcTarget)0, new object[1] { false });
			PlayerAvatar instance = PlayerAvatar.instance;
			PlayerUpgrade upgrade = Upgrades.GetUpgrade("GenesisLove");
			instance.playerHealth.Hurt(5 + ((upgrade != null) ? (upgrade.GetLevel(instance) * 5) : 0), false, 0);
			return;
		}
		if (petsLeft == 1 && Random.value <= 0.6f)
		{
			PlayerAvatar instance2 = PlayerAvatar.instance;
			if ((Object)(object)instance2 != (Object)null)
			{
				((MonoBehaviourPun)this).photonView.RPC("TriggerChatRPC", (RpcTarget)0, new object[2]
				{
					GenesisLines.GetRandomLine(GenesisLines.LType.Warning),
					instance2.photonView.ViewID
				});
			}
		}
		Heal();
	}

	private void Heal()
	{
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		PlayerAvatar instance = PlayerAvatar.instance;
		if ((Object)(object)instance == (Object)null || (int)GenesisPlugin.HpField.GetValue(instance.playerHealth) >= (int)GenesisPlugin.MaxHpField.GetValue(instance.playerHealth))
		{
			return;
		}
		petsLeft--;
		((MonoBehaviourPun)this).photonView.RPC("PlayCatSoundRPC", (RpcTarget)0, new object[1] { true });
		if (SemiFunc.IsMultiplayer())
		{
			((MonoBehaviourPun)this).photonView.RPC("SyncPetsRPC", (RpcTarget)1, new object[1] { petsLeft });
		}
		ValuableObject component = ((Component)this).GetComponent<ValuableObject>();
		if ((Object)(object)component != (Object)null)
		{
			if (_valuePerPet == 0f)
			{
				_valuePerPet = (float)GenesisPlugin.DollarField.GetValue(component) * 0.5f / (float)(petsLeft + 1);
			}
			float num = Mathf.Max(0f, (float)GenesisPlugin.DollarField.GetValue(component) - _valuePerPet);
			GenesisPlugin.DollarField.SetValue(component, num);
			if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("SyncValueRPC", (RpcTarget)1, new object[1] { num });
			}
		}
		Vector3 position = ((Component)this).transform.position;
		GenesisPlugin.GenesisHealEvent.RaiseEvent((object)new float[3] { position.x, position.y, position.z }, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
	}

	private void Bite()
	{
		((MonoBehaviourPun)this).photonView.RPC("PlayCatSoundRPC", (RpcTarget)0, new object[1] { false });
		PlayerAvatar instance = PlayerAvatar.instance;
		PlayerUpgrade upgrade = Upgrades.GetUpgrade("GenesisLove");
		instance.playerHealth.Hurt(5 + ((upgrade != null) ? (upgrade.GetLevel(instance) * 5) : 0), false, 0);
	}

	[PunRPC]
	private void PlayCatSoundRPC(bool purr)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		AudioSource.PlayClipAtPoint(purr ? GenesisPlugin.PurrClip : GenesisPlugin.HissClip, ((Component)this).transform.position);
	}

	[PunRPC]
	private void PlayAmbientSoundRPC(int index)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		AudioSource.PlayClipAtPoint(GenesisPlugin.SpawnSounds[index], ((Component)this).transform.position);
	}

	[PunRPC]
	private void SyncPetsRPC(int n)
	{
		petsLeft = n;
	}

	[PunRPC]
	private void SyncValueRPC(float val)
	{
		ValuableObject component = ((Component)this).GetComponent<ValuableObject>();
		if ((Object)(object)component != (Object)null)
		{
			GenesisPlugin.DollarField.SetValue(component, val);
		}
	}

	[PunRPC]
	private void TriggerChatRPC(string line, int playerViewID)
	{
		<>c__DisplayClass11_0 CS$<>8__locals0 = new <>c__DisplayClass11_0();
		CS$<>8__locals0.playerViewID = playerViewID;
		CS$<>8__locals0.line = line;
		PlayerAvatar instance = PlayerAvatar.instance;
		if (!((Object)(object)instance == (Object)null) && instance.photonView.ViewID == CS$<>8__locals0.playerViewID)
		{
			((MonoBehaviour)this).StartCoroutine(Do());
		}
		[IteratorStateMachine(typeof(<>c__DisplayClass11_0.<<TriggerChatRPC>g__Do|0>d))]
		IEnumerator Do()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <>c__DisplayClass11_0.<<TriggerChatRPC>g__Do|0>d(0)
			{
				<>4__this = CS$<>8__locals0
			};
		}
	}
}