using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.Projectile; using RoR2; using RoR2.Projectile; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EnlargedEnemies")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EnlargedEnemies")] [assembly: AssemblyTitle("EnlargedEnemies")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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; } } } namespace EnlargedEnemies { [BepInPlugin("dileppy.shrunkenenemies", "EnlargedEnemies", "1.0.0")] public class EnlargedEnemiesPlugin : BaseUnityPlugin { public enum SizeTier { Large, ExtraLarge, Colossal } private struct TierValues { public float size; public float damage; public float health; public float move; public float rewardMult; public TierValues(float s, float d, float h, float m, float r) { size = s; damage = d; health = h; move = m; rewardMult = r; } } private class SizeMarker : MonoBehaviour { public Vector3 baseScale; } public const string PluginGUID = "dileppy.shrunkenenemies"; public const string PluginName = "EnlargedEnemies"; public const string PluginVersion = "1.0.0"; private const string RivalModGUID = "dileppy.shrunkenenemies"; private static readonly Dictionary Defaults = new Dictionary { { SizeTier.Large, new TierValues(1.4f, 1.2f, 1.25f, 0.9f, 1.15f) }, { SizeTier.ExtraLarge, new TierValues(1.8f, 1.45f, 1.6f, 0.8f, 1.35f) }, { SizeTier.Colossal, new TierValues(2.5f, 1.8f, 2.2f, 0.7f, 1.6f) } }; public static ConfigEntry Tier; public static ConfigEntry ScaleProjectiles; public static ConfigEntry AffectBosses; public static ConfigEntry ScaleRewards; public static ConfigEntry UseCustomValues; public static ConfigEntry CustomSize; public static ConfigEntry CustomDamage; public static ConfigEntry CustomHealth; public static ConfigEntry CustomMove; public static ConfigEntry CustomReward; public static ConfigEntry DebugLogging; private void Awake() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown Tier = ((BaseUnityPlugin)this).Config.Bind("General", "SizeTier", SizeTier.Large, "How enlarged the enemies are. Large=140%, ExtraLarge=180%, Colossal=250%. Bigger enemies hit harder and have more HP, but move slower and drop bonus rewards."); ScaleProjectiles = ((BaseUnityPlugin)this).Config.Bind("General", "ScaleProjectiles", true, "Also enlarge enemy projectiles to match their size."); AffectBosses = ((BaseUnityPlugin)this).Config.Bind("General", "AffectBosses", true, "Whether bosses and teleporter events are enlarged too. Disable if Colossal bosses are too much."); ScaleRewards = ((BaseUnityPlugin)this).Config.Bind("Challenge", "ScaleRewards", true, "Giants drop giant rewards: +15% (Large), +35% (ExtraLarge), +60% (Colossal) gold and XP. Risk, meet reward."); UseCustomValues = ((BaseUnityPlugin)this).Config.Bind("Custom", "UseCustomValues", false, "Ignore the tier presets and use the Custom* values below instead."); CustomSize = ((BaseUnityPlugin)this).Config.Bind("Custom", "CustomSize", 1.8f, new ConfigDescription("Enemy size multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); CustomDamage = ((BaseUnityPlugin)this).Config.Bind("Custom", "CustomDamage", 1.45f, new ConfigDescription("Enemy damage multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); CustomHealth = ((BaseUnityPlugin)this).Config.Bind("Custom", "CustomHealth", 1.6f, new ConfigDescription("Enemy max HP multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); CustomMove = ((BaseUnityPlugin)this).Config.Bind("Custom", "CustomMove", 0.8f, new ConfigDescription("Enemy move speed multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 3f), Array.Empty())); CustomReward = ((BaseUnityPlugin)this).Config.Bind("Custom", "CustomReward", 1.35f, new ConfigDescription("Gold/XP drop multiplier", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 2f), Array.Empty())); DebugLogging = ((BaseUnityPlugin)this).Config.Bind("Advanced", "DebugLogging", false, "Log applied multipliers to the console for verification."); if (Chainloader.PluginInfos.ContainsKey("dileppy.shrunkenenemies")) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"EnlargedEnemies: ShrunkenEnemies is also installed. Running both at once will produce unpredictable results. Use one at a time."); } CharacterBody.Start += new hook_Start(CharacterBody_Start); CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats); ProjectileController.Start += new hook_Start(ProjectileController_Start); DeathRewards.OnKilledServer += new hook_OnKilledServer(DeathRewards_OnKilledServer); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded. Tier={2}", "EnlargedEnemies", "1.0.0", Tier.Value)); } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown CharacterBody.Start -= new hook_Start(CharacterBody_Start); CharacterBody.RecalculateStats -= new hook_RecalculateStats(CharacterBody_RecalculateStats); ProjectileController.Start -= new hook_Start(ProjectileController_Start); DeathRewards.OnKilledServer -= new hook_OnKilledServer(DeathRewards_OnKilledServer); } private TierValues Current() { if (UseCustomValues.Value) { return new TierValues(CustomSize.Value, CustomDamage.Value, CustomHealth.Value, CustomMove.Value, CustomReward.Value); } return Defaults[Tier.Value]; } private static bool IsTargetEnemy(CharacterBody body) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent)) { return false; } TeamIndex teamIndex = body.teamComponent.teamIndex; if ((int)teamIndex != 2 && (int)teamIndex != 3 && (int)teamIndex != 4) { return false; } if (!AffectBosses.Value && body.isBoss) { return false; } return true; } private static void ApplyAbsoluteScale(GameObject go, float factor) { //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)go)) { return; } Scene scene = go.scene; if (((Scene)(ref scene)).IsValid()) { SizeMarker sizeMarker = go.GetComponent(); if (!Object.op_Implicit((Object)(object)sizeMarker)) { sizeMarker = go.AddComponent(); sizeMarker.baseScale = go.transform.localScale; } go.transform.localScale = sizeMarker.baseScale * factor; } } private void CharacterBody_Start(orig_Start orig, CharacterBody self) { orig.Invoke(self); if (!IsTargetEnemy(self)) { return; } try { ModelLocator modelLocator = self.modelLocator; if (Object.op_Implicit((Object)(object)modelLocator) && Object.op_Implicit((Object)(object)modelLocator.modelTransform)) { ApplyAbsoluteScale(((Component)modelLocator.modelTransform).gameObject, Current().size); if (DebugLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0}: scaled {1} to {2:P0}", "EnlargedEnemies", self.GetDisplayName(), Current().size)); } } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("{0}: model scale failed: {1}", "EnlargedEnemies", arg)); } } private void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self) { orig.Invoke(self); if (IsTargetEnemy(self)) { TierValues tierValues = Current(); self.damage *= tierValues.damage; self.maxHealth *= tierValues.health; self.moveSpeed *= tierValues.move; } } private void ProjectileController_Start(orig_Start orig, ProjectileController self) { orig.Invoke(self); if (!ScaleProjectiles.Value || !Object.op_Implicit((Object)(object)self.owner)) { return; } CharacterBody component = self.owner.GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !IsTargetEnemy(component)) { return; } try { float size = Current().size; ApplyAbsoluteScale(((Component)self).gameObject, size); if (Object.op_Implicit((Object)(object)self.ghost)) { ApplyAbsoluteScale(((Component)self.ghost).gameObject, size); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("{0}: projectile scale failed: {1}", "EnlargedEnemies", arg)); } } private void DeathRewards_OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport) { if (ScaleRewards.Value && !UseCustomValues.Value && (Object)(object)damageReport?.victimBody != (Object)null && IsTargetEnemy(damageReport.victimBody)) { float rewardMult = Current().rewardMult; self.goldReward = (uint)((float)self.goldReward * rewardMult); self.expReward = (uint)((float)self.expReward * rewardMult); } else if (ScaleRewards.Value && UseCustomValues.Value && (Object)(object)damageReport?.victimBody != (Object)null && IsTargetEnemy(damageReport.victimBody)) { self.goldReward = (uint)((float)self.goldReward * CustomReward.Value); self.expReward = (uint)((float)self.expReward * CustomReward.Value); } orig.Invoke(self, damageReport); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "EnlargedEnemies"; public const string PLUGIN_NAME = "EnlargedEnemies"; public const string PLUGIN_VERSION = "1.0.0"; } }