Decompiled source of Arranged Marriage v1.0.2

BepInEx/plugins/Soulmates.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Chainbound;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using PeakTextChat;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using Zorro.Core;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Soulmates")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Soulmates")]
[assembly: AssemblyTitle("Soulmates")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Soulmates
{
	[BepInPlugin("soulmates", "Soulmates", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public enum ChainedPairType
		{
			PairEntireChain,
			PairWithPlayersChainedDirectly
		}

		public enum SyncType
		{
			DontFullSync,
			SyncWithLeastStatus,
			SyncWithMostStatus
		}

		internal static List<Character> happilyMarried = new List<Character>();

		internal static List<GovernmentContract> allContracts = new List<GovernmentContract>();

		internal static ConfigEntry<int> playersPerGroup;

		internal static ConfigEntry<bool> reduceBySoulmateCount;

		internal static ConfigEntry<float> overallStatusMultiplier;

		internal static ConfigEntry<bool> ragdollLink;

		internal static ConfigEntry<bool> logPairings;

		internal static ConfigEntry<bool> chatPairings;

		internal static ConfigEntry<bool> campfireRepair;

		internal static ConfigEntry<bool> deathLink;

		internal static ConfigEntry<bool> warpLink;

		internal static ConfigEntry<bool> syncCurse;

		internal static ConfigEntry<bool> detailedLogging;

		internal static ConfigEntry<bool> syncMilk;

		internal static ConfigEntry<bool> syncEnergyDrink;

		internal static ConfigEntry<bool> syncLollipop;

		internal static ConfigEntry<bool> syncHeatPack;

		internal static ConfigEntry<bool> syncMushrooms;

		internal static ConfigEntry<KeyCode> repairBind;

		internal static ConfigEntry<bool> scrambledPairs;

		internal static ConfigEntry<bool> chainedCompatibility;

		internal static ConfigEntry<ChainedPairType> chainPairType;

		internal static ConfigEntry<bool> fullSync;

		internal static ConfigEntry<SyncType> syncWith;

		internal static ConfigEntry<float> syncEverySeconds;

		internal static ConfigEntry<bool> unskellyAtCamp;

		internal static ConfigEntry<bool> gravitationalPlayers;

		internal static ConfigEntry<bool> inverseDistance;

		internal static ConfigEntry<float> gravPower;

		internal static ConfigEntry<bool> onlyWhileRag;

		internal static ConfigEntry<float> unragdolledPowerMultiplier;

		internal static ConfigEntry<bool> multiplyPullForDistanceAbove;

		internal static ConfigEntry<float> unpairAfter;

		internal static ConfigEntry<bool> rememberPairings;

		internal static ConfigEntry<float> higherPlayerMultiplier;

		internal static ConfigEntry<float> forceStopClimbingAtHeight;

		internal static ConfigEntry<float> gravUpPower;

		internal static ConfigEntry<float> gravXPower;

		internal static ConfigEntry<float> gravZPower;

		internal static ConfigEntry<float> gravDownPower;

		internal static ConfigEntry<float> maxDistanceToPair;

		public static AfflictionType YellowAffType;

		public static AfflictionType RedAffType;

		public static AfflictionType PurpleAffType;

		private const string ChainboundGuid = "patchnote.chainbound";

		internal static ManualLogSource Log { get; private set; } = null;

		private void EnableChainboundIntegration()
		{
			ChainboundAPI.GroupsChanged += OnChainboundGroupsChanged;
			OnChainboundGroupsChanged(ChainboundAPI.GetGroups());
		}

		private void OnChainboundGroupsChanged(IReadOnlyList<IReadOnlyList<ChainboundGroupMember>> groups)
		{
			if (ChainboundAPI.Enabled)
			{
				((MonoBehaviour)this).StartCoroutine((IEnumerator)ChainedParityStuff());
			}
		}

		public IEnumerator<WaitForSeconds> ChainedParityStuff()
		{
			yield return new WaitForSeconds(0.1f);
			if (Character.localCharacter.inAirport)
			{
				yield break;
			}
			if (chainPairType.Value == ChainedPairType.PairEntireChain)
			{
				foreach (IReadOnlyList<ChainboundGroupMember> chain in ChainboundAPI.GetGroups())
				{
					foreach (ChainboundGroupMember member in chain)
					{
						GovernmentContract g = ((Component)member.Character).GetComponent<GovernmentContract>();
						g.soulmates.Clear();
						foreach (ChainboundGroupMember memberDos in chain)
						{
							GovernmentContract g2 = ((Component)memberDos.Character).GetComponent<GovernmentContract>();
							if ((Object)(object)g != (Object)(object)g2)
							{
								g.soulmates.Add(g2);
							}
						}
					}
				}
				yield break;
			}
			foreach (IReadOnlyList<ChainboundGroupMember> chain2 in ChainboundAPI.GetGroups())
			{
				for (int i = 0; i < chain2.Count; i++)
				{
					GovernmentContract g3 = ((Component)chain2[i].Character).GetComponent<GovernmentContract>();
					g3.soulmates.Clear();
					if (i != 0)
					{
						g3.soulmates.Add(((Component)chain2[i - 1].Character).GetComponent<GovernmentContract>());
					}
					if (i < chain2.Count - 1)
					{
						g3.soulmates.Add(((Component)chain2[i + 1].Character).GetComponent<GovernmentContract>());
					}
				}
			}
		}

		private void Awake()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Expected O, but got Unknown
			if (Chainloader.PluginInfos.ContainsKey("patchnote.chainbound"))
			{
				EnableChainboundIntegration();
			}
			playersPerGroup = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Soulmate Group Size", 2, (ConfigDescription)null);
			reduceBySoulmateCount = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Reduce Status Gain Based on Number of Soulmates", true, (ConfigDescription)null);
			overallStatusMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Overall Status Multiplier", 1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 10f), Array.Empty<object>()));
			ragdollLink = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ragdoll Link", false, (ConfigDescription)null);
			deathLink = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Death Link", true, (ConfigDescription)null);
			warpLink = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Warp Link", true, (ConfigDescription)null);
			forceStopClimbingAtHeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Forcefully Stop Climbing at Distance Above Soulmate", 1000f, (ConfigDescription)null);
			logPairings = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Notify Pairings", false, (ConfigDescription)null);
			chatPairings = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Send Pairings in Chat (Requires PeakTextChat to Function)", false, (ConfigDescription)null);
			detailedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Detailed Logging", false, (ConfigDescription)null);
			syncCurse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Sync Curse", false, (ConfigDescription)null);
			unskellyAtCamp = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Unskeleton at Campfire (Highly Recommended)", true, (ConfigDescription)null);
			repairBind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Pairing", "Repair Bind", (KeyCode)257, (ConfigDescription)null);
			maxDistanceToPair = ((BaseUnityPlugin)this).Config.Bind<float>("Pairing", "Max Distance to Pair", 50f, (ConfigDescription)null);
			campfireRepair = ((BaseUnityPlugin)this).Config.Bind<bool>("Pairing", "Campfire Repairs", false, (ConfigDescription)null);
			scrambledPairs = ((BaseUnityPlugin)this).Config.Bind<bool>("Pairing", "Scrambled Pairings (this sucks)", false, (ConfigDescription)null);
			chainedCompatibility = ((BaseUnityPlugin)this).Config.Bind<bool>("Pairing", "Chained Compatibility (Requires Chainbound)", false, (ConfigDescription)null);
			chainPairType = ((BaseUnityPlugin)this).Config.Bind<ChainedPairType>("Pairing", "Chained Pairing Type", ChainedPairType.PairEntireChain, (ConfigDescription)null);
			rememberPairings = ((BaseUnityPlugin)this).Config.Bind<bool>("Pairing", "Remember Pairings", true, (ConfigDescription)null);
			unpairAfter = ((BaseUnityPlugin)this).Config.Bind<float>("Pairing", "Unpair After Player Has Been Gone For X Seconds", 500f, (ConfigDescription)null);
			syncWith = ((BaseUnityPlugin)this).Config.Bind<SyncType>("Bar Syncing", "Full Sync With", SyncType.SyncWithMostStatus, (ConfigDescription)null);
			syncEverySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Bar Syncing", "Full Sync Every X Seconds", 200f, (ConfigDescription)null);
			syncMilk = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect Syncing", "Sync Invincibility (Excludes Gold Bing Bong)", true, (ConfigDescription)null);
			syncEnergyDrink = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect Syncing", "Sync Energy Drink", true, (ConfigDescription)null);
			syncLollipop = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect Syncing", "Sync Lollipop", true, (ConfigDescription)null);
			syncHeatPack = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect Syncing", "Sync Heat Pack", false, (ConfigDescription)null);
			syncMushrooms = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect Syncing", "Sync Roots Mushrooms", true, (ConfigDescription)null);
			gravitationalPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Gravitational Soulmates", "Enabled", false, (ConfigDescription)null);
			gravPower = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Gravitational Power", 0.75f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			onlyWhileRag = ((BaseUnityPlugin)this).Config.Bind<bool>("Gravitational Soulmates", "Only Apply Whilst Ragdolled", true, (ConfigDescription)null);
			unragdolledPowerMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Unragdolled Multiplier", 3f, (ConfigDescription)null);
			higherPlayerMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Higher Player Multiplier", 1f, (ConfigDescription)null);
			gravXPower = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Gravitational X Power (Left and Right)", 1f, (ConfigDescription)null);
			gravUpPower = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Positive Y Power (Up)", 0f, (ConfigDescription)null);
			gravDownPower = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Negative Y Power (Down)", 2f, (ConfigDescription)null);
			gravZPower = ((BaseUnityPlugin)this).Config.Bind<float>("Gravitational Soulmates", "Gravitational Z Power (Forward and Back)", 1f, (ConfigDescription)null);
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin soulmates is loaded!");
			Harmony val = new Harmony("soulmates");
			val.PatchAll();
			val.PatchAll(typeof(HandleStatusFromHost));
		}
	}
	public class HandleStatusFromHost
	{
		[HarmonyPatch(typeof(CharacterClimbing), "StartClimbRpc")]
		[HarmonyPostfix]
		public static void StopClimb(CharacterClimbing __instance)
		{
			//IL_0047: 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)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			GovernmentContract component = ((Component)__instance).GetComponent<GovernmentContract>();
			if ((Object)(object)component == (Object)null || !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			foreach (GovernmentContract soulmate in component.soulmates)
			{
				if (component.owner.Center.y - soulmate.owner.Center.y > Plugin.forceStopClimbingAtHeight.Value)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				__instance.view.RPC("StopClimbingRpc", (RpcTarget)0, new object[1] { 0f });
				__instance.character.AddForceToBodyPart(__instance.character.GetBodypartRig((BodypartType)4), Vector3.zero, Vector3.down * 100f + -Vector3Extensions.Flat(__instance.character.data.lookDirection) * 800f);
			}
		}

		[HarmonyPatch(typeof(Character), "RPCA_Die")]
		[HarmonyPrefix]
		public static void DeathLink(Character __instance)
		{
			if (!PhotonNetwork.IsMasterClient || !Plugin.deathLink.Value)
			{
				return;
			}
			GovernmentContract component = ((Component)__instance).gameObject.GetComponent<GovernmentContract>();
			if (component.cullDeath)
			{
				return;
			}
			((MonoBehaviour)component).StartCoroutine((IEnumerator)component.CullDeaths());
			foreach (GovernmentContract soulmate in component.soulmates)
			{
				if (!soulmate.owner.data.dead)
				{
					((MonoBehaviour)soulmate).StartCoroutine((IEnumerator)soulmate.CullDeaths());
					soulmate.owner.DieInstantly();
				}
			}
		}

		[HarmonyPatch(typeof(Character), "RegainItems")]
		[HarmonyPrefix]
		public static void CheckpointLink(PhotonView regainingCharacterView)
		{
			//IL_00fa: 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_011f: Expected I4, but got Unknown
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Character component = ((Component)regainingCharacterView).GetComponent<Character>();
			GovernmentContract component2 = ((Component)component).GetComponent<GovernmentContract>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return;
			}
			((MonoBehaviour)component2).StartCoroutine((IEnumerator)component2.CullRevives());
			foreach (GovernmentContract soulmate in component2.soulmates)
			{
				if (soulmate.owner.data.dead || soulmate.owner.data.passedOut)
				{
					if (Plugin.detailedLogging.Value)
					{
						Plugin.Log.Log((LogLevel)16, (object)("Reviving " + soulmate.owner.characterName + " With " + component2.owner.characterName));
					}
					((MonoBehaviour)soulmate).StartCoroutine((IEnumerator)soulmate.CullRevives());
					soulmate.owner.view.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
					{
						component.Center,
						false,
						(int)Singleton<MapHandler>.Instance.GetCurrentSegment()
					});
				}
			}
		}

		[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
		[HarmonyPrefix]
		public static void RepairPatch()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			try
			{
				if (Plugin.campfireRepair.Value)
				{
					foreach (GovernmentContract allContract in Plugin.allContracts)
					{
						allContract.soulmates.Clear();
						allContract.soulmateCodes.Clear();
					}
					Plugin.happilyMarried.Clear();
				}
				if (!Plugin.unskellyAtCamp.Value)
				{
					return;
				}
				foreach (GovernmentContract allContract2 in Plugin.allContracts)
				{
					if ((Object)(object)allContract2.owner != (Object)null)
					{
						allContract2.owner.data.SetSkeleton(false);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Failed to repair at campfire because of this!!!!! " + ex));
			}
		}

		[HarmonyPatch(typeof(CharacterData), "RPC_SyncSkeleton")]
		[HarmonyPrefix]
		public static bool SkellySoulmatesPatch(CharacterData __instance, bool active)
		{
			GovernmentContract component = ((Component)__instance).GetComponent<GovernmentContract>();
			((MonoBehaviour)component).StartCoroutine((IEnumerator)component.CullSkelly());
			if (!PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			foreach (GovernmentContract soulmate in component.soulmates)
			{
				if (Plugin.detailedLogging.Value)
				{
					Plugin.Log.Log((LogLevel)16, (object)("Skeletonized " + component.owner.characterName + " With " + component.owner.characterName));
				}
				if (!soulmate.cullSkelly)
				{
					((MonoBehaviour)soulmate).StartCoroutine((IEnumerator)soulmate.CullSkelly());
					soulmate.owner.data.SetSkeleton(active);
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")]
		[HarmonyPrefix]
		public static bool ReviveSoulmatesPatch(Character __instance, Vector3 position, bool applyStatus)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected I4, but got Unknown
			if (!PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			GovernmentContract component = ((Component)__instance).GetComponent<GovernmentContract>();
			if (!component.cullRevive && PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviour)component).StartCoroutine((IEnumerator)component.CullRevives());
				foreach (GovernmentContract soulmate in component.soulmates)
				{
					if (soulmate.owner.data.dead || soulmate.owner.data.passedOut)
					{
						if (Plugin.detailedLogging.Value)
						{
							Plugin.Log.Log((LogLevel)16, (object)("Reviving " + soulmate.owner.characterName + " With " + component.owner.characterName));
						}
						((MonoBehaviour)soulmate).StartCoroutine((IEnumerator)soulmate.CullRevives());
						soulmate.owner.view.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
						{
							position,
							false,
							(int)Singleton<MapHandler>.Instance.GetCurrentSegment()
						});
					}
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(CharacterAfflictions), "SyncStatusesRPC")]
		[HarmonyPrefix]
		public static bool SyncStatusPatch(CharacterAfflictions __instance, byte[] data)
		{
			if (__instance.m_inAirport)
			{
				return true;
			}
			GovernmentContract component = ((Component)__instance).GetComponent<GovernmentContract>();
			component.applyOnlyToOthers = true;
			return true;
		}

		[HarmonyPatch(typeof(CharacterAfflictions), "SyncAfflictionsRPC")]
		[HarmonyPrefix]
		internal static void LinkAfflictions(CharacterAfflictions __instance)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				GovernmentContract component = ((Component)__instance).GetComponent<GovernmentContract>();
				component.applyAfflictionsToOthers = true;
			}
		}

		[HarmonyPatch(typeof(CharacterAfflictions), "AddAffliction")]
		[HarmonyPostfix]
		internal static void LinkAfflictionsHost(CharacterAfflictions __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			foreach (Affliction affliction in __instance.afflictionList)
			{
				Plugin.Log.LogInfo((object)affliction.totalTime);
				Plugin.Log.LogInfo((object)affliction.GetAfflictionType());
			}
			if (PhotonNetwork.IsMasterClient && __instance.character.IsLocal)
			{
				((Component)__instance).GetComponent<GovernmentContract>().applyAfflictionsToOthers = true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "WarpPlayerRPC")]
	internal static class WarpLink
	{
		internal static void Prefix(Character __instance, Vector3 position, bool poof)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.inAirport || !Plugin.warpLink.Value)
			{
				return;
			}
			GovernmentContract component = ((Component)__instance).gameObject.GetComponent<GovernmentContract>();
			if ((Object)(object)component == (Object)null || !PhotonNetwork.IsMasterClient || component.cullRevive)
			{
				return;
			}
			((MonoBehaviour)component).StartCoroutine((IEnumerator)component.CullRevives());
			foreach (GovernmentContract soulmate in component.soulmates)
			{
				((MonoBehaviour)soulmate).StartCoroutine((IEnumerator)soulmate.CullRevives());
				soulmate.owner.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { position, poof });
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPCA_Fall")]
	internal static class FallLinkPatch
	{
		internal static void Prefix(Character __instance, float seconds, float shake)
		{
			if (!Plugin.ragdollLink.Value || __instance.inAirport)
			{
				return;
			}
			GovernmentContract component = ((Component)__instance).gameObject.GetComponent<GovernmentContract>();
			if ((Object)(object)component == (Object)null || !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			foreach (GovernmentContract soulmate in component.soulmates)
			{
				if (Plugin.detailedLogging.Value)
				{
					Plugin.Log.Log((LogLevel)16, (object)("Fall linked " + soulmate.owner.characterName + " With " + component.owner.characterName + " for " + seconds + " seconds!"));
				}
				soulmate.owner.refs.view.RPC("RPCA_Fall", (RpcTarget)1, new object[2] { seconds, shake });
				soulmate.owner.data.fallSeconds = seconds;
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "Awake")]
	internal static class InstantiateSoulmates
	{
		internal static void Postfix(CharacterAfflictions __instance)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.character.inAirport)
			{
				return;
			}
			Plugin.allContracts.RemoveAll((GovernmentContract GovernmentContract) => (Object)(object)GovernmentContract == (Object)null);
			GovernmentContract orAddComponent = ExtGameObject.GetOrAddComponent<GovernmentContract>(((Component)__instance).gameObject);
			orAddComponent.owner = __instance.character;
			Plugin.allContracts.Add(orAddComponent);
			if (!__instance.character.IsLocal)
			{
				return;
			}
			for (int num = 0; num < 3; num++)
			{
				int num2 = -1;
				switch (num)
				{
				case 0:
					Debug.Log((object)"Checking Red");
					switch (MushroomManager.instance.mushroomEffects[0 % MushroomManager.instance.mushroomEffects.Length])
					{
					case 0:
						Plugin.RedAffType = (AfflictionType)1;
						break;
					case 1:
						Plugin.RedAffType = (AfflictionType)2;
						break;
					case 2:
						Plugin.RedAffType = (AfflictionType)17;
						break;
					case 3:
						Plugin.RedAffType = (AfflictionType)16;
						break;
					}
					break;
				case 1:
					Debug.Log((object)"Checking Yellow");
					switch (MushroomManager.instance.mushroomEffects[1 % MushroomManager.instance.mushroomEffects.Length])
					{
					case 0:
						Plugin.YellowAffType = (AfflictionType)1;
						break;
					case 1:
						Plugin.YellowAffType = (AfflictionType)2;
						break;
					case 2:
						Plugin.YellowAffType = (AfflictionType)17;
						break;
					case 3:
						Plugin.YellowAffType = (AfflictionType)16;
						break;
					}
					break;
				case 2:
					Debug.Log((object)"Checking Purple");
					switch (MushroomManager.instance.mushroomEffects[4 % MushroomManager.instance.mushroomEffects.Length])
					{
					case 0:
						Plugin.PurpleAffType = (AfflictionType)1;
						break;
					case 1:
						Plugin.PurpleAffType = (AfflictionType)2;
						break;
					case 2:
						Plugin.PurpleAffType = (AfflictionType)17;
						break;
					case 3:
						Plugin.PurpleAffType = (AfflictionType)16;
						break;
					}
					break;
				}
			}
		}
	}
	public class GovernmentContract : MonoBehaviour
	{
		public Character owner;

		public List<GovernmentContract> soulmates = new List<GovernmentContract>();

		public List<string> soulmateCodes = new List<string>();

		public float[] previousStatuses;

		public float previousStatusAmount;

		public float ragdollLinkCooldown = 0f;

		public bool itsFromYourHuzz;

		public bool ignoreNextShroomberry;

		public float[] decrement;

		public float[] increment;

		public float[] selfIncrement;

		public float syncClock;

		public float gravClock = 0f;

		public float selfSyncClock;

		public bool applyOnlyToOthers = false;

		public bool applyAfflictionsToOthers = false;

		public float affsAreFromHuzz = 0f;

		public bool cullRevive = false;

		public bool cullDeath = false;

		public bool cullSkelly = false;

		public float timeUntilDivorce = 0f;

		private PlayerConnectionLog pLog;

		public static GovernmentContract masterContract;

		public List<string> logs = new List<string>();

		public int prevPetrify;

		public bool preventNextPetrifySync;

		public void OnEnable()
		{
			pLog = Object.FindAnyObjectByType<PlayerConnectionLog>();
			decrement = new float[CharacterAfflictions.NumStatusTypes];
			increment = new float[CharacterAfflictions.NumStatusTypes];
			selfIncrement = new float[CharacterAfflictions.NumStatusTypes];
			((MonoBehaviour)this).StartCoroutine((IEnumerator)CheckForLoneliness());
			((MonoBehaviour)this).StartCoroutine((IEnumerator)LogPairs());
		}

		public IEnumerator<WaitForSeconds> LogPairs()
		{
			WaitForSeconds _cache = new WaitForSeconds(5f);
			yield return new WaitForSeconds(1f);
			foreach (Character c in Character.AllCharacters)
			{
				if (c.IsLocal)
				{
					masterContract = ((Component)c).GetComponent<GovernmentContract>();
					break;
				}
			}
			if (!owner.IsLocal)
			{
				yield break;
			}
			while (true)
			{
				if (logs.Count > 0)
				{
					pLog.AddMessage(logs[0]);
					if (Plugin.chatPairings.Value)
					{
						try
						{
							SendChatMessage(logs[0]);
						}
						catch
						{
							pLog.AddMessage("<color=#" + ColorUtility.ToHtmlStringRGB(Color.red) + ">You dont have the PeakTextChat mod, the \"Send Pairings in Chat\" option requires you have it");
						}
					}
					logs.RemoveAt(0);
				}
				yield return _cache;
			}
		}

		private static string GetPlayerStableKey(Player player)
		{
			if (!string.IsNullOrWhiteSpace(player.UserId))
			{
				return "u:" + player.UserId.Trim();
			}
			if (!string.IsNullOrWhiteSpace(player.NickName))
			{
				return "n:" + player.NickName.Trim();
			}
			return "a:" + player.ActorNumber;
		}

		public void SendChatMessage(string message)
		{
			TextChatManager.instance.SendChatMessage(message);
		}

		public float StatusSum()
		{
			float num = 0f;
			for (int i = 0; i < owner.refs.afflictions.currentIncrementalStatuses.Length; i++)
			{
				num += owner.refs.afflictions.currentIncrementalStatuses[i];
			}
			return owner.refs.afflictions.statusSum - owner.refs.afflictions.GetCurrentStatus((STATUSTYPE)7) - owner.refs.afflictions.GetCurrentStatus((STATUSTYPE)9);
		}

		public void SetPreviousStatuses()
		{
			float[] array = new float[CharacterAfflictions.NumStatusTypes];
			for (int i = 0; i < CharacterAfflictions.NumStatusTypes; i++)
			{
				array[i] = owner.refs.afflictions.currentStatuses[i] + owner.refs.afflictions.currentIncrementalStatuses[i];
			}
			previousStatuses = array;
			previousStatusAmount = StatusSum();
		}

		public void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (!owner.IsLocal || !PhotonNetwork.IsMasterClient || !Input.GetKeyDown(Plugin.repairBind.Value))
			{
				return;
			}
			string text = "<color=#" + ColorUtility.ToHtmlStringRGB(Color.red) + ">Divorced everyone!";
			pLog.AddMessage(text);
			pLog.sfxLeave.Play(default(Vector3));
			foreach (GovernmentContract allContract in Plugin.allContracts)
			{
				allContract.soulmates.Clear();
				allContract.soulmateCodes.Clear();
			}
			Plugin.happilyMarried.Clear();
		}

		public string GetMushTypeForAffliciton(AfflictionType aff)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 3; i++)
			{
				switch (i)
				{
				case 0:
					if (Plugin.RedAffType == aff)
					{
						return "0_items/Shroomberry_Red";
					}
					break;
				case 1:
					if (Plugin.YellowAffType == aff)
					{
						return "0_items/Shroomberry_Yellow";
					}
					break;
				case 2:
					if (Plugin.PurpleAffType == aff)
					{
						return "0_items/Shroomberry_Purple";
					}
					break;
				}
			}
			return "0_items/Shroomberry_Red";
		}

		public void SyncAffliction()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Invalid comparison between Unknown and I4
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Invalid comparison between Unknown and I4
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Invalid comparison between Unknown and I4
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Invalid comparison between Unknown and I4
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Invalid comparison between Unknown and I4
			//IL_0916: Unknown result type (might be due to invalid IL or missing references)
			//IL_0859: Unknown result type (might be due to invalid IL or missing references)
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: 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_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			if (applyAfflictionsToOthers && affsAreFromHuzz < 0f)
			{
				for (int i = 0; i < owner.refs.afflictions.afflictionList.Count; i++)
				{
					if (owner.refs.afflictions.afflictionList[i].timeElapsed != 0f && (!owner.IsLocal || !(owner.refs.afflictions.afflictionList[i].timeElapsed < 1f)))
					{
						continue;
					}
					AfflictionType afflictionType = owner.refs.afflictions.afflictionList[i].GetAfflictionType();
					if ((int)afflictionType == 1)
					{
						if (owner.refs.afflictions.afflictionList[i].totalTime == 4f && Plugin.syncMushrooms.Value && !ignoreNextShroomberry)
						{
							string mushTypeForAffliciton = GetMushTypeForAffliciton(afflictionType);
							foreach (GovernmentContract soulmate in soulmates)
							{
								Item component = PhotonNetwork.Instantiate(mushTypeForAffliciton, Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate.owner.FeedItem(component);
								soulmate.affsAreFromHuzz = 5f;
								soulmate.ignoreNextShroomberry = true;
								if ((Object)(object)component != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component).gameObject);
								}
							}
						}
						else if (owner.refs.afflictions.afflictionList[i].totalTime == 4f && Plugin.syncMushrooms.Value && ignoreNextShroomberry)
						{
							ignoreNextShroomberry = false;
						}
						else if (owner.refs.afflictions.afflictionList[i].totalTime == 8f && Plugin.syncLollipop.Value)
						{
							foreach (GovernmentContract soulmate2 in soulmates)
							{
								Item component2 = PhotonNetwork.Instantiate("0_items/Lollipop", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component2).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate2.owner.FeedItem(component2);
								soulmate2.affsAreFromHuzz = 5f;
								if ((Object)(object)component2 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component2).gameObject);
								}
							}
						}
					}
					if ((int)afflictionType == 2)
					{
						if (owner.refs.afflictions.afflictionList[i].totalTime == 8f && Plugin.syncEnergyDrink.Value)
						{
							foreach (GovernmentContract soulmate3 in soulmates)
							{
								Item component3 = PhotonNetwork.Instantiate("0_items/Energy Drink", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component3).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate3.owner.FeedItem(component3);
								soulmate3.affsAreFromHuzz = 5f;
								if ((Object)(object)component3 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component3).gameObject);
								}
							}
						}
						else if (owner.refs.afflictions.afflictionList[i].totalTime == 12f && Plugin.syncEnergyDrink.Value)
						{
							foreach (GovernmentContract soulmate4 in soulmates)
							{
								Item component4 = PhotonNetwork.Instantiate("0_items/Energy Drink", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component4).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate4.owner.FeedItem(component4);
								soulmate4.affsAreFromHuzz = 5f;
								if ((Object)(object)component4 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component4).gameObject);
								}
							}
						}
						else if (owner.refs.afflictions.afflictionList[i].totalTime == 5f && Plugin.syncMushrooms.Value && !ignoreNextShroomberry)
						{
							string mushTypeForAffliciton2 = GetMushTypeForAffliciton(afflictionType);
							foreach (GovernmentContract soulmate5 in soulmates)
							{
								Item component5 = PhotonNetwork.Instantiate(mushTypeForAffliciton2, Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component5).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate5.owner.FeedItem(component5);
								soulmate5.affsAreFromHuzz = 5f;
								soulmate5.ignoreNextShroomberry = true;
								if ((Object)(object)component5 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component5).gameObject);
								}
							}
						}
						else if (owner.refs.afflictions.afflictionList[i].totalTime == 5f && Plugin.syncMushrooms.Value && ignoreNextShroomberry)
						{
							ignoreNextShroomberry = false;
						}
					}
					if ((int)afflictionType == 16)
					{
						foreach (GovernmentContract soulmate6 in soulmates)
						{
							if ((owner.refs.afflictions.afflictionList[i].totalTime == 15f || owner.refs.afflictions.afflictionList[i].totalTime == 10f) && Plugin.syncMilk.Value)
							{
								Item component6 = PhotonNetwork.Instantiate("0_items/FortifiedMilk", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								soulmate6.owner.FeedItem(component6);
								soulmate6.affsAreFromHuzz = 5f;
								if ((Object)(object)component6 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component6).gameObject);
								}
							}
							else if (owner.refs.afflictions.afflictionList[i].totalTime == 25f && Plugin.syncMilk.Value)
							{
								Item component7 = PhotonNetwork.Instantiate("0_items/FortifiedMilk", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
								((MonoBehaviourPun)component7).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
								soulmate6.owner.FeedItem(component7);
								soulmate6.affsAreFromHuzz = 5f;
								if ((Object)(object)component7 != (Object)null)
								{
									PhotonNetwork.Destroy(((Component)component7).gameObject);
								}
							}
						}
					}
					if ((int)afflictionType == 5 && Plugin.syncHeatPack.Value)
					{
						foreach (GovernmentContract soulmate7 in soulmates)
						{
							Item component8 = PhotonNetwork.Instantiate("0_items/Heat Pack", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
							soulmate7.owner.FeedItem(component8);
							soulmate7.affsAreFromHuzz = 5f;
							if ((Object)(object)component8 != (Object)null)
							{
								PhotonNetwork.Destroy(((Component)component8).gameObject);
							}
						}
					}
					if ((int)afflictionType == 17 && Plugin.syncMushrooms.Value && !ignoreNextShroomberry && owner.refs.afflictions.afflictionList[i].totalTime != 3f)
					{
						string mushTypeForAffliciton3 = GetMushTypeForAffliciton(afflictionType);
						foreach (GovernmentContract soulmate8 in soulmates)
						{
							Item component9 = PhotonNetwork.Instantiate(mushTypeForAffliciton3, Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<Item>();
							((MonoBehaviourPun)component9).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { 1 });
							soulmate8.owner.FeedItem(component9);
							soulmate8.affsAreFromHuzz = 5f;
							soulmate8.ignoreNextShroomberry = true;
							if ((Object)(object)component9 != (Object)null)
							{
								PhotonNetwork.Destroy(((Component)component9).gameObject);
							}
						}
					}
					else if ((int)afflictionType == 17 && Plugin.syncMushrooms.Value && ignoreNextShroomberry)
					{
						ignoreNextShroomberry = false;
					}
				}
				applyAfflictionsToOthers = false;
			}
			else if (affsAreFromHuzz >= 0f)
			{
				affsAreFromHuzz -= Time.fixedDeltaTime;
				applyAfflictionsToOthers = false;
			}
		}

		public void FixedUpdate()
		{
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: 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_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			if (owner.data.dead)
			{
				return;
			}
			if (prevPetrify != owner.data.petrifyAmount && !preventNextPetrifySync)
			{
				prevPetrify = owner.data.petrifyAmount;
				foreach (GovernmentContract soulmate in soulmates)
				{
					soulmate.owner.view.RPC("RPC_SyncPetrify", (RpcTarget)0, new object[1] { owner.data.petrifyAmount });
					soulmate.preventNextPetrifySync = true;
				}
			}
			else
			{
				preventNextPetrifySync = false;
				prevPetrify = owner.data.petrifyAmount;
			}
			syncClock += Time.fixedDeltaTime;
			gravClock += 1f;
			if (Plugin.gravitationalPlayers.Value && gravClock > 5f && ((owner.data.fallSeconds > 0f && Plugin.onlyWhileRag.Value) || !Plugin.onlyWhileRag.Value))
			{
				try
				{
					GovernmentContract governmentContract = null;
					foreach (GovernmentContract soulmate2 in soulmates)
					{
						if ((Object)(object)governmentContract == (Object)null || Vector3.Distance(soulmate2.owner.Center, owner.Center) > Vector3.Distance(governmentContract.owner.Center, owner.Center))
						{
							governmentContract = soulmate2;
						}
					}
					if ((Object)(object)governmentContract != (Object)null && !governmentContract.owner.data.dead)
					{
						Vector3 val = governmentContract.owner.Center - owner.Center;
						if (val.y > 0f)
						{
							((Vector3)(ref val))..ctor(val.x, val.y * Plugin.gravUpPower.Value, val.z);
						}
						else
						{
							((Vector3)(ref val))..ctor(val.x, val.y * Plugin.gravDownPower.Value, val.z);
						}
						if (owner.data.fallSeconds <= 0f)
						{
							val *= Plugin.unragdolledPowerMultiplier.Value;
						}
						if (governmentContract.owner.Center.y < owner.Center.y)
						{
							val *= Plugin.higherPlayerMultiplier.Value;
						}
						owner.AddForceAtPosition(val * Plugin.gravPower.Value * 0.5f, owner.Center, 1f);
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.Log((LogLevel)16, (object)ex);
				}
				gravClock = 0f;
			}
			SyncAffliction();
			for (int i = 0; i < owner.refs.afflictions.afflictionList.Count; i++)
			{
				if (!owner.IsLocal)
				{
					Affliction obj = owner.refs.afflictions.afflictionList[i];
					obj.timeElapsed += Time.fixedDeltaTime;
				}
			}
			if (previousStatuses == null)
			{
				SetPreviousStatuses();
			}
			if (itsFromYourHuzz)
			{
				itsFromYourHuzz = false;
				SetPreviousStatuses();
				return;
			}
			if ((StatusSum() - previousStatusAmount != 0f && owner.IsLocal) || applyOnlyToOthers)
			{
				for (int j = 0; j < CharacterAfflictions.NumStatusTypes; j++)
				{
					float[] array = new float[CharacterAfflictions.NumStatusTypes];
					if (j == 9 || j == 7 || previousStatuses[j] - owner.refs.afflictions.currentStatuses[j] - owner.refs.afflictions.currentIncrementalStatuses[j] == 0f || (j == 5 && !Plugin.syncCurse.Value))
					{
						array[j] = 0f;
						continue;
					}
					double num = 1f / ((float)soulmates.Count + 1f);
					float num2 = 0f;
					num2 = 0f - (previousStatuses[j] - owner.refs.afflictions.currentStatuses[j] - owner.refs.afflictions.currentIncrementalStatuses[j]);
					float num3 = ((num2 > 0f) ? Plugin.overallStatusMultiplier.Value : 1f) * ((Plugin.reduceBySoulmateCount.Value && num2 > 0f) ? ((float)num) : 1f);
					array[j] = num2 * num3;
					if (array[j] > 0f)
					{
						increment[j] += array[j];
						if (Plugin.reduceBySoulmateCount.Value)
						{
							selfIncrement[j] += array[j] / num3 * (num3 - 1f);
						}
						else
						{
							selfIncrement[j] += array[j] / Plugin.overallStatusMultiplier.Value * (Plugin.overallStatusMultiplier.Value - 1f);
						}
					}
					else
					{
						decrement[j] += array[j];
					}
				}
				SyncStatusesWithOwnerAndSoulmates();
				SetPreviousStatuses();
				applyOnlyToOthers = false;
			}
			if (syncClock > Plugin.syncEverySeconds.Value)
			{
				TrySync();
			}
		}

		public IEnumerator<WaitForSeconds> CullRevives()
		{
			cullRevive = true;
			gravClock = -200f;
			yield return new WaitForSeconds(5f);
			cullRevive = false;
		}

		public IEnumerator<WaitForSeconds> CullDeaths()
		{
			cullDeath = true;
			yield return new WaitForSeconds(5f);
			cullDeath = false;
		}

		public IEnumerator<WaitForSeconds> CullSkelly()
		{
			cullSkelly = true;
			yield return new WaitForSeconds(5f);
			cullSkelly = false;
		}

		public void TrySync()
		{
			if (Plugin.syncWith.Value == Plugin.SyncType.DontFullSync || (Plugin.chainedCompatibility.Value && Plugin.chainPairType.Value == Plugin.ChainedPairType.PairWithPlayersChainedDirectly))
			{
				return;
			}
			float num = 0f;
			GovernmentContract governmentContract = this;
			foreach (GovernmentContract soulmate in soulmates)
			{
				if ((num == 0f || soulmate.StatusSum() > num) && !soulmate.owner.data.dead && Plugin.syncWith.Value == Plugin.SyncType.SyncWithMostStatus)
				{
					governmentContract = soulmate;
					num = soulmate.StatusSum();
				}
				else if ((num == 0f || soulmate.StatusSum() < num) && !soulmate.owner.data.dead && Plugin.syncWith.Value == Plugin.SyncType.SyncWithLeastStatus)
				{
					governmentContract = soulmate;
					num = soulmate.StatusSum();
				}
			}
			if (num < StatusSum())
			{
				governmentContract = this;
			}
			governmentContract.SyncWithMe(this);
			syncClock = 0f;
		}

		public void SyncWithMe(GovernmentContract c)
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			float[] array = new float[CharacterAfflictions.NumStatusTypes];
			for (int i = 0; i < CharacterAfflictions.NumStatusTypes; i++)
			{
				array[i] = -2f;
				if ((i == 5 && !Plugin.syncCurse.Value) || i == 13)
				{
					array[i] = 0f;
				}
			}
			float[] array2 = previousStatuses;
			if (!Plugin.syncCurse.Value)
			{
				array2[5] = 0f;
			}
			if (!c.owner.IsLocal)
			{
				c.owner.refs.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)1, new object[1] { array });
				c.owner.refs.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)1, new object[1] { array2 });
			}
			c.owner.refs.afflictions.ApplyStatusesFromFloatArray(array);
			c.owner.refs.afflictions.ApplyStatusesFromFloatArray(array2);
			if (Plugin.detailedLogging.Value)
			{
				Plugin.Log.Log((LogLevel)16, (object)("Synced " + c.owner.characterName + " statuses with " + owner.characterName + " status bar was:"));
				for (int j = 0; j < CharacterAfflictions.NumStatusTypes; j++)
				{
					Plugin.Log.Log((LogLevel)16, (object)(previousStatuses[j] + "  " + ((object)(STATUSTYPE)j/*cast due to .constrained prefix*/).ToString()));
				}
			}
			c.itsFromYourHuzz = true;
		}

		public void SyncStatusesWithOwnerAndSoulmates()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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)
			float[] array = new float[CharacterAfflictions.NumStatusTypes];
			float[] array2 = new float[CharacterAfflictions.NumStatusTypes];
			for (int i = 0; i < CharacterAfflictions.NumStatusTypes; i++)
			{
				while (increment[i] > 0.0001f)
				{
					array[i] += 0.025f;
					increment[i] -= 0.025f;
				}
				if (array[i] > 0f && Plugin.detailedLogging.Value)
				{
					Plugin.Log.Log((LogLevel)16, (object)(owner.characterName + " Applied " + array[i] + " " + ((object)(STATUSTYPE)i/*cast due to .constrained prefix*/).ToString() + " to soulmates."));
				}
				while (decrement[i] < -0.025f)
				{
					array[i] -= 0.025f;
					decrement[i] += 0.025f;
				}
				if (array[i] < 0f && Plugin.detailedLogging.Value)
				{
					Plugin.Log.Log((LogLevel)16, (object)(owner.characterName + " Removed " + (0f - array[i]) + " " + ((object)(STATUSTYPE)i/*cast due to .constrained prefix*/).ToString() + " from soulmates."));
				}
				while (selfIncrement[i] < -0.025f || selfIncrement[i] > 0.025f)
				{
					if (selfIncrement[i] > 0.025f)
					{
						array2[i] += 0.025f;
						selfIncrement[i] -= 0.025f;
					}
					else
					{
						array2[i] -= 0.025f;
						selfIncrement[i] += 0.025f;
					}
				}
				if (array2[i] != 0f && Plugin.detailedLogging.Value)
				{
					Plugin.Log.Log((LogLevel)16, (object)(owner.characterName + " Applied " + array2[i] + " " + ((object)(STATUSTYPE)i/*cast due to .constrained prefix*/).ToString() + " to themselves."));
				}
			}
			foreach (GovernmentContract soulmate in soulmates)
			{
				if (!soulmate.owner.IsLocal)
				{
					soulmate.owner.refs.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)1, new object[1] { array });
				}
				soulmate.owner.refs.afflictions.ApplyStatusesFromFloatArray(array);
				soulmate.itsFromYourHuzz = true;
			}
			owner.refs.view.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array2 });
		}

		public IEnumerator<WaitForSeconds> CheckForLoneliness()
		{
			WaitForSeconds _cache = new WaitForSeconds(10f);
			Plugin.happilyMarried.Add(owner);
			yield return new WaitForSeconds(30f);
			while (true)
			{
				if (!Plugin.chainedCompatibility.Value)
				{
					soulmates.RemoveAll((GovernmentContract Character) => (Object)(object)Character == (Object)null || (Object)(object)Character.owner == (Object)(object)owner);
					Plugin.happilyMarried.RemoveAll((Character Character) => (Object)(object)Character == (Object)null);
					if (soulmates.Count < Plugin.playersPerGroup.Value - 1)
					{
						Plugin.happilyMarried.RemoveAll((Character Character) => Object.op_Implicit((Object)(object)owner));
						timeUntilDivorce += Time.fixedDeltaTime * 500f;
						MatchMake();
					}
					else
					{
						timeUntilDivorce = 0f;
					}
				}
				yield return _cache;
			}
		}

		public void MatchMake()
		{
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			if (owner.isBot)
			{
				return;
			}
			foreach (string soulmateCode in soulmateCodes)
			{
				Plugin.Log.Log((LogLevel)16, (object)("codes are " + soulmateCode));
			}
			if (soulmateCodes.Count >= Plugin.playersPerGroup.Value - 1 && Plugin.rememberPairings.Value)
			{
				Plugin.Log.Log((LogLevel)16, (object)"Well they should be trying to use a code");
				if (timeUntilDivorce > Plugin.unpairAfter.Value)
				{
					soulmateCodes.Clear();
					timeUntilDivorce = 0f;
					return;
				}
				List<string> list = new List<string>();
				foreach (string soulmateCode2 in soulmateCodes)
				{
					list.Add(soulmateCode2);
					foreach (GovernmentContract soulmate in soulmates)
					{
						if (GetPlayerStableKey(soulmate.owner.view.Owner) == soulmateCode2)
						{
							list.Remove(soulmateCode2);
						}
					}
				}
				{
					foreach (string item2 in list)
					{
						foreach (Character allCharacter in Character.AllCharacters)
						{
							if (!(GetPlayerStableKey(allCharacter.view.Owner) == item2))
							{
								continue;
							}
							GovernmentContract component = ((Component)allCharacter).GetComponent<GovernmentContract>();
							if (!((Object)(object)component != (Object)null))
							{
								continue;
							}
							soulmates.Add(component);
							component.soulmates.Add(this);
							foreach (GovernmentContract soulmate2 in soulmates)
							{
								component.soulmates.Add(soulmate2);
							}
						}
					}
					return;
				}
			}
			int num = 0;
			if (Plugin.detailedLogging.Value)
			{
				Plugin.Log.Log((LogLevel)16, (object)(owner.characterName + " is trying to find a partner!"));
			}
			while (soulmates.Count < Plugin.playersPerGroup.Value - 1 && num < 20)
			{
				GovernmentContract governmentContract = Plugin.allContracts[Random.Range(0, Plugin.allContracts.Count)];
				num++;
				if (!((Object)(object)governmentContract != (Object)(object)this) || Plugin.happilyMarried.Contains(governmentContract.owner) || governmentContract.soulmates.Count >= Plugin.playersPerGroup.Value - 1 || soulmates.Contains(governmentContract) || governmentContract.owner.isBot || !(Vector3.Distance(owner.Center, governmentContract.owner.Center) < Plugin.maxDistanceToPair.Value) || governmentContract.owner.data.passedOut || governmentContract.soulmateCodes.Count >= Plugin.playersPerGroup.Value - 1)
				{
					continue;
				}
				if (Plugin.logPairings.Value || Plugin.chatPairings.Value)
				{
					string item = "<color=#" + ColorUtility.ToHtmlStringRGB(Color.green) + ">" + owner.characterName + "<color=#" + ColorUtility.ToHtmlStringRGB(Color.white) + "> paired with <color=#" + ColorUtility.ToHtmlStringRGB(Color.green) + ">" + governmentContract.owner.characterName + "!";
					masterContract.logs.Add(item);
				}
				if (Plugin.scrambledPairs.Value)
				{
					continue;
				}
				foreach (GovernmentContract soulmate3 in soulmates)
				{
					if ((Object)(object)soulmate3 != (Object)(object)governmentContract && !soulmate3.owner.isBot)
					{
						soulmate3.soulmates.Add(governmentContract);
						governmentContract.soulmates.Add(soulmate3);
						soulmate3.soulmateCodes.Add(GetPlayerStableKey(governmentContract.owner.view.Owner));
						governmentContract.soulmateCodes.Add(GetPlayerStableKey(soulmate3.owner.view.Owner));
					}
				}
				foreach (GovernmentContract soulmate4 in governmentContract.soulmates)
				{
					if (!soulmates.Contains(soulmate4))
					{
						soulmates.Add(soulmate4);
						soulmateCodes.Add(GetPlayerStableKey(soulmate4.owner.view.Owner));
					}
					if (!soulmate4.soulmates.Contains(this))
					{
						soulmate4.soulmates.Add(this);
						soulmate4.soulmateCodes.Add(GetPlayerStableKey(owner.view.Owner));
					}
				}
				soulmates.Add(governmentContract);
				soulmateCodes.Add(GetPlayerStableKey(governmentContract.owner.view.Owner));
				governmentContract.soulmates.Add(this);
				governmentContract.soulmateCodes.Add(GetPlayerStableKey(owner.view.Owner));
			}
			if (soulmates.Count >= Plugin.playersPerGroup.Value - 1)
			{
				Plugin.happilyMarried.Add(owner);
				TrySync();
			}
			else if (Plugin.detailedLogging.Value)
			{
				Plugin.Log.Log((LogLevel)16, (object)("ooo thats rough " + owner.characterName));
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}