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 EntityStates;
using EntityStates.ClayBoss;
using EntityStates.Headstompers;
using IL.EntityStates;
using IL.EntityStates.Headstompers;
using MissileRework;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MoreStats;
using On.RoR2.Items;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Items;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
[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 = "")]
[assembly: AssemblyCompany("JumpRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JumpRework")]
[assembly: AssemblyTitle("JumpRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace JumpRework;
[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.RiskOfBrainrot.FruityJumps", "FruityJumps", "1.3.1")]
[R2APISubmoduleDependency(new string[] { "LanguageAPI", "ContentAddition" })]
public class JumpReworkPlugin : BaseUnityPlugin
{
public float hopooDamageBuffDuration = 0.5f;
public static float hopooDamageIncreasePerBuff = 0.1f;
private float featherBaseDuration = 0.75f;
private float featherStackDuration = 0.5f;
public const string guid = "com.RiskOfBrainrot.FruityJumps";
public const string teamName = "RiskOfBrainrot";
public const string modName = "FruityJumps";
public const string version = "1.3.1";
public int urnBallCountBase = 3;
public int urnBallCountStack = 0;
public float urnBallYawSpread = 25f;
public static GameObject miredUrnTarball;
public static PluginInfo PInfo { get; private set; }
internal static ConfigFile CustomConfigFile { get; private set; }
public static ConfigEntry<bool> NerfDoubleJumps { get; set; }
public static ConfigEntry<bool> ReworkFeather { get; set; }
public static ConfigEntry<bool> ReworkHeadstomper { get; set; }
public static ConfigEntry<bool> ReworkUrn { get; set; }
public static ConfigEntry<float> DoubleJumpVBonus { get; set; }
public static ConfigEntry<float> DoubleJumpHBonus { get; set; }
public static ConfigEntry<int> FeatherJumpCount { get; set; }
public static ConfigEntry<int> UrnJumpCount { get; set; }
public static ConfigEntry<int> HeadstomperJumpCount { get; set; }
public static ConfigEntry<bool> HeadstomperBoostLast { get; set; }
public static ConfigEntry<float> HeadstomperBoostStrengthFirst { get; set; }
public static ConfigEntry<float> HeadstomperBoostStrengthLast { get; set; }
public static ConfigEntry<float> UrnBallChance { get; set; }
public static ConfigEntry<float> UrnBallDamageCoefficient { get; set; }
private void FeatherRework()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
OnJump.OnJumpEvent += new OnJumpHandler(FeatherOnJump);
LanguageAPI.Add("ITEM_FEATHER_PICKUP", "Double jump. Jumping gives you a boost of movement speed.");
LanguageAPI.Add("ITEM_FEATHER_DESC", $"Gain <style=cIsUtility>{FeatherJumpCount.Value}</style> jumps. " + "<style=cIsUtility>On jump</style>, increases <style=cIsUtility>movement speed</style> by <style=cIsUtility>125%</style>, " + $"fading over <style=cIsUtility>{featherBaseDuration}</style> <style=cStack>(+{featherStackDuration} per stack)</style> seconds.");
}
private void FeatherOnJump(CharacterMotor motor, CharacterBody body, ref float verticalBonus)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Inventory inventory = body.inventory;
if (!Object.op_Implicit((Object)(object)inventory))
{
return;
}
int itemCount = inventory.GetItemCount(Items.Feather);
if (itemCount <= 0 || !OnJump.IsDoubleJump(motor, body))
{
return;
}
int num = 5;
float num2 = featherBaseDuration + (float)(itemCount - 1) * featherStackDuration;
body.ClearTimedBuffs(Buffs.KillMoveSpeed);
for (int i = 0; i < num; i++)
{
body.AddTimedBuff(Buffs.KillMoveSpeed, num2 * (float)(i + 1) / (float)num);
}
EffectData val = new EffectData();
val.origin = body.corePosition;
CharacterMotor characterMotor = body.characterMotor;
bool flag = false;
if (Object.op_Implicit((Object)(object)characterMotor))
{
Vector3 moveDirection = characterMotor.moveDirection;
if (moveDirection != Vector3.zero)
{
val.rotation = Util.QuaternionSafeLookRotation(moveDirection);
flag = true;
}
}
if (!flag)
{
val.rotation = body.transform.rotation;
}
EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MoveSpeedOnKillActivate"), val, true);
}
private void StompersRework()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
HeadstompersIdle.FixedUpdateAuthority += new Manipulator(HeadstompersJumpBoost);
LanguageAPI.Add("ITEM_FALLBOOTS_PICKUP", "Quadruple jump. Hold 'Interact' to slam down to the ground.");
LanguageAPI.Add("ITEM_FALLBOOTS_DESC", $"Gain <style=cIsUtility>{HeadstomperJumpCount.Value}</style> jumps. " + "Creates a <style=cIsDamage>5m-100m</style> radius <style=cIsDamage>kinetic explosion</style> on hitting the ground, dealing <style=cIsDamage>1000%-10000%</style> base damage that scales up with <style=cIsDamage>fall distance</style>. Recharges in <style=cIsDamage>10</style> <style=cStack>(-50% per stack)</style> seconds.");
}
private void HeadstompersJumpBoost(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BaseHeadstompersState>(x, "get_isGrounded")
});
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<bool, HeadstompersIdle, bool>>((Func<bool, HeadstompersIdle, bool>)delegate(bool isGrounded, HeadstompersIdle self)
{
bool result = isGrounded;
if (HeadstomperBoostLast.Value)
{
CharacterMotor bodyMotor = ((BaseHeadstompersState)self).bodyMotor;
if (Object.op_Implicit((Object)(object)bodyMotor))
{
result = OnJump.IsLastJump(bodyMotor, ((BaseHeadstompersState)self).body);
}
}
return result;
});
val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdflda<Vector3>(x, "y"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x)
});
float num = default(float);
val.GotoNext((MoveType)0, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num),
(Instruction x) => ILPatternMatchingExt.MatchMul(x)
});
val.Remove();
val.Emit(OpCodes.Ldc_R4, HeadstomperBoostLast.Value ? HeadstomperBoostStrengthLast.Value : HeadstomperBoostStrengthFirst.Value);
}
public static bool IsMissileArtifactEnabled()
{
if (Tools.isLoaded("com.RiskOfBrainrot.IAmBecomeMissiles"))
{
return GetMissileArtifactEnabled();
}
return false;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static bool GetMissileArtifactEnabled()
{
return RunArtifactManager.instance.IsArtifactEnabled(MissileReworkPlugin.MissileArtifact);
}
public void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Expected O, but got Unknown
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Expected O, but got Unknown
CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\FruityJumps.cfg", true);
NerfDoubleJumps = CustomConfigFile.Bind<bool>("Reworks", "Nerf Double Jump Strength", true, "");
ReworkFeather = CustomConfigFile.Bind<bool>("Reworks", "Rework Hopoo Feather", true, "");
ReworkHeadstomper = CustomConfigFile.Bind<bool>("Reworks", "Rework Hopoo Feather", true, "");
ReworkUrn = CustomConfigFile.Bind<bool>("Reworks", "Rework Hopoo Feather", true, "");
DoubleJumpVBonus = CustomConfigFile.Bind<float>("Jump Strength", "Double Jump Vertical Strength", 0.8f, "Vertical strength bonus of double jumps. Vanilla base jumps are 1, double jumps 1.5");
DoubleJumpHBonus = CustomConfigFile.Bind<float>("Jump Strength", "Double Jump Horizontal Strength", 1.1f, "Horizontal strength bonus of double jumps. Vanilla base jumps are 1, double jumps 1.3");
FeatherJumpCount = CustomConfigFile.Bind<int>("Jump Counts", "Hopoo Feather Jump Count", 1, "Only applies if its respective rework is enabled.");
HeadstomperJumpCount = CustomConfigFile.Bind<int>("Jump Counts", "Headstomper Jump Count", 3, "Only applies if its respective rework is enabled.");
UrnJumpCount = CustomConfigFile.Bind<int>("Jump Counts", "Mired Urn Jump Count", 2, "Only applies if its respective rework is enabled.");
HeadstomperBoostLast = CustomConfigFile.Bind<bool>("Headstompers", "Should Headstompers boost the last jump instead of the first?", true, "");
HeadstomperBoostStrengthFirst = CustomConfigFile.Bind<float>("Headstompers", "Headstompers First Super Jump Strength", 1.2f, "Only applies if the Super Jump is configured to be first. Vanilla is 2");
HeadstomperBoostStrengthLast = CustomConfigFile.Bind<float>("Headstompers", "Headstompers Final Super Jump Strength", 2f, "Only applies if the Super Jump is configured to be last");
UrnBallChance = CustomConfigFile.Bind<float>("Mired Urn", "Mired Urn Ball Chance", 0.25f, "Stacks identically, approaches 100%");
UrnBallDamageCoefficient = CustomConfigFile.Bind<float>("Mired Urn", "Urn Ball Damage Coefficient", 6.5f, "Multiply by 100 for %, ie 6.5 is 650%");
CreateMiredUrnTarball();
if (ReworkUrn.Value || ReworkHeadstomper.Value)
{
StatHooks.GetMoreStatCoefficients += new MoreStatHookEventHandler(JumpCounts);
}
if (NerfDoubleJumps.Value)
{
GenericCharacterMain.ProcessJump_bool += new Manipulator(DoubleJumpStrengthNerf);
}
if (ReworkFeather.Value)
{
BaseStats.FeatherJumpCountBase = FeatherJumpCount.Value;
BaseStats.FeatherJumpCountStack = 0;
FeatherRework();
}
if (ReworkHeadstomper.Value)
{
StompersRework();
}
if (ReworkUrn.Value)
{
MiredUrnRework();
}
}
private void JumpCounts(CharacterBody sender, MoreStatHookEventArgs args)
{
Inventory inventory = sender.inventory;
if (Object.op_Implicit((Object)(object)inventory))
{
if (inventory.GetItemCount(Items.SiphonOnLowHealth) > 0 && ReworkUrn.Value)
{
args.jumpCountAdd += UrnJumpCount.Value;
}
if (inventory.GetItemCount(Items.FallBoots) > 0 && ReworkHeadstomper.Value)
{
args.jumpCountAdd += HeadstomperJumpCount.Value;
}
}
}
private void DoubleJumpStrengthNerf(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext((MoveType)2, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityState>(x, "get_characterBody"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CharacterBody>(x, "baseJumpCount")
});
int horizontalBoostLoc = 3;
float num2 = default(float);
val.GotoNext((MoveType)0, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num2),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref horizontalBoostLoc)
});
val.Remove();
val.Emit(OpCodes.Ldc_R4, DoubleJumpHBonus.Value);
int index = val.Index;
val.Index = index + 1;
int verticalBoostLoc = 4;
float num = default(float);
val.GotoNext((MoveType)0, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref verticalBoostLoc)
});
val.Remove();
val.Emit(OpCodes.Ldc_R4, DoubleJumpVBonus.Value);
}
private void MiredUrnRework()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
OnJump.OnJumpEvent += new OnJumpHandler(UrnOnJump);
SiphonOnLowHealthItemBodyBehavior.OnEnable += new hook_OnEnable(VoidVanillaUrnBehavior);
LanguageAPI.Add("ITEM_SIPHONONLOWHEALTH_PICKUP", "Triple jump. Jumping fires tar balls in front of you.");
LanguageAPI.Add("ITEM_SIPHONONLOWHEALTH_DESC", $"Gain <style=cIsUtility>{UrnJumpCount.Value}</style> jumps. " + "While in danger, jumping has a <style=cIsUtility>" + Tools.ConvertDecimal(UrnBallChance.Value) + " chance</style> <style=cStack>(+" + Tools.ConvertDecimal(UrnBallChance.Value) + " per stack)</style> to fire <style=cIsDamage>sentient tar pots</style> in front of you, dealing <style=cIsDamage>" + Tools.ConvertDecimal(UrnBallDamageCoefficient.Value) + "</style> damage and <style=cIsUtility>tarring</style> enemies hit.");
}
private void CreateMiredUrnTarball()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
miredUrnTarball = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ClayBoss/TarSeeker.prefab").WaitForCompletion(), "MiredUrnTarball", true);
ProjectileImpactExplosion component = miredUrnTarball.GetComponent<ProjectileImpactExplosion>();
if (Object.op_Implicit((Object)(object)component))
{
component.lifetime = 2f;
}
ContentAddition.AddProjectile(miredUrnTarball);
}
private void VoidVanillaUrnBehavior(orig_OnEnable orig, SiphonOnLowHealthItemBodyBehavior self)
{
self.DestroyAttachment();
Object.Destroy((Object)(object)self);
}
private void UrnOnJump(CharacterMotor motor, CharacterBody body, ref float verticalBonus)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
if (body.outOfDanger)
{
return;
}
int num = 0;
Inventory inventory = body.inventory;
if (Object.op_Implicit((Object)(object)inventory))
{
num = body.inventory.GetItemCount(Items.SiphonOnLowHealth);
}
if (!Util.CheckRoll((1f - Mathf.Pow(1f - UrnBallChance.Value, (float)num)) * 100f, body.master))
{
return;
}
Util.PlaySound(FireTarball.attackSoundString, ((Component)body).gameObject);
Ray aimRay = body.inputBank.GetAimRay();
if (Object.op_Implicit((Object)(object)FireTarball.effectPrefab))
{
EffectManager.SimpleMuzzleFlash(FireTarball.effectPrefab, ((Component)body).gameObject, "", false);
}
if (((NetworkBehaviour)body).hasAuthority)
{
if (IsMissileArtifactEnabled())
{
int num2 = 3;
float num3 = urnBallYawSpread * 2f / (float)(num2 + 1);
float num4 = (float)(num2 - 1) * urnBallYawSpread;
float num5 = num4 / 2f;
for (int i = 0; i < num2; i++)
{
float num6 = (float)(i / (num2 - 1)) * num4 - num5;
float num7 = urnBallYawSpread * (float)i - num3 * 2f;
Vector3 forward = Util.ApplySpread(((Ray)(ref aimRay)).direction, 0f, 0f, 1f, 0f, num7, 0f);
FireTarballProjectile(body, ((Ray)(ref aimRay)).origin, forward);
}
}
else
{
FireTarballProjectile(body, ((Ray)(ref aimRay)).origin, ((Ray)(ref aimRay)).direction);
}
}
body.AddSpreadBloom(FireTarball.spreadBloomValue);
}
private void FireTarballProjectile(CharacterBody body, Vector3 origin, Vector3 forward)
{
//IL_000b: 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_000d: Unknown result type (might be due to invalid IL or missing references)
ProjectileManager.instance.FireProjectile(miredUrnTarball, origin, Util.QuaternionSafeLookRotation(forward), ((Component)body).gameObject, body.damage * UrnBallDamageCoefficient.Value, 0f, Util.CheckRoll(body.crit, body.master), (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
}
}
public static class Tools
{
internal static bool isLoaded(string modguid)
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
string key = pluginInfo.Key;
PluginInfo value = pluginInfo.Value;
if (key == modguid)
{
return true;
}
}
return false;
}
internal static string ConvertDecimal(float d)
{
return d * 100f + "%";
}
public static void ClearDotStacksForType(this DotController dotController, DotIndex dotIndex)
{
//IL_001e: 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)
for (int num = dotController.dotStackList.Count - 1; num >= 0; num--)
{
if (dotController.dotStackList[num].dotIndex == dotIndex)
{
dotController.RemoveDotStackAtServer(num);
}
}
}
}