using System;
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.Logging;
using EntityStates;
using EntityStates.Treebot.TreebotFlower;
using IL.EntityStates.Treebot.TreebotFlower;
using IL.RoR2;
using IL.RoR2.Projectile;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.Orbs;
using RoR2.Projectile;
using UnityEngine;
[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("ChunkyMode")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6cd045b3c9830a244f5913011d130ecf1086306b")]
[assembly: AssemblyProduct("ChunkyMode")]
[assembly: AssemblyTitle("ChunkyMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 ChunkyMode
{
[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("HDeDeDe.ChunkyMode", "ChunkyMode", "0.1.4")]
public class ChunkyMode : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Action<Run, RuleBook> <0>__Run_onRunSetRuleBookGlobal;
public static hook_Heal <1>__OnHeal;
public static StatHookEventHandler <2>__RecalculateStatsAPI_GetStatCoefficients;
}
public const string PluginGUID = "HDeDeDe.ChunkyMode";
public const string PluginAuthor = "HDeDeDe";
public const string PluginName = "ChunkyMode";
public const string PluginVersion = "0.1.4";
public AssetBundle ChunkyModeDifficultyModBundle;
public static DifficultyDef ChunkyModeDifficultyDef;
public static DifficultyIndex ChunkyModeDifficultyIndex;
private const float rexHealOverride = 1.5f;
private static bool shouldRun;
private static bool swarmsEnabled;
private static int ogMonsterCap;
private static bool getFuckedLMAO;
private static bool teleporterExists;
private static float stagePunishTimer;
private static bool teleporterHit;
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
ChunkyModeDifficultyModBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("ChunkyMode.dll", "chunkydifficon"));
AddDifficulty();
FillTokens();
Run.onRunSetRuleBookGlobal += Run_onRunSetRuleBookGlobal;
Run.onRunStartGlobal += Run_onRunStartGlobal;
Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
}
public void AddDifficulty()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ChunkyModeDifficultyDef = new DifficultyDef(4f, "CHUNKYMODEDIFFMOD_NAME", "CHUNKYMODEDIFFMOD_ICON", "CHUNKYMODEDIFFMOD_DESCRIPTION", Color32.op_Implicit(new Color32((byte)61, (byte)25, byte.MaxValue, byte.MaxValue)), "cm", true);
ChunkyModeDifficultyDef.iconSprite = ChunkyModeDifficultyModBundle.LoadAsset<Sprite>("texChunkyModeDiffIcon");
ChunkyModeDifficultyDef.foundIconSprite = true;
ChunkyModeDifficultyIndex = DifficultyAPI.AddDifficulty(ChunkyModeDifficultyDef);
}
public void FillTokens()
{
LanguageAPI.Add("CHUNKYMODEDIFFMOD_NAME", "Chunky Mode");
LanguageAPI.Add("CHUNKYMODEDIFFMOD_DESCRIPTION", "<color=#C80000>For fools</color>. The nightmares this planet holds will devour you faster than ever before. You will be overwhelmed. You will suffer.\n\n<style=cStack>>Player Health Regeneration: <style=cIsHealth>-40%</style>\n>Difficulty Scaling: <style=cIsHealth>+100%</style>\n>Ally Healing: <style=cIsHealth>-50%</style>\n>Ally Shield Recharge Rate: <style=cIsHealth>-50%</style>\n>Enemy Speed: <style=cIsHealth>+40%</style>\n>Enemy Cooldowns: <style=cIsHealth>-50%</style>\n>Enemy Spawn Rate: <style=cIsHealth>+10%</style>\n>Loot Spawn Rate: <style=cIsHealing>+20%</style>\nand <style=cIsHealth>more</style>...</style>");
}
private static void Run_onRunSetRuleBookGlobal(Run arg1, RuleBook arg2)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (arg1.selectedDifficulty == ChunkyModeDifficultyIndex)
{
if (RunArtifactManager.instance.IsArtifactEnabled(Artifacts.swarmsArtifactDef))
{
swarmsEnabled = true;
}
else
{
swarmsEnabled = false;
}
Run.ambientLevelCap = 9999;
}
}
private void Run_onRunStartGlobal(Run run)
{
//IL_0029: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
shouldRun = false;
teleporterHit = false;
teleporterExists = false;
getFuckedLMAO = false;
ogMonsterCap = TeamCatalog.GetTeamDef((TeamIndex)2).softCharacterLimit;
if (run.selectedDifficulty == ChunkyModeDifficultyIndex)
{
Log.Info("Chunky Mode Run started");
shouldRun = true;
TeamCatalog.GetTeamDef((TeamIndex)2).softCharacterLimit = (int)((double)ogMonsterCap * 1.5);
TeamCatalog.GetTeamDef((TeamIndex)4).softCharacterLimit = (int)((double)ogMonsterCap * 1.5);
TeamCatalog.GetTeamDef((TeamIndex)3).softCharacterLimit = (int)((double)ogMonsterCap * 1.5);
HealthComponent.ServerFixedUpdate += new Manipulator(ShieldRechargeRate);
TreebotFlower2Projectile.HealPulse += new Manipulator(REXHealPulse);
ProjectileHealOwnerOnDamageInflicted.OnDamageInflictedServer += new Manipulator(REXPrimaryAttack);
CharacterBody.RecalculateStats += new Manipulator(AcridRegenBuff);
SceneDirector.onPrePopulateSceneServer += SceneDirector_onPrePopulateSceneServer;
CombatDirector.Awake += new hook_Awake(CombatDirector_Awake);
object obj = <>O.<1>__OnHeal;
if (obj == null)
{
hook_Heal val = OnHeal;
<>O.<1>__OnHeal = val;
obj = (object)val;
}
HealthComponent.Heal += (hook_Heal)obj;
object obj2 = <>O.<2>__RecalculateStatsAPI_GetStatCoefficients;
if (obj2 == null)
{
StatHookEventHandler val2 = RecalculateStatsAPI_GetStatCoefficients;
<>O.<2>__RecalculateStatsAPI_GetStatCoefficients = val2;
obj2 = (object)val2;
}
RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj2;
Run.OnServerTeleporterPlaced += new hook_OnServerTeleporterPlaced(Run_OnServerTeleporterPlaced);
Run.BeginStage += new hook_BeginStage(Run_BeginStage);
IdleState.OnInteractionBegin += new hook_OnInteractionBegin(OnInteractTeleporter);
}
}
private void Run_onRunDestroyGlobal(Run run)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_009c: 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_00a7: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
if (shouldRun)
{
Log.Info("Chunky Mode Run ended");
shouldRun = false;
TeamCatalog.GetTeamDef((TeamIndex)2).softCharacterLimit = ogMonsterCap;
TeamCatalog.GetTeamDef((TeamIndex)4).softCharacterLimit = ogMonsterCap;
TeamCatalog.GetTeamDef((TeamIndex)3).softCharacterLimit = ogMonsterCap;
HealthComponent.ServerFixedUpdate -= new Manipulator(ShieldRechargeRate);
TreebotFlower2Projectile.HealPulse -= new Manipulator(REXHealPulse);
ProjectileHealOwnerOnDamageInflicted.OnDamageInflictedServer -= new Manipulator(REXPrimaryAttack);
CharacterBody.RecalculateStats -= new Manipulator(AcridRegenBuff);
object obj = <>O.<2>__RecalculateStatsAPI_GetStatCoefficients;
if (obj == null)
{
StatHookEventHandler val = RecalculateStatsAPI_GetStatCoefficients;
<>O.<2>__RecalculateStatsAPI_GetStatCoefficients = val;
obj = (object)val;
}
RecalculateStatsAPI.GetStatCoefficients -= (StatHookEventHandler)obj;
object obj2 = <>O.<1>__OnHeal;
if (obj2 == null)
{
hook_Heal val2 = OnHeal;
<>O.<1>__OnHeal = val2;
obj2 = (object)val2;
}
HealthComponent.Heal -= (hook_Heal)obj2;
CombatDirector.Awake -= new hook_Awake(CombatDirector_Awake);
SceneDirector.onPrePopulateSceneServer -= SceneDirector_onPrePopulateSceneServer;
Run.OnServerTeleporterPlaced -= new hook_OnServerTeleporterPlaced(Run_OnServerTeleporterPlaced);
Run.BeginStage -= new hook_BeginStage(Run_BeginStage);
IdleState.OnInteractionBegin -= new hook_OnInteractionBegin(OnInteractTeleporter);
}
}
private static float OnHeal(orig_Heal orig, HealthComponent self, float amount, ProcChainMask procChainMask, bool nonRegen)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
float num = amount;
if ((int)self.body.teamComponent.teamIndex == 1)
{
num /= 2f;
}
return orig.Invoke(self, num, procChainMask, nonRegen);
}
private static void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)sender) && (int)sender.teamComponent.teamIndex != 1)
{
switch (((Object)sender).name)
{
case "BeetleGuardBody(Clone)":
args.moveSpeedMultAdd += 0.4f;
args.cooldownReductionAdd += 0.5f;
break;
case "VagrantBody(Clone)":
args.attackSpeedMultAdd += 0.25f;
args.moveSpeedMultAdd += 0.4f;
args.cooldownReductionAdd += 0.5f;
break;
case "BellBody(Clone)":
args.attackSpeedMultAdd += 2f;
args.moveSpeedMultAdd += 0.4f;
args.cooldownMultAdd += 0.25f;
break;
default:
args.attackSpeedMultAdd += 0.5f;
args.moveSpeedMultAdd += 0.4f;
args.cooldownReductionAdd += 0.5f;
break;
}
if (getFuckedLMAO)
{
args.healthMultAdd += 1f;
}
}
}
private void CombatDirector_Awake(orig_Awake origAwake, CombatDirector self)
{
self.creditMultiplier *= 1.1f;
self.goldRewardCoefficient *= 0.9f;
origAwake.Invoke(self);
}
private void SceneDirector_onPrePopulateSceneServer(SceneDirector self)
{
self.interactableCredit = (int)((double)self.interactableCredit * 1.2);
Log.Info("Updated Credits: " + self.interactableCredit);
}
private void Run_BeginStage(orig_BeginStage beginStage, Run self)
{
teleporterHit = false;
teleporterExists = false;
getFuckedLMAO = false;
Log.Info("Stage begin! Waiting for Teleporter to be created.");
beginStage.Invoke(self);
}
private void Run_OnServerTeleporterPlaced(orig_OnServerTeleporterPlaced teleporterPlaced, Run self, SceneDirector sceneDirector, GameObject thing)
{
teleporterExists = true;
stagePunishTimer = self.NetworkfixedTime + 300f;
Log.Info("Teleporter created! Timer set to " + stagePunishTimer);
teleporterPlaced.Invoke(self, sceneDirector, thing);
}
private void FixedUpdate()
{
if (shouldRun && !swarmsEnabled && !Run.instance.isGameOverServer && !teleporterHit && teleporterExists && !getFuckedLMAO && !(stagePunishTimer >= Run.instance.NetworkfixedTime))
{
Log.Info("Time's up! Swarms has been enabled. StagePunishTimer " + stagePunishTimer);
getFuckedLMAO = true;
RunArtifactManager.instance.SetArtifactEnabled(Artifacts.swarmsArtifactDef, true);
}
}
private void OnInteractTeleporter(orig_OnInteractionBegin interact, BaseState teleporterState, Interactor interactor)
{
if (swarmsEnabled)
{
interact.Invoke(teleporterState, interactor);
return;
}
if (RunArtifactManager.instance.IsArtifactEnabled(Artifacts.swarmsArtifactDef))
{
RunArtifactManager.instance.SetArtifactEnabled(Artifacts.swarmsArtifactDef, false);
}
getFuckedLMAO = false;
teleporterHit = true;
interact.Invoke(teleporterState, interactor);
}
private void ShieldRechargeRate(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[6]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<HealthComponent>(x, "body"),
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_maxShield"),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f),
(Instruction x) => ILPatternMatchingExt.MatchMul(x)
});
val.Index += 5;
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldfld, typeof(HealthComponent).GetField("body"));
val.EmitDelegate<Func<float, CharacterBody, float>>((Func<float, CharacterBody, float>)((float consumed, CharacterBody cb) => ((int)cb.teamComponent.teamIndex != 1) ? 0.5f : 0.25f));
}
private void REXHealPulse(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[5]
{
(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
(Instruction x) => ILPatternMatchingExt.MatchMul(x),
(Instruction x) => ILPatternMatchingExt.MatchStfld<HealOrb>(x, "healValue"),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 2),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.3f)
});
val.Index += 2;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<float, TreebotFlower2Projectile, float>>((Func<float, TreebotFlower2Projectile, float>)delegate(float toHeal, TreebotFlower2Projectile tbf)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Invalid comparison between Unknown and I4
if (!Object.op_Implicit((Object)(object)tbf.owner))
{
return toHeal;
}
return ((int)tbf.owner.GetComponent<CharacterBody>().teamComponent.teamIndex != 1) ? toHeal : (toHeal * 1.5f);
});
}
private void REXPrimaryAttack(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[5]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<ProjectileHealOwnerOnDamageInflicted>(x, "fractionOfDamage"),
(Instruction x) => ILPatternMatchingExt.MatchMul(x),
(Instruction x) => ILPatternMatchingExt.MatchStfld<HealOrb>(x, "healValue"),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.3f)
});
val.Index += 2;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<float, ProjectileHealOwnerOnDamageInflicted, float>>((Func<float, ProjectileHealOwnerOnDamageInflicted, float>)delegate(float toHeal, ProjectileHealOwnerOnDamageInflicted self)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if (((Object)self.projectileController).name != "SyringeProjectileHealing(Clone)")
{
return toHeal;
}
return ((int)self.projectileController.owner.GetComponent<CharacterBody>().teamComponent.teamIndex != 1) ? toHeal : (toHeal * 1.5f);
});
}
private void AcridRegenBuff(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[7]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<CharacterBody>(x, "GetBuffCount"),
(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCall<CharacterBody>(x, "get_maxHealth"),
(Instruction x) => ILPatternMatchingExt.MatchMul(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.1f),
(Instruction x) => ILPatternMatchingExt.MatchMul(x)
});
val.Index += 6;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<float, CharacterBody, float>>((Func<float, CharacterBody, float>)((float toHeal, CharacterBody cb) => ((int)cb.teamComponent.teamIndex != 1) ? toHeal : 0.2f));
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}