Decompiled source of Add Employees On The Start v1.0.3

BepInEx/plugins/MyCustomMod/MyCustomMod.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MyCustomMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyCustomMod")]
[assembly: AssemblyTitle("MyCustomMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("likefools.EmployeesToAdd", "EmployeesToAdd", "1.0.0")]
public class MyCustomMod : BaseUnityPlugin
{
	private bool employeeCreated = false;

	private ConfigEntry<int> employeesToAdd;

	private void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		employeesToAdd = ((BaseUnityPlugin)this).Config.Bind<int>("General", "EmployeesToAdd", 1, new ConfigDescription("Number of employees to add at the start of the game", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
	}

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(WaitForGameToStart());
	}

	private IEnumerator WaitForGameToStart()
	{
		while ((Object)(object)GameData.Instance == (Object)null || !IsGameStarted())
		{
			yield return (object)new WaitForSeconds(5f);
		}
		if (!employeeCreated)
		{
			NPC_Manager instance = NPC_Manager.Instance;
			instance.maxEmployees += employeesToAdd.Value;
			NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
			Debug.Log((object)$"Employees created after game started! Total employees: {NPC_Manager.Instance.maxEmployees}");
			employeeCreated = true;
		}
	}

	private bool IsGameStarted()
	{
		return GameData.Instance.gameFunds > 0f;
	}
}