Decompiled source of PartyMod v2.5.6

PartyMod(Level).dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SentinelSpawnTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SentinelSpawnTest")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("63b41161-5bf4-42dd-8776-932e76830489")]
[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")]
[BepInPlugin("com.Reckss.erenshor.nolevelsmart", "Erenshor No Level Restriction + Smart Whisper", "2.5.6")]
[BepInProcess("Erenshor.exe")]
public class NoLevelRestrictionPlugin : BaseUnityPlugin
{
	internal static NoLevelRestrictionPlugin Instance;

	internal static ConfigEntry<bool> EnableLevelCheck;

	internal static ConfigEntry<int> MaxLevelDifference;

	internal static ConfigEntry<float> MinOpinionToInvite;

	internal static ConfigEntry<float> XPMultiplier;

	private void Awake()
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Expected O, but got Unknown
		Instance = this;
		EnableLevelCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("PartyMod", "EnableLevelCheck", false, "Decline invites outside level range");
		MaxLevelDifference = ((BaseUnityPlugin)this).Config.Bind<int>("PartyMod", "MaxLevelDifference", 3, "Allowed ± levels for invites");
		MinOpinionToInvite = ((BaseUnityPlugin)this).Config.Bind<float>("PartyMod", "MinOpinionToInvite", 0f, "Minimum Sim opinion (0–100) to accept");
		XPMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("PartyMod", "XPMultiplier", 1f, "Global XP multiplier");
		Harmony val = new Harmony("com.Reckss.erenshor.nolevelsmart");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"NoLevelRestriction + Smart Whisper mod v2.5.6 loaded.");
	}

	internal static bool IsTrackGrouped(SimPlayerTracking track)
	{
		if (track == GameData.GroupMember1 || track == GameData.GroupMember2 || track == GameData.GroupMember3)
		{
			return true;
		}
		SimPlayerMngr simMngr = GameData.SimMngr;
		if (simMngr?.LiveGroups != null)
		{
			foreach (SimPlayerIndependentGroup liveGroup in simMngr.LiveGroups)
			{
				if (liveGroup.DoesGroupContain(track))
				{
					return true;
				}
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(SimPlayerGrouping), "InviteToGroup", new Type[] { })]
public class InviteToGroupPatch
{
	public static bool Prefix(SimPlayerGrouping __instance)
	{
		Character myself = GameData.PlayerControl.Myself;
		if ((Object)(object)myself == (Object)null || !myself.Alive)
		{
			UpdateSocialLog.LogAdd("Can't invite while dead.", "yellow");
			return false;
		}
		GameData.PlayerAud.PlayOneShot(GameData.Misc.Click, GameData.SFXVol);
		Character currentTarget = GameData.PlayerControl.CurrentTarget;
		SimPlayer val = ((currentTarget != null) ? ((Component)currentTarget).GetComponent<SimPlayer>() : null);
		if ((Object)(object)val == (Object)null)
		{
			UpdateSocialLog.LogAdd("Invalid invite: not a SimPlayer.", "yellow");
			return false;
		}
		SimPlayerTracking val2 = GameData.SimMngr.Sims[val.myIndex];
		if (NoLevelRestrictionPlugin.EnableLevelCheck.Value)
		{
			int num = Mathf.Abs(GameData.PlayerStats.Level - val2.MyStats.Level);
			if (num > NoLevelRestrictionPlugin.MaxLevelDifference.Value)
			{
				UpdateSocialLog.LogAdd($"{val2.SimName} is outside your level range (±{NoLevelRestrictionPlugin.MaxLevelDifference.Value}).", "yellow");
				return false;
			}
			if (val2.OpinionOfPlayer < NoLevelRestrictionPlugin.MinOpinionToInvite.Value)
			{
				UpdateSocialLog.LogAdd(val2.SimName + " doesn’t consider you a friend yet.", "yellow");
				return false;
			}
		}
		if (NoLevelRestrictionPlugin.IsTrackGrouped(val2))
		{
			UpdateSocialLog.LogAdd(val2.SimName + " is already in a group.", "yellow");
			return false;
		}
		val2.PersonalInvite = true;
		val2.seekingPlayer = true;
		if (GameData.GroupMember1 == null)
		{
			InviteHelpers.AssignToSlot(__instance, val, currentTarget, 1);
		}
		else if (GameData.GroupMember2 == null)
		{
			InviteHelpers.AssignToSlot(__instance, val, currentTarget, 2);
		}
		else
		{
			if (GameData.GroupMember3 != null)
			{
				UpdateSocialLog.LogAdd("Your group is full (max 4).", "yellow");
				return false;
			}
			InviteHelpers.AssignToSlot(__instance, val, currentTarget, 3);
		}
		__instance.SetRoles();
		__instance.UpdateGroupNames();
		return false;
	}
}
[HarmonyPatch(typeof(SimPlayer), "Update")]
public static class Patch_SimPlayer_Update
{
	private static void Postfix(SimPlayer __instance)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		SimPlayerTracking val = GameData.SimMngr.Sims[__instance.myIndex];
		if (val.PersonalInvite || val.seekingPlayer)
		{
			Character myself = GameData.PlayerControl.Myself;
			Vector3 val2 = ((Component)myself).transform.position + ((Component)myself).transform.forward * 2f;
			NavMeshAgent component = ((Component)__instance).GetComponent<NavMeshAgent>();
			if ((Object)(object)component != (Object)null && component.isOnNavMesh)
			{
				component.Warp(val2);
				component.isStopped = true;
			}
			else
			{
				((Component)__instance).transform.position = val2;
			}
			val.PersonalInvite = false;
			val.seekingPlayer = false;
			Scene activeScene = SceneManager.GetActiveScene();
			val.CurScene = ((Scene)(ref activeScene)).name;
			__instance.InGroup = true;
			val.KnowsPlayer = true;
			Animator component2 = ((Component)__instance).GetComponent<Animator>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.SetBool("Walking", false);
			}
		}
	}
}
public static class InviteHelpers
{
	public static void AssignToSlot(SimPlayerGrouping instance, SimPlayer simPlayer, Character target, int slot)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		SimPlayerTracking val = GameData.SimMngr.Sims[simPlayer.myIndex];
		string nPCName = ((Component)target).GetComponent<NPC>().NPCName;
		switch (slot)
		{
		case 1:
			((TMP_Text)instance.PlayerOneName).text = nPCName;
			((Graphic)instance.PlayerOneName).color = Color.white;
			GameData.GroupMember1 = val;
			instance.D1.SetActive(true);
			break;
		case 2:
			((TMP_Text)instance.PlayerTwoName).text = nPCName;
			((Graphic)instance.PlayerTwoName).color = Color.white;
			GameData.GroupMember2 = val;
			instance.D2.SetActive(true);
			break;
		case 3:
			((TMP_Text)instance.PlayerThreeName).text = nPCName;
			((Graphic)instance.PlayerThreeName).color = Color.white;
			GameData.GroupMember3 = val;
			instance.D3.SetActive(true);
			break;
		}
		simPlayer.InGroup = true;
		simPlayer.awaitInvite = false;
		simPlayer.WaitForInv = -1f;
		NPC component = ((Component)target).GetComponent<NPC>();
		component.InGroup = true;
		target.NearbyFriends.Add(GameData.PlayerControl.Myself);
		UpdateSocialLog.LogAdd(val.SimName + " has joined your group!", "yellow");
	}
}
[HarmonyPatch(typeof(Stats), "EarnedXP")]
public static class Patch_XPMultiplier
{
	[HarmonyPrefix]
	public static void EarnedXP_Prefix(Stats __instance, ref int _incomingXP)
	{
		if ((Object)(object)__instance != (Object)(object)GameData.PlayerStats)
		{
			return;
		}
		_incomingXP = Mathf.RoundToInt((float)_incomingXP * NoLevelRestrictionPlugin.XPMultiplier.Value);
		int num = _incomingXP;
		SimPlayerTracking[] array = (SimPlayerTracking[])(object)new SimPlayerTracking[3]
		{
			GameData.GroupMember1,
			GameData.GroupMember2,
			GameData.GroupMember3
		};
		SimPlayerTracking[] array2 = array;
		foreach (SimPlayerTracking val in array2)
		{
			if ((Object)(object)val?.MyStats != (Object)null)
			{
				val.MyStats.EarnedXP(num);
			}
		}
	}
}