Decompiled source of ModdingUtils v0.4.8
ModdingUtils.dll
Decompiled a year ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using InControl; using ModdingUtils.AIMinion; using ModdingUtils.AIMinion.Extensions; using ModdingUtils.Extensions; using ModdingUtils.GameModes; using ModdingUtils.MonoBehaviours; using ModdingUtils.Patches; using ModdingUtils.RoundsEffects; using ModdingUtils.Utils; using Photon.Pun; using Sonigon; using SoundImplementation; using TMPro; using UnboundLib; using UnboundLib.Cards; using UnboundLib.Extensions; using UnboundLib.GameModes; using UnboundLib.Networking; using UnboundLib.Utils; using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ModdingUtils")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ModdingUtils")] [assembly: AssemblyTitle("ModdingUtils")] [assembly: AssemblyVersion("1.0.0.0")] namespace ModdingUtils { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("pykess.rounds.plugins.moddingutils", "Modding Utilities", "0.4.8")] [BepInProcess("Rounds.exe")] public class ModdingUtils : BaseUnityPlugin { private const string ModId = "pykess.rounds.plugins.moddingutils"; private const string ModName = "Modding Utilities"; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("pykess.rounds.plugins.moddingutils").PatchAll(); ((Component)this).gameObject.AddComponent<InterfaceGameModeHooksManager>(); } private void Start() { //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) Unbound.RegisterCredits("Modding Utilities", new string[3] { "Pykess", "BossSloth (Migration of several tools from PCE)", "Willuwontu (game mode hooks interface)" }, new string[2] { "github", "Support Pykess" }, new string[2] { "https://github.com/Rounds-Modding/ModdingUtils", "https://ko-fi.com/pykess" }); GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => EndPickPhaseShow())); GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)CharacterStatModifiersExtension.Reset); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetEffectsBetweenBattles())); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetTimers())); GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetEffectsBetweenBattles())); GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetTimers())); GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)AIMinionHandler.InitPlayerAssigner); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)AIMinionHandler.CreateAllAIs); GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)AIMinionHandler.RemoveAllAIs); GameModeManager.AddHook("PickStart", (Func<IGameModeHandler, IEnumerator>)AIMinionHandler.RemoveAllAIs); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)TimeSinceBattleStart.BattleStart); GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)AIMinionHandler.StartStalemateHandler); GameModeManager.AddHook("PointStart", (Func<IGameModeHandler, IEnumerator>)TimeSinceBattleStart.FreezeTimer); GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => AIMinionHandler.SetPlayersCanJoin(playersCanJoin: false))); GameModeManager.AddHook("InitStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => AIMinionHandler.SetPlayersCanJoin(playersCanJoin: true))); CardChoicePatchGetRanomCard.CardChoiceSpawnUniqueCardPatch = ((List<BaseUnityPlugin>)typeof(Chainloader).GetField("_plugins", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).Exists((BaseUnityPlugin plugin) => plugin.Info.Metadata.GUID == "pykess.rounds.plugins.cardchoicespawnuniquecardpatch"); if (CardChoicePatchGetRanomCard.CardChoiceSpawnUniqueCardPatch) { CardChoicePatchGetRanomCard.UniqueCardPatch = AppDomain.CurrentDomain.GetAssemblies().First((Assembly a) => a.FullName == "CardChoiceSpawnUniqueCardPatch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); } ((GameObject)Resources.Load("Bullet_EMP")).AddComponent<StopRecursion>(); ((GameObject)Resources.Load("Bullet_NoTrail")).AddComponent<StopRecursion>(); ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)this, 5f, (Action)delegate { GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); GameObject[] array2 = array; foreach (GameObject val in array2) { AudioMixerFixer[] componentsInChildren = val.GetComponentsInChildren<AudioMixerFixer>(); AudioMixerFixer[] array3 = componentsInChildren; foreach (AudioMixerFixer audioMixerFixer in array3) { audioMixerFixer.RunFix(); } } }); } private IEnumerator EndPickPhaseShow() { yield return (object)new WaitForSecondsRealtime(0.5f); yield return CardBarUtils.instance.EndPickPhaseShow(); } private IEnumerator ResetEffectsBetweenBattles() { Player[] players = PlayerManager.instance.players.ToArray(); for (int i = 0; i < players.Length; i++) { CustomEffects.ClearAllReversibleEffects(((Component)players[i]).gameObject); InConeEffect[] components = ((Component)players[i]).GetComponents<InConeEffect>(); foreach (InConeEffect effect in components) { effect.RemoveAllEffects(); } } yield break; } private IEnumerator ResetTimers() { Player[] players = PlayerManager.instance.players.ToArray(); for (int i = 0; i < players.Length; i++) { CustomEffects.ResetAllTimers(((Component)players[i]).gameObject); } yield break; } } } namespace ModdingUtils.Utils { [RequireComponent(typeof(SoundUnityEventPlayer))] public class AudioMixerFixer : MonoBehaviour { public enum AudioType { SFX, MASTER, MUSIC } public AudioType type; private Dictionary<AudioType, string> groupNames = new Dictionary<AudioType, string> { { AudioType.MASTER, "MasterPrivate" }, { AudioType.MUSIC, "MUS" }, { AudioType.SFX, "SFX" } }; private AudioMixerGroup audioGroup; public void RunFix() { Awake(); } private void Awake() { audioGroup = SoundVolumeManager.Instance.audioMixer.FindMatchingGroups(groupNames[type])[0]; SoundUnityEventPlayer component = ((Component)this).GetComponent<SoundUnityEventPlayer>(); SetAudioMixerGroup(component.soundStart); SetAudioMixerGroup(component.soundStartLoop); SetAudioMixerGroup(component.soundEnd); } private void SetAudioMixerGroup(SoundEvent soundEvent) { if (!((Object)(object)soundEvent == (Object)null)) { soundEvent.variables.audioMixerGroup = audioGroup; } } } public sealed class CardBarUtils { public static readonly CardBarUtils instance = new CardBarUtils(); private static readonly float displayDuration = 1.5f; public static readonly Vector3 localShift = new Vector3(-50f, 0f, 0f); public static readonly float barlocalScaleMult = 1.1f; public static readonly float cardLocalScaleMult = 1f; private DictionaryOfLists<Player, CardInfo> cardsToShow = new DictionaryOfLists<Player, CardInfo>(); private CardBar[] CardBars => (CardBar[])Traverse.Create((object)CardBarHandler.instance).Field("cardBars").GetValue(); public CardBar PlayersCardBar(int playerID) { return CardBars[playerID]; } public CardBar PlayersCardBar(Player player) { return CardBars[player.playerID]; } private CardBarUtils() { } private void Reset() { cardsToShow = new DictionaryOfLists<Player, CardInfo>(); } private void Reset(Player player) { cardsToShow[player] = new List<CardInfo>(); } public void ShowAtEndOfPhase(Player player, CardInfo card) { if (!((Object)(object)card == (Object)null)) { List<CardInfo> list = new List<CardInfo>(cardsToShow[player]); list.Add(card); cardsToShow[player] = list; } } public void ShowCard(Player player, CardInfo card) { ShowCard(player.playerID, ((Object)card).name); } public void ShowCard(int playerID, CardInfo card) { ShowCard(playerID, ((Object)card).name); } public void ShowCard(Player player, int cardID) { ShowCard(player.playerID, ((Object)Cards.instance.GetCardWithID(cardID)).name); } public void ShowCard(int playerID, int cardID) { ShowCard(playerID, ((Object)Cards.instance.GetCardWithID(cardID)).name); } public void ShowCard(int playerID, string objectName) { if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(CardBarUtils), "RPCA_ShowCard", new object[2] { playerID, objectName }); } } [UnboundRPC] private static void RPCA_ShowCard(int playerID, string objectName) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0086: Unknown result type (might be due to invalid IL or missing references) int cardIDFromObjectName = Cards.instance.GetCardIDFromObjectName(objectName); try { if ((Object)(object)Cards.instance.GetCardWithID(cardIDFromObjectName) == (Object)null) { return; } } catch { return; } instance.PlayersCardBar(playerID).OnHover(Cards.instance.GetCardWithID(cardIDFromObjectName), Vector3.zero); ((GameObject)Traverse.Create((object)instance.PlayersCardBar(playerID)).Field("currentCard").GetValue()).gameObject.transform.localScale = Vector3.one * cardLocalScaleMult; } public void HideCard(Player player) { HideCard(player.playerID); } public void HideCard(int playerID) { if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(CardBarUtils), "RPCA_HideCard", new object[1] { playerID }); } } [UnboundRPC] private static void RPCA_HideCard(int playerID) { instance.PlayersCardBar(playerID).StopHover(); } [UnboundRPC] private static void RPCA_HighlightCardBar(int playerID) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) ((Component)instance.PlayersCardBar(playerID)).gameObject.transform.localScale = Vector3.one * barlocalScaleMult; Transform transform = ((Component)instance.PlayersCardBar(playerID)).gameObject.transform; transform.localPosition += localShift; instance.ChangePlayersLineColor(playerID, Color.white); float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(instance.GetPlayersBarColor(playerID), ref num, ref num2, ref num3); instance.ChangePlayersBarColor(playerID, Color.HSVToRGB(num, num2 + 0.1f, num3 + 0.1f)); } [UnboundRPC] private static void RPCA_UnhighlightCardBar(int playerID, float r, float g, float b, float a) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) ((Component)instance.PlayersCardBar(playerID)).gameObject.transform.localScale = Vector3.one * 1f; Transform transform = ((Component)instance.PlayersCardBar(playerID)).gameObject.transform; transform.localPosition -= localShift; instance.ResetPlayersLineColor(playerID); instance.ChangePlayersBarColor(playerID, new Color(r, g, b, a)); } public Color HighlightCardBar(int playerID) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Color playersBarColor = GetPlayersBarColor(playerID); if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(CardBarUtils), "RPCA_HighlightCardBar", new object[1] { playerID }); } return playersBarColor; } public void UnhighlightCardBar(int playerID, Color original_color) { //IL_0035: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(CardBarUtils), "RPCA_UnhighlightCardBar", new object[5] { playerID, original_color.r, original_color.g, original_color.b, original_color.a }); } } public GameObject GetCardBarSquare(int playerID, int idx) { return GetCardBarSquares(playerID)[idx + 1]; } public GameObject GetCardBarSquare(Player player, int idx) { return GetCardBarSquare(player.playerID, idx); } public GameObject[] GetCardBarSquares(int playerID) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown List<GameObject> list = new List<GameObject>(); foreach (Transform item in ((Component)PlayersCardBar(playerID)).transform) { Transform val = item; list.Add(((Component)val).gameObject); } return list.ToArray(); } public GameObject[] GetCardBarSquares(Player player) { return GetCardBarSquares(player.playerID); } public void ResetPlayersLineColor(int playerID) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = (from gr in ((Component)PlayersCardBar(playerID)).gameObject.GetComponentsInChildren<Graphic>() where !((Object)((Component)gr).gameObject).name.Contains("CarrdOrange") select gr).ToList(); foreach (Graphic item in list) { if (((Object)((Component)item).gameObject).name.Contains("Card")) { item.color = new Color(0.462f, 0.462f, 0.462f, 1f); } else if (((Object)((Component)item).gameObject).name.Contains("Text")) { item.color = new Color(0.6509f, 0.6509f, 0.6509f, 1f); } } } public void ResetPlayersLineColor(Player player) { ResetPlayersLineColor(player.playerID); } public void ChangePlayersLineColor(int playerID, Color color) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = (from gr in ((Component)PlayersCardBar(playerID)).gameObject.GetComponentsInChildren<Graphic>() where !((Object)((Component)gr).gameObject).name.Contains("CarrdOrange") select gr).ToList(); foreach (Graphic item in list) { item.color = color; } } public void ChangePlayersLineColor(Player player, Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ChangePlayersLineColor(player.playerID, color); } public Color GetPlayersBarColor(int playerID) { //IL_0043: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = (from gr in ((Component)PlayersCardBar(playerID)).gameObject.GetComponentsInChildren<Graphic>() where ((Object)((Component)gr).gameObject).name.Contains("CarrdOrange") select gr).ToList(); return list[0].color; } public Color GetPlayersBarColor(Player player) { //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_0010: Unknown result type (might be due to invalid IL or missing references) return GetPlayersBarColor(player.playerID); } public Color ChangePlayersBarColor(int playerID, Color color) { //IL_0043: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = (from gr in ((Component)PlayersCardBar(playerID)).gameObject.GetComponentsInChildren<Graphic>() where ((Object)((Component)gr).gameObject).name.Contains("CarrdOrange") select gr).ToList(); Color color2 = list[0].color; foreach (Graphic item in list) { item.color = color; } return color2; } public Color ChangePlayersBarColor(Player player, Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0011: Unknown result type (might be due to invalid IL or missing references) return ChangePlayersBarColor(player.playerID, color); } public Color GetCardSquareColor(GameObject cardSquare) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = cardSquare.GetComponentsInChildren<Graphic>().ToList(); return list[0].color; } public Color ChangeCardSquareColor(GameObject cardSquare, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) List<Graphic> list = cardSquare.GetComponentsInChildren<Graphic>().ToList(); Color color2 = list[0].color; foreach (Graphic item in list) { item.color = color; } return color2; } public static void SilentAddToCardBar(int playerID, CardInfo card, string twoLetterCode = "") { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) Traverse.Create((object)instance.PlayersCardBar(playerID)).Field("ci").SetValue((object)card); GameObject val = (GameObject)Traverse.Create((object)instance.PlayersCardBar(playerID)).Field("source").GetValue(); GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.position, val.transform.rotation, val.transform.parent); val2.transform.localScale = Vector3.one; string text = card.cardName; if (twoLetterCode != "") { text = twoLetterCode; } while (text.Length < 2) { text += " "; } text = text.Substring(0, 2); string text2 = text[0].ToString().ToUpper(); if (text.Length > 1) { string text3 = text[1].ToString().ToLower(); text = text2 + text3; } else { text = text2; } ((TMP_Text)val2.GetComponentInChildren<TextMeshProUGUI>()).text = text; Traverse.Create((object)val2.GetComponent<CardBarButton>()).Field("card").SetValue((object)card); val2.gameObject.SetActive(true); } public static void SilentAddToCardBar(Player player, CardInfo card, string twoLetterCode = "") { SilentAddToCardBar(player.playerID, card, twoLetterCode); } internal IEnumerator EndPickPhaseShow() { foreach (Player player in PlayerManager.instance.players) { _ = Color.clear; Color orig; try { orig = GetPlayersBarColor(player); } catch { continue; } if (cardsToShow[player].Count > 0) { orig = HighlightCardBar(player.playerID); } using (IEnumerator<CardInfo> enumerator2 = cardsToShow[player].Where((CardInfo card) => player.data.currentCards.Select((CardInfo card) => ((Object)card).name).Contains(((Object)card).name)).GetEnumerator()) { while (enumerator2.MoveNext()) { ShowCard(card: enumerator2.Current, player: player); yield return (object)new WaitForSecondsRealtime(displayDuration); HideCard(player); } } if (cardsToShow[player].Count > 0) { UnhighlightCardBar(player.playerID, orig); } } Reset(); } public IEnumerator ShowImmediate(int playerID, int cardID, float? duration = null) { float displayDuration = duration ?? CardBarUtils.displayDuration; Color orig = HighlightCardBar(playerID); ShowCard(playerID, cardID); yield return (object)new WaitForSecondsRealtime(displayDuration); HideCard(playerID); UnhighlightCardBar(playerID, orig); } public IEnumerator ShowImmediate(Player player, int cardID, float? duration = null) { return ShowImmediate(player.playerID, cardID, duration); } public IEnumerator ShowImmediate(Player player, CardInfo card, float? duration = null) { return ShowImmediate(player.playerID, Cards.instance.GetCardID(card), duration); } public IEnumerator ShowImmediate(int playerID, CardInfo card, float? duration = null) { return ShowImmediate(playerID, Cards.instance.GetCardID(card), duration); } public IEnumerator ShowImmediate(Player player, int[] cardIDs, float? duration = null) { return ShowImmediate(player.playerID, cardIDs, duration); } public IEnumerator ShowImmediate(int playerID, CardInfo[] cards, float? duration = null) { List<int> list = new List<int>(); foreach (CardInfo card in cards) { list.Add(Cards.instance.GetCardID(card)); } return ShowImmediate(playerID, list.ToArray(), duration); } public IEnumerator ShowImmediate(Player player, CardInfo[] cards, float? duration = null) { List<int> list = new List<int>(); foreach (CardInfo card in cards) { list.Add(Cards.instance.GetCardID(card)); } return ShowImmediate(player.playerID, list.ToArray(), duration); } public IEnumerator ShowImmediate(Player player, int cardID) { return ShowImmediate(player, cardID, null); } public IEnumerator ShowImmediate(Player player, CardInfo card) { return ShowImmediate(player, card, null); } public IEnumerator ShowImmediate(int playerID, CardInfo card) { return ShowImmediate(playerID, card, null); } public IEnumerator ShowImmediate(Player player, int[] cardIDs) { return ShowImmediate(player, cardIDs, null); } public IEnumerator ShowImmediate(int playerID, CardInfo[] cards) { return ShowImmediate(playerID, cards, null); } public IEnumerator ShowImmediate(Player player, CardInfo[] cards) { return ShowImmediate(player, cards, null); } public IEnumerator ShowImmediate(int playerID, int[] cardIDs, float? duration = null) { float displayDuration = duration ?? CardBarUtils.displayDuration; Color orig = HighlightCardBar(playerID); foreach (int cardID in cardIDs) { ShowCard(playerID, cardID); yield return (object)new WaitForSecondsRealtime(displayDuration); HideCard(playerID); } UnhighlightCardBar(playerID, orig); } public void ClearCardBar(Player player) { if (PhotonNetwork.OfflineMode) { PlayersCardBar(player).ClearBar(); } else if (PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(CardBarUtils), "RPCA_ClearCardBar", new object[1] { player.playerID }); } } [UnboundRPC] private static void RPCA_ClearCardBar(int playerID) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Player val = (Player)ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "GetPlayerWithID", new object[1] { playerID }); instance.PlayersCardBar(val.playerID).ClearBar(); } } public class DictionaryOfLists<TKey, TListValue> : Dictionary<TKey, List<TListValue>> { public new List<TListValue> this[TKey key] { get { List<TListValue> value; return TryGetValue(key, out value) ? value : new List<TListValue>(); } set { base[key] = value; } } } public sealed class Cards { public enum SelectionType { All, Oldest, Newest, Random } public static readonly Cards instance = new Cards(); private static readonly Random rng = new Random(); private List<CardInfo> hiddenCards = new List<CardInfo>(); private List<Action<Player, CardInfo, int>> removalCallbacks = new List<Action<Player, CardInfo, int>>(); private List<Func<Player, CardInfo, bool>> cardValidationFunctions = new List<Func<Player, CardInfo, bool>>(); public static List<CardInfo> active { get { return ((ObservableCollection<CardInfo>)typeof(CardManager).GetField("activeCards", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).ToList(); } set { } } public static List<CardInfo> inactive { get { return (List<CardInfo>)typeof(CardManager).GetField("inactiveCards", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); } set { } } public static List<CardInfo> all { get { return active.Concat(inactive).ToList(); } set { } } public ReadOnlyCollection<CardInfo> HiddenCards => new ReadOnlyCollection<CardInfo>(hiddenCards); private List<CardInfo> allCards => ((ObservableCollection<CardInfo>)typeof(CardManager).GetField("activeCards", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).ToList().Concat((List<CardInfo>)typeof(CardManager).GetField("inactiveCards", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).Concat(hiddenCards) .ToList(); private List<CardInfo> ACTIVEANDHIDDENCARDS { get { return activeCards.ToList().Concat(hiddenCards).ToList(); } set { } } private CardInfo[] activeCards => CardChoice.instance.cards; private Cards() { } public void AddOnRemoveCallback(Action<Player, CardInfo, int> callback) { removalCallbacks.Add(callback); } public void AddCardToPlayer(Player player, CardInfo card, bool reassign = false, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f) { AddCardToPlayer(player, card, reassign, twoLetterCode, forceDisplay, forceDisplayDelay, addToCardBar: true); } public void AddCardToPlayer(Player player, CardInfo card, bool reassign = false, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f, bool addToCardBar = true) { if ((Object)(object)card == (Object)null) { return; } if (PhotonNetwork.OfflineMode) { ApplyCardStats componentInChildren = ((Component)card).gameObject.GetComponentInChildren<ApplyCardStats>(); typeof(ApplyCardStats).InvokeMember("Start", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, componentInChildren, new object[0]); ((Component)componentInChildren).GetComponent<CardInfo>().sourceCard = card; Traverse.Create((object)componentInChildren).Field("playerToUpgrade").SetValue((object)player); if (reassign && (Object)(object)((Component)card).GetComponent<CustomCard>() != (Object)null) { try { Gun component = ((Component)((Component)player).GetComponent<Holding>().holdable).GetComponent<Gun>(); CharacterData component2 = ((Component)player).GetComponent<CharacterData>(); HealthHandler component3 = ((Component)player).GetComponent<HealthHandler>(); Gravity component4 = ((Component)player).GetComponent<Gravity>(); Block component5 = ((Component)player).GetComponent<Block>(); GunAmmo componentInChildren2 = ((Component)component).GetComponentInChildren<GunAmmo>(); CharacterStatModifiers component6 = ((Component)player).GetComponent<CharacterStatModifiers>(); ((Component)card).GetComponent<CustomCard>().OnReassignCard(player, component, componentInChildren2, component2, component3, component4, component5, component6); } catch (NotImplementedException) { } catch (Exception ex2) { Debug.LogError((object)("[ModdingUtils] EXCEPTION: " + ex2.GetType().ToString() + "\nThrown by: " + ((Component)card).GetComponent<CustomCard>().GetModName() + " - " + card.cardName + " - OnReassignCard(Player, Gun, GunAmmo, HealthHandler, Gravity, Block, CharacterStatModifiers)")); } } if (!reassign || card.GetAdditionalData().canBeReassigned) { typeof(ApplyCardStats).InvokeMember("ApplyStats", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, componentInChildren, new object[0]); } else { player.data.currentCards.Add(card); } if (addToCardBar) { SilentAddToCardBar(player.playerID, ((Component)componentInChildren).GetComponent<CardInfo>().sourceCard, twoLetterCode, forceDisplay, forceDisplayDelay); } } else if (PhotonNetwork.IsMasterClient) { if (addToCardBar) { NetworkingManager.RPC(typeof(Cards), "RPCA_AssignCard", new object[6] { ((Object)card).name, player.playerID, reassign, twoLetterCode, forceDisplay, forceDisplayDelay }); } else { NetworkingManager.RPC(typeof(Cards), "RPCA_AssignCardWithoutCardBar", new object[6] { ((Object)card).name, player.playerID, reassign, twoLetterCode, forceDisplay, forceDisplayDelay }); } } } public void AddCardsToPlayer(Player player, CardInfo[] cards, bool reassign = false, string[] twoLetterCodes = null, float[] forceDisplays = null, float[] forceDisplayDelays = null) { AddCardsToPlayer(player, cards, reassign, twoLetterCodes, forceDisplays, forceDisplayDelays, addToCardBar: true); } public void AddCardsToPlayer(Player player, CardInfo[] cards, bool reassign = false, string[] twoLetterCodes = null, float[] forceDisplays = null, float[] forceDisplayDelays = null, bool addToCardBar = true) { bool[] array = new bool[cards.Length]; for (int i = 0; i < cards.Length; i++) { array[i] = reassign; } AddCardsToPlayer(player, cards, array, twoLetterCodes, forceDisplays, forceDisplayDelays, addToCardBar); } public void AddCardsToPlayer(Player player, CardInfo[] cards, bool[] reassigns = null, string[] twoLetterCodes = null, float[] forceDisplays = null, float[] forceDisplayDelays = null) { AddCardsToPlayer(player, cards, reassigns, twoLetterCodes, forceDisplays, forceDisplayDelays, addToCardBar: true); } public void AddCardsToPlayer(Player player, CardInfo[] cards, bool[] reassigns = null, string[] twoLetterCodes = null, float[] forceDisplays = null, float[] forceDisplayDelays = null, bool addToCardBar = true) { if (reassigns == null) { reassigns = new bool[cards.Length]; for (int i = 0; i < reassigns.Length; i++) { reassigns[i] = false; } } if (twoLetterCodes == null) { twoLetterCodes = new string[cards.Length]; for (int j = 0; j < twoLetterCodes.Length; j++) { twoLetterCodes[j] = ""; } } if (forceDisplays == null) { forceDisplays = new float[cards.Length]; for (int k = 0; k < forceDisplays.Length; k++) { forceDisplays[k] = 0f; } } if (forceDisplayDelays == null) { forceDisplayDelays = new float[cards.Length]; for (int l = 0; l < forceDisplayDelays.Length; l++) { forceDisplayDelays[l] = 0f; } } for (int m = 0; m < cards.Length; m++) { AddCardToPlayer(player, cards[m], reassigns[m], twoLetterCodes[m], forceDisplays[m], forceDisplayDelays[m], addToCardBar); } } public CardInfo[] RemoveCardsFromPlayer(Player player, int[] indeces) { return RemoveCardsFromPlayer(player, indeces, editCardBar: true); } public CardInfo[] RemoveCardsFromPlayer(Player player, int[] indeces, bool editCardBar = true) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo currentCard in player.data.currentCards) { list.Add(currentCard); } List<CardInfo> newCards = new List<CardInfo>(); for (int i = 0; i < list.Count; i++) { if (!indeces.Contains(i)) { newCards.Add(list[i]); } } RemoveAllCardsFromPlayer(player); ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Unbound.Instance, 0.1f, (Action)delegate { if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } AddCardsToPlayer(player, newCards.ToArray(), reassign: true, null, null, null, editCardBar); }); foreach (Action<Player, CardInfo, int> removalCallback in removalCallbacks) { foreach (int num in indeces) { try { removalCallback(player, list[num], num); } catch { } } } return list.Except(newCards).ToArray(); } public int RemoveCardsFromPlayer(Player player, CardInfo[] cards, SelectionType selectType = SelectionType.All) { return RemoveCardsFromPlayer(player, cards, selectType, editCardBar: true); } public int RemoveCardsFromPlayer(Player player, CardInfo[] cards, SelectionType selectType = SelectionType.All, bool editCardBar = true) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo currentCard in player.data.currentCards) { list.Add(currentCard); } List<int> list2 = new List<int>(); foreach (CardInfo card in cards) { List<int> list3 = (from idx in Enumerable.Range(0, player.data.currentCards.Count) where ((Object)player.data.currentCards[idx]).name == ((Object)card).name select idx).ToList(); int num = 0; int num2 = list3.Count; switch (selectType) { case SelectionType.All: num = 0; num2 = list3.Count; break; case SelectionType.Newest: num = list3.Count - 1; num2 = num + 1; break; case SelectionType.Oldest: num = 0; num2 = num + 1; break; case SelectionType.Random: num = rng.Next(0, list3.Count); num2 = num + 1; break; } for (int j = num; j < num2; j++) { list2.Add(list3[j]); } } List<CardInfo> newCards = new List<CardInfo>(); for (int k = 0; k < list.Count; k++) { if (!list2.Contains(k)) { newCards.Add(list[k]); } } RemoveAllCardsFromPlayer(player, clearBar: false); ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Unbound.Instance, 0.1f, (Action)delegate { if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } AddCardsToPlayer(player, newCards.ToArray(), reassign: true, null, null, null, editCardBar); }); foreach (Action<Player, CardInfo, int> removalCallback in removalCallbacks) { foreach (int item in list2) { try { removalCallback(player, list[item], item); } catch { } } } return list2.Count; } public CardInfo RemoveCardFromPlayer(Player player, int idx) { return RemoveCardFromPlayer(player, idx, editCardBar: true); } public CardInfo RemoveCardFromPlayer(Player player, int idx, bool editCardBar) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo currentCard in player.data.currentCards) { list.Add(currentCard); } List<CardInfo> newCards = new List<CardInfo>(); for (int i = 0; i < list.Count; i++) { if (i != idx) { newCards.Add(list[i]); } } RemoveAllCardsFromPlayer(player); ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Unbound.Instance, 0.1f, (Action)delegate { if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } AddCardsToPlayer(player, newCards.ToArray(), reassign: true, null, null, null, editCardBar); }); foreach (Action<Player, CardInfo, int> removalCallback in removalCallbacks) { try { removalCallback(player, list[idx], idx); } catch { } } return list[idx]; } public int RemoveCardFromPlayer(Player player, CardInfo card, SelectionType selectType = SelectionType.All) { return RemoveCardFromPlayer(player, card, selectType, editCardBar: true); } public int RemoveCardFromPlayer(Player player, CardInfo card, SelectionType selectType = SelectionType.All, bool editCardBar = true) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo currentCard in player.data.currentCards) { list.Add(currentCard); } List<int> list2 = (from idx in Enumerable.Range(0, player.data.currentCards.Count) where ((Object)player.data.currentCards[idx]).name == ((Object)card).name select idx).ToList(); int num = 0; int num2 = list2.Count; switch (selectType) { case SelectionType.All: num = 0; num2 = list2.Count; break; case SelectionType.Newest: num = list2.Count - 1; num2 = num + 1; break; case SelectionType.Oldest: num = 0; num2 = 1; break; case SelectionType.Random: num = rng.Next(0, list2.Count); num2 = num + 1; break; } List<int> list3 = new List<int>(); for (int i = num; i < num2; i++) { list3.Add(list2[i]); } List<CardInfo> newCards = new List<CardInfo>(); for (int j = 0; j < list.Count; j++) { if (!list3.Contains(j)) { newCards.Add(list[j]); } } RemoveAllCardsFromPlayer(player, clearBar: false); ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Unbound.Instance, 0.1f, (Action)delegate { if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } AddCardsToPlayer(player, newCards.ToArray(), reassign: true, null, null, null, editCardBar); }); foreach (Action<Player, CardInfo, int> removalCallback in removalCallbacks) { foreach (int item in list3) { try { removalCallback(player, list[item], item); } catch { } } } return list3.Count; } public CardInfo[] RemoveAllCardsFromPlayer(Player player, bool clearBar = true) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo currentCard in player.data.currentCards) { list.Add(currentCard); } if (PhotonNetwork.OfflineMode) { typeof(Player).InvokeMember("FullReset", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, player, new object[0]); if (clearBar) { CardBarUtils.instance.ClearCardBar(player); } } else if (PhotonNetwork.IsMasterClient) { NetworkingManager.RPC(typeof(Cards), "RPCA_FullReset", new object[1] { player.playerID }); if (clearBar) { CardBarUtils.instance.ClearCardBar(player); } } return list.ToArray(); } public IEnumerator ReplaceCard(Player player, int idx, CardInfo newCard, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f) { yield return ReplaceCard(player, idx, newCard, twoLetterCode, forceDisplay, forceDisplayDelay, editCardBar: true); } public IEnumerator ReplaceCard(Player player, int idx, CardInfo newCard, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f, bool editCardBar = true) { if ((Object)(object)newCard == (Object)null) { yield break; } List<string> twoLetterCodes = new List<string>(); List<float> forceDisplays = new List<float>(); List<float> forceDisplayDelays = new List<float>(); List<bool> reassigns = new List<bool>(); List<CardInfo> originalCards = new List<CardInfo>(); foreach (CardInfo origCard in player.data.currentCards) { originalCards.Add(origCard); } List<CardInfo> newCards = new List<CardInfo>(); for (int j = 0; j < originalCards.Count; j++) { if (j != idx) { newCards.Add(originalCards[j]); twoLetterCodes.Add(""); forceDisplays.Add(0f); forceDisplayDelays.Add(0f); reassigns.Add(item: true); } else { newCards.Add(newCard); twoLetterCodes.Add(twoLetterCode); forceDisplays.Add(forceDisplay); forceDisplayDelays.Add(forceDisplayDelay); reassigns.Add(item: false); } } RemoveAllCardsFromPlayer(player, editCardBar); for (int i = 0; i < 20; i++) { yield return null; } if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } yield return null; AddCardsToPlayer(player, newCards.ToArray(), reassigns.ToArray(), twoLetterCodes.ToArray(), forceDisplays.ToArray(), forceDisplayDelays.ToArray(), editCardBar); } public IEnumerator ReplaceCards(Player player, int[] indeces, CardInfo[] newCards, string[] twoLetterCodes = null) { yield return ReplaceCards(player, indeces, newCards, twoLetterCodes, editCardBar: true); } public IEnumerator ReplaceCards(Player player, int[] indeces, CardInfo[] newCards, string[] twoLetterCodes = null, bool editCardBar = true) { if (twoLetterCodes == null) { twoLetterCodes = new string[indeces.Length]; for (int k = 0; k < twoLetterCodes.Length; k++) { twoLetterCodes[k] = ""; } } List<CardInfo> originalCards = new List<CardInfo>(); foreach (CardInfo origCard in player.data.currentCards) { originalCards.Add(origCard); } List<CardInfo> newCardsToAssign = new List<CardInfo>(); List<string> twoLetterCodesToAssign = new List<string>(); List<bool> reassigns = new List<bool>(); int l = 0; for (int j = 0; j < originalCards.Count; j++) { if (!indeces.Contains(j)) { newCardsToAssign.Add(originalCards[j]); twoLetterCodesToAssign.Add(""); reassigns.Add(item: true); } else if ((Object)(object)newCards[l] == (Object)null) { newCardsToAssign.Add(originalCards[j]); twoLetterCodesToAssign.Add(""); reassigns.Add(item: true); l++; } else { newCardsToAssign.Add(newCards[l]); twoLetterCodesToAssign.Add(twoLetterCodes[l]); reassigns.Add(item: false); l++; } } RemoveAllCardsFromPlayer(player, editCardBar); for (int i = 0; i < 20; i++) { yield return null; } if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } yield return null; AddCardsToPlayer(player, newCardsToAssign.ToArray(), reassigns.ToArray(), twoLetterCodesToAssign.ToArray(), null, null, editCardBar); } public IEnumerator ReplaceCard(Player player, CardInfo cardToReplace, CardInfo newCard, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f, SelectionType selectType = SelectionType.All) { yield return ReplaceCard(player, cardToReplace, newCard, twoLetterCode, forceDisplay, forceDisplayDelay, selectType, editCardBar: true); } public IEnumerator ReplaceCard(Player player, CardInfo cardToReplace, CardInfo newCard, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f, SelectionType selectType = SelectionType.All, bool editCardBar = true) { if ((Object)(object)newCard == (Object)null) { yield break; } List<string> twoLetterCodes = new List<string>(); List<float> forceDisplays = new List<float>(); List<float> forceDisplayDelays = new List<float>(); List<bool> reassigns = new List<bool>(); List<CardInfo> originalCards = new List<CardInfo>(); foreach (CardInfo origCard in player.data.currentCards) { originalCards.Add(origCard); } List<int> indeces = (from idx in Enumerable.Range(0, player.data.currentCards.Count) where ((Object)player.data.currentCards[idx]).name == ((Object)cardToReplace).name select idx).ToList(); int start = 0; int end = indeces.Count; switch (selectType) { case SelectionType.All: start = 0; end = indeces.Count; break; case SelectionType.Newest: start = indeces.Count - 1; end = start + 1; break; case SelectionType.Oldest: start = 0; end = 1; break; case SelectionType.Random: start = rng.Next(0, indeces.Count); end = start + 1; break; } List<int> indecesToReplace = new List<int>(); for (int k = start; k < end; k++) { indecesToReplace.Add(indeces[k]); } List<CardInfo> newCards = new List<CardInfo>(); for (int j = 0; j < originalCards.Count; j++) { if (!indecesToReplace.Contains(j)) { newCards.Add(originalCards[j]); twoLetterCodes.Add(""); forceDisplays.Add(0f); forceDisplayDelays.Add(0f); reassigns.Add(item: true); } else { newCards.Add(newCard); twoLetterCodes.Add(twoLetterCode); forceDisplays.Add(forceDisplay); forceDisplayDelays.Add(forceDisplayDelay); reassigns.Add(item: false); } } RemoveAllCardsFromPlayer(player, editCardBar); for (int i = 0; i < 20; i++) { yield return null; } if (editCardBar) { CardBarUtils.instance.ClearCardBar(player); } yield return null; AddCardsToPlayer(player, newCards.ToArray(), reassigns.ToArray(), twoLetterCodes.ToArray(), forceDisplays.ToArray(), forceDisplayDelays.ToArray(), editCardBar); } [UnboundRPC] internal static void RPCA_AssignCard(string cardObjectName, int playerID, bool reassign, string twoLetterCode, float forceDisplay, float forceDisplayDelay) { RPCA_AssignCard(cardObjectName, playerID, reassign, twoLetterCode, forceDisplay, forceDisplayDelay, addToCardBar: true); } [UnboundRPC] internal static void RPCA_AssignCard(string cardObjectName, int playerID, bool reassign, string twoLetterCode, float forceDisplay, float forceDisplayDelay, bool addToCardBar) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown CardInfo cardWithObjectName = instance.GetCardWithObjectName(cardObjectName); ApplyCardStats componentInChildren = ((Component)cardWithObjectName).gameObject.GetComponentInChildren<ApplyCardStats>(); typeof(ApplyCardStats).InvokeMember("Start", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, componentInChildren, new object[0]); ((Component)componentInChildren).GetComponent<CardInfo>().sourceCard = cardWithObjectName; Player val = (Player)ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "GetPlayerWithID", new object[1] { playerID }); Traverse.Create((object)componentInChildren).Field("playerToUpgrade").SetValue((object)val); if (reassign && (Object)(object)((Component)cardWithObjectName).GetComponent<CustomCard>() != (Object)null) { try { Gun component = ((Component)((Component)val).GetComponent<Holding>().holdable).GetComponent<Gun>(); CharacterData component2 = ((Component)val).GetComponent<CharacterData>(); HealthHandler component3 = ((Component)val).GetComponent<HealthHandler>(); Gravity component4 = ((Component)val).GetComponent<Gravity>(); Block component5 = ((Component)val).GetComponent<Block>(); GunAmmo componentInChildren2 = ((Component)component).GetComponentInChildren<GunAmmo>(); CharacterStatModifiers component6 = ((Component)val).GetComponent<CharacterStatModifiers>(); ((Component)cardWithObjectName).GetComponent<CustomCard>().OnReassignCard(val, component, componentInChildren2, component2, component3, component4, component5, component6); } catch (NotImplementedException) { } catch (Exception ex2) { Debug.LogError((object)("[ModdingUtils] EXCEPTION: " + ex2.GetType().ToString() + "\nThrown by: " + ((Component)cardWithObjectName).GetComponent<CustomCard>().GetModName() + " - " + cardWithObjectName.cardName + " - OnReassignCard(Player, Gun, GunAmmo, HealthHandler, Gravity, Block, CharacterStatModifiers)")); } } if (!reassign || cardWithObjectName.GetAdditionalData().canBeReassigned) { typeof(ApplyCardStats).InvokeMember("ApplyStats", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, componentInChildren, new object[0]); } else { val.data.currentCards.Add(cardWithObjectName); } if (addToCardBar) { SilentAddToCardBar(val.playerID, ((Component)componentInChildren).GetComponent<CardInfo>().sourceCard, twoLetterCode, forceDisplay, forceDisplayDelay); } } [UnboundRPC] internal static void RPCA_AssignCardWithoutCardBar(string cardObjectName, int playerID, bool reassign, string twoLetterCode, float forceDisplay, float forceDisplayDelay) { RPCA_AssignCard(cardObjectName, playerID, reassign, twoLetterCode, forceDisplay, forceDisplayDelay, addToCardBar: false); } [UnboundRPC] public static void RPCA_FullReset(int playerID) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Player target = (Player)ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "GetPlayerWithID", new object[1] { playerID }); typeof(Player).InvokeMember("FullReset", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, target, new object[0]); } [UnboundRPC] public static void RPCA_ClearCardBar(int playerID) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown CardBar[] array = (CardBar[])Traverse.Create((object)CardBarHandler.instance).Field("cardBars").GetValue(); Player val = (Player)ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "GetPlayerWithID", new object[1] { playerID }); array[val.playerID].ClearBar(); } public bool CardIsUniqueFromCards(CardInfo card, CardInfo[] cards) { if ((Object)(object)card == (Object)null) { return false; } bool result = true; foreach (CardInfo val in cards) { if (((Object)card).name == ((Object)val).name) { result = false; } } return result; } public bool CardIsNotBlacklisted(CardInfo card, CardCategory[] blacklistedCategories) { if ((Object)(object)card == (Object)null) { return false; } bool flag = card.categories.Intersect(blacklistedCategories).Any(); return !flag; } public bool CardDoesNotConflictWithCardsCategories(CardInfo card, CardInfo[] cards) { if ((Object)(object)card == (Object)null) { return false; } bool flag = false; if (cards.Length == 0) { return !flag; } foreach (CardInfo val in cards) { if (card.categories != null && val.blacklistedCategories != null && card.categories.Intersect(val.blacklistedCategories).Any()) { flag = true; } } return !flag; } public bool CardDoesNotConflictWithCards(CardInfo card, CardInfo[] cards) { if ((Object)(object)card == (Object)null) { return false; } bool flag = false; if (cards.Length == 0) { return !flag; } foreach (CardInfo val in cards) { if (card.categories != null && val.blacklistedCategories != null && card.categories.Intersect(val.blacklistedCategories).Any()) { flag = true; } } return !flag && (card.allowMultiple || cards.All((CardInfo cardinfo) => ((Object)cardinfo).name != ((Object)card).name)); } public bool PlayerIsAllowedCard(Player player, CardInfo card) { if ((Object)(object)card == (Object)null) { return false; } if ((Object)(object)player == (Object)null) { return true; } bool flag = false; foreach (CardInfo currentCard in player.data.currentCards) { if (card.categories.Intersect(currentCard.blacklistedCategories).Any()) { flag = true; } } if (card.categories.Intersect(player.data.stats.GetAdditionalData().blacklistedCategories).Any()) { flag = true; } bool flag2 = true; if (cardValidationFunctions.Count > 0) { flag2 = !cardValidationFunctions.Any(delegate(Func<Player, CardInfo, bool> f) { bool flag3 = true; try { flag3 = f(player, card); } catch (Exception ex) { flag3 = true; Debug.LogError((object)"Card Validation Function threw an error, returning true instead. See Log below for details."); Debug.LogException(ex); } return !flag3; }); } return !flag && (card.allowMultiple || player.data.currentCards.All((CardInfo cardinfo) => ((Object)((Component)cardinfo).gameObject).name != ((Object)((Component)card).gameObject).name)) && flag2; } public void AddCardValidationFunction(Func<Player, CardInfo, bool> function) { cardValidationFunctions.Add(function); } public int CountPlayerCardsWithCondition(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition) { return GetPlayerCardsWithCondition(player, gun, gunAmmo, data, health, gravity, block, characterStats, condition).Length; } public CardInfo[] GetPlayerCardsWithCondition(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition) { if (player?.data?.currentCards == null) { return (CardInfo[])(object)new CardInfo[0]; } return player.data.currentCards.Where((CardInfo cardinfo) => condition(cardinfo, player, gun, gunAmmo, data, health, gravity, block, characterStats)).ToArray(); } public int NORARITY_GetRandomCardIDWithCondition(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition, int maxattempts = 1000) { CardInfo val = NORARITY_GetRandomCardWithCondition(player, gun, gunAmmo, data, health, gravity, block, characterStats, condition, maxattempts); if ((Object)(object)val != (Object)null) { return GetCardID(val); } return -1; } public CardInfo NORARITY_GetRandomCardWithCondition(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition, int maxattempts = 1000) { CardInfo[] array = activeCards.Where((CardInfo card) => condition(card, player, gun, gunAmmo, data, health, gravity, block, characterStats) && PlayerIsAllowedCard(player, card)).ToArray(); if (array.Length == 0) { return null; } int num = rng.Next(0, array.Length); return array[num]; } public CardInfo NORARITY_DrawRandomCardWithCondition(CardInfo[] cardsToDrawFrom, Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition, int maxattempts = 1000) { cardsToDrawFrom = cardsToDrawFrom.Where((CardInfo card) => condition(card, player, gun, gunAmmo, data, health, gravity, block, characterStats) && PlayerIsAllowedCard(player, card)).ToArray(); if (cardsToDrawFrom.Length == 0) { return null; } int num = rng.Next(0, cardsToDrawFrom.Length); return cardsToDrawFrom[num]; } public CardInfo DrawRandomCardWithCondition(CardInfo[] cardsToDrawFrom, Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition, int maxattempts = 1000) { cardsToDrawFrom = cardsToDrawFrom.Where((CardInfo card) => condition(card, player, gun, gunAmmo, data, health, gravity, block, characterStats) && PlayerIsAllowedCard(player, card)).ToArray(); if (cardsToDrawFrom.Length == 0) { return null; } return CardChoicePatchGetRanomCard.OrignialGetRanomCard(cardsToDrawFrom).GetComponent<CardInfo>(); } public CardInfo GetRandomCardWithCondition(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats, Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool> condition, int maxattempts = 1000) { CardInfo[] array = activeCards.Where((CardInfo card) => condition(card, player, gun, gunAmmo, data, health, gravity, block, characterStats) && PlayerIsAllowedCard(player, card)).ToArray(); if (array.Length == 0) { return null; } return CardChoicePatchGetRanomCard.OrignialGetRanomCard(array).GetComponent<CardInfo>(); } [Obsolete("GetCardID(string) is deprecated, use GetCardIDFromObjectName(string) instead.")] public int GetCardID(string cardName) { try { return (from card in allCards where card.cardName == cardName select GetCardID(card)).First(); } catch { return -1; } } public int GetCardIDFromObjectName(string objectName) { try { return (from card in allCards where ((Object)card).name == objectName select GetCardID(card)).First(); } catch { return -1; } } public int GetCardID(CardInfo card) { return Array.IndexOf(allCards.ToArray(), card); } public CardInfo GetCardWithID(int cardID) { try { return allCards[cardID]; } catch { return null; } } [Obsolete("GetCardWithName is deprecated since multiple cards can have the same cardName. Use GetCardWithObjectName instead and provided the desired Card's .name field.")] public CardInfo GetCardWithName(string cardName) { return allCards.Where((CardInfo card) => card.cardName == cardName).First(); } public CardInfo GetCardWithObjectName(string name) { CardInfo val = allCards.Where((CardInfo card) => ((Object)card).name == name).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)val)) { val = HiddenCards.Where((CardInfo card) => ((Object)card).name == name).FirstOrDefault(); } return val; } public CardInfo[] GetAllCardsWithCondition(CardChoice cardChoice, Player player, Func<CardInfo, Player, bool> condition) { List<CardInfo> list = new List<CardInfo>(); CardInfo[] cards = cardChoice.cards; foreach (CardInfo val in cards) { if (condition(val, player)) { list.Add(val); } } return list.ToArray(); } public CardInfo[] GetAllCardsWithCondition(CardInfo[] cards, Player player, Func<CardInfo, Player, bool> condition) { List<CardInfo> list = new List<CardInfo>(); foreach (CardInfo val in cards) { if (condition(val, player)) { list.Add(val); } } return list.ToArray(); } public static void SilentAddToCardBar(int playerID, CardInfo card, string twoLetterCode = "", float forceDisplay = 0f, float forceDisplayDelay = 0f) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) CardBar[] array = (CardBar[])Traverse.Create((object)CardBarHandler.instance).Field("cardBars").GetValue(); Traverse.Create((object)array[playerID]).Field("ci").SetValue((object)card); GameObject val = (GameObject)Traverse.Create((object)array[playerID]).Field("source").GetValue(); GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.position, val.transform.rotation, val.transform.parent); val2.transform.localScale = Vector3.one; string text = card.cardName; if (twoLetterCode != "") { text = twoLetterCode; } text = text.Substring(0, 2); string text2 = text[0].ToString().ToUpper(); if (text.Length > 1) { string text3 = text[1].ToString().ToLower(); text = text2 + text3; } else { text = text2; } ((TMP_Text)val2.GetComponentInChildren<TextMeshProUGUI>()).text = text; Traverse.Create((object)val2.GetComponent<CardBarButton>()).Field("card").SetValue((object)card); val2.gameObject.SetActive(true); } public void AddHiddenCard(CardInfo card) { hiddenCards.Add(card); } } public static class FindPlayer { public static Player GetPlayerWithActorAndPlayerIDs(int actorID, int playerID) { Player result = null; foreach (Player player in PlayerManager.instance.players) { if (player.data.view.ControllerActorNr == actorID && player.playerID == playerID) { result = player; break; } } return result; } } public static class PlayerStatus { public static bool PlayerAlive(Player player) { return !player.data.dead; } public static bool PlayerSimulated(Player player) { return (bool)Traverse.Create((object)player.data.playerVel).Field("simulated").GetValue(); } public static bool PlayerAliveAndSimulated(Player player) { return PlayerAlive(player) && PlayerSimulated(player); } public static int GetNumberOfEnemyPlayers(Player player) { int num = 0; foreach (Player player2 in PlayerManager.instance.players) { if (player2.teamID != player.teamID) { num++; } } return num; } public static List<Player> GetEnemyPlayers(Player player) { List<Player> list = new List<Player>(); foreach (Player player2 in PlayerManager.instance.players) { if (player2.teamID != player.teamID) { list.Add(player2); } } return list; } public static Player GetRandomEnemyPlayer(Player player) { List<Player> enemyPlayers = GetEnemyPlayers(player); if (GetNumberOfEnemyPlayers(player) == 0) { return null; } return enemyPlayers[Random.Range(0, GetNumberOfEnemyPlayers(player))]; } public static List<Player> GetOtherPlayers(Player player) { List<Player> list = new List<Player>(); foreach (Player player2 in PlayerManager.instance.players) { if (player2.playerID != player.playerID) { list.Add(player2); } } return list; } } public class SortingController : MonoBehaviour { public enum Layer { Default, Background, UI, Map, Card, Player1, Player2, Player3, Player4, Player5, Player6, Player7, Player8, Player9, Player10, Front, MapParticle, MostFront } [SerializeField] private Layer sortingLayer; [SerializeField] private int sortingOrder = 0; [SerializeField] private Renderer[] objectToSet; private void Start() { Renderer[] array = objectToSet; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null)) { val.sortingLayerName = sortingLayer.ToString(); val.sortingOrder = sortingOrder; } } } } } namespace ModdingUtils.RoundsEffects { public class GravityDealtDamageEffect : HitEffect { public override void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer = null) { if (!((Object)(object)damagedPlayer == (Object)null)) { GravityEffect orAddComponent = ExtensionMethods.GetOrAddComponent<GravityEffect>(((Component)damagedPlayer).gameObject, false); orAddComponent.SetDuration(((Component)this).GetComponent<CharacterStatModifiers>().GetAdditionalData().gravityDurationOnDoDamage); orAddComponent.SetGravityForceMultiplier(((Component)this).GetComponent<CharacterStatModifiers>().GetAdditionalData().gravityMultiplierOnDoDamage); orAddComponent.ResetTimer(); if (((Component)this).GetComponent<CharacterStatModifiers>().GetAdditionalData().gravityMultiplierOnDoDamage < 0f && damagedPlayer.data.isGrounded) { damagedPlayer.data.jump.Jump(true, 1f / damagedPlayer.data.stats.jump); CharacterData data = damagedPlayer.data; data.currentJumps++; } } } } public abstract class HitEffect : MonoBehaviour { public abstract void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer = null); public void Destroy() { Object.Destroy((Object)(object)this); } } public abstract class HitSurfaceEffect : MonoBehaviour { public abstract void Hit(Vector2 position, Vector2 normal, Vector2 velocity); public void Destroy() { Object.Destroy((Object)(object)this); } } public abstract class WasHitEffect : MonoBehaviour { public abstract void WasDealtDamage(Vector2 damage, bool selfDamage); public void Destroy() { Object.Destroy((Object)(object)this); } } } namespace ModdingUtils.Patches { [HarmonyPatch(typeof(ApplyCardStats))] internal class CheckBulletsAfterGettingCards { [HarmonyPostfix] [HarmonyPatch("CopyGunStats")] private static void StopStackingObjectsToSpawn(ApplyCardStats __instance, Gun copyFromGun, Gun copyToGun) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown List<ObjectsToSpawn> list = new List<ObjectsToSpawn>(); ObjectsToSpawn[] objectsToSpawn = copyToGun.objectsToSpawn; foreach (ObjectsToSpawn val in objectsToSpawn) { if (copyFromGun.objectsToSpawn.Contains(val)) { ObjectsToSpawn val2 = new ObjectsToSpawn(); int stacks = 0; if (val.stacks > 0) { stacks = val.stacks; val.stacks = 0; } CopyObjectsToSpawn(val2, val); val2.stacks = stacks; list.Add(val2); } else { list.Add(val); } } copyToGun.objectsToSpawn = list.ToArray(); } private static void CopyObjectsToSpawn(ObjectsToSpawn to, ObjectsToSpawn from) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) to.effect = from.effect; to.direction = from.direction; to.spawnOn = from.spawnOn; to.spawnAsChild = from.spawnAsChild; to.numberOfSpawns = from.numberOfSpawns; to.normalOffset = from.normalOffset; to.stickToBigTargets = from.stickToBigTargets; to.stickToAllTargets = from.stickToAllTargets; to.zeroZ = from.zeroZ; to.AddToProjectile = from.AddToProjectile; to.removeScriptsFromProjectileObject = from.removeScriptsFromProjectileObject; to.scaleStacks = from.scaleStacks; to.scaleStackM = from.scaleStackM; to.scaleFromDamage = from.scaleFromDamage; to.stacks = from.stacks; } } [Serializable] [HarmonyPatch(typeof(CardChoice), "GetRanomCard")] public class CardChoicePatchGetRanomCard { internal static bool CardChoiceSpawnUniqueCardPatch; internal static Assembly UniqueCardPatch; [HarmonyPriority(800)] private static bool Prefix(CardChoice __instance, ref GameObject __result) { __result = null; if ((bool)ExtensionMethods.GetFieldValue((object)CardChoiceVisuals.instance, "isShowinig") && (Object)(object)PickingPlayer(__instance) != (Object)null) { __result = EfficientGetRanomCard(PickingPlayer(__instance)); } else { __result = OrignialGetRanomCard(); } return true; } public static GameObject EfficientGetRanomCard(Player player) { return EfficientGetRanomCard(player, CardChoice.instance.cards); } public static GameObject EfficientGetRanomCard(Player player, CardInfo[] cards) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) CardInfo[] source = cards.Where((CardInfo c) => Cards.instance.PlayerIsAllowedCard(player, c)).ToArray(); CardInfo[] array = source.ToArray(); try { if ((bool)ExtensionMethods.GetFieldValue((object)CardChoiceVisuals.instance, "isShowinig")) { List<string> spawnedCards = ((List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards")).Select((GameObject obj) => obj.GetComponent<CardInfo>().cardName).ToList(); array = ((!CardChoiceSpawnUniqueCardPatch) ? source.Where((CardInfo c) => !spawnedCards.Contains(c.cardName)).ToArray() : source.Where((CardInfo c) => c.categories.Contains(ExtensionMethods.GetFieldValue((object)UniqueCardPatch.GetType("CustomCardCategories"), "CanDrawMultipleCategory")) || !spawnedCards.Contains(c.cardName)).ToArray()); } } catch (NullReferenceException) { array = source.ToArray(); } if (!array.Any()) { if (CardChoiceSpawnUniqueCardPatch) { return ((Component)(CardInfo)UniqueCardPatch.GetType("CardChoiceSpawnUniqueCardPatch").GetField("NullCard", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).gameObject; } return ((Component)((IEnumerable<CardInfo>)CardChoice.instance.cards).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => c.cardName.ToLower() == "huge"))).gameObject; } return OrignialGetRanomCard(array); } public static GameObject OrignialGetRanomCard() { return OrignialGetRanomCard(CardChoice.instance.cards); } public static GameObject OrignialGetRanomCard(CardInfo[] cards) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Invalid comparison between Unknown and I4 GameObject result = null; float num = 0f; for (int i = 0; i < cards.Length; i++) { if ((int)cards[i].rarity == 0) { num += 10f; } if ((int)cards[i].rarity == 1) { num += 4f; } if ((int)cards[i].rarity == 2) { num += 1f; } } float num2 = Random.Range(0f, num); for (int j = 0; j < cards.Length; j++) { if ((int)cards[j].rarity == 0) { num2 -= 10f; } if ((int)cards[j].rarity == 1) { num2 -= 4f; } if ((int)cards[j].rarity == 2) { num2 -= 1f; } if (num2 <= 0f) { result = ((Component)cards[j]).gameObject; break; } } return result; } internal static Player PickingPlayer(CardChoice cardChoice) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 Player val = null; try { if ((int)(PickerType)ExtensionMethods.GetFieldValue((object)cardChoice, "pickerType") == 0) { return PlayerManager.instance.GetPlayersInTeam(cardChoice.pickrID).FirstOrDefault(); } return (cardChoice.pickrID < PlayerManager.instance.players.Count() && cardChoice.pickrID >= 0) ? PlayerManager.instance.players[cardChoice.pickrID] : null; } catch { return null; } } } [HarmonyPatch(typeof(CardChoice))] public class CardChoicePatchGetSourceCard { [HarmonyPostfix] [HarmonyPatch("GetSourceCard")] private static void CheckHiddenCards(CardInfo info, ref CardInfo __result) { if ((Object)(object)__result != (Object)null) { return; } CardInfo[] array = Cards.instance.HiddenCards.ToArray(); for (int i = 0; i < array.Length; i++) { if (((Object)((Component)array[i]).gameObject).name + "(Clone)" == ((Object)((Component)info).gameObject).name) { __result = array[i]; break; } } } } [HarmonyPatch(typeof(CharacterStatModifiers), "ResetStats")] internal class CharacterStatModifiers_Patch_ResetStats { private static void TryDestroy(Object obj) { if (obj != (Object)null) { Object.Destroy(obj); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo m_destroy = ExtensionMethods.GetMethodInfo(typeof(GameObject), "Destroy", new Type[1] { typeof(Object) }); MethodInfo m_tryDestroy = ExtensionMethods.GetMethodInfo(typeof(CharacterStatModifiers_Patch_ResetStats), "TryDestroy"); foreach (CodeInstruction code in instructions) { if (CodeInstructionExtensions.Calls(code, m_destroy)) { yield return new CodeInstruction(OpCodes.Call, (object)m_tryDestroy); } else { yield return code; } } } } [Serializable] [HarmonyPatch(typeof(GunAmmo), "ReloadAmmo")] internal class GunAmmoPatchReloadAmmo { private static void Postfix(GunAmmo __instance) { __instance.ReDrawTotalBullets(); } } [Serializable] [HarmonyPriority(800)] [HarmonyPatch(typeof(Player), "FullReset")] internal class PlayerPatchFullReset { private static void Prefix(Player __instance) { CustomEffects.DestroyAllEffects(((Component)__instance).gameObject); } } [Serializable] [HarmonyPatch(typeof(ProjectileHit), "Start")] internal class ProjectileHitPatchStart { private static void Prefix(ProjectileHit __instance) { __instance.GetAdditionalData().startTime = Time.time; } } [Serializable] [HarmonyPatch(typeof(ProjectileHit), "RPCA_DoHit")] internal class ProjectileHitPatchRPCA_DoHit { private static bool Prefix(ProjectileHit __instance, Vector2 hitPoint, Vector2 hitNormal, Vector2 vel, int viewID, int colliderID, bool wasBlocked, out bool __state) { __state = false; if (Time.time < __instance.GetAdditionalData().startTime + __instance.GetAdditionalData().inactiveDelay || ((Object)(object)__instance.ownPlayer != (Object)null && (Object)(object)((Component)((Component)__instance.ownPlayer).GetComponent<Holding>().holdable).GetComponent<Gun>() != (Object)null && Time.time < __instance.GetAdditionalData().startTime + ((Component)((Component)__instance.ownPlayer).GetComponent<Holding>().holdable).GetComponent<Gun>().GetAdditionalData().inactiveDelay)) { __state = false; return false; } __state = true; return true; } private static void Postfix(ProjectileHit __instance, Vector2 hitPoint, Vector2 hitNormal, Vector2 vel, int viewID, int colliderID, bool wasBlocked, bool __state) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Expected O, but got Unknown //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Invalid comparison between Unknown and I4 //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Invalid comparison between Unknown and I4 if (!__state) { return; } HitInfo val = new HitInfo(); val.point = hitPoint; val.normal = hitNormal; val.collider = null; if (viewID != -1) { PhotonView photonView = PhotonNetwork.GetPhotonView(viewID); val.collider = ((Component)photonView).GetComponentInChildren<Collider2D>(); val.transform = ((Component)photonView).transform; } else if (colliderID != -1) { val.collider = ((Component)MapManager.instance.currentMap.Map).GetComponentsInChildren<Collider2D>()[colliderID]; val.transform = ((Component)val.collider).transform; } if (Object.op_Implicit((Object)(object)val.collider) && (Object)(object)((Component)__instance).gameObject.GetComponentInChildren<StopRecursion>() == (Object)null) { HitSurfaceEffect[] hitSurfaceEffects = __instance.ownPlayer.data.stats.GetAdditionalData().HitSurfaceEffects; HitSurfaceEffect[] array = hitSurfaceEffects; foreach (HitSurfaceEffect hitSurfaceEffect in array) { hitSurfaceEffect.Hit(hitPoint, hitNormal, vel); } } HealthHandler val2 = null; if (Object.op_Implicit((Object)(object)val.transform)) { val2 = ((Component)val.transform).GetComponent<HealthHandler>(); } if ((Object)(object)val2 == (Object)null) { return; } CharacterStatModifiers component = ((Component)val2).GetComponent<CharacterStatModifiers>(); if ((Object)(object)component == (Object)null) { return; } Player ownPlayer = __instance.ownPlayer; Player player = ((CharacterData)Traverse.Create((object)component).Field("data").GetValue()).player; bool selfDamage = (Object)(object)ownPlayer != (Object)null && (Object)(object)((Component)ownPlayer).transform.root == (Object)(object)((Component)player).transform; WasHitEffect[] wasHitEffects = component.GetAdditionalData().WasHitEffects; HitEffect[] hitEffects = ownPlayer.data.stats.GetAdditionalData().HitEffects; if (!wasBlocked) { WasHitEffect[] array2 = wasHitEffects; foreach (WasHitEffect wasHitEffect in array2) { wasHitEffect.WasDealtDamage(Vector2.op_Implicit(((Component)__instance).transform.forward * __instance.damage * __instance.dealDamageMultiplierr), selfDamage); } HitEffect[] array3 = hitEffects; foreach (HitEffect hitEffect in array3) { hitEffect.DealtDamage(Vector2.op_Implicit(((Component)__instance).transform.forward * __instance.damage * __instance.dealDamageMultiplierr), selfDamage, player); } } if (!(__instance.ownPlayer.data.stats.GetAdditionalData().punch && wasBlocked)) { return; } WasHitEffect[] array4 = wasHitEffects; foreach (WasHitEffect wasHitEffect2 in array4) { wasHitEffect2.WasDealtDamage(Vector2.op_Implicit(((Component)__instance).transform.forward * __instance.damage * __instance.dealDamageMultiplierr), selfDamage); } HitEffect[] array5 = hitEffects; foreach (HitEffect hitEffect2 in array5) { hitEffect2.DealtDamage(Vector2.op_Implicit(((Component)__instance).transform.forward * __instance.damage * __instance.dealDamageMultiplierr), selfDamage, player); } if (__instance.isAllowedToSpawnObjects) { GamefeelManager.GameFeel(Vector2.op_Implicit(((Component)__instance).transform.forward * 3f * __instance.shake)); DynamicParticles.instance.PlayBulletHit(__instance.damage, ((Component)__instance).transform, val, __instance.projectileColor); for (int n = 0; n < __instance.objectsToSpawn.Length; n++) { ObjectsToSpawn.SpawnObject(((Component)__instance).transform, val, __instance.objectsToSpawn[n], val2, __instance.team, __instance.damage, (SpawnedAttack)Traverse.Create((object)__instance).Field("spawnedAttack").GetValue(), false); } ((Component)__instance).transform.position = Vector2.op_Implicit(val.point + val.normal * 0.01f); } bool flag = false; if (__instance.effects != null && __instance.effects.Count != 0) { for (int num = 0; num < __instance.effects.Count; num++) { HasToReturn val3 = __instance.effects[num].DoHitEffect(val); if ((int)val3 == 0) { flag = true; } if ((int)val3 == 2) { return; } } } if (!flag) { if ((Action)Traverse.Create((object)__instance).Field("hitAction").GetValue() != null) { ((Action)Traverse.Create((object)__instance).Field("hitAction").GetValue())(); } if ((Action<HitInfo>)Traverse.Create((object)__instance).Field("hitActionWithData").GetValue() != null) { ((Action<HitInfo>)Traverse.Create((object)__instance).Field("hitActionWithData").GetValue())(val); } ((Component)__instance).gameObject.SetActive(false); PhotonNetwork.Destroy(((Component)__instance).gameObject); } } } } namespace ModdingUtils.MonoBehaviours { public class ReversibleColorEffect : ColorEffect { private int livesToEffect = 1; private int livesEffected; public void OnEnable() { if (livesEffected >= livesToEffect) { Object.Destroy((Object)(object)this); } } public void OnDisable() { livesEffected++; if (livesEffected >= livesToEffect) { Object.Destroy((Object)(object)this); } } public void SetLivesToEffect(int lives = 1) { livesToEffect = lives; } } public class ColorEffect : MonoBehaviour { internal ColorEffectBase colorEffectBase; private SetTeamColor[] teamColors; private Player player; private Color colorMinToSet; private Color colorMaxToSet; public void Awake() { player = ((Component)this).gameObject.GetComponent<Player>(); colorEffectBase = ExtensionMethods.GetOrAddComponent<ColorEffectBase>(((Component)player).gameObject, false); colorEffectBase.colorEffectDrones.Add(this); teamColors = ((Component)((Component)player).transform.root).GetComponentsInChildren<SetTeamColor>(); } public void Start() { ApplyColor(); } public void Update() { } public void OnDestroy() { colorEffectBase.OnDroneDestroy(this); } public void ApplyColor() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown if (((Component)player).gameObject.GetComponentInChildren<PlayerSkinHandler>().simpleSkin) { SpriteMask[] componentsInChildren = ((Component)((Component)((Component)player).gameObject.GetComponentInChildren<SetPlayerSpriteLayer>()).transform.root).GetComponentsInChildren<SpriteMask>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).GetComponent<SpriteRenderer>().color = colorMaxToSet; } return; } PlayerSkinParticle[] componentsInChildren2 = ((Component)player).gameObject.GetComponentsInChildren<PlayerSkinParticle>(); for (int j = 0; j < componentsInChildren2.Length; j++) { ParticleSystem val = (ParticleSystem)ExtensionMethods.GetFieldValue((object)componentsInChildren2[j], "part"); MainModule main = val.main; MainModule main2 = val.main; MinMaxGradient startColor = ((MainModule)(ref main2)).startColor; ((MinMaxGradient)(ref startColor)).colorMin = colorMinToSet; ((MinMaxGradient)(ref startColor)).colorMax = colorMaxToSet; ((MainModule)(ref main)).startColor = startColor; } SetTeamColor[] array = teamColors; for (int k = 0; k < array.Length; k++) { array[k].Set(new PlayerSkin { color = colorMaxToSet, backgroundColor = colorMaxToSet, winText = colorMaxToSet, particleEffect = colorMaxToSet }); } } public void SetColor(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) colorMaxToSet = color; colorMinToSet = color; } public void SetColorMax(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) colorMaxToSet = color; } public void SetColorMin(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) colorMinToSet = color; } public void Destroy() { Object.Destroy((Object)(object)this); } public Color GetOriginalColorMax() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return colorEffectBase.originalColorMax; } public Color GetOriginalColorMin() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return colorEffectBase.originalColorMin; } } internal sealed class ColorEffectBase : MonoBehaviour { internal List<ColorEffect> colorEffectDrones = new List<ColorEffect>(); internal Color originalColorMax; internal Color originalColorMin; private Player player; private SetTeamColor[] teamColors; public void Awake() { //IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) player = ((Component)this).gameObject.GetComponent<Player>(); originalColorMin = GetPlayerColor.GetColorMin(player); originalColorMax = GetPlayerColor.GetColorMax(player); teamColors = ((Component)((Component)player).transform.root).GetComponentsInChildren<SetTeamColor>(); } public void OnDroneDestroy(ColorEffect colorEffect) { int num = colorEffectDrones.IndexOf(colorEffect); if (colorEffectDrones.Count == 1 && num == 0) { ResetColor(); } else if (num == colorEffectDrones.Count - 1) { colorEffectDrones[num - 1].ApplyColor(); } colorEffectDrones.Remove(colorEffect); } private void ResetColor() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002b: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown PlayerSkinParticle[] componentsInChildren = ((Component)player).gameObject.GetComponentsInChildren<PlayerSkinParticle>(); for (int i = 0; i < componentsInChildren.Length; i++) { ParticleSystem val = (ParticleSystem)ExtensionMethods.GetFieldValue((object)componentsInChildren[i], "part"); MainModule main = val.main; MainModule main2 = val.main; MinMaxGradient startColor = ((MainModule)(ref main2)).startColor; ((MinMaxGradient)(ref startColor)).colorMin = originalColorMin; ((MinMaxGradient)(ref startColor)).colorMax = originalColorMax; ((MainModule)(ref main)).startColor = startColor; } SetTeamColor[] array = teamColors; for (int j = 0; j < array.Length; j++) { array[j].Set(new PlayerSkin { color = originalColorMax, backgroundColor = originalColorMax, winText = originalColorMax, particleEffect = originalColorMax }); } } public void OnDestroy() { foreach (ColorEffect colorEffectDrone in colorEffectDrones) { if ((Object)(object)colorEffectDrone != (Object)null) { Object.Destroy((Object)(object)colorEffectDrone); } } ResetColor(); } public void Destroy() { Object.Destroy((Object)(object)this); } } public class GunColorEffect : MonoBehaviour { private GunColorEffectBase gunColorEffectBase; private Player player; private Gun gun; private Color colorToSet; public void Awake() { player = ((Component)this).gameObject.GetComponent<Player>(); gun = ((Component)((Component)player).GetComponent<Holding>().holdable).GetComponent<Gun>(); gunColorEffectBase = ExtensionMethods.GetOrAddComponent<GunColorEffectBase>(((Component)player).gameObject, false); gunColorEffectBase.gunColorEffectDrones.Add(this); } private void Start() { ApplyColor(); } private void Update() { } public void OnDestroy() { gunColorEffectBase.OnDroneDestroy(this); } public void ApplyColor() { //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) gun.projectileColor = colorToSet; } public void SetColor(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) colorToSet = color; } public void Destroy() { Object.Destroy((Object)(object)this); } } internal sealed class GunColorEffectBase : MonoBehaviour { internal List<GunColorEffect> gunColorEffectDrones = new List<GunColorEffect>(); private Color originalColor; private Player player; private Gun gun; public void Awake() { //IL_0034: 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) player = ((Component)this).gameObject.GetComponent<Player>(); gun = ((Component)((Component)player).GetComponent<Holding>().holdable).GetComponent<Gun>(); originalColor = gun.projectileColor; } public void OnDroneDestroy(GunColorEffect gunColorEffect) { int num = gunColorEffectDrones.IndexOf(gunColorEffect); if (gunColorEffectDrones.Count == 1 && num == 0) { ResetColor(); } else if (num == gunColorEffectDrones.Count - 1) { gunColorEffectDrones[num - 1].ApplyColor(); } gunColorEffectDrones.Remove(gunColorEffect); } private void ResetColor() { //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) gun.projectileColor = originalColor; } public void OnDestroy() { foreach (GunColorEffect gunColorEffectDrone in gunColorEffectDrones) { if ((Object)(object)gunColorEffectDrone != (Object)null) { Object.Destroy((Object)(object)gunColorEffectDrone); } } ResetColor(); } public void Destroy() { Object.Destroy((Object)(object)this); } } public class ColorFlash : MonoBehaviour { private float duration = 1f; private float startTime; private int numberOfFlashes = 1; private float delayBetweenFlashes = 1f; private Color colorMinToFlash = Color.black; private Color colorMaxToFlash = Color.black; private int flashNum; private bool flashing; private ColorEffect colorEffect; private Player player; private void Awake() { player = ((Component)this).gameObject.GetComponent<Player>(); } private void Start() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ResetTimer(); Flash(colorMinToFlash, colorMaxToFlash); } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (flashing && Time.time >= startTime + duration) { Unflash(); } else if (!flashing && Time.time >= startTime + delayBetweenFlashes) { Flash(colorMinToFlash, colorMaxToFlash); } else if (flashNum >= numberOfFlashes) { Destroy(); } } public void OnDestroy() { if ((Object)(object)colorEffect != (Object)null) { Object.Destroy((Object)(object)colorEffect); } } public void Flash(Color colorMin, Color colorMax) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) flashing = true; ResetTimer(); colorEffect = ((Component)player).gameObject.AddComponent<ColorEffect>(); colorEffect.SetColorMax(colorMax); colorEffect.SetColorMin(colorMin); } public void Unflash() { flashing = false; flashNum++; ResetTimer(); if ((Object)(object)colorEffect != (Object)null) { Object.Destroy((Object)(object)colorEffect); } } public void ResetTimer() { startTime = Time.time; } public void Destroy() { Object.Destroy((Object)(object)this); } public void SetNumberOfFlashes(int flashes) { numberOfFlashes = flashes; } public void SetDelayBetweenFlashes(float delay) {