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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Loader;
using HG.Reflection;
using IL.RoR2.UI;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Loader;
using On.RoR2.Projectile;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
internal static void info(object data)
{
logger.LogInfo(data);
}
internal static void message(object data)
{
logger.LogMessage(data);
}
internal static void warning(object data)
{
logger.LogWarning(data);
}
internal static void error(object data)
{
logger.LogError(data);
}
internal static void fatal(object data)
{
logger.LogFatal(data);
}
}
public class TextHud
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_Awake <>9__21_0;
public static hook_OnDisable <>9__21_1;
internal void <StartTextHud>b__21_0(orig_Awake orig, HUD self)
{
orig.Invoke(self);
hud = self;
TextHud.onAwake?.Invoke();
}
internal void <StartTextHud>b__21_1(orig_OnDisable orig, HUD self)
{
orig.Invoke(self);
hud = null;
TextHud.onOnDisable?.Invoke();
}
}
public static HUD hud;
private GameObject objhud;
private string hudName;
private HGTextMeshProUGUI textMesh;
public bool resetOnTargetChanged = true;
public Vector2 rectSize = new Vector2(200f, 200f);
private ConfigEntry<bool> toggleEntry;
private ConfigEntry<int> fontsizeEntry;
private ConfigEntry<Vector2> positionEntry;
public bool enabled
{
get
{
if (toggleEntry == null)
{
return true;
}
return toggleEntry.Value;
}
}
public int fontSize
{
get
{
if (fontsizeEntry == null)
{
return -1;
}
return fontsizeEntry.Value;
}
}
public Vector2 position => positionEntry.Value;
public static event Action onAwake;
public static event Action onOnDisable;
public static void StartTextHud()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
object obj = <>c.<>9__21_0;
if (obj == null)
{
hook_Awake val = delegate(orig_Awake orig, HUD self)
{
orig.Invoke(self);
hud = self;
TextHud.onAwake?.Invoke();
};
<>c.<>9__21_0 = val;
obj = (object)val;
}
HUD.Awake += (hook_Awake)obj;
object obj2 = <>c.<>9__21_1;
if (obj2 == null)
{
hook_OnDisable val2 = delegate(orig_OnDisable orig, HUD self)
{
orig.Invoke(self);
hud = null;
TextHud.onOnDisable?.Invoke();
};
<>c.<>9__21_1 = val2;
obj2 = (object)val2;
}
HUD.OnDisable += (hook_OnDisable)obj2;
}
public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
hudName = name;
positionEntry = configFile.Bind<Vector2>(name, "Position", defaultPosition, "Position of " + name + ", starting from bottom left corner");
DoHooks(configFile);
}
public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle)
: this(configFile, name, defaultPosition)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle, "Toggles " + name);
}
public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, int defaultFontSize)
: this(configFile, name, defaultPosition)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize, "Font size of " + name);
}
public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle, int defaultFontSize)
: this(configFile, name, defaultPosition)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle, "Toggles " + name);
fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize, "Font size of " + name);
}
public void UpdateText(StringBuilder text)
{
if (enabled)
{
if ((Object)(object)objhud == (Object)null)
{
InitHud();
}
((TMP_Text)textMesh).SetText(text);
}
}
public void UpdateText(string text)
{
if (enabled)
{
if ((Object)(object)objhud == (Object)null)
{
InitHud();
}
((TMP_Text)textMesh).SetText(text, true);
}
}
public void Destroy()
{
Object.Destroy((Object)(object)objhud);
}
private void InitHud()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
objhud = new GameObject(hudName);
if (Object.op_Implicit((Object)(object)hud))
{
objhud.transform.SetParent(hud.mainContainer.transform, false);
}
RectTransform obj = objhud.AddComponent<RectTransform>();
obj.anchorMin = Vector2.zero;
obj.anchorMax = Vector2.zero;
obj.sizeDelta = rectSize;
obj.anchoredPosition = position;
textMesh = objhud.AddComponent<HGTextMeshProUGUI>();
((TMP_Text)textMesh).outlineColor = Color32.op_Implicit(Color.black);
((TMP_Text)textMesh).fontSizeMin = 6f;
if (fontSize >= 0)
{
((TMP_Text)textMesh).fontSize = fontSize;
}
log.info("Created " + hudName);
}
private void DoHooks(ConfigFile configFile)
{
onAwake += delegate
{
if (Object.op_Implicit((Object)(object)objhud))
{
objhud.transform.SetParent(hud.mainContainer.transform, false);
}
};
HUD.onHudTargetChangedGlobal += delegate
{
if (resetOnTargetChanged && Object.op_Implicit((Object)(object)objhud))
{
UpdateText("");
}
};
configFile.ConfigReloaded += delegate
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)objhud))
{
if (!enabled)
{
Object.Destroy((Object)(object)objhud);
}
else
{
objhud.GetComponent<RectTransform>().anchoredPosition = position;
if (fontSize >= 0)
{
((TMP_Text)textMesh).fontSize = fontSize;
}
}
}
};
}
}
namespace LoaderRuler;
internal class SpeedText : MonoBehaviour
{
internal static TextHud speedTextHud;
internal static string recentNormal = "";
internal static TimeStamp timestamp = TimeStamp.negativeInfinity;
private CharacterMotor motor;
private Vector3 prevposition = Vector3.zero;
private void OnEnable()
{
motor = ((Component)this).GetComponent<CharacterMotor>();
if (!Object.op_Implicit((Object)(object)motor))
{
log.error("failed to get motor");
}
}
private void OnDisable()
{
HUD hud = TextHud.hud;
if ((Object)(object)((hud != null) ? hud.targetBodyObject : null) == (Object)(object)((Component)this).gameObject)
{
speedTextHud.Destroy();
}
}
private void FixedUpdate()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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)
HUD hud = TextHud.hud;
if ((Object)(object)((hud != null) ? hud.targetBodyObject : null) != (Object)(object)((Component)this).gameObject)
{
return;
}
float num;
if ((Object)(object)((Component)this).gameObject == (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBodyObject && Object.op_Implicit((Object)(object)motor))
{
num = ((Vector3)(ref motor.velocity)).magnitude;
}
else
{
Vector3 val = ((Component)this).transform.position - prevposition;
num = ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime;
prevposition = ((Component)this).transform.position;
}
int num2 = (int)((double)LRConfig.SpeedFontSize.Value * (2.0 - Math.Cos(Math.Min(num / 200f, 600f))));
if (recentNormal != "")
{
speedTextHud.UpdateText(new StringBuilder().AppendFormat("<size={0}>{1} : <size={2}>{3}</size></size>", LRConfig.SpeedFontSize.Value, recentNormal, num2, num.ToString("0")));
if (((TimeStamp)(ref timestamp)).hasPassed)
{
recentNormal = "";
}
}
else
{
speedTextHud.UpdateText(new StringBuilder().AppendFormat("<size={0}>{1}</size>", num2, num.ToString("0")));
}
}
}
internal static class LRConfig
{
public static ConfigFile configFile;
public static ConfigEntry<int> LRPunchHudCount;
public static ConfigEntry<bool> GLLengthToggle;
public static ConfigEntry<bool> GLEnergyToggle;
public static ConfigEntry<bool> GLSlamToggle;
public static ConfigEntry<bool> VelocityToggle;
public static ConfigEntry<float> VelocityScale;
public static ConfigEntry<string> VelocityIcon;
public static ConfigEntry<bool> VelocityStaticColor;
public static ConfigEntry<Vector3> VelocityColor;
public static ConfigEntry<int> SpeedFontSize;
public static ConfigEntry<float> speedDot;
public static ConfigEntry<bool> SprintCrosshair;
internal static void DoConfig()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
configFile = new ConfigFile(Paths.ConfigPath + "//LoaderRuler.cfg", true);
LRPunchHudCount = configFile.Bind<int>("PunchHud", "Count", 3, "How many previous punches to display");
GLLengthToggle = configFile.Bind<bool>("Grapple Length", "Length text", false, "Display length text");
GLEnergyToggle = configFile.Bind<bool>("Grapple Length", "Energy text", true, "Display your \"energy\". Kinetic + grapple length * grapple acceleration + height * gravity");
GLSlamToggle = configFile.Bind<bool>("Grapple Length", "Include Slam energy", true, "If in slam state, include slam acceleration in gravity potential");
VelocityToggle = configFile.Bind<bool>("VelocityIndicator", "Toggle", true, "Toggle display of velocity indicator, may require game restart");
VelocityScale = configFile.Bind<float>("VelocityIndicator", "Scale", 0.25f, "Scale of icon");
VelocityStaticColor = configFile.Bind<bool>("VelocityIndicator", "Static Color", false, "If color of icon should be static");
VelocityColor = configFile.Bind<Vector3>("VelocityIndicator", "Color", new Vector3(125f, 255f, 125f), "Color32 rgb of icon. Static Color must be enabled for this to apply");
VelocityIcon = configFile.Bind<string>("VelocityIndicator", "IconPath", "Textures/MiscIcons/texBarrelIcon", "Path to icon. Must be sprite or Texture2D.\nAddressables at: https://xiaoxiao921.github.io/GithubActionCacheTest/assetPathsDump.html filter for '.png', include full path.");
SpeedFontSize = configFile.Bind<int>("Speed Text", "Font size", 15, "Base font size of speed text");
speedDot = configFile.Bind<float>("Speed Text", "Punch angle duration", 1f, "How long after punching should the 'angle :' portion linger");
SprintCrosshair = configFile.Bind<bool>("Misc", "Sprint Crosshair", false, "If Loader's sprint crosshair should be enabled");
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void LRReloadConfig(ConCommandArgs args)
{
configFile.Reload();
VelocityVectorDisplay.DoPrefab();
}
}
internal class Grapple
{
internal static TextHud grappleDurationHud;
internal static TextHud grappleLengthHud;
private static float lastHeight;
internal static void DoSetup()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
grappleDurationHud = new TextHud(LRConfig.configFile, "GrappleDurationHud", new Vector2(850f, 550f), 15);
grappleLengthHud = new TextHud(LRConfig.configFile, "Grapple Length", new Vector2(1170f, 390f), defaultToggle: false, 15);
ProjectileGrappleController.OnDestroy += new hook_OnDestroy(Grapple_OnDestroy_On);
BaseState.FixedUpdate += new hook_FixedUpdate(State_FixedUpdate_On);
}
private static void State_FixedUpdate_On(orig_FixedUpdate orig, BaseState self)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: 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)
//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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
BaseState val = (BaseState)(object)((self is BaseState) ? self : null);
GameObject gameObject = val.owner.gameObject;
HUD hud = TextHud.hud;
if ((Object)(object)gameObject != (Object)(object)((hud != null) ? hud.targetBodyObject : null))
{
return;
}
ProjectileSimple projectileSimple = val.grappleController.projectileSimple;
float num = 1f - projectileSimple.stopwatch / projectileSimple.lifetime;
Color val2 = default(Color);
((Color)(ref val2))..ctor(1f, 3f * num, 3f * num);
float num2 = projectileSimple.lifetime - projectileSimple.stopwatch;
grappleDurationHud.UpdateText(Util.GenerateColoredString(num2.ToString("0"), Color32.op_Implicit(val2)));
if (!grappleLengthHud.enabled)
{
return;
}
float num3 = Vector3.Distance(val.aimOrigin, val.position);
StringBuilder stringBuilder = new StringBuilder();
if (LRConfig.GLLengthToggle.Value)
{
if (num3 < 10f)
{
stringBuilder.AppendLine(num3.ToString("0.0"));
}
else
{
stringBuilder.AppendLine(num3.ToString("0"));
}
}
if ((Object)(object)((EntityState)self).characterBody == (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody || LRConfig.GLEnergyToggle.Value)
{
float distance = lastHeight;
Ray val3 = new Ray(val.owner.characterBody.footPosition, Vector3.down);
LayerIndex world = LayerIndex.world;
RaycastHit val4 = default(RaycastHit);
if (Physics.Raycast(val3, ref val4, 300f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)2))
{
distance = ((RaycastHit)(ref val4)).distance;
}
float num4 = ((LRConfig.GLSlamToggle.Value && val.owner.characterMotor.airControl == GroundSlam.airControl) ? GroundSlam.verticalAcceleration : 0f);
stringBuilder.Append(((((Vector3)(ref val.owner.characterMotor.velocity)).sqrMagnitude / 2f + val.grappleController.acceleration * num3 - (Physics.gravity.y + num4) * distance) / 100f).ToString("0"));
}
grappleLengthHud.UpdateText(stringBuilder);
}
private static void Grapple_OnDestroy_On(orig_OnDestroy orig, ProjectileGrappleController self)
{
orig.Invoke(self);
grappleDurationHud.UpdateText("");
grappleLengthHud.UpdateText("");
}
}
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("LoaderRulerguid", "LoaderRuler", "1.0.6")]
internal class LRMain : BaseUnityPlugin
{
private void Awake()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
log.start(((BaseUnityPlugin)this).Logger);
LRConfig.DoConfig();
TextHud.StartTextHud();
PunchText.DoSetup();
Grapple.DoSetup();
VelocityVectorDisplay.DoSetup();
if (LRConfig.SprintCrosshair.Value)
{
CrosshairManager.UpdateCrosshair += new Manipulator(UpdateCrosshair_IL);
}
log.info("LoaderRuler finished");
}
private void UpdateCrosshair_IL(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_isSprinting")
});
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)((CharacterBody body) => (LRConfig.SprintCrosshair.Value || (int)body.bodyIndex != 70) ? true : false));
val.Emit(OpCodes.And);
}
}
internal class PunchText
{
internal class PunchTrack
{
internal string normal;
internal bool slamedFirst;
internal bool hasHit;
internal void Reset(float dot)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (dot < 0f)
{
dot = 0f;
}
normal = (dot * 100f).ToString("0");
Color val = default(Color);
((Color)(ref val))..ctor(2f * (1f - dot), 2f * (dot - 0.5f), 0f);
normal = Util.GenerateColoredString(normal, Color32.op_Implicit(val));
slamedFirst = false;
hasHit = false;
}
internal PunchTrack()
{
normal = string.Empty;
slamedFirst = false;
hasHit = true;
}
}
internal static TextHud punchTextHud;
private static PunchTrack punchTrack = new PunchTrack();
private static List<string> textlist = new List<string>();
internal static void DoSetup()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
punchTextHud = new TextHud(LRConfig.configFile, "PunchHud", new Vector2(750f, 150f));
TextHud.onOnDisable += delegate
{
textlist.Clear();
};
BaseSwingChargedFist.OnEnter += new hook_OnEnter(OnEnter_On);
GroundSlam.DetonateAuthority += new hook_DetonateAuthority(DetonateAuthority_On);
BaseSwingChargedFist.onHitAuthorityGlobal += OnMeleeHitAuthority_Ac;
}
private static void UpdatePunchText(string text)
{
int value = LRConfig.LRPunchHudCount.Value;
if (textlist.Count >= value)
{
textlist.RemoveRange(value - 1, textlist.Count - value + 1);
}
textlist.Insert(0, text);
string text2 = "";
foreach (string item in textlist)
{
text2 = text2 + "\n" + item;
}
punchTextHud.UpdateText(text2);
}
private static void OnEnter_On(orig_OnEnter orig, BaseSwingChargedFist self)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0078: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((EntityState)self).characterBody != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody)
{
orig.Invoke(self);
return;
}
Vector3 normalized = ((Vector3)(ref ((EntityState)self).characterMotor.velocity)).normalized;
Ray aimRay = ((BaseState)self).GetAimRay();
float dot = Vector3.Dot(normalized, ((Ray)(ref aimRay)).direction);
orig.Invoke(self);
punchTrack.Reset(dot);
SpeedText.recentNormal = punchTrack.normal;
SpeedText.timestamp = TimeStamp.now + LRConfig.speedDot.Value;
}
private static Result DetonateAuthority_On(orig_DetonateAuthority orig, GroundSlam self)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_0014: Unknown result type (might be due to invalid IL or missing references)
Result val = orig.Invoke(self);
if (!punchTrack.hasHit && val.hitCount > 0)
{
punchTrack.slamedFirst = true;
}
return val;
}
private static void OnMeleeHitAuthority_Ac(BaseSwingChargedFist self)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)((EntityState)self).characterBody != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody) && !punchTrack.hasHit)
{
Color val = (punchTrack.slamedFirst ? Color.gray : Color.white);
int num = (punchTrack.slamedFirst ? 16 : ((int)(30.0 - 15.0 * Math.Cos(Math.Min(self.punchSpeed / 200f, 600f)))));
string arg = self.punchSpeed.ToString("0");
UpdatePunchText(Util.GenerateColoredString($"<size=16>{punchTrack.normal} : <size={num}>{arg}</size></size>", Color32.op_Implicit(val)));
punchTrack.hasHit = true;
}
}
}
internal class VelocityVectorDisplay
{
private class VelocityIndicator : MonoBehaviour
{
private GameObject indicator;
private CharacterMotor motor;
private Vector3 prevposition = Vector3.zero;
private void OnEnable()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
indicator = Object.Instantiate<GameObject>(prefab);
if (!Object.op_Implicit((Object)(object)indicator))
{
log.error("vi indicator did not instantiate");
return;
}
motor = ((Component)this).GetComponent<CharacterMotor>();
if (!Object.op_Implicit((Object)(object)motor))
{
log.error("failed to get motor");
return;
}
UICamera.onUICameraPreCull += new UICameraDelegate(CamUpdate);
CameraRigController.onCameraTargetChanged += CamTargetChanged;
}
private void OnDestroy()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
Object.Destroy((Object)(object)indicator);
UICamera.onUICameraPreCull -= new UICameraDelegate(CamUpdate);
CameraRigController.onCameraTargetChanged -= CamTargetChanged;
}
internal void CamUpdate(UICamera uiCamera)
{
//IL_0083: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_0079: 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_00c8: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00e4: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: 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_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
if (!LRConfig.VelocityToggle.Value)
{
return;
}
CameraRigController cameraRigController = uiCamera.cameraRigController;
if ((Object)(object)cameraRigController.target != (Object)(object)((Component)this).gameObject)
{
return;
}
Camera sceneCam = cameraRigController.sceneCam;
Camera camera = uiCamera.camera;
SpriteRenderer component = indicator.GetComponent<SpriteRenderer>();
float num;
Vector3 normalized;
if ((Object)(object)LocalUserManager.GetFirstLocalUser().cachedBodyObject == (Object)(object)((Component)this).gameObject)
{
num = ((Vector3)(ref motor.velocity)).magnitude;
normalized = ((Vector3)(ref motor.velocity)).normalized;
}
else
{
Vector3 val = ((Component)this).transform.position - prevposition;
num = ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime;
normalized = ((Vector3)(ref val)).normalized;
prevposition = ((Component)this).transform.position;
}
Vector3 val2 = ((Component)cameraRigController).transform.position + normalized * 100f;
Vector3 val3 = sceneCam.WorldToScreenPoint(val2);
if (val3.z <= 0f)
{
((Renderer)component).enabled = false;
return;
}
val3.z = 1f;
Vector3 val4 = camera.ScreenToWorldPoint(val3);
InputBankTest component2 = ((Component)this).GetComponent<InputBankTest>();
if (LRConfig.VelocityStaticColor.Value || !Object.op_Implicit((Object)(object)component2))
{
component.color = Color.op_Implicit(Vector4.op_Implicit(LRConfig.VelocityColor.Value) / 255f + new Vector4(0f, 0f, 0f, num / 100f));
}
else
{
float num2 = Vector3.Dot(normalized, component2.aimDirection);
component.color = new Color(2f * (1f - num2), 2f * (num2 - 0.5f), 0f, num / 100f);
}
((Renderer)component).enabled = true;
indicator.transform.SetPositionAndRotation(val4, ((Component)uiCamera).transform.rotation);
}
private void CamTargetChanged(CameraRigController camrig, GameObject target)
{
((Renderer)indicator.GetComponent<SpriteRenderer>()).enabled = false;
}
}
private static GameObject prefab;
internal static void DoSetup()
{
//IL_0019: 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)
DoPrefab();
SpeedText.speedTextHud = new TextHud(LRConfig.configFile, "Speed Text", new Vector2(970f, 490f), defaultToggle: true);
if (LRConfig.VelocityToggle.Value || SpeedText.speedTextHud.enabled)
{
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderBody.prefab").WaitForCompletion();
val.AddComponent<VelocityIndicator>();
if (SpeedText.speedTextHud.enabled)
{
val.AddComponent<SpeedText>();
}
}
}
internal static void DoPrefab()
{
//IL_002a: 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_0072: 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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Expected O, but got Unknown
//IL_0167: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
log.info("Loading sprite");
Sprite val = ((!LRConfig.VelocityIcon.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Sprite>(LRConfig.VelocityIcon.Value) : Addressables.LoadAssetAsync<Sprite>((object)LRConfig.VelocityIcon.Value).WaitForCompletion());
if (!Object.op_Implicit((Object)(object)val))
{
Texture2D val2 = ((!LRConfig.VelocityIcon.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Texture2D>(LRConfig.VelocityIcon.Value) : Addressables.LoadAssetAsync<Texture2D>((object)LRConfig.VelocityIcon.Value).WaitForCompletion());
if (Object.op_Implicit((Object)(object)val2))
{
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height);
val = Sprite.Create(val2, val3, new Vector2(0.5f, 0.5f));
}
}
if (!Object.op_Implicit((Object)(object)val))
{
Debug.LogError((object)"Failed to load sprite, using default instead");
val = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texBarrelIcon");
}
else
{
log.info("Loaded " + ((Object)val).name);
}
GameObject val4 = new GameObject("VelocitySprite")
{
layer = LayerIndex.ui.intVal
};
Transform transform = val4.transform;
transform.localScale *= LRConfig.VelocityScale.Value / 10f;
val4.AddComponent<SpriteRenderer>().sprite = val;
prefab = PrefabAPI.InstantiateClone(val4, "VelocityPrefab", false);
Object.Destroy((Object)val4);
}
}