using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BattleMatch;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cards;
using Cards.Data;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Essentials;
using OversizedPets;
using UnityEngine;
[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("com.binbin.OversizedPets")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+339703168abb47be17694a80d5de91ee3f64200f")]
[assembly: AssemblyProduct("OversizedPets")]
[assembly: AssemblyTitle("com.binbin.OversizedPets")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public static class EssentialsCompatibility
{
private static bool? _enabled;
public static bool Enabled
{
get
{
bool valueOrDefault = _enabled == true;
if (!_enabled.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.stiffmeds.obeliskialessentials");
_enabled = valueOrDefault;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void EssentialsRegister()
{
Essentials.RegisterMod(Plugin.PluginName, "binbin", "Oversized Pets", Plugin.PluginVersion, Plugin.ModDate, "https://github.com/binbinmods/OversizedPets", (string[])null, "", 100, (string[])null, "", true);
Plugin.LogInfo(Plugin.PluginVersion + " has loaded with Essentials!");
}
}
namespace OversizedPets
{
public class OversizedPetsFunctions
{
public static bool IsHost()
{
return GameManager.Instance.IsMultiplayer() && NetworkManager.Instance.IsMaster();
}
public static void ResizeTransform(ref Transform transform, float scale, string id = "")
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
transform.localScale = new Vector3(transform.localScale.x * scale, transform.localScale.y * scale, transform.localScale.z);
Plugin.LogDebug("Setting " + id + " size to: " + scale, "ResizeTransform");
}
}
[HarmonyPatch]
public class OversizedPetsPatches
{
public static bool devMode;
public static bool bSelectingPerk;
public static void BeginMatchPostfix(ref Character __instance)
{
bool flag = __instance != null && (Object)(object)__instance.HeroData != (Object)null && (Object)(object)__instance.HeroData.HeroSubClass != (Object)null && __instance.Alive && (Object)(object)__instance.HeroItem != (Object)null && (Object)(object)__instance.HeroItem.animatedTransform != (Object)null;
bool flag2 = __instance != null && (Object)(object)__instance.NpcData != (Object)null && __instance.Alive && (Object)(object)__instance.NPCItem != (Object)null && (Object)(object)__instance.NPCItem.animatedTransform != (Object)null;
if (flag)
{
string id = __instance.HeroData.HeroSubClass.Id;
if (Plugin.IncreaseHeroSize.Value)
{
float value = Plugin.HeroSizeScaleFactor.Value;
OversizedPetsFunctions.ResizeTransform(ref __instance.HeroItem.animatedTransform, value, id);
}
if (Plugin.IncreasePetSize.Value && __instance.Pet != null)
{
string pet = __instance.Pet;
float value2 = Plugin.PetSizeScaleFactor.Value;
if ((Object)(object)((CharacterItem)__instance.HeroItem).PetItem != (Object)null && (Object)(object)((CharacterItem)__instance.HeroItem).PetItem.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.HeroItem).PetItem.animatedTransform, value2, pet);
}
if ((Object)(object)((CharacterItem)__instance.HeroItem).PetItemEnchantment != (Object)null && (Object)(object)((CharacterItem)__instance.HeroItem).PetItemEnchantment.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.HeroItem).PetItemEnchantment.animatedTransform, value2, pet);
}
}
}
else
{
if (!(Plugin.IncreaseNPCSize.Value && flag2))
{
return;
}
float value3 = Plugin.NPCSizeScaleFactor.Value;
OversizedPetsFunctions.ResizeTransform(ref __instance.NPCItem.animatedTransform, value3, __instance.NpcData.Id);
if (Plugin.IncreasePetSize.Value && __instance.Pet != null)
{
string pet2 = __instance.Pet;
float value4 = Plugin.PetSizeScaleFactor.Value;
if ((Object)(object)((CharacterItem)__instance.NPCItem).PetItem != (Object)null && (Object)(object)((CharacterItem)__instance.NPCItem).PetItem.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.NPCItem).PetItem.animatedTransform, value4, pet2);
}
if ((Object)(object)((CharacterItem)__instance.NPCItem).PetItemEnchantment != (Object)null && (Object)(object)((CharacterItem)__instance.NPCItem).PetItemEnchantment.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.NPCItem).PetItemEnchantment.animatedTransform, value4, pet2);
}
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Character), "BeginRound")]
public static void BeginRoundPostfix(ref Character __instance)
{
bool flag = __instance != null && (Object)(object)__instance.HeroData != (Object)null && (Object)(object)__instance.HeroData.HeroSubClass != (Object)null && __instance.Alive && (Object)(object)__instance.HeroItem != (Object)null && (Object)(object)__instance.HeroItem.animatedTransform != (Object)null;
bool flag2 = __instance != null && (Object)(object)__instance.NpcData != (Object)null && __instance.Alive && (Object)(object)__instance.NPCItem != (Object)null && (Object)(object)__instance.NPCItem.animatedTransform != (Object)null;
if (flag)
{
string id = __instance.HeroData.HeroSubClass.Id;
if (Plugin.IncreaseHeroSize.Value)
{
float value = Plugin.HeroSizeScaleFactor.Value;
OversizedPetsFunctions.ResizeTransform(ref __instance.HeroItem.animatedTransform, value, id);
}
if (Plugin.IncreasePetSize.Value && __instance.Pet != null)
{
string pet = __instance.Pet;
float value2 = Plugin.PetSizeScaleFactor.Value;
if ((Object)(object)((CharacterItem)__instance.HeroItem).PetItem != (Object)null && (Object)(object)((CharacterItem)__instance.HeroItem).PetItem.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.HeroItem).PetItem.animatedTransform, value2, pet);
}
if ((Object)(object)((CharacterItem)__instance.HeroItem).PetItemEnchantment != (Object)null && (Object)(object)((CharacterItem)__instance.HeroItem).PetItemEnchantment.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.HeroItem).PetItemEnchantment.animatedTransform, value2, pet);
}
}
}
else
{
if (!(Plugin.IncreaseNPCSize.Value && flag2))
{
return;
}
float value3 = Plugin.NPCSizeScaleFactor.Value;
OversizedPetsFunctions.ResizeTransform(ref __instance.NPCItem.animatedTransform, value3, __instance.NpcData.Id);
if (Plugin.IncreasePetSize.Value && __instance.Pet != null)
{
string pet2 = __instance.Pet;
float value4 = Plugin.PetSizeScaleFactor.Value;
if ((Object)(object)((CharacterItem)__instance.NPCItem).PetItem != (Object)null && (Object)(object)((CharacterItem)__instance.NPCItem).PetItem.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.NPCItem).PetItem.animatedTransform, value4, pet2);
}
if ((Object)(object)((CharacterItem)__instance.NPCItem).PetItemEnchantment != (Object)null && (Object)(object)((CharacterItem)__instance.NPCItem).PetItemEnchantment.animatedTransform != (Object)null)
{
OversizedPetsFunctions.ResizeTransform(ref ((CharacterItem)__instance.NPCItem).PetItemEnchantment.animatedTransform, value4, pet2);
}
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BattleTeamManager), "CreatePet")]
public static void CreatePetPostfix(ref CardRealtimeData petCard, GameObject charGO, Hero _hero, ref NPC _npc, bool _fromEnchant = false, string _enchantName = "")
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.IncreasePetSize.Value || petCard == (CardRealtimeData)null || (Object)(object)charGO == (Object)null || (_hero == null && _npc == null))
{
return;
}
PetData writablePetData = GetWritablePetData(petCard);
if (writablePetData != null)
{
float value = Plugin.PetSizeScaleFactor.Value;
if (petCard.Id.StartsWith("sharpy") || petCard.Id.StartsWith("harley") || petCard.Id.StartsWith("inky"))
{
writablePetData.PetOffset = new Vector2(writablePetData.PetOffset.x, writablePetData.PetOffset.y - writablePetData.PetSize.y * (value * (petCard.Id.StartsWith("inky") ? 1.5f : 1f) - 1f));
}
writablePetData.PetSize *= value;
}
}
private static PetData GetWritablePetData(CardRealtimeData petCard)
{
CardDataNew value = Traverse.Create((object)petCard).Field("card").GetValue<CardDataNew>();
return (value != null) ? value.PetData : null;
}
}
[BepInPlugin("com.binbin.OversizedPets", "OversizedPets", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
public static string PluginName;
public static string PluginVersion;
public static string PluginGUID;
internal static int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
private readonly Harmony harmony = new Harmony("com.binbin.OversizedPets");
internal static ManualLogSource Log;
public static string debugBase = "com.binbin.OversizedPets ";
public static ConfigEntry<bool> EnableMod { get; set; }
public static ConfigEntry<bool> EnableDebugging { get; set; }
public static ConfigEntry<bool> IncreasePetSize { get; set; }
public static ConfigEntry<float> PetSizeScaleFactor { get; set; }
public static ConfigEntry<bool> IncreaseHeroSize { get; set; }
public static ConfigEntry<float> HeroSizeScaleFactor { get; set; }
public static ConfigEntry<bool> IncreaseNPCSize { get; set; }
public static ConfigEntry<float> NPCSizeScaleFactor { get; set; }
private void Awake()
{
//IL_001e: 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)
//IL_0039: Expected O, but got Unknown
//IL_0039: Expected O, but got Unknown
//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_0066: Expected O, but got Unknown
//IL_0066: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0093: Expected O, but got Unknown
//IL_00a5: 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: Expected O, but got Unknown
//IL_00c4: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_00f1: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0122: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_014f: Expected O, but got Unknown
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_0180: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
string text = "OversizedPets";
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableMod"), true, new ConfigDescription("Enables the mod. If false, the mod will not work then next time you load the game.", (AcceptableValueBase)null, Array.Empty<object>()));
EnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableDebugging"), false, new ConfigDescription("Enables the debugging", (AcceptableValueBase)null, Array.Empty<object>()));
IncreasePetSize = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Increase Pet Size"), true, new ConfigDescription("If true, will increase all pets by the PetSizeScaleFactor. Updates every round, so restart combat to see changes.", (AcceptableValueBase)null, Array.Empty<object>()));
PetSizeScaleFactor = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition(text, "PetSizeScaleFactor"), 1.25f, new ConfigDescription("Scale factor to increase pets by. 1.0 = no change, 2.0 = double size, 0.5 = half size. Does not work if less than 0.05.", (AcceptableValueBase)null, Array.Empty<object>()));
IncreaseHeroSize = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Increase Hero Size"), false, new ConfigDescription("If true, will increase all Heroes by the HeroSizeScaleFactor. Updates every round, so restart combat to see changes.", (AcceptableValueBase)null, Array.Empty<object>()));
HeroSizeScaleFactor = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition(text, "HeroSizeScaleFactor"), 1.25f, new ConfigDescription("Scale factor to increase Heroes by. 1.0 = no change, 2.0 = double size, 0.5 = half size. Does not work if less than 0.05.", (AcceptableValueBase)null, Array.Empty<object>()));
IncreaseNPCSize = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Increase NPC Size"), false, new ConfigDescription("If true, will increase all NPCs by the NPCSizeScaleFactor. Updates every round, so restart combat to see changes.", (AcceptableValueBase)null, Array.Empty<object>()));
NPCSizeScaleFactor = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition(text, "NPCSizeScaleFactor"), 1.25f, new ConfigDescription("Scale factor to increase NPCs by. 1.0 = no change, 2.0 = double size, 0.5 = half size. Does not work if less than 0.05.", (AcceptableValueBase)null, Array.Empty<object>()));
if (PetSizeScaleFactor.Value < 0.05f)
{
PetSizeScaleFactor.Value = 1f;
}
if (HeroSizeScaleFactor.Value < 0.05f)
{
HeroSizeScaleFactor.Value = 1f;
}
if (NPCSizeScaleFactor.Value < 0.05f)
{
NPCSizeScaleFactor.Value = 1f;
}
PetSizeScaleFactor.SettingChanged += delegate
{
if (PetSizeScaleFactor.Value < 0.05f)
{
PetSizeScaleFactor.Value = 1f;
LogDebug($"Set PetSizeScaleFactor to {PetSizeScaleFactor.Value}", "Awake");
}
};
HeroSizeScaleFactor.SettingChanged += delegate
{
if (HeroSizeScaleFactor.Value < 0.05f)
{
HeroSizeScaleFactor.Value = 1f;
LogDebug($"Set HeroSizeScaleFactor to {HeroSizeScaleFactor.Value}", "Awake");
}
};
NPCSizeScaleFactor.SettingChanged += delegate
{
if (NPCSizeScaleFactor.Value < 0.05f)
{
NPCSizeScaleFactor.Value = 1f;
LogDebug($"Set NPCSizeScaleFactor to {NPCSizeScaleFactor.Value}", "Awake");
}
};
PluginName = "OversizedPets";
PluginVersion = "1.1.1";
PluginGUID = "com.binbin.OversizedPets";
if (EnableMod.Value)
{
if (EssentialsCompatibility.Enabled)
{
EssentialsCompatibility.EssentialsRegister();
}
else
{
LogInfo(PluginGUID + " " + PluginVersion + " has loaded!");
}
harmony.PatchAll();
}
}
internal static void LogDebug(string msg, [CallerMemberName] string caller = "")
{
if (EnableDebugging.Value)
{
Log.LogDebug((object)(debugBase + "- " + caller + " - " + msg));
}
}
internal static void LogInfo(string msg)
{
Log.LogInfo((object)(debugBase + msg));
}
internal static void LogError(string msg, [CallerMemberName] string caller = "")
{
Log.LogError((object)(debugBase + "- " + caller + " - " + msg));
}
public static IEnumerator RunAfter(IEnumerator original, Action action)
{
while (original.MoveNext())
{
yield return original.Current;
}
action();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.OversizedPets";
public const string PLUGIN_NAME = "OversizedPets";
public const string PLUGIN_VERSION = "1.1.1";
}
}