using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using KinematicCharacterController;
using On.EntityStates;
using On.RoR2;
using On.RoR2.UI;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
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("RaisingTheBar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RaisingTheBar")]
[assembly: AssemblyTitle("RaisingTheBar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RaissingTheBar;
[BepInPlugin("com.brynzananas.raisingthebar", "Raising The Bar", "1.0.0")]
[BepInDependency("com.bepis.r2api", "5.0.10")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
public struct LineDrawer
{
private LineRenderer lineRenderer;
private float lineSize;
public LineDrawer(Material material, float lineSize = 0.2f)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("LineObj");
lineRenderer = val.AddComponent<LineRenderer>();
((Renderer)lineRenderer).material = material;
this.lineSize = lineSize;
}
private void init(Material material, float lineSize = 0.2f)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if ((Object)(object)lineRenderer == (Object)null)
{
GameObject val = new GameObject("LineObj");
lineRenderer = val.AddComponent<LineRenderer>();
((Renderer)lineRenderer).material = material;
this.lineSize = lineSize;
}
}
public void DrawLineInGameView(Vector3 start, Vector3 end, Color color, Material material)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lineRenderer == (Object)null)
{
init(material);
}
lineRenderer.startColor = color;
lineRenderer.endColor = color;
lineRenderer.startWidth = lineSize;
lineRenderer.endWidth = lineSize;
lineRenderer.positionCount = 2;
lineRenderer.SetPosition(0, start);
lineRenderer.SetPosition(1, end);
}
public void Destroy()
{
if ((Object)(object)lineRenderer != (Object)null)
{
Object.Destroy((Object)(object)((Component)lineRenderer).gameObject);
}
}
}
public const string ModGuid = "com.brynzananas.raisingthebar";
public const string ModName = "Raising The Bar";
public const string ModVer = "1.0.0";
public LineDrawer lineDrawer;
public LineDrawer lineDrawer2;
public Material lineDrawerMaterial = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Bear/matBear.mat").WaitForCompletion();
public Material lineDrawer2Material = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC1/BearVoid/matBearVoid.mat").WaitForCompletion();
public static ConfigEntry<bool> EnableBunnyHop;
public static ConfigEntry<bool> EnableAutoJump;
public static ConfigEntry<bool> EnableStrafe;
public static ConfigEntry<bool> EnableStrafeDebug;
public static ConfigEntry<bool> EnableDirectLook;
public static ConfigEntry<bool> EnableVelocityText;
public static ConfigEntry<Color> VelocityTextColor;
public static ConfigEntry<bool> EnableRainbowVelocityText;
public static ConfigEntry<float> VelocityTextXPosition;
public static ConfigEntry<float> VelocityTextYPosition;
public int red = 255;
public int green = 0;
public int blue = 0;
private HUD hud = null;
public GameObject hudObject;
public RectTransform RectTransform;
public bool enabledDebug = false;
public bool firstPersonActive = false;
public bool firstPersonApplied = false;
public CameraParamsOverrideHandle overrideHandle;
private void Awake()
{
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Expected O, but got Unknown
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Expected O, but got Unknown
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: 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_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Expected O, but got Unknown
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Expected O, but got Unknown
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Expected O, but got Unknown
EnableBunnyHop = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable bunny hop", true, "Enable bunny hop function?");
EnableAutoJump = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable auto jump", false, "Enable auto jump function?");
EnableStrafe = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable strafing", true, "Enable strafing function?");
EnableStrafeDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable debug mode", false, "Enable debug mode?\nLong brown bear: current velocity\nShort purple bear: wish direction");
EnableDirectLook = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable direct look", true, "Enable direct look?");
EnableVelocityText = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enable velocity meter", true, "Enable velocity meter?");
VelocityTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("HUD", "Velocity meter color", Color.white, "Choose color of velocity meter");
EnableRainbowVelocityText = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enable rainbow velocity meter", false, "or make it rainbow");
VelocityTextXPosition = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Velocity meter X position", 0f, "Control velocity text X position");
VelocityTextYPosition = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Velocity meter Y position", -500f, "Control velocity meter Y position");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableBunnyHop));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableAutoJump));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableStrafe));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableStrafeDebug));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableDirectLook));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableVelocityText));
ModSettingsManager.AddOption((BaseOption)new ColorOption(VelocityTextColor));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableRainbowVelocityText));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(VelocityTextXPosition));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(VelocityTextYPosition));
ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Refresh velocity meter", "HUD", "Refreshes velocity meter position", " ", new UnityAction(RefreshVelocityMeter)));
GenericCharacterMain.ApplyJumpVelocity += new hook_ApplyJumpVelocity(BunnyHop);
PlayerCharacterMasterController.Update += new hook_Update(Look);
PlayerCharacterMasterController.FixedUpdate += new hook_FixedUpdate(Strafe);
HUD.Awake += new hook_Awake(AwakeHud);
HUD.Update += new hook_Update(UpdateNumbers);
lineDrawer = default(LineDrawer);
lineDrawer2 = default(LineDrawer);
if (Object.op_Implicit((Object)(object)LoadSpriteFromDisk()))
{
ModSettingsManager.SetModIcon(LoadSpriteFromDisk());
}
}
private Sprite LoadSpriteFromDisk()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "icon.png");
if (!File.Exists(path))
{
return null;
}
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
return null;
}
private void Strafe(orig_FixedUpdate orig, PlayerCharacterMasterController self)
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
if (EnableStrafe.Value && Object.op_Implicit((Object)(object)self.body) && self.body.isPlayerControlled && Object.op_Implicit((Object)(object)self.body.characterMotor) && !self.body.characterMotor.isGrounded)
{
if (self.body.characterMotor.airControl != 0.01f)
{
self.body.characterMotor.airControl = 0.01f;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(self.body.characterMotor.velocity.x, 0f, self.body.characterMotor.velocity.z);
Vector3 val2 = new Vector3(self.body.inputBank.moveVector.x, 0f, self.body.inputBank.moveVector.z);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
float num = Vector3.Dot(((Vector3)(ref val)).normalized, normalized);
if ((double)num < 0.1 && (double)num > -0.1)
{
CharacterMotor characterMotor = self.body.characterMotor;
characterMotor.velocity += new Vector3(normalized.x, 0f, normalized.z);
}
}
orig.Invoke(self);
}
private void RefreshVelocityMeter()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
((Transform)RectTransform).localPosition = new Vector3(0.5f, 0.5f, 0f);
RectTransform rectTransform = RectTransform;
((Transform)rectTransform).localPosition = ((Transform)rectTransform).localPosition + new Vector3(VelocityTextXPosition.Value, VelocityTextYPosition.Value, 0f);
}
private void UpdateNumbers(orig_Update orig, HUD self)
{
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (EnableRainbowVelocityText.Value)
{
if (red >= 255 && blue <= 0)
{
green++;
}
if (green >= 255 && red > 0)
{
red--;
}
if (green >= 255 && red <= 0)
{
blue++;
}
if (blue >= 255 && green > 0)
{
green--;
}
if (blue >= 255 && green <= 0)
{
red++;
}
if (red >= 255 && blue > 0)
{
blue--;
}
}
if (Object.op_Implicit((Object)(object)hudObject) && Object.op_Implicit((Object)(object)self.targetMaster) && Object.op_Implicit((Object)(object)self.targetMaster.GetBody()) && Object.op_Implicit((Object)(object)self.targetMaster.GetBody().characterMotor))
{
float num = 0f;
if (EnableVelocityText.Value)
{
Text component = hudObject.GetComponent<Text>();
Vector2 val = new Vector2(self.targetMaster.GetBody().characterMotor.velocity.x, self.targetMaster.GetBody().characterMotor.velocity.z);
component.text = ((int)((Vector2)(ref val)).magnitude).ToString();
num = 1f;
}
Color color = default(Color);
((Color)(ref color))..ctor(VelocityTextColor.Value.r, VelocityTextColor.Value.g, VelocityTextColor.Value.b, num);
if (EnableRainbowVelocityText.Value)
{
((Color)(ref color))..ctor((float)red / 255f, (float)green / 255f, (float)blue / 255f, num);
}
((Graphic)hudObject.GetComponent<Text>()).color = color;
}
}
private void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
HUD.Awake -= new hook_Awake(AwakeHud);
}
private void AwakeHud(orig_Awake orig, HUD self)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
hud = self;
hudObject = new GameObject("velocityMeter");
hudObject.transform.SetParent(hud.mainContainer.transform);
RectTransform = hudObject.AddComponent<RectTransform>();
RectTransform.anchorMin = Vector2.zero;
RectTransform.anchorMax = Vector2.one;
RectTransform.sizeDelta = Vector2.zero;
RectTransform.pivot = new Vector2(0.5f, 0.5f);
RectTransform.anchoredPosition = new Vector2(0.5f, 0.5f);
((Transform)RectTransform).localScale = Vector2.op_Implicit(new Vector2(1f, 1f));
RectTransform rectTransform = RectTransform;
((Transform)rectTransform).localPosition = ((Transform)rectTransform).localPosition + new Vector3(VelocityTextXPosition.Value, VelocityTextYPosition.Value, 0f);
hudObject.AddComponent<Text>();
hudObject.GetComponent<Text>().font = Addressables.LoadAssetAsync<Font>((object)"RoR2/Base/Common/Fonts/Bombardier/BOMBARD_.ttf").WaitForCompletion();
hudObject.GetComponent<Text>().fontStyle = (FontStyle)0;
hudObject.GetComponent<Text>().fontSize = 32;
hudObject.GetComponent<Text>().lineSpacing = 1f;
hudObject.GetComponent<Text>().supportRichText = true;
hudObject.GetComponent<Text>().alignment = (TextAnchor)4;
hudObject.GetComponent<Text>().alignByGeometry = true;
hudObject.GetComponent<Text>().horizontalOverflow = (HorizontalWrapMode)0;
hudObject.GetComponent<Text>().verticalOverflow = (VerticalWrapMode)1;
hudObject.GetComponent<Text>().resizeTextForBestFit = true;
hudObject.GetComponent<Text>().text = "Your current velocity";
((Object)hudObject.GetComponent<Text>()).name = "currentVelocity";
((Graphic)hudObject.GetComponent<Text>()).color = Color.white;
((Graphic)hudObject.GetComponent<Text>()).material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/Fonts/Bombardier/BOMBARD_.ttf").WaitForCompletion();
}
private void Look(orig_Update orig, PlayerCharacterMasterController self)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (EnableDirectLook.Value && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.characterMotor))
{
_ = self.body.characterDirection.forward;
if (true)
{
self.body.characterDirection.forward = Vector3.RotateTowards(self.body.characterDirection.forward, self.body.inputBank.aimDirection, 90f, 0f);
}
}
if (EnableStrafeDebug.Value && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.characterMotor))
{
lineDrawer.DrawLineInGameView(self.body.corePosition, self.body.corePosition + self.bodyMotor.velocity, Color.red, lineDrawerMaterial);
lineDrawer2.DrawLineInGameView(self.body.corePosition, self.body.corePosition + self.bodyInputs.moveVector, Color.blue, lineDrawer2Material);
if (!enabledDebug)
{
enabledDebug = true;
}
}
if (enabledDebug && !EnableStrafeDebug.Value)
{
lineDrawer.Destroy();
lineDrawer2.Destroy();
enabledDebug = false;
}
if (EnableAutoJump.Value && Object.op_Implicit((Object)(object)self.bodyInputs) && self.bodyInputs.jump.down)
{
self.bodyInputs.jump.down = false;
}
}
private void BunnyHop(orig_ApplyJumpVelocity orig, CharacterMotor characterMotor, CharacterBody characterBody, float horizontalBonus, float verticalBonus, bool vault)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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)
if (EnableBunnyHop.Value)
{
if (vault)
{
characterMotor.velocity = characterMotor.moveDirection;
}
else
{
Vector3 val = (((Vector3)(ref characterMotor.velocity)).magnitude + (horizontalBonus - 1f) * 20f - ((Vector3)(ref characterMotor.velocity)).magnitude) * ((Vector3)(ref characterMotor.velocity)).normalized;
characterMotor.velocity += new Vector3(val.x, characterBody.jumpPower * verticalBonus, val.z);
}
((BaseCharacterController)characterMotor).Motor.ForceUnground(0.1f);
}
else
{
orig.Invoke(characterMotor, characterBody, horizontalBonus, verticalBonus, vault);
}
}
}