Decompiled source of GuysOnly v1.0.1

GuysOnly.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GuysOnly.Patches;
using HarmonyLib;
using Mirror;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GuysOnly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GuysOnly")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("97004fce-0c17-4a58-ba1e-d958c49430bd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GuysOnly
{
	[BepInPlugin("EmsekYaHareeedy-GuysOnly", "GuysOnly", "1.0.0.0")]
	public class ModBase : BaseUnityPlugin
	{
		public const string modGUID = "EmsekYaHareeedy-GuysOnly";

		public const string modName = "GuysOnly";

		public const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("EmsekYaHareeedy-GuysOnly");

		private static ModBase instance;

		public static ManualLogSource Log = new ManualLogSource("GuysOnly");

		public static bool DoDebug = false;

		private string FilePath = Application.persistentDataPath + "/Settings/GameOptions.es3";

		public void Awake()
		{
			harmony.PatchAll(typeof(ModBase));
			harmony.PatchAll(typeof(BillboardPatch));
			harmony.PatchAll(typeof(CustomerPatch));
			harmony.PatchAll(typeof(EmployeePatch));
			harmony.PatchAll(typeof(DummyPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Alhamdullah");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		public void Start()
		{
			if (ES3.FileExists(FilePath))
			{
				if (DoDebug)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"GameOptions.es3 Was Found");
				}
				if (ES3.KeyExists("MusicVol", FilePath) && DoDebug)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"MusicVol Was Found");
				}
				ES3.Save<float>("MusicVol", 0.01f, FilePath);
				((MonoBehaviour)this).StartCoroutine(MusicCheck());
			}
		}

		private IEnumerator MusicCheck()
		{
			if (DoDebug)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Waiting for MusicVol to change...");
			}
			yield return (object)new WaitUntil((Func<bool>)(() => ES3.Load<float>("MusicVol", FilePath) > 0.01f));
			Application.Quit();
		}
	}
}
namespace GuysOnly.Patches
{
	public static class BillboardPatch
	{
		private static readonly ManualLogSource Logger = Logger.CreateLogSource("GuysOnly");

		[HarmonyPatch(typeof(Billboard))]
		[HarmonyPatch("ChangeAdd")]
		[HarmonyPrefix]
		public static bool ChangeAddPatch(Billboard __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			int num = Random.Range(1, __instance.Adverts.Length);
			__instance.mat.SetTexture("_MainTexture", __instance.Adverts[num].Advert);
			__instance.mat.SetFloat("_ScanAmount", __instance.Scans);
			if (Object.op_Implicit((Object)(object)__instance.MainLight))
			{
				__instance.MainLight.color = __instance.Adverts[num].LightColor;
			}
			((MonoBehaviour)__instance).StartCoroutine(__instance.StartEffect());
			return false;
		}
	}
	[HarmonyPatch(typeof(NPC_Manager))]
	public static class CustomerPatch
	{
		private static readonly ManualLogSource Logger = Logger.CreateLogSource("GuysOnly");

		public static bool SpawnCustomerNCP(NPC_Manager __instance, ref IEnumerator __result)
		{
			__result = CustomSpawnCustomerNCP(__instance);
			return false;
		}

		public static IEnumerator CustomSpawnCustomerNCP(NPC_Manager instance)
		{
			int[] possibleIDs = new int[51]
			{
				1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
				11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
				22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
				32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
				42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
				52
			};
			int randomID = possibleIDs[Random.Range(0, possibleIDs.Length)];
			instance.spawnCooldown = true;
			float value2 = 5f - (float)(GameData.Instance.gameDay + GameData.Instance.difficulty + NetworkServer.connections.Count) * 0.05f;
			float value4 = 12f - (float)(GameData.Instance.gameDay + GameData.Instance.difficulty + NetworkServer.connections.Count) * 0.12f;
			value2 = Mathf.Clamp(value2, 2f, float.PositiveInfinity);
			value4 = Mathf.Clamp(value4, 4f, float.PositiveInfinity);
			yield return (object)new WaitForSeconds(Random.Range(value2, value4));
			int gameDay = GameData.Instance.gameDay;
			float num;
			float value7;
			if (NetworkServer.connections.Count <= 1)
			{
				num = Mathf.Clamp(instance.surveillanceFactor, 0f, 0.25f);
				value7 = ((float)gameDay - 7f) * 0.05f + (float)GameData.Instance.difficulty * 0.1f;
				value7 = Mathf.Clamp(value7, 0f, 1.25f + (float)GameData.Instance.difficulty);
			}
			else
			{
				num = Mathf.Clamp(instance.surveillanceFactor, 0f, 0.1f);
				value7 = ((float)gameDay - 7f) * 0.15f + (float)GameData.Instance.difficulty * 0.15f;
				value7 = Mathf.Clamp(value7, 0f, 2f + (float)GameData.Instance.difficulty + (float)NetworkServer.connections.Count);
			}
			float num3 = Random.Range(0.1f, 100f);
			num3 /= 1f - num;
			Vector3 position = ((Component)instance.spawnPointsOBJ.transform.GetChild(Random.Range(0, instance.spawnPointsOBJ.transform.childCount - 1))).transform.position;
			GameObject gameObject = Object.Instantiate<GameObject>(instance.npcAgentPrefab, position, Quaternion.identity);
			gameObject.transform.SetParent(instance.customersnpcParentOBJ.transform);
			NPC_Info component = gameObject.GetComponent<NPC_Info>();
			component.NetworkNPCID = randomID;
			if (ModBase.DoDebug)
			{
				Logger.LogInfo((object)$"Assigned NetworkNPCID For Customer: {randomID}");
			}
			component.NetworkisCustomer = true;
			component.productItemPlaceWait = Mathf.Clamp(0.5f - (float)GameData.Instance.gameDay * 0.003f, 0.1f, 0.5f);
			if (num3 < value7)
			{
				component.isAThief = true;
			}
			NetworkServer.Spawn(gameObject, (NetworkConnection)null);
			int num4 = Random.Range(2 + GameData.Instance.difficulty, GameData.Instance.maxProductsCustomersToBuy);
			for (int i = 0; i < num4; i++)
			{
				int item = ProductListing.Instance.availableProducts[Random.Range(0, ProductListing.Instance.availableProducts.Count)];
				component.productsIDToBuy.Add(item);
			}
			component.productsIDToBuy.Sort();
			if ((double)Random.value < 0.5)
			{
				component.productsIDToBuy.Reverse();
			}
			NavMeshAgent component2 = gameObject.GetComponent<NavMeshAgent>();
			((Behaviour)component2).enabled = true;
			component2.stoppingDistance = 1f;
			component2.speed = 1.9f + (float)Mathf.Clamp(GameData.Instance.gameDay - 7, 0, 40) * 0.07f + (float)NetworkServer.connections.Count * 0.1f + (float)GameData.Instance.difficulty * 0.15f;
			component2.angularSpeed = 120f + (float)Mathf.Clamp(GameData.Instance.gameDay / 2, 0, 60);
			component2.acceleration = 8f + (float)Mathf.Clamp(GameData.Instance.gameDay / 3, 0, 24);
			Vector3 position2 = ((Component)instance.shelvesOBJ.transform.GetChild(Random.Range(0, instance.shelvesOBJ.transform.childCount - 1)).Find("Standspot")).transform.position;
			component2.destination = position2;
			instance.spawnCooldown = false;
		}
	}
	internal class DummyPatch
	{
		private static readonly ManualLogSource Logger = Logger.CreateLogSource("GuysOnly");

		[HarmonyPatch(typeof(NPC_Manager))]
		[HarmonyPatch("SpawnDummyNCP")]
		[HarmonyPrefix]
		public static bool SpawnDummyNCP(NPC_Manager __instance, ref IEnumerator __result)
		{
			__result = CustomSpawnDummyNPC(__instance);
			return false;
		}

		public static IEnumerator CustomSpawnDummyNPC(NPC_Manager instance)
		{
			instance.dummySpawnCooldown = true;
			yield return (object)new WaitForSeconds(Random.Range(1f, 6f));
			Vector3 position = ((Component)instance.spawnPointsOBJ.transform.GetChild(Random.Range(0, instance.spawnPointsOBJ.transform.childCount - 1))).transform.position;
			GameObject obj = Object.Instantiate<GameObject>(instance.npcAgentPrefab, position, Quaternion.identity);
			obj.transform.SetParent(instance.dummynpcParentOBJ.transform);
			int[] possibleIDs = new int[51]
			{
				1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
				11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
				22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
				32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
				42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
				52
			};
			int randomID = possibleIDs[Random.Range(0, possibleIDs.Length)];
			obj.GetComponent<NPC_Info>().NetworkNPCID = randomID;
			if (ModBase.DoDebug)
			{
				Logger.LogInfo((object)$"Assigned NetworkNPCID For Dummy: {randomID}");
			}
			NetworkServer.Spawn(obj, (NetworkConnection)null);
			NavMeshAgent component = obj.GetComponent<NavMeshAgent>();
			((Behaviour)component).enabled = true;
			component.destination = ((Component)instance.randomPointsOBJ.transform.GetChild(Random.Range(0, instance.randomPointsOBJ.transform.childCount - 1))).transform.position;
			yield return (object)new WaitForSeconds(0.3f);
			instance.dummySpawnCooldown = false;
		}
	}
	internal class EmployeePatch
	{
		[HarmonyPatch(typeof(EmployeesDataGeneration))]
		[HarmonyPatch("GenerateTodayEmployeesData")]
		[HarmonyPrefix]
		public static bool GenerateTodayEmployeesDataPatch(EmployeesDataGeneration __instance)
		{
			ManualLogSource val = Logger.CreateLogSource("EmployeesDataPatch");
			int num = 0;
			int num2 = Random.Range(0, 5);
			int num3 = Random.Range(5, 10);
			if (ModBase.DoDebug)
			{
				val.LogInfo((object)$"Initial values: num = {num2}, num2 = {num3}");
			}
			for (int i = 0; i < 10; i++)
			{
				if (ModBase.DoDebug)
				{
					val.LogInfo((object)$"--- Iteration {i} start ---");
				}
				int[] array = new int[2] { 0, 2 };
				int num4 = array[Random.Range(0, array.Length)];
				int num5 = num4;
				num++;
				if (ModBase.DoDebug)
				{
					val.LogInfo((object)$"num3 (Random.Range(0, 7)): {num5}");
				}
				int num6;
				int num7;
				int num8;
				int num9;
				if (i == num2)
				{
					num6 = Random.Range(6, 11);
					num7 = Random.Range(7, 11);
					num8 = Random.Range(6, 11);
					num9 = Random.Range(7, 11);
					if (ModBase.DoDebug)
					{
						val.LogInfo((object)$"i equals num ({num2}): num4 = {num6}, num5 = {num7}, num6 = {num8}, num7 = {num9}");
					}
				}
				else if (i == num3)
				{
					num6 = Random.Range(5, 11);
					num7 = Random.Range(4, 11);
					num8 = Random.Range(5, 11);
					num9 = Random.Range(4, 11);
					if (ModBase.DoDebug)
					{
						val.LogInfo((object)$"i equals num2 ({num3}): num4 = {num6}, num5 = {num7}, num6 = {num8}, num7 = {num9}");
					}
				}
				else
				{
					num6 = Random.Range(1, 11);
					num7 = Random.Range(1, 11);
					num8 = Random.Range(1, 11);
					num9 = Random.Range(1, 11);
					if (ModBase.DoDebug)
					{
						val.LogInfo((object)$"Default case: num4 = {num6}, num5 = {num7}, num6 = {num8}, num7 = {num9}");
					}
				}
				int num10 = (num6 + num7 + num8 + num9) * Random.Range(3, 6) + Random.Range(-2, 3) * 10;
				num10 = Mathf.Clamp(num10, 30, 1000);
				if (ModBase.DoDebug)
				{
					val.LogInfo((object)$"Computed value: {num10}");
				}
				string text = num5 + "|" + num10 + "|" + num6 + "|" + num7 + "|" + num8 + "|" + num9;
				if (ModBase.DoDebug)
				{
					val.LogInfo((object)("Generated text: " + text));
				}
				__instance.managerComponent.todaysEmployeesData[i] = text;
				__instance.managerComponent.UpdateTodayEmployeesOnClients(i, text);
				if (ModBase.DoDebug)
				{
					val.LogInfo((object)$"--- Iteration {i} end ---\n");
				}
			}
			return false;
		}
	}
}
namespace GuysOnly.MonoBehaviours
{
	internal class GuysOnlyComponent : MonoBehaviour
	{
		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void LateUpdate()
		{
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}