Decompiled source of EmployeeAssignments v1.1.0

BepInEx/plugins/EmployeeAssignments.dll

Decompiled a year 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 System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using PersonalAssignments.AssignmentLogic;
using PersonalAssignments.Components;
using PersonalAssignments.Data;
using PersonalAssignments.Network;
using PersonalAssignments.UI;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmployeeAssignments")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("PersonalAssignments")]
[assembly: AssemblyFileVersion("1.0.9.0")]
[assembly: AssemblyInformationalVersion("1.0.9")]
[assembly: AssemblyProduct("EmployeeAssignments")]
[assembly: AssemblyTitle("EmployeeAssignments")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 PersonalAssignments
{
	[BepInPlugin("EmployeeAssignments", "EmployeeAssignments", "1.0.9")]
	public class Plugin : BaseUnityPlugin
	{
		private static bool Initialized;

		public static ManualLogSource Log { get; private set; }

		private void Start()
		{
			Initialize();
		}

		private void OnDestroy()
		{
			Initialize();
		}

		private void Initialize()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			if (!Initialized)
			{
				Initialized = true;
				GameObject val = new GameObject("PersonalAssignmentManager");
				Object.DontDestroyOnLoad((Object)(object)val);
				PersonalAssignmentManager personalAssignmentManager = val.AddComponent<PersonalAssignmentManager>();
				personalAssignmentManager.Config = new PAConfig(((BaseUnityPlugin)this).Config);
				val.AddComponent<KillableEnemiesOutput>();
				val.AddComponent<UpdateChecker>();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EmployeeAssignments is loaded!");
			}
		}
	}
	[Serializable]
	public enum AssignmentType
	{
		CollectScrapItem,
		KillMonster,
		RepairValve
	}
	[Serializable]
	public struct Assignment
	{
		public string Name;

		public string UID;

		public byte ID;

		public string BodyText;

		public string ShortText;

		public string TargetText;

		public string FailureReason;

		public int CashReward;

		public int XPReward;

		public AssignmentType Type;

		public ulong PlayerId;

		public ulong[] TargetIds;

		public int TargetsComplete;

		public Vector3 FixedTargetPosition;
	}
	public static class Assignments
	{
		public static readonly Assignment[] All = new Assignment[3]
		{
			new Assignment
			{
				Name = "SCRAP RETRIEVAL",
				UID = "collect_scrap",
				BodyText = "YOU MUST COLLECT THE FOLLOWING SCRAP ITEM: [{0}] IT WILL BE MARKED AS [ASSIGNMENT TARGET]",
				ShortText = "FIND THE [{0}] MARKED 'ASSIGNMENT TARGET'",
				FailureReason = "ANOTHER EMPLOYEE COLLECTED THE ITEM",
				CashReward = 100,
				XPReward = 0,
				Type = AssignmentType.CollectScrapItem,
				TargetIds = new ulong[1]
			},
			new Assignment
			{
				Name = "HUNT & KILL",
				UID = "hunt_kill",
				BodyText = "YOU MUST HUNT AND KILL THE FOLLOWING ENEMY: [{0}] IT WILL BE MARKED AS [ASSIGNMENT TARGET]",
				ShortText = "FIND AND KILL THE [{0}]",
				FailureReason = "THE ENEMY WAS NOT KILLED",
				CashReward = 200,
				XPReward = 0,
				Type = AssignmentType.KillMonster,
				TargetIds = new ulong[1]
			},
			new Assignment
			{
				Name = "REPAIR VALVE",
				UID = "repair_valve",
				BodyText = "YOU MUST FIND AND REPAIR THE BROKEN VALVE",
				ShortText = "FIND AND REPAIR THE BROKEN VALVE",
				TargetText = "BROKEN VALVE",
				FailureReason = "THE BROKEN VALVE WAS NOT FIXED",
				CashReward = 100,
				XPReward = 0,
				Type = AssignmentType.RepairValve,
				TargetIds = new ulong[1]
			}
		};

		public static Assignment GetAssignment(string guid)
		{
			Assignment[] all = All;
			for (int i = 0; i < all.Length; i++)
			{
				Assignment result = all[i];
				if (result.UID == guid)
				{
					return result;
				}
			}
			return default(Assignment);
		}
	}
	public class PersonalAssignmentManager : MonoBehaviour
	{
		private readonly List<IAssignmentLogic> _assignmentLogic = new List<IAssignmentLogic>();

		private NetworkUtils _networkUtils;

		private AssignmentUI _assignmentUI;

		private PAContext _context;

		private GameContext _gameContext;

		private int _maxAssignedPlayers = 20;

		private int _minAssignedPlayers = 1;

		public PAConfig Config;

		private Coroutine _lootValueSyncRoutine;

		private WaitForSecondsRealtime _rewardValueSyncDelay = new WaitForSecondsRealtime(1f);

		private void Log(string log)
		{
			Plugin.Log.LogInfo((object)log);
		}

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			_context = new PAContext();
			_assignmentUI = new GameObject("UI").AddComponent<AssignmentUI>();
			((Component)_assignmentUI).transform.SetParent(((Component)this).transform);
			_networkUtils = ((Component)this).gameObject.AddComponent<NetworkUtils>();
			NetworkUtils networkUtils = _networkUtils;
			networkUtils.OnNetworkData = (Action<string, byte[]>)Delegate.Combine(networkUtils.OnNetworkData, new Action<string, byte[]>(OnNetworkData));
			NetworkUtils networkUtils2 = _networkUtils;
			networkUtils2.OnDisconnect = (Action)Delegate.Combine(networkUtils2.OnDisconnect, new Action(OnDisconnect));
			_gameContext = new GameContext();
			GameStateSync gameStateSync = ((Component)this).gameObject.AddComponent<GameStateSync>();
			gameStateSync.Inject(_gameContext, _networkUtils);
			GameContext gameContext = _gameContext;
			gameContext.GameStateChanged = (Action<GameStateEnum>)Delegate.Combine(gameContext.GameStateChanged, new Action<GameStateEnum>(GameStateChanged));
			InstallAssignmentLogic();
		}

		private void InstallAssignmentLogic()
		{
			_assignmentLogic.Add(new CollectScrapLogic(_context));
			_assignmentLogic.Add(new HuntAndKillLogic(_context));
			_assignmentLogic.Add(new RepairValveLogic(_context));
		}

		public void Start()
		{
			_maxAssignedPlayers = Config.MaxAssignedPlayers.Value;
			_minAssignedPlayers = Config.MinAssignedPlayers.Value;
			_context.AssignAllPlayers = Config.AssignAllPlayers.Value;
			_context.AllPlayersComplete = Config.AllPlayersCanComplete.Value;
			Assignments.All[0].CashReward = Config.ScrapRetrievalReward.Value;
			Assignments.All[2].CashReward = Config.BrokenValveReward.Value;
			_context.ParseStringArray(ref _context.EnemyWhitelist, Config.HuntAndKillWhitelist);
			_context.ParseStringArray(ref _context.AssignmentWhitelist, Config.AssignmentWhiteList);
			_context.ParseIntArray(ref _context.AssignmentWeights, Config.AssignmentWeights);
			_context.ParseIntArray(ref _context.EnemyWeights, Config.HuntAndKillWeights);
			_context.ParseIntArray(ref _context.EnemyRewards, Config.HuntAndKillRewards);
		}

		private void OnDisconnect()
		{
			HandleResetEvent();
		}

		private void SendNetworkEvent<T>(T netEvent) where T : IPAEvent
		{
			string s = JsonUtility.ToJson((object)netEvent);
			byte[] bytes = Encoding.UTF8.GetBytes(s);
			_networkUtils.SendToAll(netEvent.TAG, bytes);
		}

		private void OnNetworkData(string tag, byte[] data)
		{
			if (tag.StartsWith("PA-"))
			{
				string @string = Encoding.UTF8.GetString(data);
				Log("Incoming data " + tag + " " + @string);
				switch (tag)
				{
				case "PA-Reset":
					HandleResetEvent();
					break;
				case "PA-Allocation":
				{
					AssignmentEvent assignmentEvent2 = JsonUtility.FromJson<AssignmentEvent>(@string);
					HandleAllocationEvent(assignmentEvent2);
					break;
				}
				case "PA-Complete":
				{
					CompleteEvent assignmentEvent = JsonUtility.FromJson<CompleteEvent>(@string);
					HandleCompleteEvent(assignmentEvent);
					break;
				}
				case "PA-Failed":
				{
					FailedEvent failedEvent = JsonUtility.FromJson<FailedEvent>(@string);
					HandleFailedEvent(failedEvent);
					break;
				}
				}
			}
		}

		private void HandleResetEvent()
		{
			_context.AssignmentsGenerated = false;
			_context.CurrentAssignment = null;
			_context.ActiveAssignments.Clear();
			_context.CompletedAssignments.Clear();
			_assignmentUI.ClearAssignment();
		}

		private void HandleAllocationEvent(AssignmentEvent assignmentEvent)
		{
			Assignment assignment = Assignments.GetAssignment(assignmentEvent.AssignmentUID);
			assignment.PlayerId = assignmentEvent.PlayerId;
			assignment.TargetIds = assignmentEvent.TargetIds;
			assignment.CashReward = assignmentEvent.RewardValue;
			assignment.TargetText = assignmentEvent.TargetName;
			assignment.ID = assignmentEvent.AssignmentID;
			bool flag = assignment.PlayerId == NetworkManager.Singleton.LocalClientId;
			bool flag2 = _assignmentLogic[(int)assignment.Type].HandleAllocationEvent(ref assignment, flag);
			if (flag && flag2)
			{
				_context.CurrentAssignment = assignment;
				ShowAssignment(_context.CurrentAssignment.Value);
			}
			else
			{
				Log($"Assignment not assigned to local player: (ForLocalPlayer){flag} | (SetupComplete){flag2}");
			}
		}

		private void HandleCompleteEvent(CompleteEvent assignmentEvent)
		{
			Assignment assignment = Assignments.GetAssignment(assignmentEvent.AssignmentUID);
			assignment.CashReward = assignmentEvent.RewardValue;
			assignment.TargetIds = assignmentEvent.TargetIds;
			assignment.PlayerId = assignmentEvent.PlayerId;
			assignment.ID = assignmentEvent.AssignmentID;
			bool flag = _context.CurrentAssignment.HasValue && _context.CurrentAssignment.Value.ID == assignmentEvent.AssignmentID && assignment.PlayerId == NetworkManager.Singleton.LocalClientId;
			_assignmentLogic[(int)assignment.Type].CompleteAssignment(ref assignment, flag);
			if (flag)
			{
				CompleteAssignment();
			}
		}

		private void HandleFailedEvent(FailedEvent failedEvent)
		{
			if (_context.CurrentAssignment.HasValue && _context.CurrentAssignment.Value.ID == failedEvent.AssignmentID && failedEvent.PlayerId == NetworkManager.Singleton.LocalClientId)
			{
				FailAssignment(failedEvent.Reason);
			}
		}

		private void GameStateChanged(GameStateEnum state)
		{
			switch (state)
			{
			case GameStateEnum.MainMenu:
				HandleResetEvent();
				break;
			case GameStateEnum.Orbit:
				ShipTookOff();
				break;
			case GameStateEnum.CompanyHQ:
				HandleResetEvent();
				break;
			case GameStateEnum.Level:
				LandedOnMoon();
				if (NetworkManager.Singleton.IsHost)
				{
					GenerateAssignments();
				}
				break;
			}
		}

		public void LandedOnMoon()
		{
		}

		public void ShipTookOff()
		{
			ClearAllAssignments();
		}

		private void ClearAllAssignments()
		{
			SendNetworkEvent(default(ResetEvent));
		}

		public void Update()
		{
			if (_gameContext.GameState != GameStateEnum.Level)
			{
				return;
			}
			if (_context.CurrentAssignment.HasValue)
			{
				_assignmentUI.SetAssignment(_context.CurrentAssignment.Value);
			}
			if (NetworkManager.Singleton.IsHost)
			{
				if (_context.ActiveAssignments.Count > 0)
				{
					CheckCompleted();
				}
				if (_lootValueSyncRoutine == null && _context.SyncedRewardValues.Count > 0)
				{
					_lootValueSyncRoutine = ((MonoBehaviour)this).StartCoroutine(SyncLootValues());
				}
			}
		}

		private IEnumerator SyncLootValues()
		{
			yield return _rewardValueSyncDelay;
			for (int i = _context.SyncedRewardValues.Count - 1; i >= 0; i--)
			{
				if ((Object)(object)_context.SyncedRewardValues[i].Item1 == (Object)null)
				{
					_context.SyncedRewardValues.RemoveAt(i);
				}
			}
			if (_context.SyncedRewardValues.Count > 0)
			{
				List<NetworkObjectReference> references = new List<NetworkObjectReference>();
				List<int> values = new List<int>();
				foreach (var item in _context.SyncedRewardValues)
				{
					references.Add(NetworkObjectReference.op_Implicit(item.Item1));
					values.Add(item.Item2);
				}
				RoundManager.Instance.SyncScrapValuesClientRpc(references.ToArray(), values.ToArray());
			}
			_lootValueSyncRoutine = null;
		}

		private void GenerateAssignments()
		{
			int num = 0;
			_context.CompletedAssignments.Clear();
			_context.ActiveAssignments.Clear();
			_context.ExcludeTargetIds.Clear();
			IReadOnlyList<ulong> connectedClientsIds = NetworkManager.Singleton.ConnectedClientsIds;
			int num2 = Mathf.Max(_minAssignedPlayers, Mathf.Min(_maxAssignedPlayers, RoundManager.Instance.playersManager.connectedPlayersAmount / 2));
			List<int> list = new List<int>();
			for (int i = 0; i < connectedClientsIds.Count; i++)
			{
				list.Add(i);
			}
			num2 = Mathf.Min(num2, list.Count);
			if (_context.AssignAllPlayers)
			{
				num2 = list.Count;
			}
			Log($"Starting assignment generation for {num2} players");
			byte b = 0;
			for (int j = 0; j < num2; j++)
			{
				b++;
				int index = Random.Range(0, list.Count);
				int index2 = list[index];
				int num3 = Utils.WeightedRandom(_context.AssignmentWeights);
				Assignment assignment = Assignments.GetAssignment(_context.AssignmentWhitelist[num3]);
				if (!string.IsNullOrEmpty(assignment.UID))
				{
					assignment.PlayerId = connectedClientsIds[index2];
					assignment.ID = b;
					bool flag = _assignmentLogic[(int)assignment.Type].ServerSetupAssignment(ref assignment);
					if (!flag && num < 5)
					{
						j--;
						Log($"trying to find another assignment {connectedClientsIds[index2]}");
						num++;
					}
					else if (flag)
					{
						Log($"created assignment for player {connectedClientsIds[index2]}");
						AssignmentEvent assignmentEvent = default(AssignmentEvent);
						assignmentEvent.PlayerId = connectedClientsIds[index2];
						assignmentEvent.AssignmentUID = _context.AssignmentWhitelist[num3];
						assignmentEvent.TargetIds = assignment.TargetIds;
						assignmentEvent.RewardValue = assignment.CashReward;
						assignmentEvent.TargetName = assignment.TargetText;
						assignmentEvent.AssignmentID = b;
						AssignmentEvent netEvent = assignmentEvent;
						SendNetworkEvent(netEvent);
						_context.ActiveAssignments.Add(assignment);
						list.RemoveAt(index);
					}
				}
			}
			_context.AssignmentsGenerated = true;
			Log("Finishing assignment generation");
		}

		private void CheckCompleted()
		{
			bool wasPressedThisFrame = ((ButtonControl)Keyboard.current.oKey).wasPressedThisFrame;
			bool wasPressedThisFrame2 = ((ButtonControl)Keyboard.current.pKey).wasPressedThisFrame;
			for (int num = _context.ActiveAssignments.Count - 1; num >= 0; num--)
			{
				Assignment assignment = _context.ActiveAssignments[num];
				AssignmentState assignmentState = _assignmentLogic[(int)assignment.Type].CheckCompletion(ref assignment);
				if (assignmentState != 0)
				{
					_context.ActiveAssignments.RemoveAt(num);
					_context.CompletedAssignments.Add(assignment);
				}
				switch (assignmentState)
				{
				case AssignmentState.Complete:
					SendNetworkEvent(new CompleteEvent
					{
						PlayerId = assignment.PlayerId,
						AssignmentUID = assignment.UID,
						TargetIds = assignment.TargetIds,
						RewardValue = assignment.CashReward,
						AssignmentID = assignment.ID
					});
					break;
				case AssignmentState.Failed:
					SendNetworkEvent(new FailedEvent
					{
						PlayerId = assignment.PlayerId,
						Reason = assignment.FailureReason,
						AssignmentID = assignment.ID
					});
					break;
				}
			}
		}

		private void ShowAssignment(Assignment assignment)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			if (!((Object)(object)HUDManager.Instance == (Object)null))
			{
				DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[1]
				{
					new DialogueSegment
					{
						speakerText = "ASSIGNMENT:" + assignment.Name,
						bodyText = "YOU HAVE BEEN SELECTED BY THE COMPANY FOR ASSIGNMENT, " + string.Format(assignment.BodyText, assignment.TargetText),
						waitTime = 10f
					}
				};
				_assignmentUI.SetAssignment(assignment);
				HUDManager.Instance.ReadDialogue(array);
			}
		}

		private void CompleteAssignment()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (_context.CurrentAssignment.HasValue)
			{
				DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[1]
				{
					new DialogueSegment
					{
						speakerText = "ASSIGNMENT COMPLETE",
						bodyText = "YOU HAVE COMPLETED THE ASSIGNMENT, WELL DONE. THE COMPANY VALUES YOUR LOYALTY",
						waitTime = 5f
					}
				};
				_assignmentUI.ClearAssignment();
				HUDManager.Instance.ReadDialogue(array);
				_context.CurrentAssignment = null;
			}
		}

		private void FailAssignment(string reason)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (_context.CurrentAssignment.HasValue)
			{
				DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[1]
				{
					new DialogueSegment
					{
						speakerText = "ASSIGNMENT FAILED",
						bodyText = "YOU FAILED TO COMPLETE THE ASSIGNMENT. REASON: " + reason,
						waitTime = 5f
					}
				};
				_assignmentUI.ClearAssignment();
				HUDManager.Instance.ReadDialogue(array);
				_context.CurrentAssignment = null;
			}
		}
	}
	public static class Utils
	{
		private const float EASE_IN_OUT_MAGIC1 = 1.7f;

		private const float EASE_IN_OUT_MAGIC2 = 2.5500002f;

		public static float EaseInOutBack(float x)
		{
			return (x < 0.5f) ? (MathF.Pow(2f * x, 2f) * (7.1000004f * x - 2.5500002f) / 2f) : ((MathF.Pow(2f * x - 2f, 2f) * (3.5500002f * (x * 2f - 2f) + 2.5500002f) + 2f) / 2f);
		}

		public static int WeightedRandom(int[] weights)
		{
			int num = 0;
			for (int i = 0; i < weights.Length; i++)
			{
				num += weights[i];
			}
			int num2 = Random.Range(0, num);
			int num3 = 0;
			for (int j = 0; j < weights.Length; j++)
			{
				num3 += weights[j];
				if (num3 >= num2)
				{
					return j;
				}
			}
			return 0;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "EmployeeAssignments";

		public const string PLUGIN_NAME = "EmployeeAssignments";

		public const string PLUGIN_VERSION = "1.0.9";
	}
}
namespace PersonalAssignments.UI
{
	public class AssignmentUI : MonoBehaviour
	{
		private enum State
		{
			Showing,
			Shown,
			Hiding,
			Hidden
		}

		private readonly Color NONE_TEXT_COLOR = new Color(1f, 0.8277124f, 0.5235849f, 0.3254902f);

		private readonly Color BG_COLOR = new Color(1f, 0.6916346f, 0.259434f, 1f);

		private readonly Color TITLE_COLOR = new Color(1f, 0.9356132f, 0.8160377f, 1f);

		private readonly Color TEXT_COLOR = new Color(0.3584906f, 0.2703371f, 0f, 1f);

		private const float SHOW_SPEED = 1f;

		private const float HIDE_SPEED = 2f;

		private readonly Vector2 SHOW_POSITION = new Vector2(-50f, -350f);

		private readonly Vector2 HIDE_POSITION = new Vector2(500f, -350f);

		private Canvas _canvas;

		private GameObject _noneText;

		private RectTransform _assignment;

		private Text _assignmentTitle;

		private Text _assignmentText;

		private Font _font;

		private QuickMenuManager _menuManager;

		private State _state;

		private float _animationProgress;

		public Assignment? _activeAssignment;

		private void Awake()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: 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)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: 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_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_state = State.Hidden;
			((Component)this).gameObject.layer = 5;
			_font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			_canvas = new GameObject("Canvas").AddComponent<Canvas>();
			((Component)_canvas).transform.SetParent(((Component)this).transform);
			_canvas.sortingOrder = -100;
			_canvas.renderMode = (RenderMode)0;
			RectTransform component = ((Component)_canvas).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(1920f, 1080f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = Vector2.zero / 2f;
			CanvasScaler val = ((Component)_canvas).gameObject.AddComponent<CanvasScaler>();
			val.uiScaleMode = (ScaleMode)1;
			val.screenMatchMode = (ScreenMatchMode)2;
			val.referenceResolution = new Vector2(1920f, 1080f);
			_noneText = new GameObject("NoneText");
			Text val2 = _noneText.AddComponent<Text>();
			val2.fontSize = 20;
			val2.font = _font;
			val2.fontStyle = (FontStyle)1;
			val2.text = "NO ASSIGNMENT ACTIVE";
			((Graphic)val2).color = NONE_TEXT_COLOR;
			val2.alignment = (TextAnchor)4;
			RectTransform component2 = _noneText.GetComponent<RectTransform>();
			((Transform)component2).SetParent((Transform)(object)component);
			component2.pivot = Vector2.one;
			component2.anchorMin = Vector2.one;
			component2.anchorMax = Vector2.one;
			component2.anchoredPosition = new Vector2(-70f, -360f);
			component2.sizeDelta = new Vector2(310f, 50f);
			CanvasGroup val3 = new GameObject("AssignmentPanel").AddComponent<CanvasGroup>();
			val3.alpha = 0.5f;
			Image val4 = ((Component)val3).gameObject.AddComponent<Image>();
			((Graphic)val4).color = BG_COLOR;
			_assignment = ((Component)val3).gameObject.GetComponent<RectTransform>();
			((Transform)_assignment).SetParent((Transform)(object)component);
			_assignment.pivot = Vector2.one;
			_assignment.anchorMin = Vector2.one;
			_assignment.anchorMax = Vector2.one;
			_assignment.anchoredPosition = new Vector2(-50f, -350f);
			_assignment.sizeDelta = new Vector2(350f, 80f);
			_assignmentTitle = new GameObject("Title").AddComponent<Text>();
			_assignmentTitle.font = _font;
			_assignmentTitle.fontSize = 20;
			_assignmentTitle.fontStyle = (FontStyle)1;
			_assignmentTitle.text = "NO ASSIGNMENT ACTIVE";
			((Graphic)_assignmentTitle).color = TITLE_COLOR;
			_assignmentTitle.alignment = (TextAnchor)0;
			RectTransform component3 = ((Component)_assignmentTitle).gameObject.GetComponent<RectTransform>();
			((Transform)component3).SetParent((Transform)(object)_assignment);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = Vector2.one;
			component3.anchoredPosition = new Vector2(0f, -10f);
			component3.sizeDelta = new Vector2(-40f, 100f);
			_assignmentText = new GameObject("Text").AddComponent<Text>();
			_assignmentText.font = _font;
			_assignmentText.fontSize = 16;
			_assignmentText.fontStyle = (FontStyle)1;
			_assignmentText.text = "NO ASSIGNMENT ACTIVE";
			((Graphic)_assignmentText).color = TEXT_COLOR;
			_assignmentText.alignment = (TextAnchor)6;
			RectTransform component4 = ((Component)_assignmentText).gameObject.GetComponent<RectTransform>();
			((Transform)component4).SetParent((Transform)(object)_assignment);
			component4.pivot = new Vector2(0.5f, 0.5f);
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = Vector2.one;
			component4.anchoredPosition = new Vector2(0f, -10f);
			component4.sizeDelta = new Vector2(-40f, -40f);
		}

		public void SetAssignment(Assignment assignment)
		{
			if (_state == State.Hidden || _state == State.Hiding)
			{
				ChangeState(State.Showing);
				_activeAssignment = assignment;
				_assignmentTitle.text = assignment.Name;
				_assignmentText.text = string.Format(assignment.ShortText, assignment.TargetText);
			}
		}

		public void ClearAssignment(bool force = false)
		{
			if (force || _state == State.Shown || _state == State.Showing)
			{
				ChangeState(State.Hiding);
				_activeAssignment = null;
			}
		}

		private void ChangeState(State state)
		{
			_state = state;
			_animationProgress = 0f;
		}

		private void PanelAnimation()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (_state == State.Shown || _state == State.Hidden)
			{
				return;
			}
			if (_animationProgress >= 1f)
			{
				_state++;
				return;
			}
			float num = 1f;
			if (_state == State.Hiding)
			{
				num = 2f;
			}
			_animationProgress += num * Time.deltaTime;
			float num2 = _animationProgress;
			if (_state == State.Hiding)
			{
				num2 = 1f - num2;
			}
			_assignment.anchoredPosition = Vector2.Lerp(HIDE_POSITION, SHOW_POSITION, Utils.EaseInOutBack(num2));
		}

		private void Update()
		{
			//IL_0083: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			PanelAnimation();
			bool flag = (Object)(object)GameNetworkManager.Instance?.localPlayerController != (Object)null && !GameNetworkManager.Instance.localPlayerController.isPlayerDead;
			if ((Object)(object)_menuManager == (Object)null)
			{
				flag = false;
				_menuManager = Object.FindAnyObjectByType<QuickMenuManager>();
			}
			else
			{
				flag &= !_menuManager.isMenuOpen;
			}
			if (_activeAssignment.HasValue && _activeAssignment.Value.FixedTargetPosition != Vector3.zero)
			{
				float num = Vector3.Distance(_activeAssignment.Value.FixedTargetPosition, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position);
				_assignmentText.text = string.Format(_activeAssignment.Value.ShortText, _activeAssignment.Value.TargetText) + $" {(int)num}m";
			}
			((Component)_assignment).gameObject.SetActive(_state != State.Hidden);
			_noneText.SetActive(!_activeAssignment.HasValue);
			((Behaviour)_canvas).enabled = flag;
		}
	}
}
namespace PersonalAssignments.Network
{
	[Serializable]
	public struct NetworkMessage
	{
		public string MessageTag;

		public ulong TargetId;

		public Hash128 Checksum;

		public byte[] Data;
	}
	public class NetworkUtils : MonoBehaviour
	{
		public Action<string, byte[]> OnNetworkData;

		public Action OnDisconnect;

		public Action OnConnect;

		private bool _initialized;

		private bool _connected;

		public bool IsConnected => _connected;

		private void Initialize()
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.CustomMessagingManager != null)
			{
				_initialized = true;
				Debug.Log((object)"[Network Transport] Initialized");
			}
		}

		private void UnInitialize()
		{
			if (_connected)
			{
				Disconnected();
			}
			_initialized = false;
		}

		private void Connected()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			NetworkManager.Singleton.CustomMessagingManager.OnUnnamedMessage += new UnnamedMessageDelegate(OnMessageEvent);
			OnConnect?.Invoke();
			_connected = true;
			Debug.Log((object)"[Network Transport] Connected");
		}

		private void Disconnected()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			if (((singleton != null) ? singleton.CustomMessagingManager : null) != null)
			{
				NetworkManager.Singleton.CustomMessagingManager.OnUnnamedMessage -= new UnnamedMessageDelegate(OnMessageEvent);
			}
			OnDisconnect?.Invoke();
			_connected = false;
			Debug.Log((object)"[Network Transport] Disconnected");
		}

		public void Update()
		{
			if (!_initialized)
			{
				Initialize();
			}
			else if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				UnInitialize();
			}
			else if (!_connected && NetworkManager.Singleton.IsConnectedClient)
			{
				Connected();
			}
			else if (_connected && !NetworkManager.Singleton.IsConnectedClient)
			{
				Disconnected();
			}
		}

		private void OnMessageEvent(ulong clientId, FastBufferReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			Hash128 val = default(Hash128);
			string text = "";
			NetworkMessage networkMessage = default(NetworkMessage);
			try
			{
				((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				Debug.Log((object)$"[Network Transport] Incoming message from {clientId} {text}");
				networkMessage = JsonUtility.FromJson<NetworkMessage>(text);
				val = Hash128.Compute<byte>(networkMessage.Data);
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
			if (!(val == default(Hash128)) && ((Hash128)(ref val)).CompareTo(val) == 0)
			{
				OnNetworkData?.Invoke(networkMessage.MessageTag, networkMessage.Data);
			}
		}

		public void SendToAll(string tag, byte[] data)
		{
			if (!_initialized)
			{
				return;
			}
			foreach (var (num2, val2) in NetworkManager.Singleton.ConnectedClients)
			{
				SendTo(val2.ClientId, tag, data);
			}
		}

		public void SendTo(ulong clientId, string tag, byte[] data)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (!_initialized)
			{
				return;
			}
			NetworkMessage networkMessage = default(NetworkMessage);
			networkMessage.MessageTag = tag;
			networkMessage.TargetId = clientId;
			networkMessage.Data = data;
			networkMessage.Checksum = Hash128.Compute<byte>(data);
			NetworkMessage networkMessage2 = networkMessage;
			string text = JsonUtility.ToJson((object)networkMessage2);
			byte[] bytes = Encoding.UTF8.GetBytes(text);
			int writeSize = FastBufferWriter.GetWriteSize(text, false);
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(writeSize + 1, (Allocator)2, -1);
			FastBufferWriter val2 = val;
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				Debug.Log((object)$"[Network Transport] Sending message to {clientId} {text}");
				NetworkManager.Singleton.CustomMessagingManager.SendUnnamedMessage(clientId, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val2)).Dispose();
			}
		}
	}
}
namespace PersonalAssignments.Data
{
	public interface IPAEvent
	{
		string TAG { get; }
	}
	[Serializable]
	public struct AssignmentEvent : IPAEvent
	{
		public byte AssignmentID;

		public ulong PlayerId;

		public string AssignmentUID;

		public int RewardValue;

		public ulong[] TargetIds;

		public string TargetName;

		public string TAG => "PA-Allocation";
	}
	[Serializable]
	public struct CompleteEvent : IPAEvent
	{
		public byte AssignmentID;

		public ulong PlayerId;

		public string AssignmentUID;

		public int RewardValue;

		public ulong[] TargetIds;

		public string TAG => "PA-Complete";
	}
	[Serializable]
	public struct FailedEvent : IPAEvent
	{
		public byte AssignmentID;

		public ulong PlayerId;

		public string Reason;

		public string TAG => "PA-Failed";
	}
	[Serializable]
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct ResetEvent : IPAEvent
	{
		public string TAG => "PA-Reset";
	}
	public class GameContext
	{
		private GameStateEnum _gameState;

		public Action<GameStateEnum> GameStateChanged;

		public GameStateEnum GameState
		{
			get
			{
				return _gameState;
			}
			set
			{
				if (value != _gameState)
				{
					_gameState = value;
					GameStateChanged?.Invoke(value);
				}
			}
		}
	}
	public enum GameStateEnum
	{
		MainMenu,
		Orbit,
		CompanyHQ,
		Level
	}
	public class PAConfig
	{
		public readonly ConfigEntry<int> MaxAssignedPlayers;

		public readonly ConfigEntry<int> MinAssignedPlayers;

		public readonly ConfigEntry<bool> AssignAllPlayers;

		public readonly ConfigEntry<int> ScrapRetrievalReward;

		public readonly ConfigEntry<string> HuntAndKillWhitelist;

		public readonly ConfigEntry<string> HuntAndKillWeights;

		public readonly ConfigEntry<string> HuntAndKillRewards;

		public readonly ConfigEntry<int> BrokenValveReward;

		public readonly ConfigEntry<bool> AllPlayersCanComplete;

		public readonly ConfigEntry<string> AssignmentWhiteList;

		public readonly ConfigEntry<string> AssignmentWeights;

		public PAConfig(ConfigFile configFile)
		{
			MaxAssignedPlayers = configFile.Bind<int>("0_HostOnly.0_General", "MaxAssignedPlayers", 10, "The maximum number of players that can be assigned each round.");
			MinAssignedPlayers = configFile.Bind<int>("0_HostOnly.0_General", "MinAssignedPlayers", 1, "The minimum number of players that can be assigned each round.");
			AssignAllPlayers = configFile.Bind<bool>("0_HostOnly.0_General", "AssignAllPlayers", false, "When this is true all connected players will always get an assignment  each time you land.");
			AllPlayersCanComplete = configFile.Bind<bool>("0_HostOnly.0_General", "AllPlayersCanComplete", false, "All players can complete someone elses assignment and it will not fail for the owner");
			AssignmentWhiteList = configFile.Bind<string>("0_HostOnly.0_General", "AssignmentWhiteList", "collect_scrap,hunt_kill,repair_valve", "All allowed Assignments");
			AssignmentWeights = configFile.Bind<string>("0_HostOnly.0_General", "AssignmentWeights", "50,25,25", "Weights for allowed assignments");
			ScrapRetrievalReward = configFile.Bind<int>("0_HostOnly.1_ScrapRetrieval", "AssignmentReward", 100, "The reward for completing a Scrap Retrieval Assignment");
			HuntAndKillWhitelist = configFile.Bind<string>("0_HostOnly.2_HuntAndKill", "EnemyWhitelist", "Centipede,Bunker Spider,Hoarding bug,Crawler", "The EnemyNames that are allowed to spawn");
			HuntAndKillRewards = configFile.Bind<string>("0_HostOnly.2_HuntAndKill", "EnemyRewards", "100,200,100,200", "The reward for completing a Hunt And KillReward Assignment for each enemy in the whitelist");
			HuntAndKillWeights = configFile.Bind<string>("0_HostOnly.2_HuntAndKill", "EnemyWeights", "50,25,50,25", "Spawn Weights for each enemy in the whitelist");
			BrokenValveReward = configFile.Bind<int>("0_HostOnly.3_BrokenValve", "AssignmentReward", 100, "The reward for completing a Broken Valve Assignment");
		}
	}
	public class PAContext
	{
		public bool AssignmentsGenerated;

		public readonly List<Assignment> ActiveAssignments = new List<Assignment>();

		public readonly List<Assignment> CompletedAssignments = new List<Assignment>();

		public readonly List<ulong> ExcludeTargetIds = new List<ulong>();

		public readonly List<(NetworkObject, int)> SyncedRewardValues = new List<(NetworkObject, int)>();

		public string[] EnemyWhitelist = new string[0];

		public int[] EnemyWeights = new int[0];

		public int[] EnemyRewards = new int[0];

		public string[] AssignmentWhitelist = new string[0];

		public int[] AssignmentWeights = new int[0];

		public Assignment? CurrentAssignment;

		public bool AssignAllPlayers;

		public bool AllPlayersComplete;

		public void ParseStringArray(ref string[] array, ConfigEntry<string> data)
		{
			string[] array2 = GetConfigValue(data).Split(',', StringSplitOptions.RemoveEmptyEntries);
			array = new string[array2.Length];
			for (int i = 0; i < array2.Length; i++)
			{
				array[i] = array2[i].TrimEnd(',').TrimStart(',');
			}
		}

		public void ParseIntArray(ref int[] array, ConfigEntry<string> data)
		{
			string[] array2 = GetConfigValue(data).Split(',', StringSplitOptions.RemoveEmptyEntries);
			array = new int[array2.Length];
			for (int i = 0; i < array2.Length; i++)
			{
				string s = array2[i].TrimEnd(',').TrimStart(',');
				if (int.TryParse(s, out var result))
				{
					array[i] = result;
				}
				else
				{
					array[i] = 0;
				}
			}
		}

		private string GetConfigValue(ConfigEntry<string> data)
		{
			string text = data.Value;
			if (string.IsNullOrWhiteSpace(text))
			{
				text = (string)((ConfigEntryBase)data).DefaultValue;
			}
			return text;
		}
	}
	public static class PAEventTags
	{
		public const string PREFIX = "PA-";

		public const string RESET = "PA-Reset";

		public const string ALLOCATION = "PA-Allocation";

		public const string COMPLETE = "PA-Complete";

		public const string FAILED = "PA-Failed";
	}
}
namespace PersonalAssignments.Components
{
	public class GameStateSync : MonoBehaviour
	{
		private const string COMPANY_BUILDING_SCENE = "CompanyBuilding";

		private GameContext _gameContext;

		private NetworkUtils _networkUtils;

		private bool _hasLanded;

		public void Inject(GameContext gameContext, NetworkUtils networkUtils)
		{
			_gameContext = gameContext;
			_networkUtils = networkUtils;
		}

		public void Update()
		{
			if (!_networkUtils.IsConnected || (Object)(object)StartOfRound.Instance == (Object)null)
			{
				_gameContext.GameState = GameStateEnum.MainMenu;
			}
			else if (StartOfRound.Instance.inShipPhase && _hasLanded)
			{
				_hasLanded = false;
				_gameContext.GameState = GameStateEnum.Orbit;
			}
			else if (StartOfRound.Instance.shipHasLanded && !_hasLanded)
			{
				_hasLanded = true;
				Debug.Log((object)("Landed on moon : " + RoundManager.Instance.currentLevel.sceneName));
				if (RoundManager.Instance.currentLevel.sceneName == "CompanyBuilding")
				{
					_gameContext.GameState = GameStateEnum.CompanyHQ;
				}
				else
				{
					_gameContext.GameState = GameStateEnum.Level;
				}
			}
		}
	}
	public class KillableEnemiesOutput : MonoBehaviour
	{
		private const string OUTPUT_PATH = "/../BepInEx/config2/KillableEnemies.md";

		private const string OUTPUT_PREFIX = "#KILLABLE ENEMIES LIST\r\nCopy the names from this list into the enemy assignment whilelist config entry to allow them to spawn.\r\nNote that some enemies would normally be spawnable on certain maps only, I'm not sure how well some\r\nenemies will handle being spawned on those maps but they should work I would have thought.";

		public void Update()
		{
			if (!((Object)(object)StartOfRound.Instance == (Object)null))
			{
				OutputList();
				Object.Destroy((Object)(object)this);
			}
		}

		private void OutputList()
		{
			List<string> list = new List<string>();
			string text = "#KILLABLE ENEMIES LIST\r\nCopy the names from this list into the enemy assignment whilelist config entry to allow them to spawn.\r\nNote that some enemies would normally be spawnable on certain maps only, I'm not sure how well some\r\nenemies will handle being spawned on those maps but they should work I would have thought.";
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
				{
					if (!list.Contains(enemy.enemyType.enemyName) && enemy.enemyType.canDie)
					{
						list.Add(enemy.enemyType.enemyName);
						text = text + "\n" + enemy.enemyType.enemyName;
					}
				}
			}
			try
			{
				FileStream fileStream = File.OpenWrite(Application.dataPath + "/../BepInEx/config2/KillableEnemies.md");
				using (StreamWriter streamWriter = new StreamWriter(fileStream))
				{
					streamWriter.Write(text);
				}
				fileStream.Close();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
			}
		}
	}
	public class UpdateChecker : MonoBehaviour
	{
		public const string EXPECTED_VERSION = "1.1.0";

		public const int MAINMENU_BUILDINDEX = 2;

		public const string THUNDERSTORE_URL = "https://thunderstore.io/package/download/amnsoft/EmployeeAssignments/";

		private UnityWebRequestAsyncOperation _webRequest;

		public bool IsLatestVersion { get; private set; }

		private void Awake()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (((Scene)(ref scene)).buildIndex == 2)
			{
				UnityWebRequest val = new UnityWebRequest("https://thunderstore.io/package/download/amnsoft/EmployeeAssignments/" + "1.1.0");
				_webRequest = val.SendWebRequest();
				((AsyncOperation)_webRequest).completed += OnComplete;
				SceneManager.sceneLoaded -= OnSceneLoaded;
			}
		}

		private void OnComplete(AsyncOperation obj)
		{
			IsLatestVersion = _webRequest.webRequest.responseCode == 404;
			if (!IsLatestVersion)
			{
				MenuManager val = Object.FindObjectOfType<MenuManager>();
				((TMP_Text)val.menuNotificationText).SetText("Employee Assignments mod is out of date, new version is atleast 1.1.0. Please update the mod.", true);
				((TMP_Text)val.menuNotificationButtonText).SetText("[ CLOSE ]", true);
				val.menuNotification.SetActive(true);
			}
			_webRequest = null;
		}
	}
}
namespace PersonalAssignments.AssignmentLogic
{
	public class CollectScrapLogic : IAssignmentLogic
	{
		private readonly PAContext _context;

		public CollectScrapLogic(PAContext context)
		{
			_context = context;
		}

		public bool ServerSetupAssignment(ref Assignment assignment)
		{
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if (!_context.ExcludeTargetIds.Contains(((NetworkBehaviour)array[i]).NetworkObjectId) && !array[i].scrapPersistedThroughRounds && array[i].itemProperties.isScrap)
				{
					assignment.TargetIds[0] = ((NetworkBehaviour)array[i]).NetworkObjectId;
					assignment.TargetText = array[i].itemProperties.itemName.ToUpper();
					_context.ExcludeTargetIds.Add(((NetworkBehaviour)array[i]).NetworkObjectId);
					return true;
				}
			}
			return false;
		}

		public bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer)
		{
			if (!localPlayer)
			{
				return false;
			}
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if (((NetworkBehaviour)array[i]).NetworkObjectId == assignment.TargetIds[0])
				{
					assignment.TargetText = array[i].itemProperties.itemName.ToUpper();
					ScanNodeProperties componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<ScanNodeProperties>();
					if ((Object)(object)componentInChildren == (Object)null)
					{
						Debug.LogError((object)("Scan node is missing for item!: " + ((Object)((Component)array[i]).gameObject).name));
						return false;
					}
					componentInChildren.headerText = "ASSIGNMENT TARGET";
					componentInChildren.subText = "Value : ???";
					break;
				}
			}
			return true;
		}

		public AssignmentState CheckCompletion(ref Assignment assignment)
		{
			foreach (GrabbableObject item in RoundManager.Instance.scrapCollectedThisRound)
			{
				if (item.isInShipRoom && ((NetworkBehaviour)item).NetworkObjectId == assignment.TargetIds[0])
				{
					if (_context.AllPlayersComplete || ((NetworkBehaviour)item).OwnerClientId == assignment.PlayerId)
					{
						return AssignmentState.Complete;
					}
					return AssignmentState.Failed;
				}
			}
			return AssignmentState.InProgress;
		}

		public void CompleteAssignment(ref Assignment assignment, bool localPlayer)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.SpawnManager.SpawnedObjects.TryGetValue(assignment.TargetIds[0], out var value))
			{
				GrabbableObject component = ((Component)value).gameObject.GetComponent<GrabbableObject>();
				component.SetScrapValue(assignment.CashReward + component.scrapValue);
				ScanNodeProperties componentInChildren = ((Component)component).gameObject.GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.headerText = component.itemProperties.itemName;
				}
				if (NetworkManager.Singleton.IsHost)
				{
					_context.SyncedRewardValues.Add((((NetworkBehaviour)component).NetworkObject, component.scrapValue));
				}
			}
		}
	}
	public class HuntAndKillLogic : IAssignmentLogic
	{
		private const float MAX_SPAWNDISTANCE = 20f;

		private const float MAX_PLAYERDISTANCE = 10f;

		private const string REWARD = "Gold bar";

		private readonly PAContext _context;

		public HuntAndKillLogic(PAContext context)
		{
			_context = context;
		}

		public bool ServerSetupAssignment(ref Assignment assignment)
		{
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RoundManager.Instance == (Object)null)
			{
				return false;
			}
			int num = Utils.WeightedRandom(_context.EnemyWeights);
			string text = _context.EnemyWhitelist[num];
			assignment.CashReward = _context.EnemyRewards[num];
			bool flag = false;
			for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++)
			{
				EnemyAI val = RoundManager.Instance.SpawnedEnemies[i];
				if (!(val.enemyType.enemyName != text) && ((NetworkBehaviour)val).IsSpawned && !val.isEnemyDead && !_context.ExcludeTargetIds.Contains(((NetworkBehaviour)val).NetworkObjectId))
				{
					assignment.TargetIds[0] = ((NetworkBehaviour)val).NetworkObjectId;
					assignment.TargetText = val.enemyType.enemyName.ToUpper();
					_context.ExcludeTargetIds.Add(((NetworkBehaviour)val).NetworkObjectId);
					flag = true;
					ScanNodeProperties componentInChildren = ((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>();
					componentInChildren.headerText = "ASSIGNMENT TARGET";
					break;
				}
			}
			if (!flag)
			{
				SpawnableEnemyWithRarity val2 = null;
				num = 0;
				for (int j = 0; j < RoundManager.Instance.currentLevel.Enemies.Count; j++)
				{
					if (RoundManager.Instance.currentLevel.Enemies[j].enemyType.enemyName == text)
					{
						val2 = RoundManager.Instance.currentLevel.Enemies[j];
						num = j;
						break;
					}
				}
				if (val2 == null)
				{
					return false;
				}
				Vector3 val3 = Vector3.zero;
				EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
				for (int k = 0; k < array.Length; k++)
				{
					if (!array[k].isEntranceToBuilding && array[k].entranceId == 0)
					{
						val3 = ((Component)array[k]).transform.position;
					}
				}
				List<(EnemyVent, float)> list = new List<(EnemyVent, float)>();
				EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
				foreach (EnemyVent val4 in allEnemyVents)
				{
					list.Add((val4, Vector3.Distance(val4.floorNode.position, val3)));
				}
				list = list.OrderByDescending<(EnemyVent, float), float>(((EnemyVent vent, float distance) a) => a.distance).ToList();
				bool flag2 = false;
				int num2 = 0;
				Vector3 val5 = Vector3.zero;
				NavMeshHit val6 = default(NavMeshHit);
				while (!flag2 && num2 < 5)
				{
					EnemyVent item = list[Random.Range(0, list.Count / 2)].Item1;
					flag2 = NavMesh.SamplePosition(item.floorNode.position, ref val6, 20f, -1);
					val5 = ((NavMeshHit)(ref val6)).position;
					num2++;
				}
				if (!flag2)
				{
					return false;
				}
				RoundManager.Instance.SpawnEnemyOnServer(val5, 0f, num);
				ulong[] targetIds = assignment.TargetIds;
				List<EnemyAI> spawnedEnemies = RoundManager.Instance.SpawnedEnemies;
				targetIds[0] = ((NetworkBehaviour)spawnedEnemies[spawnedEnemies.Count - 1]).NetworkObjectId;
				List<EnemyAI> spawnedEnemies2 = RoundManager.Instance.SpawnedEnemies;
				assignment.TargetText = spawnedEnemies2[spawnedEnemies2.Count - 1].enemyType.enemyName.ToUpper();
				_context.ExcludeTargetIds.Add(assignment.TargetIds[0]);
				List<EnemyAI> spawnedEnemies3 = RoundManager.Instance.SpawnedEnemies;
				ScanNodeProperties componentInChildren2 = ((Component)spawnedEnemies3[spawnedEnemies3.Count - 1]).gameObject.GetComponentInChildren<ScanNodeProperties>();
				componentInChildren2.headerText = "ASSIGNMENT TARGET";
			}
			return true;
		}

		public bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer)
		{
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (((NetworkBehaviour)spawnedEnemy).NetworkObjectId == assignment.TargetIds[0])
				{
					assignment.TargetText = spawnedEnemy.enemyType.enemyName.ToUpper();
					ScanNodeProperties componentInChildren = ((Component)spawnedEnemy).gameObject.GetComponentInChildren<ScanNodeProperties>();
					componentInChildren.headerText = "ASSIGNMENT TARGET";
					return true;
				}
			}
			return true;
		}

		public AssignmentState CheckCompletion(ref Assignment assignment)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (((NetworkBehaviour)spawnedEnemy).NetworkObjectId != assignment.TargetIds[0] || !spawnedEnemy.isEnemyDead)
				{
					continue;
				}
				float num = float.MaxValue;
				foreach (NetworkClient connectedClients in NetworkManager.Singleton.ConnectedClientsList)
				{
					float num2 = Vector3.Distance(((Component)connectedClients.PlayerObject).transform.position, ((Component)spawnedEnemy.agent).transform.position);
					if (num2 < num)
					{
						num = num2;
					}
				}
				if (num < 10f)
				{
					return AssignmentState.Complete;
				}
				return AssignmentState.Failed;
			}
			return AssignmentState.InProgress;
		}

		public void CompleteAssignment(ref Assignment assignment, bool localPlayer)
		{
			//IL_00b6: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost)
			{
				return;
			}
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (((NetworkBehaviour)spawnedEnemy).NetworkObjectId == assignment.TargetIds[0])
				{
					GameObject val = (from a in StartOfRound.Instance.allItemsList.itemsList?.Where((Item a) => a.itemName == "Gold bar")
						select a.spawnPrefab).First();
					GameObject val2 = Object.Instantiate<GameObject>(val, spawnedEnemy.serverPosition, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
					GrabbableObject component = val2.GetComponent<GrabbableObject>();
					((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
					component.fallTime = 0f;
					component.SetScrapValue(assignment.CashReward);
					NetworkObject component2 = val2.GetComponent<NetworkObject>();
					component2.Spawn(false);
					_context.SyncedRewardValues.Add((component2, assignment.CashReward));
					break;
				}
			}
		}
	}
	public interface IAssignmentLogic
	{
		bool ServerSetupAssignment(ref Assignment assignment);

		bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer);

		AssignmentState CheckCompletion(ref Assignment assignment);

		void CompleteAssignment(ref Assignment assignment, bool localPlayer);
	}
	public enum AssignmentState
	{
		InProgress,
		Complete,
		Failed
	}
	public class RepairValveLogic : IAssignmentLogic
	{
		private readonly PAContext _context;

		public RepairValveLogic(PAContext context)
		{
			_context = context;
		}

		public bool ServerSetupAssignment(ref Assignment assignment)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			SteamValveHazard[] array = Object.FindObjectsByType<SteamValveHazard>((FindObjectsSortMode)0);
			if (array.Length == 0)
			{
				return false;
			}
			Vector3 val = RoundManager.FindMainEntrancePosition(false, false);
			float num = 0f;
			int num2 = 0;
			for (int i = 0; i < array.Length; i++)
			{
				float num3 = Vector3.Distance(val, ((Component)array[i]).transform.position);
				if (num3 > num && num3 > 80f)
				{
					num2 = i;
					num = num3;
				}
			}
			if (!_context.ExcludeTargetIds.Contains(((NetworkBehaviour)array[num2]).NetworkObjectId) && ((NetworkBehaviour)array[num2]).IsSpawned)
			{
				assignment.TargetIds[0] = ((NetworkBehaviour)array[num2]).NetworkObjectId;
				_context.ExcludeTargetIds.Add(((NetworkBehaviour)array[num2]).NetworkObjectId);
				array[num2].valveCrackTime = 0.001f;
				array[num2].valveBurstTime = 0.01f;
				array[num2].triggerScript.interactable = true;
				assignment.FixedTargetPosition = ((Component)array[num2]).gameObject.transform.position;
				return true;
			}
			return false;
		}

		public bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer)
		{
			return true;
		}

		public AssignmentState CheckCompletion(ref Assignment assignment)
		{
			SteamValveHazard[] array = Object.FindObjectsOfType<SteamValveHazard>();
			SteamValveHazard[] array2 = array;
			foreach (SteamValveHazard val in array2)
			{
				if (((NetworkBehaviour)val).NetworkObjectId == assignment.TargetIds[0] && !val.triggerScript.interactable)
				{
					if (_context.AllPlayersComplete || ((NetworkBehaviour)val.triggerScript).OwnerClientId == assignment.PlayerId)
					{
						return AssignmentState.Complete;
					}
					return AssignmentState.Failed;
				}
			}
			return AssignmentState.InProgress;
		}

		public void CompleteAssignment(ref Assignment assignment, bool localPlayer)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost)
			{
				return;
			}
			SteamValveHazard[] array = Object.FindObjectsOfType<SteamValveHazard>();
			SteamValveHazard[] array2 = array;
			foreach (SteamValveHazard val in array2)
			{
				if (((NetworkBehaviour)val).NetworkObjectId == assignment.TargetIds[0])
				{
					GameObject val2 = (from a in StartOfRound.Instance.allItemsList.itemsList?.Where((Item a) => a.itemName == "Gold bar")
						select a.spawnPrefab).First();
					GameObject val3 = Object.Instantiate<GameObject>(val2, ((Component)val).gameObject.transform.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
					GrabbableObject component = val3.GetComponent<GrabbableObject>();
					((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
					component.fallTime = 0f;
					component.SetScrapValue(assignment.CashReward);
					NetworkObject component2 = val3.GetComponent<NetworkObject>();
					component2.Spawn(false);
					_context.SyncedRewardValues.Add((component2, assignment.CashReward));
					break;
				}
			}
		}
	}
}