using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CardChoiceSpawnUniqueCardPatch.CustomCategories;
using HarmonyLib;
using InControl;
using ModdingUtils.Extensions;
using RWF;
using RWF.UI;
using RarityLib.Utils;
using RoundWithBot.RWB;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
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("RoundWithBot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoundWithBot")]
[assembly: AssemblyTitle("RoundWithBot")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RoundWithBot
{
internal class ConfigHandler
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__3_0;
internal void <RegesterMenu>b__3_0()
{
}
}
public static ConfigEntry<bool> RandomizationFace;
public static ConfigEntry<int> SelectedFace;
public static ConfigEntry<bool> DebugMode;
public static void RegesterMenu(string modName, ConfigFile config)
{
//IL_0016: 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_0021: Expected O, but got Unknown
object obj = <>c.<>9__3_0;
if (obj == null)
{
UnityAction val = delegate
{
};
<>c.<>9__3_0 = val;
obj = (object)val;
}
Unbound.RegisterMenu(modName, (UnityAction)obj, (Action<GameObject>)NewGui, (GameObject)null, false);
RandomizationFace = config.Bind<bool>(modName, "RandomizationFace", true, "Enable randomization of bots' faces.");
SelectedFace = config.Bind<int>(modName, "SelectedFace", 0, "Set the index for bots to select a specific face.");
DebugMode = config.Bind<bool>(modName, "DebugMode", false, "Enabled or disabled Debug Mode");
}
public static void addBlank(GameObject menu)
{
TextMeshProUGUI val = default(TextMeshProUGUI);
MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
}
public static void NewGui(GameObject menu)
{
TextMeshProUGUI val2 = default(TextMeshProUGUI);
MenuHandler.CreateText("Rounds With Bots | Config", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
addBlank(menu);
MenuHandler.CreateToggle(RandomizationFace.Value, "Randomization Face", menu, (UnityAction<bool>)RandomizationFaceChanged, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
addBlank(menu);
MenuHandler.CreateText("Selected Face | <#c41010> Only Work When 'Randomization Face' Config Is Off!", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
addBlank(menu);
Slider val3 = default(Slider);
MenuHandler.CreateSlider("Selected Face", menu, 30, 0f, 7f, (float)SelectedFace.Value, (UnityAction<float>)SelectedFaceChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
addBlank(menu);
MenuHandler.CreateToggle(DebugMode.Value, "<#c41010> Debug Mode", menu, (UnityAction<bool>)DebugModeChanged, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
static void DebugModeChanged(bool val)
{
DebugMode.Value = val;
}
static void RandomizationFaceChanged(bool val)
{
RandomizationFace.Value = val;
}
static void SelectedFaceChanged(float val)
{
SelectedFace.Value = (int)Math.Round(val);
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.aalund13.rounds.Round_With_Bot", "Round With Bot", "2.3.0")]
[BepInProcess("Rounds.exe")]
public class RoundWithBots : BaseUnityPlugin
{
private const string ModId = "com.aalund13.rounds.Round_With_Bot";
private const string ModName = "Round With Bot";
public const string Version = "2.3.0";
public const string ModInitials = "RWB";
public static CardCategory NoBot;
public bool isPicking = false;
private List<int> botPlayer = new List<int>();
public static RoundWithBots instance { get; private set; }
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.aalund13.rounds.Round_With_Bot");
val.PatchAll();
}
private void Start()
{
instance = this;
ConfigHandler.RegesterMenu("Round With Bot", ((BaseUnityPlugin)this).Config);
NoBot = CustomCardCategories.instance.CardCategory("not-for-bots");
RoundWithBot.RWB.RoundWithBot.AddExcludeCard("Remote");
GameModeManager.AddHook("PlayerPickStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => BotPicks()));
GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler _) => RegesterBots()));
}
private IEnumerator RegesterBots()
{
botPlayer.Clear();
for (int i = 0; i < PlayerManager.instance.players.Count; i++)
{
Player player = PlayerManager.instance.players[i];
if (((Behaviour)((Component)player).GetComponent<PlayerAPI>()).enabled)
{
botPlayer.Add(player.playerID);
CharacterStatModifiersExtension.GetAdditionalData(player.data.stats).blacklistedCategories.Add(NoBot);
((TMP_Text)((Component)((Component)player).GetComponentInChildren<PlayerName>()).GetComponent<TextMeshProUGUI>()).text = "<#07e0f0>[BOT]";
}
}
RoundWithBot.RWB.RoundWithBot.SetBotsId();
yield break;
}
private IEnumerator BotPicks()
{
((MonoBehaviour)this).StartCoroutine(RoundWithBot.RWB.RoundWithBot.AiPickCard());
yield break;
}
}
}
namespace RoundWithBot.RWB
{
public class RoundWithBot
{
public static List<int> botsId = new List<int>();
public static List<CardInfo> excludeCards = new List<CardInfo>();
public static void Log(string message, bool log = true)
{
if (ConfigHandler.DebugMode.Value && log)
{
Debug.Log((object)message);
}
}
public static void AddExcludeCard(CardInfo excludeCard, bool log = true)
{
if ((Object)(object)excludeCard == (Object)null)
{
Log("Card is null", log);
return;
}
excludeCard.categories = CollectionExtensions.AddItem<CardCategory>((IEnumerable<CardCategory>)excludeCard.categories, RoundWithBots.NoBot).ToArray();
excludeCards.Add(excludeCard);
Log("'" + excludeCard.cardName + "' Have be added to the exclude cards", log);
}
public static void AddExcludeCard(string excludeCardName, bool log = true)
{
CardInfo cardInfoWithName = CardManager.GetCardInfoWithName(excludeCardName);
AddExcludeCard(cardInfoWithName, log);
}
public static bool isAExcludeCard(CardInfo card)
{
if (excludeCards.Contains(card))
{
return true;
}
return false;
}
public static void SetBotsId(bool log = true)
{
Log("Getting bots player.", log);
botsId.Clear();
for (int i = 0; i < PlayerManager.instance.players.Count; i++)
{
Player val = PlayerManager.instance.players[i];
if (((Behaviour)((Component)val).GetComponent<PlayerAPI>()).enabled)
{
botsId.Add(val.playerID);
Log("Bot '" + val.playerID + "' Have be added to the list of bots id.", log);
}
}
Log("Successfully get list of bots player.", log);
}
public static List<GameObject> GetRarestCards(List<GameObject> spawnCards, bool log = true)
{
Log("getting rarest cards...", log);
List<GameObject> spawnCards2 = GetSpawnCards();
float rarestRarityModifier = spawnCards.Select((GameObject card) => RarityUtils.GetRarityData(card.GetComponent<CardInfo>().rarity).relativeRarity).Min();
return spawnCards.Where((GameObject card) => RarityUtils.GetRarityData(card.GetComponent<CardInfo>().rarity).relativeRarity == rarestRarityModifier).ToList();
}
public static List<GameObject> GetSpawnCards(bool log = true)
{
Log("Getting spawn cards", log);
return (List<GameObject>)AccessTools.Field(typeof(CardChoice), "spawnedCards").GetValue(CardChoice.instance);
}
public static IEnumerator CycleThroughCards(float delay, List<GameObject> spawnedCards, bool log = true)
{
Log("Cycling through cards", log);
CardInfo lastCardInfo = null;
int index = 0;
foreach (GameObject cardObject in spawnedCards)
{
CardInfo cardInfo = cardObject.GetComponent<CardInfo>();
Log("Cycling through '" + cardInfo.cardName + "' card", log);
if ((Object)(object)lastCardInfo != (Object)null)
{
lastCardInfo.RPCA_ChangeSelected(false);
}
cardInfo.RPCA_ChangeSelected(true);
AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").SetValue(CardChoice.instance, index);
lastCardInfo = cardInfo;
index++;
yield return (object)new WaitForSeconds(delay);
}
Log("Successfully gone through all cards");
}
public static IEnumerator GoToCards(List<GameObject> rarestCards, List<GameObject> spawnedCards, float delay, bool log = true)
{
int randomIndex = Random.Range(0, rarestCards.Count - 1);
GameObject cardToPick = rarestCards[randomIndex];
Log("Going to '" + ((object)cardToPick)?.ToString() + "' card", log);
int selectedCardIndex = spawnedCards.IndexOf(cardToPick);
int handIndex = int.Parse(AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").GetValue(CardChoice.instance).ToString());
while (handIndex != selectedCardIndex)
{
CardInfo cardInfo2 = spawnedCards[handIndex].GetComponent<CardInfo>();
cardInfo2.RPCA_ChangeSelected(false);
Log("Currently on '" + ((object)cardInfo2)?.ToString() + "' card", log);
if (handIndex > selectedCardIndex)
{
handIndex--;
}
else if (handIndex < selectedCardIndex)
{
handIndex++;
}
cardInfo2 = spawnedCards[handIndex].GetComponent<CardInfo>();
cardInfo2.RPCA_ChangeSelected(true);
AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").SetValue(CardChoice.instance, handIndex);
yield return (object)new WaitForSeconds(delay);
}
Log("Successfully got to '" + ((object)cardToPick)?.ToString() + "' card", log);
}
public static IEnumerator PickCard(List<GameObject> spawnCards)
{
CardChoice.instance.Pick(spawnCards[(int)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "currentlySelectedCard")], true);
yield break;
}
public static IEnumerator AiPickCard()
{
yield return (object)new WaitUntil((Func<bool>)(() => CardChoice.instance.IsPicking && ((List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards")).Count == ((Transform[])ExtensionMethods.GetFieldValue((object)CardChoice.instance, "children")).Count() && !((List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards")).Any((GameObject card) => (Object)(object)card == (Object)null)));
for (int i = 0; i < PlayerManager.instance.players.Count; i++)
{
Player player = PlayerManager.instance.players[i];
if (((Behaviour)((Component)player).GetComponent<PlayerAPI>()).enabled && botsId.Contains(CardChoice.instance.pickrID))
{
Log("AI picking card");
List<GameObject> spawnCards = GetSpawnCards();
spawnCards[0].GetComponent<CardInfo>().RPCA_ChangeSelected(true);
yield return (object)new WaitForSeconds(0.25f);
yield return CycleThroughCards(0.3f, spawnCards);
yield return (object)new WaitForSeconds(1f);
List<GameObject> rarestCards = GetRarestCards(spawnCards);
yield return GoToCards(rarestCards, spawnCards, 0.2f);
yield return (object)new WaitForSeconds(1f);
yield return PickCard(spawnCards);
break;
}
}
}
}
}
namespace RoundWithBot.Pacthes
{
[HarmonyPatch(typeof(PlayerAIPhilip))]
internal class PlayerAiPatch
{
[HarmonyPatch("Update")]
private static void Postfix(PlayerAIPhilip __instance)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0076: 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)
//IL_008b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
OutOfBoundsHandler val = Object.FindObjectOfType<OutOfBoundsHandler>();
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"OutOfBoundsHandler not found in the scene.");
return;
}
MethodInfo methodInfo = AccessTools.Method(typeof(OutOfBoundsHandler), "GetPoint", (Type[])null, (Type[])null);
GeneralInput val2 = (GeneralInput)AccessTools.Field(typeof(PlayerAPI), "input").GetValue(((Component)__instance).GetComponentInParent<PlayerAPI>());
Vector3 val3 = (Vector3)methodInfo.Invoke(val, new object[1] { ((Component)__instance).gameObject.transform.position });
float num = Mathf.Abs(((Component)__instance).gameObject.transform.position.x - val3.x);
float num2 = Mathf.Abs(((Component)__instance).gameObject.transform.position.y - val3.y);
float num3 = 1f;
if ((num <= num3 || num2 <= num3) && (num >= num3 || num2 >= num3))
{
RoundWithBot.RWB.RoundWithBot.Log("Bot Is Near Boundaries");
val2.shieldWasPressed = true;
}
}
}
}
namespace RoundWithBot.Pacthes.RWF
{
[HarmonyPatch(typeof(CharacterSelectionInstance))]
internal class CharacterSelectionInstancePatch
{
[HarmonyPatch("Start")]
[HarmonyBefore(new string[] { "io.olavim.rounds.rwf" })]
private static void Postfix(CharacterSelectionInstance __instance)
{
if (((Behaviour)((Component)__instance.currentPlayer).GetComponent<PlayerAPI>()).enabled)
{
PlayerAI componentInChildren = ((Component)__instance.currentPlayer).GetComponentInChildren<PlayerAI>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Component)componentInChildren).gameObject.AddComponent<PlayerAIPhilip>();
Object.Destroy((Object)(object)componentInChildren);
}
if (ConfigHandler.RandomizationFace.Value)
{
__instance.currentlySelectedFace = Random.Range(0, 7);
}
else
{
__instance.currentlySelectedFace = ConfigHandler.SelectedFace.Value;
}
}
}
[HarmonyPatch("Update")]
[HarmonyBefore(new string[] { "io.olavim.rounds.rwf" })]
private static bool Prefix(CharacterSelectionInstance __instance)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
if ((Object)(object)__instance.currentPlayer == (Object)null)
{
return false;
}
if (((Behaviour)((Component)__instance.currentPlayer).GetComponent<PlayerAPI>()).enabled)
{
ExtensionMethods.SetFieldValue((object)__instance.currentPlayer.data.playerVel, "simulated", (object)false);
if (__instance.currentPlayer.data.playerActions == null)
{
__instance.currentPlayer.data.playerActions = new PlayerActions();
((PlayerActionSet)__instance.currentPlayer.data.playerActions).Device = InputDevice.Null;
}
if (Input.GetKeyDown((KeyCode)114))
{
AccessTools.Method(typeof(CharacterSelectionInstance), "ReadyUp", (Type[])null, (Type[])null).Invoke(__instance, null);
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(KeybindHints))]
internal class KeybindHintsPatch
{
[HarmonyPatch("CreateLocalHints")]
[HarmonyBefore(new string[] { "io.olavim.rounds.rwf" })]
private static void Postfix()
{
if (PlayerPrefs.GetInt(RWFMod.GetCustomPropertyKey("ShowKeybinds"), 1) != 0)
{
KeybindHints.AddHint("to ready up all bots", "[R]", (Vector2?)null);
}
}
}
[HarmonyPatch(typeof(PlayerSpotlight))]
internal class RWFAddSpotToPlayerPatch
{
[HarmonyPatch("AddSpotToPlayer")]
private static bool Prefix(Player player)
{
return !((Behaviour)((Component)player).GetComponent<PlayerAPI>()).enabled;
}
}
}