Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of chai tea v0.1.0
MintTea.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using On.EntityStates; using On.RoR2; using R2API.Utils; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MintTea")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MintTea")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("57a82728-34f5-4024-9c24-40e2824c6bde")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace MintTea; internal class Configuration { public static ConfigEntry<float> MaxAirAccel { get; set; } public static ConfigEntry<float> AirAccel { get; set; } public static ConfigEntry<bool> AutoHop { get; set; } public static void InitConfig(ConfigFile configFile) { MaxAirAccel = configFile.Bind<float>("Quake", "Max air acceleration", 3f, "I don't know what this number does. Default: 3"); AirAccel = configFile.Bind<float>("Quake", "Air acceleration", 30f, "Higher values mean more speedgain while strafing. Default: 30"); AutoHop = configFile.Bind<bool>("Quake", "Auto hop", true, "Automatically jump when landing while holding the jump key. Default: true"); } } internal class DefaultMovement { public static void AirMovement(CharacterMotor self, float deltaTime) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) //IL_00cb: 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_0084: 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) float num = self.acceleration * (self.disableAirControlUntilCollision ? 0f : self.airControl); Vector3 val = self.moveDirection; if (!self.isFlying) { val.y = 0f; } CharacterBody obj = Reflection.Access<CharacterBody>(self, "body"); if (obj != null && obj.isSprinting && 0f < ((Vector3)(ref val)).magnitude && ((Vector3)(ref val)).magnitude < 1f) { val /= ((Vector3)(ref val)).magnitude; } Vector3 val2 = val * self.walkSpeed; if (!self.isFlying) { val2.y = self.velocity.y; } self.velocity = Vector3.MoveTowards(self.velocity, val2, num * deltaTime); } public static void GroundMovement(CharacterMotor self, float deltaTime) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) float acceleration = self.acceleration; Vector3 val = self.moveDirection; if (!self.isFlying) { val.y = 0f; } CharacterBody obj = Reflection.Access<CharacterBody>(self, "body"); if (obj != null && obj.isSprinting && 0f < ((Vector3)(ref val)).magnitude && ((Vector3)(ref val)).magnitude < 1f) { val /= ((Vector3)(ref val)).magnitude; } Vector3 val2 = val * self.walkSpeed; if (!self.isFlying) { val2.y = self.velocity.y; } self.velocity = Vector3.MoveTowards(self.velocity, val2, acceleration * deltaTime); } } [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.wellme.MintTea", "Mint tea", "0.1.4")] public class MintTea : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_ApplyJumpVelocity <>9__1_3; internal void <Awake>b__1_3(orig_ApplyJumpVelocity orig, CharacterMotor characterMotor, CharacterBody characterBody, float horizontalBonus, float verticalBonus, bool vault) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity = characterMotor.velocity; orig.Invoke(characterMotor, characterBody, horizontalBonus, verticalBonus, vault); Vector3 velocity2 = characterMotor.moveDirection * characterBody.moveSpeed * horizontalBonus; if (((Vector3)(ref characterMotor.velocity)).sqrMagnitude < ((Vector3)(ref velocity2)).sqrMagnitude) { velocity2.y = characterMotor.velocity.y; characterMotor.velocity = velocity2; } else { velocity.y = characterMotor.velocity.y; characterMotor.velocity = velocity; } } } private Dictionary<CharacterMotor, MintTeaInfo> info = new Dictionary<CharacterMotor, MintTeaInfo>(); public void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //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) //IL_007e: Expected O, but got Unknown Reflection.Logger = ((BaseUnityPlugin)this).Logger; Configuration.InitConfig(((BaseUnityPlugin)this).Config); CharacterMotor.PreMove += (hook_PreMove)delegate(orig_PreMove orig, CharacterMotor self, float deltaTime) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity3 = self.velocity; orig.Invoke(self, deltaTime); if (IsPlayerControlled(self)) { self.velocity = velocity3; PreMove(self, deltaTime); } }; if (Configuration.AutoHop.Value) { GenericCharacterMain.GatherInputs += (hook_GatherInputs)delegate(orig_GatherInputs orig, GenericCharacterMain self) { orig.Invoke(self); CharacterMotor motor2; if (Reflection.Access<bool>(self, "hasInputBank") && (motor2 = GetMotor(self)) != null) { GetInfo(motor2).GroundedJump = Reflection.AccessProperty<InputBankTest>(self, typeof(EntityState), "inputBank").jump.down; } }; } GenericCharacterMain.ProcessJump += (hook_ProcessJump)delegate(orig_ProcessJump orig, GenericCharacterMain self) { CharacterMotor motor = GetMotor(self); if (motor != null && motor.isGrounded) { MintTeaInfo mintTeaInfo = GetInfo(motor); if (mintTeaInfo != null && mintTeaInfo.GroundedJump) { Reflection.Set(self, "jumpInputReceived", true); } } orig.Invoke(self); }; object obj = <>c.<>9__1_3; if (obj == null) { hook_ApplyJumpVelocity val = delegate(orig_ApplyJumpVelocity orig, CharacterMotor characterMotor, CharacterBody characterBody, float horizontalBonus, float verticalBonus, bool vault) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity = characterMotor.velocity; orig.Invoke(characterMotor, characterBody, horizontalBonus, verticalBonus, vault); Vector3 velocity2 = characterMotor.moveDirection * characterBody.moveSpeed * horizontalBonus; if (((Vector3)(ref characterMotor.velocity)).sqrMagnitude < ((Vector3)(ref velocity2)).sqrMagnitude) { velocity2.y = characterMotor.velocity.y; characterMotor.velocity = velocity2; } else { velocity.y = characterMotor.velocity.y; characterMotor.velocity = velocity; } }; <>c.<>9__1_3 = val; obj = (object)val; } GenericCharacterMain.ApplyJumpVelocity += (hook_ApplyJumpVelocity)obj; } private void PreMove(CharacterMotor self, float deltaTime) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!self.hasEffectiveAuthority) { return; } if (GetInfo(self).LeniencyFrame || !self.isGrounded) { Quake.AirMovement(self, Configuration.MaxAirAccel.Value, Configuration.AirAccel.Value); } else { DefaultMovement.GroundMovement(self, deltaTime); } if (self.useGravity) { self.velocity.y += Physics.gravity.y * deltaTime; if (self.isGrounded) { self.velocity.y = Mathf.Max(self.velocity.y, 0f); } } GetInfo(self).LeniencyFrame = !self.isGrounded; } private MintTeaInfo GetInfo(CharacterMotor motor) { if ((Object)(object)motor == (Object)null) { return null; } if (info.TryGetValue(motor, out var value)) { return value; } return info[motor] = new MintTeaInfo { Motor = motor, LeniencyFrame = false }; } private static CharacterMotor GetMotor(GenericCharacterMain genericCharacterMain) { return Reflection.AccessProperty<CharacterMotor>(genericCharacterMain, typeof(EntityState), "characterMotor"); } private bool IsPlayerControlled(CharacterMotor motor) { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { object obj; if (instance == null) { obj = null; } else { CharacterMaster master = instance.master; if (master == null) { obj = null; } else { CharacterBody body = master.GetBody(); obj = ((body != null) ? body.characterMotor : null); } } if ((Object)obj == (Object)(object)motor) { return true; } } return false; } } internal class MintTeaInfo { public CharacterMotor Motor { get; set; } public bool LeniencyFrame { get; set; } public bool GroundedJump { get; set; } } internal class Reflection { public static ManualLogSource Logger { get; set; } public static T Access<T>(object o, string field) { FieldInfo field2 = o.GetType().GetField(field, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.GetField); if (field2 == null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("Unrecognized field " + field + " in class " + o.GetType().FullName)); } } return (T)field2.GetValue(o); } public static T AccessProperty<T>(object o, Type type, string field) { PropertyInfo property = type.GetProperty(field, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty); if (property == null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("Unrecognized property " + field + " in class " + type.FullName)); } } return (T)property.GetValue(o); } public static void Set(object o, string field, object value) { FieldInfo field2 = o.GetType().GetField(field, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.GetField); field2.SetValue(o, value); } } internal class Quake { public static void AirMovement(CharacterMotor characterMotor, float maxAirAccel, float airAccel) { //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_0037: 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_0049: 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) //IL_0050: 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_008b: 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) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) Vector3 moveDirection = characterMotor.moveDirection; float num = (((double)((Vector3)(ref moveDirection)).sqrMagnitude > 0.0001) ? quake_getMoveSpeed(characterMotor) : 0f); if (num > maxAirAccel) { num = maxAirAccel; } Vector3 velocity = characterMotor.velocity; velocity.y = 0f; Vector3 val = velocity; moveDirection = characterMotor.moveDirection; float num2 = Vector3.Dot(val, ((Vector3)(ref moveDirection)).normalized); float num3 = num - num2; if (num3 > 0f) { float num4 = airAccel * num; if (num4 > num3) { num4 = num3; } Vector3 velocity2 = characterMotor.velocity; moveDirection = characterMotor.moveDirection; characterMotor.velocity = velocity2 + ((Vector3)(ref moveDirection)).normalized * num4; } } private static float quake_getMoveSpeed(CharacterMotor characterMotor) { return characterMotor.walkSpeed; } }