Decompiled source of Gamemodes Base v0.7.3
plugins/Gamemodes.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using AIGraph; using AK; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using BoosterImplants; using CellMenu; using CullingSystem; using Enemies; using Expedition; using GTFO.API; using GameData; using Gamemodes.Components; using Gamemodes.Components.L2; using Gamemodes.Core; using Gamemodes.Core.Voice; using Gamemodes.Core.Voice.Modulators; using Gamemodes.Extensions; using Gamemodes.Interfaces; using Gamemodes.Net; using Gamemodes.Net.Packets; using Gamemodes.Net.Packets.Data; using Gamemodes.Patches.Required; using Gamemodes.Resources; using Gamemodes.UI; using Gamemodes.UI.Menu; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Localization; using Microsoft.CodeAnalysis; using Player; using SNetwork; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("0.7.3")] [assembly: AssemblyInformationalVersion("0.7.3")] [assembly: InternalsVisibleTo("GamemodesTests", AllInternalsVisible = true)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.7.3.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Gamemodes { public static class GameEvents { public static event Action OnGameDataInit; public static event Action OnGameSessionStart; public static event Action<ExpeditionEndState, (int Muted, int Bold, int Aggressive)> OnGameSessionEnd; public static event Action<SNet_Lobby> OnJoinedLobby; public static event Action<eGameStateName> OnGameStateChanged; public static event Action OnFoundMaster; public static event Action PreItemPrefabsSetup; public static event Action OnItemPrefabsSetup; internal static void InvokeOnGameDataInit() { GameEvents.OnGameDataInit?.Invoke(); } internal static void InvokeOnGameSessionStart() { GameEvents.OnGameSessionStart?.Invoke(); } internal static void InvokeOnGameSessionEnd(ExpeditionEndState state, (int Muted, int Bold, int Aggressive) artifacts) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameEvents.OnGameSessionEnd?.Invoke(state, artifacts); } internal static void InvokeOnJoinedLobby(SNet_Lobby lobby) { GameEvents.OnJoinedLobby?.Invoke(lobby); } internal static void InvokeOnGameStateChanged(eGameStateName nextState) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameEvents.OnGameStateChanged?.Invoke(nextState); } internal static void InvokeOnFoundMaster() { GameEvents.OnFoundMaster?.Invoke(); } internal static void InvokePreItemPrefabsSetup() { GameEvents.PreItemPrefabsSetup?.Invoke(); } internal static void InvokeOnItemPrefabsSetup() { GameEvents.OnItemPrefabsSetup?.Invoke(); } } public class PatchManager { public static class PatchGroups { public const string NO_SLEEPING_ENEMIES = "NoSleepingEnemies"; public const string NO_RESPAWN = "NoRespawn"; public const string NO_FAIL = "NoFail"; public const string REQUIRED = "Required"; public const string DEBUG = "Debug"; public const string NO_CHECKPOINTS = "NoCheckpoints"; public const string NO_WORLDEVENTS = "NoWorldEvents"; public const string FORCE_ARENA_DIM = "ForceArenaDimension"; public const string NO_VOICE = "NoVoice"; public const string USE_TEAM_VISIBILITY = "UseTeamVis"; public const string NO_TERMINAL_COMMANDS = "NoTerminalCommands"; public const string NO_BLOOD_DOORS = "NoBloodDoors"; public const string NO_PLAYER_REVIVE = "NoPlayerRevive"; public const string INF_PLAYER_AMMO = "InfPlayerAmmo"; public const string INF_SENTRY_AMMO = "InfSentryAmmo"; public const string PROXIMITY_VOICE = "ProximityVoiceComp"; internal const string ACHIEVEMENT_PATCHES = "Achievement_Patch_Beeg_Lag_Yay"; } private class PatchGroup { internal readonly string Name; internal readonly HashSet<Type> Types = new HashSet<Type>(); internal readonly Harmony HarmonyInstance; internal bool IsPatched; public PatchGroup(string group) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Name = group; HarmonyInstance = new Harmony("dev.aurirex.gtfo.gamemodes." + group); } public bool Patch(bool patch) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown if (IsPatched == patch) { return false; } bool flag = default(bool); if (patch) { ManualLogSource l = Plugin.L; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(25, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Patching "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PatchGroup"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Types.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Types) ..."); } l.LogDebug(val); foreach (Type type in Types) { HarmonyInstance.PatchAll(type); } } else { if (Name == "Required") { return false; } if (Name == "Default" && DefaultLock) { return false; } ManualLogSource l2 = Plugin.L; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(18, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unpatching "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PatchGroup"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" ..."); } l2.LogDebug(val); HarmonyInstance.UnpatchSelf(); } IsPatched = patch; return true; } } internal const string DEFAULT_PATCHGROUP = "Default"; public const string PATCHGROUP_FIELDNAME = "PatchGroup"; internal static bool DefaultLock = true; private static readonly Dictionary<string, PatchGroup> _patchGroups = new Dictionary<string, PatchGroup>(); internal static void Init() { IterateTypes("Gamemodes.Patches", Assembly.GetExecutingAssembly()); ApplyPatchGroup("Required", patch: true); ApplyPatchGroup("Default", patch: true); } public static void IterateTypes(string nameSpacePrefix, Assembly asm) { if (string.IsNullOrWhiteSpace(nameSpacePrefix)) { throw new ArgumentException("Invalid parameter.", "nameSpacePrefix"); } Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(asm); foreach (Type type in typesFromAssembly) { if (type.Namespace.StartsWith(nameSpacePrefix) && ((MemberInfo)type).GetCustomAttribute<HarmonyPatch>() != null) { FieldInfo field = type.GetField("PatchGroup", AccessTools.all); string text = null; if (field != null) { text = (string)field.GetValue(null); } if (string.IsNullOrWhiteSpace(text)) { text = "Default"; } AddToGroup(text, type); } } } private static void AddToGroup(string group, Type type) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!_patchGroups.TryGetValue(group, out var value)) { value = new PatchGroup(group); _patchGroups.Add(group, value); } ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(7, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PatchManager"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(group); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": + "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name); } l.LogDebug(val); value.Types.Add(type); } public static bool ApplyPatchGroup(string group, bool patch) { if (!_patchGroups.TryGetValue(group, out var value)) { return false; } return value.Patch(patch); } } [BepInPlugin("dev.aurirex.gtfo.gamemodes", "Gamemodes", "0.7.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { public const string GUID_DIMENSIONMAPS = "dev.aurirex.gtfo.dimensionmaps"; public const string GUID = "dev.aurirex.gtfo.gamemodes"; public const string NAME = "Gamemodes"; public const string VERSION = "0.7.3"; internal static ManualLogSource L; internal static MethodInfo MI_dimensionMaps_revealMapTexture; internal static PrimitiveVersion Version { get; private set; } public override void Load() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown L = ((BasePlugin)this).Log; Version = new PrimitiveVersion("0.7.3"); ClassInjector.RegisterTypeInIl2Cpp<PlayerToken>(); ClassInjector.RegisterTypeInIl2Cpp<TimerHUD>(); ClassInjector.RegisterTypeInIl2Cpp<PUI_TeamDisplay>(); ClassInjector.RegisterTypeInIl2Cpp<ProximityVoice>(); ClassInjector.RegisterTypeInIl2Cpp<NodeDistance>(); ClassInjector.RegisterTypeInIl2Cpp<FlashBlinder>(); ClassInjector.RegisterTypeInIl2Cpp<GenericGrenadeInstance>(); ClassInjector.RegisterTypeInIl2Cpp<SmokeGrenadeInstance>(); ClassInjector.RegisterTypeInIl2Cpp<FlashGrenadeInstance>(); PatchManager.Init(); NetworkingManager.Init(); GamemodeManager.Init(); PlayerVoiceManager.Init(); GameEvents.OnGameDataInit += PrefabManager.Init; GameEvents.PreItemPrefabsSetup += PrefabManager.PreItemLoading; GameEvents.OnItemPrefabsSetup += PrefabManager.OnAssetLoaded; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("dev.aurirex.gtfo.dimensionmaps", out var value)) { return; } MI_dimensionMaps_revealMapTexture = value.Instance.GetType().Assembly.GetType("DimensionMaps.Core.CMapDetails")?.GetProperty("RevealMapTexture")?.GetSetMethod(); bool flag = default(bool); if (MI_dimensionMaps_revealMapTexture != null) { ManualLogSource log = ((BasePlugin)this).Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found 'CMapDetails.RevealMapTexture' SetMethod MethodInfo!"); } log.LogInfo(val); } else { ManualLogSource log2 = ((BasePlugin)this).Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(65, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Did NOT find 'CMapDetails.RevealMapTexture' SetMethod MethodInfo!"); } log2.LogWarning(val2); } } public static void SendChatMessage(string msg) { PlayerChatManager current = PlayerChatManager.Current; if (!((Object)(object)current == (Object)null)) { string currentValue = current.m_currentValue; current.m_currentValue = msg; current.PostMessage(); current.m_currentValue = currentValue; } } public static void PostLocalMessage(string msg, eGameEventChatLogType type = 2) { //IL_0012: 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_0042: Unknown result type (might be due to invalid IL or missing references) CM_PageLoadout current = CM_PageLoadout.Current; PostLocalMessageTo((current != null) ? current.m_gameEventLog : null, msg, type); CM_PageMap current2 = CM_PageMap.Current; PostLocalMessageTo((current2 != null) ? current2.m_gameEventLog : null, msg, type); PlayerGuiLayer playerLayer = GuiManager.PlayerLayer; PostLocalMessageTo((playerLayer != null) ? playerLayer.m_gameEventLog : null, msg, type); } private static void PostLocalMessageTo(PUI_GameEventLog log, string msg, eGameEventChatLogType type = 2) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)log == (Object)null)) { log.AddLogItem(msg, type); } } internal static void LogException(Exception ex, string info, bool printInChat = false) { string text = ex.GetType().Name + " thrown in " + info + "."; if (printInChat) { PostLocalMessage(text, (eGameEventChatLogType)3); } L.LogError((object)text); L.LogError((object)ex.Message); L.LogWarning((object)("Stacktrace:\n" + ex.StackTrace)); } } public record PrimitiveVersion { public int Major { get; private set; } public int Minor { get; private set; } public int Patch { get; private set; } public static readonly PrimitiveVersion None = new PrimitiveVersion(0); public PrimitiveVersion(int major, int minor = 0, int patch = 0) { Major = major; Minor = minor; Patch = patch; } public PrimitiveVersion(string versionString) { string[] array = versionString.Split('.', 4); for (int i = 0; i < array.Length; i++) { if (!int.TryParse(array[i], out var result)) { throw new ArgumentException($"Invalid version string \"{versionString}\" supplied! ({array[i]})", "versionString"); } switch (i) { default: return; case 0: Major = result; break; case 1: Minor = result; break; case 2: Patch = result; break; } } } public static bool operator >(PrimitiveVersion self, PrimitiveVersion other) { if (self == other) { return false; } if (self.Major > other.Major) { return true; } if (self.Major == other.Major) { if (self.Minor > other.Minor) { return true; } if (self.Minor == other.Minor && self.Patch > other.Patch) { return true; } } return false; } public static bool operator <(PrimitiveVersion self, PrimitiveVersion other) { return other > self; } public override string ToString() { return $"{Major}.{Minor}.{Patch}"; } [CompilerGenerated] protected PrimitiveVersion(PrimitiveVersion original) { Major = original.Major; Minor = original.Minor; Patch = original.Patch; } } } namespace Gamemodes.UI { public class GameBaseTimerGraphics : ITimerHudGraphics { public void SetText(string text) { GuiManager.InteractionLayer.SetMessage(text, (ePUIMessageStyle)1, 10); } public void SetTimer(float value) { GuiManager.InteractionLayer.SetMessageTimer(value); } public void SetStyle(string textHex, Color color, bool blinking = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) PUI_InteractionPrompt message = GuiManager.InteractionLayer.m_message; message.m_colorHex = textHex; message.m_timer.color = new Color(color.r, color.g, color.b, message.m_timerAlpha); message.m_blinking = blinking; } public void Shutdown() { SetTimerVisible(visible: false); SetVisible(visible: false); } public void Initialize() { } public void SetVisible(bool visible) { GuiManager.InteractionLayer.MessageVisible = visible; } public void SetTimerVisible(bool visible) { GuiManager.InteractionLayer.SetTimerAlphaMul(visible ? 1f : 0f); GuiManager.InteractionLayer.MessageTimerVisible = visible; } } internal static class LobbyUI { private static CM_Item _changeGameModeButton; private static TextMeshPro _subText; private static SelectionPopupMenu _menu; internal static void Setup(CM_PageLoadout instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown Plugin.L.LogDebug((object)"Setting up Gamemodes UI ..."); CM_TimedButton obj = ((Il2CppObjectBase)((GuiLayer)((CM_PageBase)instance).m_guiLayer).AddRectComp(instance.m_readyButtonPrefab, (GuiAnchor)0, new Vector2(500f, 0f), instance.m_readyButtonAlign)).Cast<CM_TimedButton>(); GameObject gameObject = ((Component)obj).gameObject; Il2CppReferenceArray<TextMeshPro> texts = ((CM_Item)obj).GetTexts(); ((Behaviour)obj).enabled = false; Object.Destroy((Object)(object)obj); _changeGameModeButton = gameObject.AddComponent<CM_Item>(); _changeGameModeButton.m_texts = texts; _changeGameModeButton.TextMeshRoot = ((Component)instance).transform; _changeGameModeButton.SetText("<#ccc><b>Switch Gamemode</b></color>"); gameObject.SetActive(true); Action<int> action = delegate { Plugin.L.LogDebug((object)"Attempting to show popup ..."); TrySetupOrGetMenu().Show(); }; _changeGameModeButton.m_onBtnPress = new UnityEvent(); _changeGameModeButton.OnBtnPressCallback = Action<int>.op_Implicit(action); Transform transform = gameObject.transform; ((Component)transform.FindChild("ProgressFillBase")).gameObject.SetActive(false); ((Component)transform.FindChild("ProgressFill")).gameObject.SetActive(false); ((Component)transform.FindChild("Progress")).gameObject.SetActive(false); ((Component)transform.FindChild("Arrow")).gameObject.SetActive(false); _subText = ((Component)transform.FindChild("PressAndHold")).GetComponent<TextMeshPro>(); SetSubText(GamemodeManager.CurrentMode.DisplayName); GamemodeManager.OnGamemodeChanged += OnModeChange; GameEvents.OnGameStateChanged += OnGameStateChanged; } private static void OnGameStateChanged(eGameStateName state) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (!((Object)(object)_changeGameModeButton == (Object)null)) { if ((int)state == 6) { ((Component)_changeGameModeButton).gameObject.SetActive(false); } if ((int)state == 5) { ((Component)_changeGameModeButton).gameObject.SetActive(true); } } } private static void SetSubText(string text) { ((TMP_Text)_subText).SetText("<color=orange>" + text + "</color>", true); } private static void OnModeChange(ModeInfo mode) { SetSubText(mode.DisplayName); } private static SelectionPopupMenu TrySetupOrGetMenu() { if (_menu != null) { return _menu; } SelectionPopupHeader selectionPopupHeader = new SelectionPopupHeader("Gamemode Selection"); selectionPopupHeader.ActiveItemID = "GTFO"; selectionPopupHeader.LastSelectedItemID = "GTFO"; selectionPopupHeader.IsActiveText = "<color=orange>Active</color>"; selectionPopupHeader.SetActiveConfirmText = "<color=orange>Click again to switch to mode.</color>"; selectionPopupHeader.AllowedToSelectItem = (SelectionPopupHeader self, ISelectionPopupItem item) => SNet.IsMaster && (!NetworkingManager.InLevel || (NetworkingManager.InLevel && (GamemodeManager.CurrentSettings?.AllowMidGameModeSwitch ?? false))); selectionPopupHeader.PreDraw = delegate(SelectionPopupHeader self) { self.ActiveItemID = GamemodeManager.CurrentMode?.ID; if (!self.IsUpdating) { self.LastSelectedItemID = GamemodeManager.CurrentMode?.ID; } }; foreach (ModeInfo loadedMode in GamemodeManager.LoadedModes) { selectionPopupHeader.AddItem(new SelectionPopupItem { DisplayName = loadedMode.DisplayName, SubTitle = loadedMode.SubTitle, ID = loadedMode.ID, Description = loadedMode.Description, SpriteSmall = loadedMode.SpriteSmall, SpriteLarge = loadedMode.SpriteLarge, clickedAction = ModeSelectItemClickedAction, upperTextCustomization = UpperTextCustomization }); } _menu = new SelectionPopupMenu().AddHeader(selectionPopupHeader); return _menu; } private static void ModeSelectItemClickedAction(ISelectionPopupItem self) { if (SNet.IsMaster && self.WasDoubleClick && !self.IsActive) { NetworkingManager.SendSwitchModeAll(self.ID); } } private static string UpperTextCustomization(ISelectionPopupItem self, string upperText) { if (self.ID == "GTFO" && (string.IsNullOrEmpty(upperText) || self.IsActive) && GamemodeManager.ModeSwitchCount > 1) { return upperText + "<#F00>" + (self.IsActive ? string.Empty : "<alpha=#33>") + "<u>/!\\</u> Restart Recommended to play Vanilla again!</color>"; } return upperText; } } public record TeamDisplayData(string Prefix, Color Color, Func<PlayerWrapper, string> UpdateExtraInfo = null, bool Hide = false) { [CompilerGenerated] protected virtual bool PrintMembers(StringBuilder builder) { //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) RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("Prefix = "); builder.Append((object?)Prefix); builder.Append(", Color = "); Color color = Color; builder.Append(((object)(Color)(ref color)).ToString()); builder.Append(", UpdateExtraInfo = "); builder.Append(UpdateExtraInfo); builder.Append(", Hide = "); builder.Append(Hide.ToString()); return true; } } public enum TimerDisplayStyle { Default, Green, Warning, Red, Custom } public record struct TimerStyleOverride(TimerDisplayStyle Style, bool DoBlink = false, Color? CustomColor = null, string CustomColorHex = null); } namespace Gamemodes.UI.Menu { public class CustomGearSelector { private readonly SelectionPopupMenu _menu; private readonly SelectionPopupHeader _header; private readonly GearIDRange[] _gear; private readonly InventorySlot _slot; public Func<bool> RefillGunsAndToolOnPick { get; set; } = () => true; public event Action<GearIDRange, InventorySlot> OnPickedGear; public CustomGearSelector(IEnumerable<GearIDRange> availableGear, InventorySlot slot, string title = "Gear Selector") { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) _gear = availableGear.ToArray(); _slot = slot; _menu = new SelectionPopupMenu(); _header = new SelectionPopupHeader(title); _header.IsActiveText = "<color=orange>Equipped</color>"; _header.SetActiveConfirmText = "<color=orange>Click again to equip.</color>"; _header.PreDraw = delegate(SelectionPopupHeader self) { if (TryGetItemFromBP(SNet.LocalPlayer, out var item)) { self.ActiveItemID = item.GearIDRange.PlayfabItemId; if (!self.IsUpdating) { self.LastSelectedItemID = item.GearIDRange.PlayfabItemId; } } }; GearIDRange[] gear = _gear; Sprite val2 = default(Sprite); foreach (GearIDRange val in gear) { GearIconRendering.TryGetGearIconSprite(val.GetChecksum(), ref val2); _header.AddItem(new SelectionPopupItem { ID = val.PlayfabItemId, DisplayName = val.PublicGearName, SubTitle = val.PlayfabItemId, SpriteSmall = val2, SpriteLarge = val2, Description = "<alpha=#01>Hello cutie, this is where the description would usually go but, you see, I cba to actually look up this items description, so you're getting this lovely text instead! uwu\n\nMaybe someone will implement this little feature in the future tho!", clickedAction = OnItemClicked }); } _menu.AddHeader(_header); } public void Show() { _menu.Show(); } public void Hide() { _menu.Hide(); } private void OnItemClicked(ISelectionPopupItem item) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!item.WasDoubleClick) { return; } GearIDRange gear; if (item.IsSelected && item.IsActive) { item.CloseMenu = true; FocusStateManager.ExitMenu(true); } else if (TryGetItemByIDFromAvailable(item.ID, out gear)) { if ((int)_slot == 3) { GearUtils.LocalTryPickupDeployedSentry(); } GearUtils.EquipGear(gear, _slot, RefillGunsAndToolOnPick?.Invoke() ?? false); item.CloseMenu = true; FocusStateManager.ExitMenu(true); this.OnPickedGear?.Invoke(gear, _slot); } } public bool TryGetItemByIDFromAvailable(string id, out GearIDRange gear) { gear = ((IEnumerable<GearIDRange>)_gear).FirstOrDefault((Func<GearIDRange, bool>)((GearIDRange gear) => gear.PlayfabItemId == id)); return gear != null; } public bool TryGetItemFromBP(SNet_Player player, out BackpackItem item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PlayerBackpackManager.TryGetItem(player, _slot, ref item); } public bool PlayerHasEquipped(SNet_Player player, GearIDRange gear, out BackpackItem backpackItem) { if (TryGetItemFromBP(player, out backpackItem)) { return backpackItem.GearIDRange.IsEqual(gear); } return false; } public void Ree(GearIDRange gear, SpriteRenderer renderer) { GearManager.RegisterAsGearIconTargetCallback(gear.GetChecksum(), (eGearIconType)1, "playerSlot", Action<RenderTexture>.op_Implicit((Action<RenderTexture>)delegate(RenderTexture iconTexture) { GearIconRendering.SetSpriteTexture(gear.GetChecksum(), renderer, iconTexture); })); } } public interface ISelectionPopupItem { string DisplayName { get; } string ID { get; } string SubTitle { get; } string Description { get; } Sprite SpriteSmall { get; } Sprite SpriteLarge { get; } bool WasDoubleClick { get; set; } bool IsActive { get; set; } bool IsSelected { get; set; } bool IsAllowedToSelect { get; set; } bool CloseMenu { get; set; } void OnClicked(); void SubtitleTextCustomization(ref string suptitleText, ref string subtitleText) { } } public class SelectionPopupHeader { private Action<int> _drawAction; private CM_PlayerLobbyBar _lobbyBar; public string HeaderText { get; set; } = "No Text Set"; public string IsActiveText { get; set; } = "<color=orange>Selected</color>"; public string SetActiveConfirmText { get; set; } = "<color=orange>Click again to select.</color>"; public Func<SelectionPopupHeader, ISelectionPopupItem, bool> AllowedToSelectItem { get; set; } public List<ISelectionPopupItem> Items { get; } = new List<ISelectionPopupItem>(); public string ActiveItemID { get; set; } public string LastSelectedItemID { get; set; } public Action<SelectionPopupHeader> PreDraw { get; set; } internal Action<int> DrawAction => Draw; internal SelectionPopupMenu Parent { get; set; } public bool IsUpdating { get; private set; } public ISelectionPopupItem LastClickedItem { get; private set; } public SelectionPopupHeader(string headerText) { HeaderText = headerText; } public void Show() { Parent.Show(Parent.GetKey(this)); } public void Hide() { Parent.Hide(); } public SelectionPopupHeader AddItem(ISelectionPopupItem item) { if (Items.Contains(item)) { return this; } Items.Add(item); return this; } internal void Setup(CM_PlayerLobbyBar lobbyBar) { _lobbyBar = lobbyBar; } internal void Draw(int key) { if (!((Object)(object)_lobbyBar == (Object)null)) { IsUpdating = false; UpdateContent(key); } } private void UpdateContent(int key, float? scrollPosOffset = null, float? scrollHandlePosY = null) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) PreDraw?.Invoke(this); List<iScrollWindowContent> val = new List<iScrollWindowContent>(); int num = 0; foreach (ISelectionPopupItem item in Items) { CM_LobbyScrollItem val2 = GOUtil.SpawnChildAndGetComp<CM_LobbyScrollItem>(_lobbyBar.m_clothesCardPrefab, ((Component)_lobbyBar).transform); val.Add(new iScrollWindowContent(((Il2CppObjectBase)val2).Pointer)); ((CM_Item)val2).TextMeshRoot = ((Component)_lobbyBar.m_parentPage).transform; val2.SetupFromLobby(((Component)_lobbyBar).transform, _lobbyBar, true); ((RectTransformComp)val2).ForcePopupLayer(true, (GameObject)null); ((Component)val2).transform.localScale = Vector3.one; ((TMP_Text)val2.m_nameText).SetText(item.DisplayName ?? "", true); bool flag = item.ID == LastSelectedItemID; item.IsSelected = flag; val2.IsSelected = flag; bool flag2 = item.ID == ActiveItemID; item.IsActive = flag2; ((Component)((Component)val2).transform.FindChild("EmptyIcon")).gameObject.SetActive(false); ((Component)((Component)val2).transform.FindChild("Background")).gameObject.SetActive(flag); string suptitleText = string.Empty; item.IsAllowedToSelect = AllowedToSelectItem?.Invoke(this, item) ?? true; if (flag) { _lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, (Sprite)null); _lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, item.SpriteLarge); if (item.IsAllowedToSelect) { suptitleText = SetActiveConfirmText; } } if (flag2) { suptitleText = IsActiveText; } string subtitleText = item.ID; item.SubtitleTextCustomization(ref suptitleText, ref subtitleText); ((TMP_Text)val2.m_subTitleText).SetText(suptitleText, true); ((TMP_Text)val2.m_descText).SetText(" <#666>" + subtitleText + "</color>", true); ((CM_Item)val2).OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate { //IL_0166: Unknown result type (might be due to invalid IL or missing references) bool flag3 = LastSelectedItemID == item.ID; item.WasDoubleClick = flag3; item.OnClicked(); if (item.CloseMenu) { item.CloseMenu = false; Hide(); } else { if (flag3) { ActiveItemID = item.ID; } LastSelectedItemID = item.ID; _lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, item.SpriteLarge); IsUpdating = true; LastClickedItem = item; UpdateContent(key, _lobbyBar.m_popupScrollWindow.m_posOffset, _lobbyBar.m_popupScrollWindow.m_scrollBar.GetHandlePosition().y); } }); if ((Object)(object)item.SpriteSmall != (Object)null) { val2.m_icon.sprite = item.SpriteSmall; } val2.PlayIntro((float)num * 0.1f, -1); ((CM_Item)val2).m_alphaSpriteOnHover = true; ((CM_Item)val2).m_alphaTextOnHover = true; num++; } _lobbyBar.m_popupScrollWindow.SetContentItems(val, 0f); Enumerator<iScrollWindowContent> enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { CM_LobbyScrollItem val3 = ((Il2CppObjectBase)enumerator2.Current).TryCast<CM_LobbyScrollItem>(); if (!((Object)(object)val3 == (Object)null)) { val3.UpdateSizesAndOffsets(); } } if (scrollPosOffset.HasValue) { ScrollTo(scrollPosOffset.Value, scrollHandlePosY.GetValueOrDefault()); } _lobbyBar.Select(); _lobbyBar.ShowPopup(); _lobbyBar.m_popupScrollWindow.SelectHeader(key); } private void ScrollTo(float posOffset, float handleY) { //IL_003e: 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_005e: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) CM_ScrollWindow popupScrollWindow = _lobbyBar.m_popupScrollWindow; if (popupScrollWindow.m_scrollBar.Visible) { popupScrollWindow.m_posOffset = Mathf.Clamp(posOffset, 0f, popupScrollWindow.m_contentContainerHeight - popupScrollWindow.m_windowHeight); Vector2 position = popupScrollWindow.m_contentContainer.GetPosition(); position.y = popupScrollWindow.m_posStart + popupScrollWindow.m_posOffset; popupScrollWindow.m_contentContainer.SetPosition(position); popupScrollWindow.UpdateContentItemVisibility(); Vector2 handlePosition = popupScrollWindow.m_scrollBar.GetHandlePosition(); popupScrollWindow.m_scrollBar.SetHandlePosition(new Vector2(handlePosition.x, handleY)); } } } public class SelectionPopupItem : ISelectionPopupItem { public Action<ISelectionPopupItem> clickedAction; public Func<ISelectionPopupItem, string, string> upperTextCustomization; public Func<ISelectionPopupItem, string, string> subtitleTextCustomization; public string DisplayName { get; set; } public string ID { get; set; } public string SubTitle { get; set; } public string Description { get; set; } public Sprite SpriteSmall { get; set; } public Sprite SpriteLarge { get; set; } public bool WasDoubleClick { get; set; } public bool IsActive { get; set; } public bool IsSelected { get; set; } public bool IsAllowedToSelect { get; set; } public bool CloseMenu { get; set; } public void OnClicked() { clickedAction?.Invoke(this); } public void SubtitleTextCustomization(ref string suptitleText, ref string subtitleText) { string text = upperTextCustomization?.Invoke(this, suptitleText); if (text != null) { suptitleText = text; } string text2 = subtitleTextCustomization?.Invoke(this, subtitleText); if (text2 != null) { subtitleText = text2; } } } public class SelectionPopupMenu { private readonly List<SelectionPopupHeader> _headers = new List<SelectionPopupHeader>(); private CM_PlayerLobbyBar _lobbyBar; public SelectionPopupMenu AddHeader(SelectionPopupHeader header) { if (_headers.Contains(header)) { return this; } _headers.Add(header); header.Parent = this; return this; } public void Show(int key = 0) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 FocusStateManager.EnterMenu((eCM_MenuPage)13, false); eGameStateName currentStateName = GameStateManager.CurrentStateName; if ((int)currentStateName == 6 || (int)currentStateName == 10) { FocusStateManager.Current.m_previousToggleState = (eFocusState)4; } _lobbyBar = ((IEnumerable<CM_PlayerLobbyBar>)CM_PageLoadout.Current.m_playerLobbyBars).FirstOrDefault((Func<CM_PlayerLobbyBar, bool>)((CM_PlayerLobbyBar plb) => ((Behaviour)plb).isActiveAndEnabled)); if ((Object)(object)_lobbyBar == (Object)null) { _lobbyBar = ((Il2CppArrayBase<CM_PlayerLobbyBar>)(object)CM_PageLoadout.Current.m_playerLobbyBars)[0]; } Transform popupAlign = CM_PageLoadout.Current.m_popupAlign; ShowSelectionPopup(_lobbyBar, popupAlign, key); } public void Hide() { if (!((Object)(object)_lobbyBar == (Object)null)) { _lobbyBar.HidePopup(); } } public int GetKey(SelectionPopupHeader header) { return _headers.IndexOf(header); } public bool TryGetHeader(int key, out SelectionPopupHeader header) { header = null; if (key < 0 || key >= _headers.Count) { return false; } header = _headers[key]; return header != null; } private void ShowSelectionPopup(CM_PlayerLobbyBar lobbyBar, Transform align, int keyToShow) { //IL_0013: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) lobbyBar.m_popupVisible = true; ((Component)lobbyBar.m_popupHolder).transform.position = align.position + new Vector3(300f, 0f, 0f); lobbyBar.m_popupScrollWindow.m_infoBoxWidth = 600f; ((Component)lobbyBar.m_popupHolder).gameObject.SetActive(true); ((Component)lobbyBar.m_popupItemHolder).gameObject.SetActive(true); ((RectTransformComp)lobbyBar.m_popupScrollWindow).SetSize(new Vector2(1600f, 760f)); lobbyBar.m_popupScrollWindow.ResetHeaders(); int num = 0; foreach (SelectionPopupHeader header2 in _headers) { header2.Setup(lobbyBar); lobbyBar.m_popupScrollWindow.AddHeader(header2.HeaderText, num, Action<int>.op_Implicit(header2.DrawAction)); num++; } ((RectTransformComp)lobbyBar.m_popupScrollWindow).SetPosition(new Vector2(0f, 350f)); lobbyBar.m_popupScrollWindow.RespawnInfoBoxFromPrefab(lobbyBar.m_popupInfoBoxWeaponPrefab); if (TryGetHeader(keyToShow, out var header)) { header.Draw(keyToShow); } } } } namespace Gamemodes.Resources { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Data { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { resourceMan = new ResourceManager("Gamemodes.Resources.Data", typeof(Data).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] flashbundle => (byte[])ResourceManager.GetObject("flashbundle", resourceCulture); internal static byte[] GTFO_Icon => (byte[])ResourceManager.GetObject("GTFO_Icon", resourceCulture); internal static byte[] smokebundle => (byte[])ResourceManager.GetObject("smokebundle", resourceCulture); internal Data() { } } } namespace Gamemodes.Patches { [HarmonyPatch(typeof(PlayerAmmoStorage), "GetClipBulletsFromPack")] internal class AmmoPatch { public static readonly string PatchGroup = "InfPlayerAmmo"; public static bool Prefix(PlayerAmmoStorage __instance, AmmoType ammoType, ref int __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown if ((int)ammoType == 3 || (int)ammoType == 5) { return true; } InventorySlotAmmo val = ((Il2CppArrayBase<InventorySlotAmmo>)(object)__instance.m_ammoStorage)[(int)ammoType]; __result = val.BulletClipSize; __instance.UpdateAllAmmoUI(); __instance.UpdateSlotAmmoUI(val, __result); return false; } } [HarmonyPatch(typeof(PlayerAgent), "Setup")] internal class DisablePlayerRevive { public static readonly string PatchGroup = "NoPlayerRevive"; public static void Postfix(PlayerAgent __instance) { ((Component)__instance.ReviveInteraction).gameObject.SetActive(false); } } [HarmonyPatch(typeof(Builder), "Build")] internal class Builder_Build_Patch { public static readonly string PatchGroup = "ForceArenaDimension"; internal static bool hasAddedArenaDimension = false; internal static ExpeditionInTierData activeExpedition; internal static DimensionInExpeditionData[] originalDDs; public static void Prefix() { //IL_0066: 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) //IL_0073: 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_0087: Expected O, but got Unknown ExpeditionInTierData val = RundownManager.Current.m_activeExpedition; if (!((IEnumerable<DimensionInExpeditionData>)val.DimensionDatas.ToArray()).Any((DimensionInExpeditionData dd) => (int)dd.DimensionIndex == 22 && dd.DimensionData == 14)) { Plugin.L.LogDebug((object)"Forcefully adding a snatcher dim."); originalDDs = Il2CppArrayBase<DimensionInExpeditionData>.op_Implicit(val.DimensionDatas.ToArray()); val.DimensionDatas.Add(new DimensionInExpeditionData { DimensionData = 14u, DimensionIndex = (eDimensionIndex)22, Enabled = true }); hasAddedArenaDimension = true; activeExpedition = val; } } } [HarmonyPatch(typeof(Builder), "OnLevelCleanup")] internal class Builder_OnLevelCleanup_Patch { public static readonly string PatchGroup = "ForceArenaDimension"; public static void Prefix() { if (Builder_Build_Patch.hasAddedArenaDimension) { Plugin.L.LogDebug((object)"Reverting forced snatcher dim."); List<DimensionInExpeditionData> val = new List<DimensionInExpeditionData>(); DimensionInExpeditionData[] originalDDs = Builder_Build_Patch.originalDDs; foreach (DimensionInExpeditionData val2 in originalDDs) { val.Add(val2); } Builder_Build_Patch.activeExpedition.DimensionDatas = val; Builder_Build_Patch.activeExpedition = null; Builder_Build_Patch.hasAddedArenaDimension = false; Builder_Build_Patch.originalDDs = Array.Empty<DimensionInExpeditionData>(); } } } [HarmonyPatch(typeof(LG_SecurityDoor), "SetupActiveEnemyWaveData")] internal class NoBloodDoors { public static readonly string PatchGroup = "NoBloodDoors"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(LG_SecurityDoor), "Setup")] internal class NoCheckpointDoorsPatch { public static readonly string PatchGroup = "NoCheckpoints"; public static void Prefix(LG_Gate gate) { gate.IsCheckpointDoor = false; } } [HarmonyPatch(typeof(LG_SecurityDoor), "OnDoorIsOpened")] internal class NoDoorOpenWorldEvents { public static readonly string PatchGroup = "NoWorldEvents"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(WardenObjectiveManager), "CheckExpeditionFailed")] internal static class WardenObjectiveManager_CheckExpeditionFailed_Patch { public static readonly string PatchGroup = "NoFail"; public static bool Prefix(ref bool __result) { __result = false; return false; } } [HarmonyPatch(typeof(PlayerVoiceManager), "DoSayLine")] internal class NoVoiceLines { public static readonly string PatchGroup = "NoVoice"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "AddCommand", new Type[] { typeof(TERM_Command), typeof(string), typeof(LocalizedText), typeof(TERM_CommandRule), typeof(List<WardenObjectiveEventData>), typeof(List<TerminalOutput>) })] internal class RemoveTerminalCommands { public static readonly string PatchGroup = "NoTerminalCommands"; public static bool Prefix() { return false; } } [HarmonyPatch] internal static class RemoveTerminalCommands_Cancel { public static readonly string PatchGroup = "NoTerminalCommands"; [HarmonyTargetMethods] public static IEnumerable<MethodBase> TargetMethods() { Type typeFromHandle = typeof(LG_ComputerTerminal); return new MethodBase[6] { typeFromHandle.GetMethod("SetupAsWardenObjectiveCorruptedTerminalUplink"), typeFromHandle.GetMethod("SetupAsWardenObjectiveTerminalUplink"), typeFromHandle.GetMethod("SetupAsWardenObjectiveTimedTerminalSequence"), typeFromHandle.GetMethod("SetupAsWardenObjectiveSpecialCommand"), typeFromHandle.GetMethod("SetupAsWardenObjectiveGatherTerminal"), typeFromHandle.GetMethod("LockWithPassword", AccessTools.all, new Type[2] { typeof(string), typeof(Il2CppStringArray) }) }; } public static bool Prefix() { return false; } } [HarmonyPatch(typeof(EGS_GuardsRespawn), "Update")] internal static class EGS_GuardsRespawn_Update_Patch { public static readonly string PatchGroup = "NoRespawn"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateAmmo")] internal class SentryPatch { public static readonly string PatchGroup = "InfSentryAmmo"; public static bool Prefix(SentryGunInstance_Firing_Bullets __instance) { __instance.m_core.Ammo = __instance.m_core.AmmoMaxCap; return false; } } [HarmonyPatch(typeof(EGS_GuardsSpawn), "Update")] internal static class EGS_GuardsSpawn_Update_Patch { public static readonly string PatchGroup = "NoSleepingEnemies"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(PlayerSyncModelData), "RefreshGhostRenderersVisibility")] internal static class PlayerSyncModelData_RefreshGhostRenderersVisibility_Patch { public static readonly string PatchGroup = "UseTeamVis"; public static void Prefix(PlayerSyncModelData __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.Owner == (Object)null) && !((Object)(object)__instance.Owner.Owner == (Object)null)) { bool flag = TeamVisibility.LocalPlayerCanSee(__instance.Owner.Owner); __instance.m_ghostEnabled = flag && __instance.m_ghostEnabled; } } } [HarmonyPatch(typeof(PlayerGuiLayer), "UpdateGUIElementsVisibility")] internal static class PlayerGuiLayer_UpdateGUIElementsVisibility_Patch { public static readonly string PatchGroup = "UseTeamVis"; public static void Postfix(eFocusState currentState) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 if (currentState - 4 <= 2) { LocalPlayerAgent val = ((Il2CppObjectBase)PlayerManager.GetLocalPlayerAgent()).TryCast<LocalPlayerAgent>(); if (!((Object)(object)val == (Object)null)) { val.SetTeammateInfoVisible(true); } } } } [HarmonyPatch(typeof(PUI_Compass), "AfterCameraUpdate")] internal static class PUI_Compass_AfterCameraUpdate_Patch { public static readonly string PatchGroup = "UseTeamVis"; public static void Postfix(PUI_Compass __instance) { for (int i = 0; i < ((Il2CppArrayBase<bool>)(object)__instance.m_playerNameMarkersVisible).Length; i++) { if (((Il2CppArrayBase<bool>)(object)__instance.m_playerNameMarkersVisible)[i] || ((Il2CppArrayBase<bool>)(object)__instance.m_playerPingMarkersActive)[i]) { PlayerAgent playerAgentInSlot = PlayerManager.Current.GetPlayerAgentInSlot(i); if (!((Object)(object)playerAgentInSlot == (Object)null) && !((Object)(object)playerAgentInSlot.Owner == (Object)null) && (!((Agent)playerAgentInSlot).IsLocallyOwned || TeamVisibility.LocalPlayerHideIcons()) && !TeamVisibility.LocalPlayerCanSee(playerAgentInSlot.Owner)) { ((Il2CppArrayBase<NavMarker>)(object)__instance.m_playerNameMarkers)[i].SetVisible(false); ((Il2CppArrayBase<NavMarker>)(object)__instance.m_playerPingMarkers)[i].SetVisible(false); ((Il2CppArrayBase<bool>)(object)__instance.m_playerNameMarkersVisible)[i] = false; ((Il2CppArrayBase<bool>)(object)__instance.m_playerPingMarkersActive)[i] = false; } } } } } [HarmonyPatch(typeof(LocalPlayerAgent), "SetTeammateInfoVisible")] internal static class LocalPlayerAgent_SetTeammateInfoVisible_Patch { public static readonly string PatchGroup = "UseTeamVis"; public static bool Prefix(LocalPlayerAgent __instance, bool value) { Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (!((Object)(object)current == (Object)null) && !((Agent)current).IsLocallyOwned) { value = TeamVisibility.LocalPlayerCanSee(current.Owner); current.NavMarker.SetMarkerVisible(value); } } __instance.m_teammatesVisible = true; return false; } } [HarmonyPatch(typeof(CM_PageMap), "UpdatePlayerData")] internal class Map_UpdatePlayerData_VisibilityPatch { public static readonly string PatchGroup = "UseTeamVis"; public static void Postfix(CM_PageMap __instance) { foreach (CM_MapPlayerGUIItem item in (Il2CppArrayBase<CM_MapPlayerGUIItem>)(object)__instance.m_syncedPlayers) { if (!((Object)(object)item == (Object)null) && (!item.IsLocal || TeamVisibility.LocalPlayerHideIcons()) && ((Component)item).gameObject.TryGetComponentButDontCrash<PlayerToken>(out var comp)) { bool visible = TeamVisibility.LocalPlayerCanSee(comp.player); ((CM_SyncedGUIItem)item).SetVisible(visible); } } } } [HarmonyPatch(typeof(CM_MapPlayerGUIItem), "SetPlayer")] internal static class MapSyncPlayerGuiItem_PlayerTokenSetter_Patch { public static readonly string PatchGroup = "UseTeamVis"; public static void Postfix(CM_MapPlayerGUIItem __instance, SNet_Player player) { ((Component)__instance).gameObject.GetOrAddComponent<PlayerToken>().player = player; } } [HarmonyPatch(typeof(SyncedNavMarkerWrapper), "OnStateChange")] internal static class SyncedNavMarkerWrapper__OnStateChange__Patch { public static readonly string PatchGroup = "UseTeamVis"; public static bool Prefix(SyncedNavMarkerWrapper __instance, pNavMarkerState newState) { //IL_002f: 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_0036: Invalid comparison between Unknown and I4 PlayerWrapper playerWrapper = NetworkingManager.AllValidPlayers.FirstOrDefault((PlayerWrapper pw) => pw.NetPlayer.PlayerSlotIndex() == __instance.m_playerIndex); if (playerWrapper == null) { return true; } if ((int)newState.status == 1) { return true; } PlayerAgent val = default(PlayerAgent); if (!PlayerManager.TryGetLocalPlayerAgent(ref val)) { return true; } if (val.PlayerSlotIndex == __instance.m_playerIndex && !TeamVisibility.LocalPlayerHideIcons()) { return true; } return TeamVisibility.LocalPlayerCanSee(playerWrapper); } } } namespace Gamemodes.Patches.Required { [HarmonyPatch] internal static class AchievementPatches { [CompilerGenerated] private sealed class <TargetMethods>d__1 : IEnumerable<MethodBase>, IEnumerable, IEnumerator<MethodBase>, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private Type[] <>7__wrap1; private int <>7__wrap2; private List<MethodInfo>.Enumerator <>7__wrap3; private MethodBase[] <>7__wrap4; MethodBase IEnumerator<MethodBase>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TargetMethods>d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>7__wrap3 = default(List<MethodInfo>.Enumerator); <>7__wrap4 = null; <>1__state = -2; } private bool MoveNext() { try { MethodBase[] array; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(AchievementTask).Assembly); <>7__wrap1 = typesFromAssembly; <>7__wrap2 = 0; goto IL_0144; } case 1: <>1__state = -3; goto IL_0117; case 2: { <>1__state = -1; <>7__wrap2++; break; } IL_0144: if (<>7__wrap2 < <>7__wrap1.Length) { Type type = <>7__wrap1[<>7__wrap2]; if (!(type == null) && type.IsAssignableTo(typeof(AchievementTask)) && !(type == typeof(AchievementTask))) { <>7__wrap3 = AccessTools.GetDeclaredMethods(type).GetEnumerator(); <>1__state = -3; goto IL_0117; } goto IL_0136; } <>7__wrap1 = null; array = new MethodBase[6] { AccessTools.Method(typeof(AchievementManager), "Update", (Type[])null, (Type[])null), AccessTools.Method(typeof(AchievementManager), "OnLevelCleanup", (Type[])null, (Type[])null), AccessTools.Method(typeof(AchievementManager), "OnStateChange", (Type[])null, (Type[])null), AccessTools.Method(typeof(AchievementManager), "OnAchievementStateChanged", (Type[])null, (Type[])null), AccessTools.Method(typeof(AchievementManager), "OnLevelGenDone", (Type[])null, (Type[])null), AccessTools.Method(typeof(AchievementManager), "AttemptInteract", (Type[])null, (Type[])null) }; <>7__wrap4 = array; <>7__wrap2 = 0; break; IL_0136: <>7__wrap2++; goto IL_0144; IL_0117: while (<>7__wrap3.MoveNext()) { MethodInfo current = <>7__wrap3.Current; if (!current.Name.StartsWith("get_") && !current.Name.StartsWith("set_") && !(current.Name == "OnSetup")) { <>2__current = current; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap3 = default(List<MethodInfo>.Enumerator); goto IL_0136; } if (<>7__wrap2 < <>7__wrap4.Length) { MethodBase methodBase = <>7__wrap4[<>7__wrap2]; <>2__current = methodBase; <>1__state = 2; return true; } <>7__wrap4 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<MethodBase> IEnumerable<MethodBase>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new <TargetMethods>d__1(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<MethodBase>)this).GetEnumerator(); } } public static readonly string PatchGroup = "Required"; [IteratorStateMachine(typeof(<TargetMethods>d__1))] public static IEnumerable<MethodBase> TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TargetMethods>d__1(-2); } public static bool Prefix() { return false; } } [HarmonyWrapSafe] [HarmonyPatch(typeof(PlayerChatManager), "PostMessage")] internal static class ChatCommandsHandler { public static readonly string PatchGroup = "Required"; private static readonly Dictionary<string, MethodInfo> _commands = new Dictionary<string, MethodInfo>(); private static bool _once = true; internal static void AddCommand(string command, Func<string[], string> func) { AddCommand(command, func.Method); } internal static void AddCommand(string command, MethodInfo methodInfo) { if (_commands.ContainsKey(command)) { throw new ArgumentException("Command \"" + command + "\" already registered!", "command"); } _commands.Add(command, methodInfo); } private static void SetupCommands() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown bool flag = default(bool); foreach (MethodInfo item in from mi in typeof(ChatCommandsHandler).GetMethods() where mi.Name != "Prefix" && mi.Name != "AddCommand" select mi) { string text = item.Name.ToLower(); if (_commands.ContainsKey(text)) { ManualLogSource l = Plugin.L; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(24, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ChatCommandsHandler"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] Duplicate method?? \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\""); } l.LogDebug(val); } else { _commands.Add(text, item); } } } private static bool SkipOG() { PlayerChatManager.Current.m_currentValue = string.Empty; PlayerChatManager.Current.ExitChatMode(); return false; } public static bool Prefix(PlayerChatManager __instance) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown string currentValue = __instance.m_currentValue; if (currentValue.Length > 2 && currentValue.StartsWith("/")) { if (_once) { SetupCommands(); _once = false; } currentValue = currentValue.Substring(1); string[] array = currentValue.Split(" ", StringSplitOptions.RemoveEmptyEntries); string text = array[0].ToLower(); string[] array2 = Array.Empty<string>(); if (array.Length > 1) { array2 = array.Skip(1).ToArray(); } if (!_commands.TryGetValue(text, out var value)) { CustomCommands customCommands = GamemodeManager.CurrentMode?.ChatCommands; if (customCommands == null || !customCommands.Get(text, out value)) { Plugin.PostLocalMessage("Unknown command \"" + text + "\".", (eGameEventChatLogType)3); return SkipOG(); } } try { string text2 = (string)value.Invoke(null, new object[1] { array2 }); if (!string.IsNullOrWhiteSpace(text2)) { Plugin.PostLocalMessage(text2, (eGameEventChatLogType)2); } } catch (Exception innerException) { if (innerException is TargetInvocationException ex) { innerException = ex.InnerException; } string text3 = $"Command \"{text}\" threw a {innerException.GetType().Name}!"; Plugin.PostLocalMessage(text3, (eGameEventChatLogType)3); Plugin.PostLocalMessage(innerException.Message, (eGameEventChatLogType)3); Plugin.L.LogError((object)text3); Plugin.L.LogError((object)innerException.Message); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("StackTrace:\n"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(innerException.StackTrace); } l.LogWarning(val); } return SkipOG(); } return true; } public static string CurrentMode(string[] args) { return "Current Gamemode: " + GamemodeManager.CurrentMode.ID + ": " + GamemodeManager.CurrentMode.DisplayName; } public static string ListModes(string[] args) { return string.Join(", ", GamemodeManager.LoadedModeIds); } public static string SwitchMode(string[] args) { string text = args[0]; string iD = GamemodeManager.CurrentMode.ID; NetworkingManager.SendSwitchModeAll(text); return $"Trying to switch mode from [{iD}] to [{text}]."; } public static string NoFlash(string[] args) { return PhotoSensitivity(args); } public static string AntiFlash(string[] args) { return PhotoSensitivity(args); } public static string PhotoSensitivity(string[] args) { GamemodeManager.PhotoSensitivityMode = !GamemodeManager.PhotoSensitivityMode; Plugin.PostLocalMessage($"<color=orange>{"PhotoSensitivityMode"}: {(GamemodeManager.PhotoSensitivityMode ? "<#0F0>Enabled</color>" : "<#F00>Disabled</color>")}!</color>", (eGameEventChatLogType)2); return "<color=white><i>(This value is currently not saved in between game sessions!)</i></color>"; } public static string Sync(string[] args) { return ManualJoin(args); } public static string ManualJoin(string[] args) { NetworkingManager.SendJoinInfo(); return "Join info sent."; } public static string SetTeam(string[] args) { if (!SNet.IsMaster) { return "Master only."; } if (GamemodeManager.IsVanilla) { return "No."; } if (int.TryParse(args[0], out var result)) { SNet_Player val = SNet.LocalPlayer; PlayerAgent val2 = default(PlayerAgent); if (args.Length > 1 && int.TryParse(args[1], out var result2) && PlayerManager.TryGetPlayerAgent(ref result2, ref val2)) { val = val2.Owner; } NetworkingManager.AssignTeam(val, result); return $"Assigned \"{val.NickName}\" to team {result}"; } return "Oh no, it borky (couldn't parse int) :c"; } public static string TP(string[] args) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster) { return "Master only."; } if (GamemodeManager.IsVanilla) { return "No."; } if (args.Length == 0) { throw new ArgumentException("No player to TP to specified.", "args"); } PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent(); if (!NetworkingManager.InLevel || (Object)(object)localPlayerAgent == (Object)null) { throw new InvalidOperationException("Not in level or local player agent is null!"); } PlayerAgent val = null; if (int.TryParse(args[0], out var result)) { PlayerManager.TryGetPlayerAgent(ref result, ref val); } else { Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (current.Owner.NickName.Contains(args[0])) { val = current; break; } } } if ((Object)(object)val == (Object)null) { throw new ArgumentException("No player to TP to found.", "args"); } NetworkingManager.SendForceTeleport(localPlayerAgent.Owner, ((Agent)val).Position, ((Agent)val).TargetLookDir, ((Agent)val).DimensionIndex, (WarpOptions)6); return "Trying to TP to " + val.Owner.NickName + " ..."; } public static string TPAll(string[] args) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!SNet.IsMaster) { return "Master only."; } if (GamemodeManager.IsVanilla) { return "No."; } PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent(); if (!NetworkingManager.InLevel || (Object)(object)localPlayerAgent == (Object)null) { throw new InvalidOperationException("Not in level or local player agent is null!"); } foreach (PlayerWrapper allValidPlayer in NetworkingManager.AllValidPlayers) { if (!allValidPlayer.NetPlayer.IsLocal) { NetworkingManager.SendForceTeleport(allValidPlayer.NetPlayer, ((Agent)localPlayerAgent).Position, ((Agent)localPlayerAgent).TargetLookDir, ((Agent)localPlayerAgent).DimensionIndex, (WarpOptions)6); } } return "Tried to teleport all players to you."; } } [HarmonyPatch(typeof(ElevatorCage), "StartPreReleaseSequence")] public static class ElevatorLightPatch { public static readonly string PatchGroup = "Required"; public static readonly Color DEFAULT_COLOR = new Color(0.2f, 0f, 0f, 1f); public static void Prefix(ElevatorCage __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references) Color brakeLightColor = (Color)(((??)GamemodeManager.CurrentMode?.GetElevatorColor()) ?? DEFAULT_COLOR); __instance.BrakeLightColor = brakeLightColor; } } [HarmonyPatch(typeof(GlueGunProjectile), "Update")] internal static class FallingPatch_Glue { public static readonly string PatchGroup = "Required"; public static void Postfix(GlueGunProjectile __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!(((Component)__instance).transform.position.y > -1000f)) { __instance.SyncDestroy(); if (SNet.IsMaster) { ProjectileManager.WantToDestroyGlue(__instance.SyncID); } } } } [HarmonyPatch(typeof(ShellCasing), "Awake")] internal static class FallingPatch_Shelling { public static readonly string PatchGroup = "Required"; public static void Postfix(ShellCasing __instance) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 if (__instance.m_bounces >= 0 && (int)GameStateManager.CurrentStateName == 10) { __instance.m_bounces = -20; Object.Destroy((Object)(object)((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(BulletWeapon), "InitializeMagDropPool")] internal static class BulletWeapon_InitializeMagDropPool_Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix(BulletWeapon __instance) { return false; } } [HarmonyPatch(typeof(GameStateManager), "DoChangeState")] internal static class GameStateManagerPatches { public static readonly string PatchGroup = "Required"; public static void Postfix(eGameStateName nextState) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameEvents.InvokeOnGameStateChanged(nextState); } } [HarmonyWrapSafe] [HarmonyPatch(typeof(GameDataInit), "Initialize")] internal class GameDataInit_Initialize_Patch { public static readonly string PatchGroup = "Required"; private static bool _hasInited = false; public static void Postfix() { if (!_hasInited) { _hasInited = true; GameEvents.InvokeOnGameDataInit(); } } } [HarmonyWrapSafe] [HarmonyPatch(typeof(ItemSpawnManager), "SetupItemPrefabs")] internal class ItemSpawnManager_SetupItemPrefabs_Patch { public static readonly string PatchGroup = "Required"; public static void Prefix() { try { GameEvents.InvokePreItemPrefabsSetup(); } catch (Exception ex) { Plugin.LogException(ex, "ItemSpawnManager_SetupItemPrefabs_Patch.Prefix"); } } public static void Postfix() { GameEvents.InvokeOnItemPrefabsSetup(); } } [HarmonyPatch(typeof(CM_PageLoadout), "Setup")] internal class LobbyPatch { public static readonly string PatchGroup = "Required"; public static void Postfix(CM_PageLoadout __instance) { LobbyUI.Setup(__instance); } } [HarmonyPatch(typeof(LocalizationManager), "Setup")] public static class MultiplayerTutorial { public static readonly string PatchGroup = "Required"; private const uint TUTORIAL_PID = 39u; public static void Postfix() { RundownDataBlock val = ((IEnumerable<RundownDataBlock>)((IEnumerable<RundownDataBlock>)GameDataBlockBase<RundownDataBlock>.GetAllBlocks()).ToArray()).FirstOrDefault((Func<RundownDataBlock, bool>)((RundownDataBlock block) => ((GameDataBlockBase<RundownDataBlock>)(object)block).persistentID == 39)); if (val == null) { Plugin.L.LogWarning((object)"Tutorial rundown is null :("); return; } Enumerator<ExpeditionInTierData> enumerator = val.TierA.GetEnumerator(); while (enumerator.MoveNext()) { ExpeditionInTierData current = enumerator.Current; current.Enabled = true; current.IsSinglePlayer = false; current.SkipLobby = false; } } } [HarmonyPatch(typeof(LocalPlayerAgent), "Setup")] public class LocalPlayerAgent__Setup__Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(LocalPlayerAgent __instance) { ((Behaviour)((Component)__instance).gameObject.GetOrAddComponent<NodeDistance>()).enabled = true; } } [HarmonyPriority(0)] [HarmonyPatch(typeof(PlayerLocomotion), "AddExternalPushForce")] internal class PushForcePatch { public static readonly string PatchGroup = "Required"; public static float SlidePushForceMultiplier { get; set; } = 1f; public static float PushForceMultiplier { get; set; } = 1f; public static int PushForceReceivedFrame { get; private set; } public static Vector3 PushForceReceived { get; private set; } public static bool Prefix(PlayerLocomotion __instance, Vector3 force) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //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) PushForceReceivedFrame = Time.frameCount; PushForceReceived = force; __instance.m_externalPushForce += force * PushForceMultiplier; __instance.m_hasExternalPushForce = true; return false; } } [HarmonyPatch(typeof(PLOC_Crouch), "Enter")] internal static class CrouchEnterPatch { public static void Postfix(PLOC_Crouch __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_002c: 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) if ((int)((PLOC_Base)__instance).m_owner.Locomotion.m_lastStateEnum == 2 && PushForcePatch.PushForceReceivedFrame == Time.frameCount) { ((PLOC_Base)__instance).m_owner.Locomotion.m_externalPushForce = PushForcePatch.PushForceReceived * PushForcePatch.SlidePushForceMultiplier; } } } [HarmonyPatch(typeof(SNet_Replication), "AllocateKey", new Type[] { typeof(SNet_ReplicatorType), typeof(ushort) })] internal static class ReplicationPatch { public static readonly string PatchGroup = "Required"; public static bool OverrideSelfManaged => OverrideCount != 0; public static bool HasOverrideID => OverrideID != 0; public static int HighestSlotUsed_SelfManaged { get { return SNet_Replication.s_highestSlotUsed_SelfManaged; } set { SNet_Replication.s_highestSlotUsed_SelfManaged = value; } } public static ushort OverrideID { get; internal set; } public static uint OverrideCount { get; internal set; } = 0u; public static bool Prefix(SNet_ReplicatorType type, ushort key, ref ushort __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if (!OverrideSelfManaged) { return true; } if ((int)type != 2) { return true; } if (HasOverrideID) { __result = OverrideID; HighestSlotUsed_SelfManaged = OverrideID + 1; OverrideID = 0; } else { __result = (ushort)SNet_Replication.s_highestSlotUsed_SelfManaged; SNet_Replication.s_highestSlotUsed_SelfManaged += 1; } return false; } } [HarmonyPatch(typeof(EnemyRespawnerVisual), "Start")] internal static class EnemyRespawnerVisual__Start__Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix() { return false; } } [HarmonyPatch(typeof(Infestation_BaseBlob), "Start")] internal static class Infestation_BaseBlob__Start__Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix() { return false; } } [HarmonyWrapSafe] [HarmonyPatch(typeof(SNet_LobbyManager), "OnJoinedLobby")] internal static class SNet_LobbyManager__OnJoinedLobby__Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(SNet_Lobby lobby) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(9, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Invoking "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OnJoinedLobby"); } l.LogDebug(val); GameEvents.InvokeOnJoinedLobby(lobby); } } [HarmonyPatch(typeof(SNet_SessionHub), "OnLeftLobby")] internal static class SNet_SessionHub__OnLeftLobby__Patch { public static readonly string PatchGroup = "Required"; public static void Prefix(SNet_Player player) { NetworkingManager.OnPlayerRemovedFromSession(player); } } [HarmonyPatch(typeof(SNet_SyncManager), "OnFoundMaster")] internal static class SNet_SyncManager__OnFoundMaster__Patch { public static readonly string PatchGroup = "Required"; public static void Postfix() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(9, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Invoking "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OnFoundMaster"); } l.LogDebug(val); GameEvents.InvokeOnFoundMaster(); } } [HarmonyPatch(typeof(SNet_SessionHub), "AddPlayerToSession")] internal static class SNet_SessionHub__AddPlayerToSession__Patch { public static readonly string PatchGroup = "Required"; public static void Prefix(SNet_Player player) { NetworkingManager.OnPlayerAddedToSession(player); } } [HarmonyPatch(typeof(SNet_GlobalManager), "OnPlayerEvent")] internal static class SNet_GlobalManager__OnPlayerEvent__Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(SNet_Player player, SNet_PlayerEvent playerEvent, SNet_PlayerEventReason reason) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (!SNet.IsMaster && (int)playerEvent <= 1) { NetworkingManager.OnPlayerRemovedFromSession(player); } } } [HarmonyPatch(typeof(MineDeployerInstance), "Setup")] internal static class Mine_Setup_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(MineDeployerInstance __instance) { ToolInstanceCaches.MineCache.Register(__instance); } } [HarmonyPatch(typeof(MineDeployerInstance), "OnDestroy")] internal static class Mine_Destroy_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(MineDeployerInstance __instance) { ToolInstanceCaches.MineCache.Deregister(__instance); } } [HarmonyPatch(typeof(GlueGunProjectile), "Awake")] internal static class Glue_Setup_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(GlueGunProjectile __instance) { ToolInstanceCaches.GlueCache.Register(__instance); } } [HarmonyPatch(typeof(GlueGunProjectile), "SyncDestroy")] internal static class Glue_Destroy_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(GlueGunProjectile __instance) { ToolInstanceCaches.GlueCache.Deregister(__instance); } } [HarmonyPatch(typeof(SentryGunInstance), "Setup")] internal static class Sentry_Setup_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(SentryGunInstance __instance) { ToolInstanceCaches.SentryCache.Register(__instance); } } [HarmonyPatch(typeof(SentryGunInstance), "OnDestroy")] internal static class Sentry_Destroy_Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(SentryGunInstance __instance) { ToolInstanceCaches.SentryCache.Deregister(__instance); } } [HarmonyPatch(typeof(PlayerAgent), "Setup")] public static class PlayerAgent__Setup__Patch { public static readonly string PatchGroup = "ProximityVoiceComp"; public static void Postfix(PlayerAgent __instance) { CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Coroutines.NextFrame(delegate { ((Component)__instance).gameObject.GetOrAddComponent<ProximityVoice>(); })), (Action)null); } } [HarmonyPatch(typeof(PUI_VoiceControls), "SetPlayer")] public static class PUI_VoiceControls__SetPlayer__Patch { public static readonly string PatchGroup = "Required"; public static void Postfix(PUI_VoiceControls __instance, SNet_Player player) { (float, bool) preferences = PlayerVoiceManager.PlayerPrefs.GetPreferences(player.Lookup); __instance.m_slider.Value = preferences.Item1; __instance.m_muteToggleButton.Value = preferences.Item2; } } [HarmonyPatch(typeof(PUI_VoiceControls), "OnVolumeChanged")] public static class PUI_VoiceControls__OnVolumeChanged__Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix(PUI_VoiceControls __instance, float volume) { PlayerVoiceManager.PlayerPrefs.SetPreference(__instance.m_playerLookup, volume); return false; } } [HarmonyPatch(typeof(PUI_VoiceControls), "OnMuteChanged")] public static class PUI_VoiceControls__OnMuteChanged__Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix(PUI_VoiceControls __instance, bool muted) { PlayerVoiceManager.PlayerPrefs.SetPreference(__instance.m_playerLookup, null, muted); PlayerVoiceManager.SetMuted(__instance.m_playerLookup, muted); return false; } } [HarmonyPatch(typeof(PUI_VoiceControls), "Update")] public static class PUI_VoiceControls__Update__Patch { public static readonly string PatchGroup = "Required"; public static bool Prefix() { return false; } } } namespace Gamemodes.Patches.Default { [HarmonyPatch(typeof(SNet_SyncManager), "KickPlayer")] public class GenerationChecksumPatch { public static bool Prefix(SNet_Player player, SNet_PlayerEventReason reason) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if ((int)reason == 3) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipped kicking player \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(player.NickName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" for generation checksum miss-match."); } l.LogDebug(val); return false; } return true; } } [HarmonyPatch(typeof(GS_Lobby), "TryStartLevelTrigger")] internal class GSLobbyPatch { public static bool Prefix(ref bool __result) { __result = false; if (!NetworkingManager.AllPlayersVersionMatches) { Plugin.SendChatMessage("Version mismatch on some players:"); foreach (PlayerWrapper item in NetworkingManager.SyncedPlayers.Where((PlayerWrapper p) => !p.VersionMatches)) { Plugin.SendChatMessage(item.NickName ?? ""); } return false; } if (!NetworkingManager.AllPlayersHaveModeInstalled) { Plugin.SendChatMessage("Gamemode missing on some players:"); foreach (PlayerWrapper item2 in NetworkingManager.SyncedPlayers.Where((PlayerWrapper p) => !p.HasModeInstalled(GamemodeManager.CurrentMode?.ID))) { Plugin.SendChatMessage(item2.NickName ?? ""); } return false; } return true; } } [HarmonyWrapSafe] [HarmonyPatch(typeof(RundownManager), "NewGameSession")] public class RundownManager_NewGameSession_Patch { public static bool Prefix() { Plugin.L.LogDebug((object)"New Game Session has started!"); GameEvents.InvokeOnGameSessionStart(); return false; } } [HarmonyWrapSafe] [HarmonyPatch(typeof(RundownManager), "OnExpeditionEnded")] public class RundownManager_EndGameSession_Patch { public static bool Prefix(ExpeditionEndState endState) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) ArtifactInventory artifactInventory = BoosterImplantManager.ArtifactInventory; (int, int, int) artifacts = (artifactInventory.GetArtifactCount((ArtifactCategory)0), artifactInventory.GetArtifactCount((ArtifactCategory)1), artifactInventory.GetArtifactCount((ArtifactCategory)2)); Plugin.L.LogDebug((object)"Game Session has ended!"); GameEvents.InvokeOnGameSessionEnd(endState, artifacts); return false; } } } namespace Gamemodes.Net { public class NetworkingManager { private const string PREFIX = "CGamemodes_"; private static readonly Dictionary<Type, string> _eventNameLookup = new Dictionary<Type, string>(); private static readonly Dictionary<Type, Delegate> _eventStorage = new Dictionary<Type, Delegate>(); private static readonly Dictionary<ulong, PlayerWrapper> _syncedPlayers = new Dictionary<ulong, PlayerWrapper>(); public static IEnumerable<PlayerWrapper> SyncedPlayers => _syncedPlayers.Values; public static IEnumerable<PlayerWrapper> AllValidPlayers => SyncedPlayers.Where((PlayerWrapper p) => p.ValidPlayer); public static IEnumerable<PlayerWrapper> Spectators => SyncedPlayers.Where((PlayerWrapper p) => p.IsSpectator); public static ulong LocalPlayerId { get { SNet_Player localPlayer = SNet.LocalPlayer; if (localPlayer == null) { return 0uL; } return localPlayer.Lookup; } } public static int LocalPlayerTeam { get; private set; } public static bool AllPlayersVersionMatches => SyncedPlayers.All((PlayerWrapper pi) => pi.VersionMatches); public static bool AllPlayersHaveModeInstalled => SyncedPlayers.All((PlayerWrapper pi) => pi.HasModeInstalled(GamemodeManager.CurrentMode?.ID)); public static bool InLevel => (int)GameStateManager.CurrentStateName == 10; public static event Action<PlayerWrapper> OnJoinedLobbySyncEvent; public static event Action OnPlayerCountChanged; public static event Action<pRayCast> OnRayCastInstructionsReceived; public static event Action<PlayerWrapper, pGearChangeNotif> OnPlayerChangedGear; public static event Action<PlayerWrapper, int> OnPlayerChangedTeams; public static event Action<string> DoSwitchModeReceived; public static event Action<string> OnRemoteModeInstalledReported; internal static void Init() { GameEvents.OnGameDataInit += OnGameDataInit; GameEvents.OnGameStateChanged += OnGameStateChanged; } private static void OnGameDataInit() { Plugin.L.LogDebug((object)"Registering base events ..."); RegisterAllEvents(); } private static void OnGameStateChanged(eGameStateName state) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("NetworkingManager"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" OnGameStateChanged(): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eGameStateName>(state); } l.LogDebug(val); if ((int)state != 4) { if ((int)state != 5) { if ((int)state == 10) { SendIHasArrived(); } } else { OnGameStateLobby(); } } else { ClearSyncedPlayers(); } } private static void OnGameStateLobby() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (SNet.IsMaster) { return; } SendJoinInfo(); if (SNet.IsInLobby) { string lobbyData = SteamMatchmaking.GetLobbyData(new CSteamID(SNet.Lobby.Identifier.ID), "c_mode"); if (string.IsNullOrWhiteSpace(lobbyData)) { Plugin.L.LogWarning((object)"No mode string found in steam lobby settings."); } else { NetworkingManager.DoSwitchModeReceived?.Invoke(lobbyData); } } } public static void ClearSyncedPlayers() { Plugin.L.LogInfo((object)"Clearing synced players ..."); _syncedPlayers.Clear(); } private static void OnPlayerJoined(SNet_Player newPlayer) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (!((Object)(object)newPlayer == (Object)null) && GetPlayerInfo(newPlayer.Lookup, out var playerInfo)) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(12, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(playerInfo.NickName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has joined!"); } l.LogDebug(val); if (SNet.IsMaster) { PostChatLog("<#0F0>>> <color=orange>" + playerInfo.NickName + "</color> has connected.</color>"); } SendWelcome(newPlayer); SendSwitchModeTo(GamemodeManager.CurrentMode.ID, newPlayer); OnPlayerCountChangedImpl(); } } private static void OnPlayerCountChangedImpl() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(20, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("OnPlayerCountChanged"); } l.LogDebug(val); NetworkingManager.OnPlayerCountChanged?.Invoke(); GamemodeManager.OnPlayerCountChanged(); } public static void OnPlayerAddedToSession(SNet_Player player) { OnPlayerJoined(player); } public static void OnPlayerRemovedFromSession(SNet_Player player) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (_syncedPlayers.Remove(player.Lookup)) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removed \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(player.NickName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" from _syncedPlayers."); } l.LogDebug(val); OnPlayerCountChangedImpl(); if (SNet.IsMaster) { PostChatLog("<#F00><< <color=orange>" + player.NickName + "</color> has disconnected.</color>"); } } } private static void OnPlayerEvent(SNet_Player player, SNet_PlayerEvent playerEvent, SNet_PlayerEventReason reason) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(34, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("OnPlayerEvent: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(player.NickName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", event: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SNet_PlayerEvent>(playerEvent); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", reason: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SNet_PlayerEventReason>(reason); } l.LogDebug(val); } internal static void CleanupPlayers() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown HashSet<ulong> connectedPlayers = new HashSet<ulong>(); Enumerator<SNet_Player> enumerator = SNet.LobbyPlayers.GetEnumerator(); while (enumerator.MoveNext()) { SNet_Player current = enumerator.Current; connectedPlayers.Add(current.Lookup); } Enumerator<PlayerAgent> enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator2.MoveNext()) { PlayerAgent current2 = enumerator2.Current; if (!((Object)(object)((current2 != null) ? current2.Owner : null) == (Object)null) && !((Agent)current2).m_isBeingDestroyed) { connectedPlayers.Add(current2.Owner.Lookup); } } PlayerWrapper[] array = _syncedPlayers.Values.Where((PlayerWrapper p) => !connectedPlayers.Contains(p.ID)).ToArray(); if (array.Length == 0) { return; } ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cleanup: Removing "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(array.Length); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" players"); } l.LogWarning(val); PlayerWrapper[] array2 = array; foreach (PlayerWrapper playerWrapper in array2) { ManualLogSource l2 = Plugin.L; BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Removing \""); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(playerWrapper.NickName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" from _syncedPlayers."); } l2.LogDebug(val2); _syncedPlayers.Remove(playerWrapper.ID); if (!playerWrapper.IsBot) { if (!SNet.IsMaster) { break; } PostChatLog("<#F00><< <color=orange>" + playerWrapper.NickName + "</color> has disconnected.</color>"); } } } public static bool GetPlayerInfo(ulong playerId, out PlayerWrapper playerInfo, bool forceReset = false) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (!forceReset && _syncedPlayers.TryGetValue(playerId, out playerInfo)) { return false; } _syncedPlayers.Remove(playerId); playerInfo = new PlayerWrapper(playerId); ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Synced: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(playerId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PlayerWrapper>(playerInfo); } l.LogWarning(val); _syncedPlayers.Add(playerId, playerInfo); return true; } public static bool GetPlayerInfo(SNet_Player player, out PlayerWrapper playerInfo, bool forceReset = false) { if ((Object)(object)player == (Object)null) { throw new ArgumentException("player is null", "player"); } return GetPlayerInfo(player.Lookup, out playerInfo, forceReset); } public static PlayerWrapper GetLocalPlayerInfo() { _syncedPlayers.TryGetValue(LocalPlayerId, out var value); return value; } public static bool TryGetSender(ulong senderId, out SNet_Player sender) { return SNet.TryGetPlayer(senderId, ref sender); } public static bool IsLocalSender(ulong senderId) { return LocalPlayerId == senderId; } public static void SendEventAndInvokeLocally<T>(T data, SNet_Player targetPlayer = null, SNet_ChannelType channelType = 2) where T : struct { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SendEvent(data, targetPlayer, invokeLocal: true, channelType); } public static void SendEvent<T>(T data, SNet_Player targetPlayer = null, bool invokeLocal = false, SNet_ChannelType channelType = 2) where T : struct { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) string eventName = GetEventName<T>(); if (!NetworkAPI.IsEventRegistered(eventName)) { throw new ArgumentException($"The provided type \"{typeof(T).Name}\" has not been registered as a valid event. ({eventName})", "data"); } if ((Object)(object)targetPlayer == (Object)null) { NetworkAPI.InvokeEvent<T>(eventName, data, channelType); } else { NetworkAPI.InvokeEvent<T>(eventName, data, targetPlayer, channelType); } if (invokeLocal && (targetPlayer == null || !targetPlayer.IsLocal) && TryGetEvent(out Action<ulong, T> eventAction)) { eventAction(LocalPlayerId, data); } } private static void EventInvoker<T>(ulong sender, T data) where T : struct { NetEvents net = GamemodeManager.CurrentMode.Net; if (net.HasEvent<T>()) { net.InvokeEvent(sender, data); } } internal static void RegisterEventWrapped<T>() where T : struct { string eventName = GetEventName<T>(); if (!NetworkAPI.IsEventRegistered(eventName)) { _eventStorage.Add(typeof(T), new Action<ulong, T>(EventInvoker)); NetworkAPI.RegisterEvent<T>(eventName, (Action<ulong, T>)EventInvoker); } } private static void RegisterEventInternal<T>(Action<ulong, T> onReceive) where T : struct { string eventName = GetEventName<T>(); if (!NetworkAPI.IsEventRegistered(eventName)) { _eventStorage.Add(typeof(T), onReceive); NetworkAPI.RegisterEvent<T>(eventName, onReceive); } } private static bool TryGetEvent<T>(out Action<ulong, T> eventAction) where T : struct { if (_eventStorage.TryGetValue(typeof(T), out var value)) { eventAction = (Action<ulong, T>)value; return true; } eventAction = null; return false; } private static string GetEventName<T>() where T : struct { if (_eventNameLookup.TryGetValue(typeof(T), out var value)) { return value; } value = "CGamemodes_" + typeof(T).Name; _eventNameLookup.Add(typeof(T), value); return value; } private static void SyncData(PlayerWrapper playerToSyncTo) { if (!SNet.IsMaster) { return; } foreach (var (_, playerWrapper2) in _syncedPlayers) { if (playerWrapper2.ID != playerToSyncTo.ID) { AssignTeamCatchup(playerWrapper2, playerWrapper2.Team, playerToSyncTo); } } } private static void RegisterAllEvents() { RegisterEventInternal<pJoinInfo>(OnJoinInfoReceived); RegisterEventInternal<pInstalledMode>(OnInstalledModeReceived); RegisterEventInternal<pSwitchMode>(OnModeSwitchReceived); RegisterEventInternal<pForcedTeleport>(OnForcedTeleportReceived); RegisterEventInternal<pSpectatorSwitch>(OnSpectatorPacketReceived); RegisterEventInternal<pSetTeam>(OnSetTeamReceived); RegisterEventInternal<pWelcome>(OnWelcomeReceived); RegisterEventInternal<pChatLogMessage>(OnChatLogReceived); RegisterEventInternal<pSpawnItemInLevel>(OnSpawnItemInLevelReceived); RegisterEventInternal<pSpawnItemForPlayer>(OnSpawnItemForPlayerReceived); RegisterEventInternal<pGearChangeNotif>(OnGearChangeNotifReceived); RegisterEventInternal<pRayCast>(OnRayCastPacketReceived); RegisterEventInternal<pHiIHasArrived>(OnIHasArrivedReceived); } public static void PostChatLog(string message) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (message.Length > 256) { message = message.Substring(0, 256); Ma