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.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EmployeeAssignmentsRevived.AssignmentLogic;
using EmployeeAssignmentsRevived.Components;
using EmployeeAssignmentsRevived.Data;
using EmployeeAssignmentsRevived.Network;
using EmployeeAssignmentsRevived.UI;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EmployeeAssignmentsRevived")]
[assembly: AssemblyDescription("EmployeeAssignmentsRevived mod by FluxTeam")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("FluxTeam")]
[assembly: AssemblyProduct("EmployeeAssignmentsRevived")]
[assembly: AssemblyCopyright("Copyright © FluxTeam 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("aca547c8-abcd-491c-8a90-5b93a3f15809")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.0.0.0")]
[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 EmployeeAssignmentsRevived
{
public class EmployeeAssignmentManager : MonoBehaviour
{
[CompilerGenerated]
private sealed class <SyncLootValues>d__30 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public EmployeeAssignmentManager <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SyncLootValues>d__30(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
EmployeeAssignmentManager employeeAssignmentManager = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = employeeAssignmentManager._rewardValueSyncDelay;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
employeeAssignmentManager._context.SyncedRewardValues.RemoveAll(((NetworkObject, int) x) => (Object)(object)x.Item1 == (Object)null);
if (employeeAssignmentManager._context.SyncedRewardValues.Count > 0)
{
List<NetworkObjectReference> list = new List<NetworkObjectReference>();
List<int> list2 = new List<int>();
foreach (var (val, item) in employeeAssignmentManager._context.SyncedRewardValues)
{
list.Add(NetworkObjectReference.op_Implicit(val));
list2.Add(item);
}
RoundManager.Instance.SyncScrapValuesClientRpc(list.ToArray(), list2.ToArray());
}
employeeAssignmentManager._lootValueSyncRoutine = null;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private readonly List<IAssignmentLogic> _assignmentLogic = new List<IAssignmentLogic>();
private NetworkUtils _networkUtils;
private AssignmentUI _assignmentUI;
private EAContext _context;
private GameContext _gameContext;
public EAConfig Config;
private int _maxAssignedPlayers = 20;
private int _minAssignedPlayers = 1;
private Coroutine _lootValueSyncRoutine;
private readonly WaitForSecondsRealtime _rewardValueSyncDelay = new WaitForSecondsRealtime(1f);
private void Log(string log)
{
Plugin.Log.LogInfo((object)log);
}
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
_context = new EAContext();
_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(HandleResetEvent));
_gameContext = new GameContext();
((Component)this).gameObject.AddComponent<GameStateSync>().Inject(_gameContext, _networkUtils);
GameContext gameContext = _gameContext;
gameContext.GameStateChanged = (Action<GameStateEnum>)Delegate.Combine(gameContext.GameStateChanged, new Action<GameStateEnum>(GameStateChanged));
InstallAssignmentLogic();
}
private 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 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 void InstallAssignmentLogic()
{
_assignmentLogic.Add(new CollectScrapLogic(_context));
_assignmentLogic.Add(new HuntAndKillLogic(_context));
_assignmentLogic.Add(new RepairValveLogic(_context));
}
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("EA-"))
{
string @string = Encoding.UTF8.GetString(data);
Log("Incoming data " + tag + " " + @string);
switch (tag)
{
case "EA-Reset":
HandleResetEvent();
break;
case "EA-Allocation":
HandleAllocationEvent(JsonUtility.FromJson<AssignmentEvent>(@string));
break;
case "EA-Complete":
HandleCompleteEvent(JsonUtility.FromJson<CompleteEvent>(@string));
break;
case "EA-Failed":
HandleFailedEvent(JsonUtility.FromJson<FailedEvent>(@string));
break;
}
}
}
private void HandleResetEvent()
{
_context.AssignmentsGenerated = false;
_context.CurrentAssignment = null;
_context.ActiveAssignments.Clear();
_context.CompletedAssignments.Clear();
_assignmentUI.ClearAssignment();
}
private void HandleAllocationEvent(AssignmentEvent e)
{
Assignment assignment = Assignments.GetAssignment(e.AssignmentUID);
assignment.PlayerId = e.PlayerId;
assignment.TargetIds = e.TargetIds;
assignment.CashReward = e.RewardValue;
assignment.TargetText = e.TargetName;
assignment.ID = e.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(assignment);
}
}
private void HandleCompleteEvent(CompleteEvent e)
{
Assignment assignment = Assignments.GetAssignment(e.AssignmentUID);
assignment.CashReward = e.RewardValue;
assignment.TargetIds = e.TargetIds;
assignment.PlayerId = e.PlayerId;
assignment.ID = e.AssignmentID;
bool flag = _context.CurrentAssignment.HasValue && _context.CurrentAssignment.Value.ID == e.AssignmentID && assignment.PlayerId == NetworkManager.Singleton.LocalClientId;
_assignmentLogic[(int)assignment.Type].CompleteAssignment(ref assignment, flag);
if (flag)
{
CompleteAssignment();
}
}
private void HandleFailedEvent(FailedEvent e)
{
if (_context.CurrentAssignment.HasValue && _context.CurrentAssignment.Value.ID == e.AssignmentID && e.PlayerId == NetworkManager.Singleton.LocalClientId)
{
FailAssignment(e.Reason);
}
}
private void GameStateChanged(GameStateEnum state)
{
switch (state)
{
case GameStateEnum.MainMenu:
case GameStateEnum.CompanyHQ:
HandleResetEvent();
break;
case GameStateEnum.Orbit:
ClearAllAssignments();
break;
case GameStateEnum.Level:
LandedOnMoon();
if (NetworkManager.Singleton.IsHost)
{
GenerateAssignments();
}
break;
}
}
public void LandedOnMoon()
{
}
public void ShipTookOff()
{
ClearAllAssignments();
}
private void ClearAllAssignments()
{
SendNetworkEvent(default(ResetEvent));
}
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--;
num++;
}
else if (flag)
{
Log($"Created assignment for player {connectedClientsIds[index2]}");
SendNetworkEvent(new AssignmentEvent
{
PlayerId = connectedClientsIds[index2],
AssignmentUID = _context.AssignmentWhitelist[num3],
TargetIds = assignment.TargetIds,
RewardValue = assignment.CashReward,
TargetName = assignment.TargetText,
AssignmentID = b
});
_context.ActiveAssignments.Add(assignment);
list.RemoveAt(index);
}
}
}
_context.AssignmentsGenerated = true;
Log("Finished assignment generation.");
}
private void CheckCompleted()
{
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 a)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
if ((Object)(object)HUDManager.Instance != (Object)null)
{
DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[1]
{
new DialogueSegment
{
speakerText = "ASSIGNMENT:" + a.Name,
bodyText = "YOU HAVE BEEN SELECTED BY THE COMPANY FOR ASSIGNMENT, " + string.Format(a.BodyText, a.TargetText),
waitTime = 10f
}
};
_assignmentUI.SetAssignment(a);
HUDManager.Instance.ReadDialogue(array);
}
}
private void CompleteAssignment()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0047: 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;
}
}
[IteratorStateMachine(typeof(<SyncLootValues>d__30))]
private IEnumerator SyncLootValues()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SyncLootValues>d__30(0)
{
<>4__this = this
};
}
}
[BepInPlugin("FluxTeam.EmployeeAssignmentsRevived", "EmployeeAssignmentsRevived", "2.0.1")]
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_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_0028: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
if (!Initialized)
{
Initialized = true;
GameObject val = new GameObject("EmployeeAssignmentManager");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<EmployeeAssignmentManager>().Config = new EAConfig(((BaseUnityPlugin)this).Config);
val.AddComponent<KillableEnemiesOutput>();
val.AddComponent<UpdateChecker>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"EmployeeAssignmentsRevived v2.0.1 loaded successfully.");
}
}
}
[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 static class Utils
{
public static float EaseInOutBack(float x)
{
if (!(x < 0.5f))
{
return ((float)Math.Pow(2.0 * (double)x - 2.0, 2.0) * (3.5500002f * (x * 2f - 2f) + 2.5500002f) + 2f) / 2f;
}
return (float)Math.Pow(2.0 * (double)x, 2.0) * (7.1000004f * x - 2.5500002f) / 2f;
}
public static int WeightedRandom(int[] weights)
{
int num = 0;
foreach (int num2 in weights)
{
num += num2;
}
int num3 = Random.Range(0, num);
int num4 = 0;
for (int j = 0; j < weights.Length; j++)
{
num4 += weights[j];
if (num4 >= num3)
{
return j;
}
}
return 0;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "FluxTeam.EmployeeAssignmentsRevived";
public const string PLUGIN_NAME = "EmployeeAssignmentsRevived";
public const string PLUGIN_AUTHOR = "FluxTeam";
public const string PLUGIN_VERSION = "2.0.1";
public const string VERSION_TEXT = "Employee Assignments Revived mod is out of date. Please update to at least v2.0.1.";
}
}
namespace EmployeeAssignmentsRevived.UI
{
public class AssignmentUI : MonoBehaviour
{
private enum State
{
Showing,
Shown,
Hiding,
Hidden
}
private readonly Color NONE_TEXT_COLOR = new Color(1f, 0.8277f, 0.5236f, 0.3255f);
private readonly Color BG_COLOR = new Color(1f, 0.6916f, 0.2594f, 1f);
private readonly Color TITLE_COLOR = new Color(1f, 0.9356f, 0.816f, 1f);
private readonly Color TEXT_COLOR = new Color(0.3585f, 0.2703f, 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: 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)
//IL_022f: 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_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: 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_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: 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_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: 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;
CanvasScaler obj = ((Component)_canvas).gameObject.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.screenMatchMode = (ScreenMatchMode)0;
obj.referenceResolution = new Vector2(1920f, 1080f);
_noneText = new GameObject("NoneText");
Text obj2 = _noneText.AddComponent<Text>();
obj2.fontSize = 20;
obj2.font = _font;
obj2.fontStyle = (FontStyle)1;
obj2.text = "NO ASSIGNMENT ACTIVE";
((Graphic)obj2).color = NONE_TEXT_COLOR;
obj2.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 val = new GameObject("AssignmentPanel").AddComponent<CanvasGroup>();
val.alpha = 0.5f;
((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = BG_COLOR;
_assignment = ((Component)val).GetComponent<RectTransform>();
((Transform)_assignment).SetParent((Transform)(object)component);
_assignment.pivot = Vector2.one;
_assignment.anchorMin = Vector2.one;
_assignment.anchorMax = Vector2.one;
_assignment.anchoredPosition = SHOW_POSITION;
_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).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)7;
RectTransform component4 = ((Component)_assignmentText).GetComponent<RectTransform>();
((Transform)component4).SetParent((Transform)(object)_assignment);
component4.pivot = new Vector2(0.5f, 0.5f);
component4.anchorMin = Vector2.zero;
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_0082: 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_0093: Unknown result type (might be due to invalid IL or missing references)
if (_state != State.Shown && _state != State.Hidden)
{
if (_animationProgress >= 1f)
{
_state = ((_state == State.Showing) ? State.Shown : State.Hidden);
return;
}
float num = ((_state == State.Hiding) ? 2f : 1f);
_animationProgress += num * Time.deltaTime;
float x = ((_state == State.Hiding) ? (1f - _animationProgress) : _animationProgress);
_assignment.anchoredPosition = Vector2.Lerp(HIDE_POSITION, SHOW_POSITION, Utils.EaseInOutBack(x));
}
}
private void Update()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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 EmployeeAssignmentsRevived.Network
{
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 => "EA-Allocation";
}
[Serializable]
public struct CompleteEvent : IPAEvent
{
public byte AssignmentID;
public ulong PlayerId;
public string AssignmentUID;
public int RewardValue;
public ulong[] TargetIds;
public string TAG => "EA-Complete";
}
[Serializable]
public struct FailedEvent : IPAEvent
{
public byte AssignmentID;
public ulong PlayerId;
public string Reason;
public string TAG => "EA-Failed";
}
[Serializable]
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct ResetEvent : IPAEvent
{
public string TAG => "EA-Reset";
}
public static class EAEventTags
{
public const string PREFIX = "EA-";
public const string RESET = "EA-Reset";
public const string ALLOCATION = "EA-Allocation";
public const string COMPLETE = "EA-Complete";
public const string FAILED = "EA-Failed";
}
[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()
{
NetworkManager singleton = NetworkManager.Singleton;
if (((singleton != null) ? singleton.CustomMessagingManager : null) != null)
{
_initialized = true;
Debug.Log((object)"[NetworkUtils] Initialized messaging");
}
}
private void UnInitialize()
{
if (_connected)
{
Disconnected();
}
_initialized = false;
}
private void Connected()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.Singleton.CustomMessagingManager.OnUnnamedMessage += new UnnamedMessageDelegate(OnMessageEvent);
OnConnect?.Invoke();
_connected = true;
Debug.Log((object)"[NetworkUtils] Connected");
}
private void Disconnected()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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)"[NetworkUtils] Disconnected");
}
private 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_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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);
networkMessage = JsonUtility.FromJson<NetworkMessage>(text);
val = Hash128.Compute<byte>(networkMessage.Data);
Debug.Log((object)$"[NetworkUtils] Received {networkMessage.MessageTag} from {clientId}");
}
catch (Exception ex)
{
Debug.LogException(ex);
}
if (val != default(Hash128) && ((Hash128)(ref val)).CompareTo(networkMessage.Checksum) == 0)
{
OnNetworkData?.Invoke(networkMessage.MessageTag, networkMessage.Data);
}
}
public void SendToAll(string tag, byte[] data)
{
if (!_initialized)
{
return;
}
foreach (KeyValuePair<ulong, NetworkClient> connectedClient in NetworkManager.Singleton.ConnectedClients)
{
SendTo(connectedClient.Value.ClientId, tag, data);
}
}
public void SendTo(ulong clientId, string tag, byte[] data)
{
//IL_002c: 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_0080: 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);
string text = JsonUtility.ToJson((object)networkMessage);
int writeSize = FastBufferWriter.GetWriteSize(text, false);
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(writeSize + 1, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
Debug.Log((object)$"[NetworkUtils] Sending {tag} to {clientId}");
NetworkManager.Singleton.CustomMessagingManager.SendUnnamedMessage(clientId, val, (NetworkDelivery)2);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
}
}
namespace EmployeeAssignmentsRevived.Data
{
public class EAContext
{
public bool AssignmentsGenerated;
public Assignment? CurrentAssignment;
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 = Array.Empty<string>();
public int[] EnemyWeights = Array.Empty<int>();
public int[] EnemyRewards = Array.Empty<int>();
public string[] AssignmentWhitelist = Array.Empty<string>();
public int[] AssignmentWeights = Array.Empty<int>();
public bool AssignAllPlayers;
public bool AllPlayersComplete;
public void ParseStringArray(ref string[] array, ConfigEntry<string> data)
{
string[] array2 = GetConfigValue(data).Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
array = new string[array2.Length];
for (int i = 0; i < array2.Length; i++)
{
array[i] = array2[i].Trim();
}
}
public void ParseIntArray(ref int[] array, ConfigEntry<string> data)
{
string[] array2 = GetConfigValue(data).Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
array = new int[array2.Length];
for (int i = 0; i < array2.Length; i++)
{
array[i] = (int.TryParse(array2[i].Trim(), out var result) ? result : 0);
}
}
private string GetConfigValue(ConfigEntry<string> data)
{
string text = data.Value;
if (string.IsNullOrWhiteSpace(text))
{
text = (string)((ConfigEntryBase)data).DefaultValue;
}
return text;
}
}
public class EAConfig
{
public readonly ConfigEntry<int> MaxAssignedPlayers;
public readonly ConfigEntry<int> MinAssignedPlayers;
public readonly ConfigEntry<bool> AssignAllPlayers;
public readonly ConfigEntry<bool> AllPlayersCanComplete;
public readonly ConfigEntry<string> AssignmentWhiteList;
public readonly ConfigEntry<string> AssignmentWeights;
public readonly ConfigEntry<int> ScrapRetrievalReward;
public readonly ConfigEntry<int> BrokenValveReward;
public readonly ConfigEntry<string> HuntAndKillWhitelist;
public readonly ConfigEntry<string> HuntAndKillWeights;
public readonly ConfigEntry<string> HuntAndKillRewards;
public EAConfig(ConfigFile config)
{
MaxAssignedPlayers = config.Bind<int>("HostOnly.General", "MaxAssignedPlayers", 10, "Maximum players assigned per round.");
MinAssignedPlayers = config.Bind<int>("HostOnly.General", "MinAssignedPlayers", 1, "Minimum players assigned per round.");
AssignAllPlayers = config.Bind<bool>("HostOnly.General", "AssignAllPlayers", false, "Assign every player instead of a random subset.");
AllPlayersCanComplete = config.Bind<bool>("HostOnly.General", "AllPlayersCanComplete", false, "Allow other players to complete someone's assignment.");
AssignmentWhiteList = config.Bind<string>("HostOnly.General", "AssignmentWhiteList", "collect_scrap,hunt_kill,repair_valve", "Assignment types allowed to spawn.");
AssignmentWeights = config.Bind<string>("HostOnly.General", "AssignmentWeights", "50,25,25", "Weighting for assignment type selection.");
ScrapRetrievalReward = config.Bind<int>("Assignment.ScrapRetrieval", "AssignmentReward", 100, "Reward for collecting marked scrap.");
BrokenValveReward = config.Bind<int>("Assignment.RepairValve", "AssignmentReward", 100, "Reward for fixing the broken valve.");
HuntAndKillWhitelist = config.Bind<string>("Assignment.HuntAndKill", "EnemyWhitelist", "Centipede,Bunker Spider,Hoarding bug,Crawler", "List of valid enemies for hunt and kill.");
HuntAndKillWeights = config.Bind<string>("Assignment.HuntAndKill", "EnemyWeights", "50,25,50,25", "Spawn weighting for enemy selection.");
HuntAndKillRewards = config.Bind<string>("Assignment.HuntAndKill", "EnemyRewards", "100,200,100,200", "Cash reward per enemy type.");
}
}
public enum GameStateEnum
{
MainMenu,
Orbit,
CompanyHQ,
Level
}
public class GameContext
{
private GameStateEnum _gameState;
public Action<GameStateEnum> GameStateChanged;
public GameStateEnum GameState
{
get
{
return _gameState;
}
set
{
if (_gameState != value)
{
_gameState = value;
GameStateChanged?.Invoke(value);
}
}
}
}
}
namespace EmployeeAssignmentsRevived.Components
{
public class KillableEnemiesOutput : MonoBehaviour
{
private const string OUTPUT_PATH = "/../BepInEx/config2/KillableEnemies.md";
public void Update()
{
if (!((Object)(object)StartOfRound.Instance == (Object)null))
{
OutputList();
Object.Destroy((Object)(object)this);
}
}
private void OutputList()
{
HashSet<string> hashSet = new HashSet<string>();
string text = "# KILLABLE ENEMIES LISTCopy the names from this list into the enemy assignment whitelist config entry to allow them to spawn.Note that some enemies would normally be spawnable on certain maps only.";
SelectableLevel[] levels = StartOfRound.Instance.levels;
for (int i = 0; i < levels.Length; i++)
{
foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies)
{
if (enemy.enemyType.canDie && hashSet.Add(enemy.enemyType.enemyName))
{
text = text + "- " + enemy.enemyType.enemyName + "\n";
}
}
}
try
{
string path = Application.dataPath + "/../BepInEx/config2/KillableEnemies.md";
Directory.CreateDirectory(Path.GetDirectoryName(path));
File.WriteAllText(path, text);
}
catch (Exception arg)
{
Debug.LogError((object)$"Failed to write killable enemies list: {arg}");
}
}
}
public class GameStateSync : MonoBehaviour
{
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;
string sceneName = RoundManager.Instance.currentLevel.sceneName;
Debug.Log((object)("Landed on moon: " + sceneName));
_gameContext.GameState = ((sceneName == "CompanyBuilding") ? GameStateEnum.CompanyHQ : GameStateEnum.Level);
}
}
}
public class UpdateChecker : MonoBehaviour
{
[Serializable]
private class ThunderstoreModInfo
{
public LatestVersion latest;
}
[Serializable]
private class LatestVersion
{
public string version_number;
}
private const string THUNDERSTORE_API_URL = "https://thunderstore.io/api/experimental/package/FluxTeam/EmployeeAssignmentsRevived/";
private UnityWebRequestAsyncOperation _webRequest;
public bool IsLatestVersion { get; private set; } = true;
private void Awake()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).buildIndex == 2)
{
UnityWebRequest val = UnityWebRequest.Get("https://thunderstore.io/api/experimental/package/FluxTeam/EmployeeAssignmentsRevived/");
_webRequest = val.SendWebRequest();
((AsyncOperation)_webRequest).completed += OnComplete;
SceneManager.sceneLoaded -= OnSceneLoaded;
}
}
private void OnComplete(AsyncOperation op)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
if ((int)_webRequest.webRequest.result != 1)
{
Debug.LogWarning((object)("[UpdateChecker] Failed to contact Thunderstore: " + _webRequest.webRequest.error));
return;
}
try
{
ThunderstoreModInfo thunderstoreModInfo = JsonUtility.FromJson<ThunderstoreModInfo>(_webRequest.webRequest.downloadHandler.text);
IsLatestVersion = string.Equals(thunderstoreModInfo.latest.version_number, "2.0.1", StringComparison.OrdinalIgnoreCase);
if (!IsLatestVersion)
{
MenuManager val = Object.FindObjectOfType<MenuManager>();
if ((Object)(object)val != (Object)null)
{
((TMP_Text)val.menuNotificationText).text = "Employee Assignments Revived mod is out of date. Please update to at least v2.0.1.";
((TMP_Text)val.menuNotificationButtonText).text = "[ CLOSE ]";
val.menuNotification.SetActive(true);
}
Debug.LogWarning((object)("[UpdateChecker] Mod is outdated. Current: 2.0.1, Latest: " + thunderstoreModInfo.latest.version_number));
}
else
{
Debug.Log((object)"[UpdateChecker] Mod is up to date (v2.0.1)");
}
}
catch (Exception arg)
{
Debug.LogError((object)$"[UpdateChecker] Failed to parse Thunderstore response: {arg}");
}
_webRequest = null;
}
}
}
namespace EmployeeAssignmentsRevived.AssignmentLogic
{
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 CollectScrapLogic : IAssignmentLogic
{
private readonly EAContext _context;
public CollectScrapLogic(EAContext context)
{
_context = context;
}
public bool ServerSetupAssignment(ref Assignment assignment)
{
GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
foreach (GrabbableObject val in array)
{
ulong networkObjectId = ((NetworkBehaviour)val).NetworkObjectId;
if (!_context.ExcludeTargetIds.Contains(networkObjectId) && !val.scrapPersistedThroughRounds && val.itemProperties.isScrap)
{
assignment.TargetIds[0] = networkObjectId;
assignment.TargetText = val.itemProperties.itemName.ToUpper();
_context.ExcludeTargetIds.Add(networkObjectId);
return true;
}
}
return false;
}
public bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer)
{
if (!localPlayer)
{
return false;
}
GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
foreach (GrabbableObject val in array)
{
if (((NetworkBehaviour)val).NetworkObjectId == assignment.TargetIds[0])
{
assignment.TargetText = val.itemProperties.itemName.ToUpper();
ScanNodeProperties componentInChildren = ((Component)val).GetComponentInChildren<ScanNodeProperties>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.headerText = "ASSIGNMENT TARGET";
componentInChildren.subText = "Value : ???";
return true;
}
Debug.LogError((object)("Scan node is missing for item: " + ((Object)val).name));
return false;
}
}
return false;
}
public AssignmentState CheckCompletion(ref Assignment assignment)
{
foreach (GrabbableObject item in RoundManager.Instance.scrapCollectedThisRound)
{
if (item.isInShipRoom && ((NetworkBehaviour)item).NetworkObjectId == assignment.TargetIds[0])
{
return (_context.AllPlayersComplete || ((NetworkBehaviour)item).OwnerClientId == assignment.PlayerId) ? AssignmentState.Complete : 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).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 readonly EAContext _context;
private const float MAX_PLAYER_DISTANCE = 10f;
public HuntAndKillLogic(EAContext context)
{
_context = context;
}
public bool ServerSetupAssignment(ref Assignment assignment)
{
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: 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_020f: 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 enemyName = _context.EnemyWhitelist[num];
assignment.CashReward = _context.EnemyRewards[num];
foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
{
if (spawnedEnemy.enemyType.enemyName == enemyName && ((NetworkBehaviour)spawnedEnemy).IsSpawned && !spawnedEnemy.isEnemyDead && !_context.ExcludeTargetIds.Contains(((NetworkBehaviour)spawnedEnemy).NetworkObjectId))
{
assignment.TargetIds[0] = ((NetworkBehaviour)spawnedEnemy).NetworkObjectId;
assignment.TargetText = spawnedEnemy.enemyType.enemyName.ToUpper();
_context.ExcludeTargetIds.Add(((NetworkBehaviour)spawnedEnemy).NetworkObjectId);
((Component)spawnedEnemy).GetComponentInChildren<ScanNodeProperties>().headerText = "ASSIGNMENT TARGET";
return true;
}
}
SpawnableEnemyWithRarity val = ((IEnumerable<SpawnableEnemyWithRarity>)RoundManager.Instance.currentLevel.Enemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity e) => e.enemyType.enemyName == enemyName));
if (val == null)
{
return false;
}
Vector3 spawnPos = Vector3.zero;
EntranceTeleport val2 = ((IEnumerable<EntranceTeleport>)Object.FindObjectsOfType<EntranceTeleport>()).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => !e.isEntranceToBuilding && e.entranceId == 0));
if ((Object)(object)val2 != (Object)null)
{
spawnPos = ((Component)val2).transform.position;
}
List<(EnemyVent, float)> list = (from v in RoundManager.Instance.allEnemyVents
select (v, Vector3.Distance(v.floorNode.position, spawnPos)) into p
orderby p.Item2 descending
select p).ToList();
NavMeshHit val3 = default(NavMeshHit);
bool flag = false;
int num2 = 0;
while (!flag && num2 < 5)
{
flag = NavMesh.SamplePosition(list[Random.Range(0, list.Count / 2)].Item1.floorNode.position, ref val3, 20f, -1);
num2++;
}
if (!flag)
{
return false;
}
RoundManager.Instance.SpawnEnemyOnServer(((NavMeshHit)(ref val3)).position, 0f, RoundManager.Instance.currentLevel.Enemies.IndexOf(val));
EnemyAI val4 = RoundManager.Instance.SpawnedEnemies.Last();
assignment.TargetIds[0] = ((NetworkBehaviour)val4).NetworkObjectId;
assignment.TargetText = val4.enemyType.enemyName.ToUpper();
_context.ExcludeTargetIds.Add(assignment.TargetIds[0]);
((Component)val4).GetComponentInChildren<ScanNodeProperties>().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();
((Component)spawnedEnemy).GetComponentInChildren<ScanNodeProperties>().headerText = "ASSIGNMENT TARGET";
return true;
}
}
return true;
}
public AssignmentState CheckCompletion(ref Assignment assignment)
{
foreach (EnemyAI enemy in RoundManager.Instance.SpawnedEnemies)
{
if (((NetworkBehaviour)enemy).NetworkObjectId == assignment.TargetIds[0] && enemy.isEnemyDead)
{
return (NetworkManager.Singleton.ConnectedClientsList.Select((NetworkClient c) => Vector3.Distance(((Component)c.PlayerObject).transform.position, ((Component)enemy.agent).transform.position)).Min() < 10f) ? AssignmentState.Complete : AssignmentState.Failed;
}
}
return AssignmentState.InProgress;
}
public void CompleteAssignment(ref Assignment assignment, bool localPlayer)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
//IL_00a7: 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 obj = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.First((Item i) => i.itemName == "Gold bar").spawnPrefab, spawnedEnemy.serverPosition, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
GrabbableObject component = obj.GetComponent<GrabbableObject>();
((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
component.fallTime = 0f;
component.SetScrapValue(assignment.CashReward);
NetworkObject component2 = obj.GetComponent<NetworkObject>();
component2.Spawn(false);
_context.SyncedRewardValues.Add((component2, assignment.CashReward));
break;
}
}
}
}
public class RepairValveLogic : IAssignmentLogic
{
private readonly EAContext _context;
public RepairValveLogic(EAContext 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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 entrance = RoundManager.FindMainEntrancePosition(false, false);
SteamValveHazard val = ((IEnumerable<SteamValveHazard>)array.OrderByDescending((SteamValveHazard v) => Vector3.Distance(entrance, ((Component)v).transform.position)).ToList()).FirstOrDefault((Func<SteamValveHazard, bool>)((SteamValveHazard v) => !_context.ExcludeTargetIds.Contains(((NetworkBehaviour)v).NetworkObjectId) && ((NetworkBehaviour)v).IsSpawned));
if ((Object)(object)val == (Object)null)
{
return false;
}
assignment.TargetIds[0] = ((NetworkBehaviour)val).NetworkObjectId;
_context.ExcludeTargetIds.Add(((NetworkBehaviour)val).NetworkObjectId);
val.valveCrackTime = 0.001f;
val.valveBurstTime = 0.01f;
val.triggerScript.interactable = true;
assignment.FixedTargetPosition = ((Component)val).transform.position;
return true;
}
public bool HandleAllocationEvent(ref Assignment assignment, bool localPlayer)
{
return true;
}
public AssignmentState CheckCompletion(ref Assignment assignment)
{
SteamValveHazard[] array = Object.FindObjectsByType<SteamValveHazard>((FindObjectsSortMode)0);
foreach (SteamValveHazard val in array)
{
if (((NetworkBehaviour)val).NetworkObjectId == assignment.TargetIds[0] && !val.triggerScript.interactable)
{
if (!_context.AllPlayersComplete && ((NetworkBehaviour)val.triggerScript).OwnerClientId != assignment.PlayerId)
{
return AssignmentState.Failed;
}
return AssignmentState.Complete;
}
}
return AssignmentState.InProgress;
}
public void CompleteAssignment(ref Assignment assignment, bool localPlayer)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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)
if (!NetworkManager.Singleton.IsHost)
{
return;
}
SteamValveHazard[] array = Object.FindObjectsByType<SteamValveHazard>((FindObjectsSortMode)0);
foreach (SteamValveHazard val in array)
{
if (((NetworkBehaviour)val).NetworkObjectId == assignment.TargetIds[0])
{
GameObject obj = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList.First((Item i) => i.itemName == "Gold bar").spawnPrefab, ((Component)val).transform.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
GrabbableObject component = obj.GetComponent<GrabbableObject>();
((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
component.fallTime = 0f;
component.SetScrapValue(assignment.CashReward);
NetworkObject component2 = obj.GetComponent<NetworkObject>();
component2.Spawn(false);
_context.SyncedRewardValues.Add((component2, assignment.CashReward));
break;
}
}
}
}
}