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 RE5Gameplay v0.3.2
patchers/RE5Gameplay.Preload.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; [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("RE5Gameplay.Preload")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RE5Gameplay.Preload")] [assembly: AssemblyTitle("RE5Gameplay.Preload")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 RE5Arsenal { public static class Preload { private static readonly ManualLogSource Log = Logger.CreateLogSource("RE5Gameplay"); private static readonly HashSet<Assembly> seen = new HashSet<Assembly>(); private static string failure; private static string castFailure; public static IEnumerable<string> TargetDLLs { get; } = Array.Empty<string>(); public static void Patch(AssemblyDefinition assembly) { } public static void Initialize() { AppDomain.CurrentDomain.AssemblyLoad += OnLoad; } private static void OnLoad(object sender, AssemblyLoadEventArgs args) { try { Assembly loadedAssembly = args.LoadedAssembly; if (!loadedAssembly.FullName.StartsWith("RE4Company,", StringComparison.Ordinal)) { return; } if (seen.Add(loadedAssembly)) { try { HashSet<string> detected = null; try { detected = Shape.ArraysWithRows(loadedAssembly.Location, Tables.Rows(loadedAssembly)); } catch (Exception ex) { Log.LogWarning((object)("RE4Gameplay's table layout could not be checked, continuing: " + ex.Message)); } Tables.Apply(Tables.Plan(loadedAssembly, detected)); } catch (Exception ex2) { failure = ex2.ToString(); } try { try { if (Bundle.Unpack(Path.Combine(Path.GetDirectoryName(typeof(Preload).Assembly.Location), "RE5Gameplay.assets"), Path.Combine(Paths.CachePath, "RE5Gameplay"))) { Log.LogInfo((object)"RE5 models and sounds unpacked from RE5Gameplay.assets."); } } catch (Exception ex3) { Log.LogWarning((object)("RE5Gameplay.assets could not be unpacked; looking for an installed Resident Evil 5 instead: " + ex3.Message)); } string archives = Re5Folder.Archives(Re5Folder.Configured(Paths.ConfigPath), Paths.GameRootPath); string models = Path.Combine(Paths.CachePath, "RE5Gameplay", "models"); List<(string, string, string, string)> members = Cast.All.Where(((string Name, string Like, string Archive, string Key) m) => File.Exists(Path.Combine(models, m.Key + ".r4m")) || (archives != null && File.Exists(Path.Combine(archives, m.Archive + ".arc")))).ToList(); HashSet<string> detected2 = null; try { detected2 = Shape.ArraysWithRows(loadedAssembly.Location, Roster.Rows(loadedAssembly)); } catch (Exception ex4) { Log.LogWarning((object)("RE4Gameplay's character layout could not be checked, continuing: " + ex4.Message)); } Tables.Apply(Roster.Plan(loadedAssembly, detected2, members)); } catch (Exception ex5) { castFailure = ex5.ToString(); } } if (failure != null) { Log.LogError((object)("RE5 guns not added, RE4Gameplay left unchanged: " + failure)); } if (castFailure != null) { Log.LogError((object)("RE5 characters not added, RE4Gameplay's characters left unchanged: " + castFailure)); } } catch (Exception ex6) { Log.LogError((object)ex6); } } } public static class Roster { private const string List = "RE4Company.PlayableCharacters.All"; public static int Rows(Assembly re4) { return ((Array)re4.GetType("RE4Company.PlayableCharacters", throwOnError: true).GetField("All").GetValue(null)).Length; } public static List<(FieldInfo Field, Array Old, Array Grown)> Plan(Assembly re4, ISet<string> detected, IReadOnlyList<(string Name, string Like, string Archive, string Key)> members) { List<(FieldInfo, Array, Array)> list = new List<(FieldInfo, Array, Array)>(); if (members.Count == 0) { return list; } if (detected != null && !detected.SetEquals(new string[1] { "RE4Company.PlayableCharacters.All" })) { throw new InvalidOperationException("RE4Gameplay's per-character tables changed (" + string.Join(", ", detected) + "). This add-on needs an update for this RE4Gameplay version"); } Type character = re4.GetType("RE4Company.PlayableCharacter", throwOnError: true); FieldInfo kind = Of("Kind"); FieldInfo fieldInfo = Of("Key"); FieldInfo name = Of("Name"); FieldInfo fieldInfo2 = Of("Bank"); FieldInfo fieldInfo3 = Of("Parts"); ConstructorInfo constructorInfo = character.GetConstructor(new Type[5] { typeof(int), typeof(string), typeof(string), typeof(string), typeof(string[]) }) ?? throw new MissingMethodException(character.Name, ".ctor"); FieldInfo fieldInfo4 = re4.GetType("RE4Company.PlayableCharacters", throwOnError: true).GetField("All", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingFieldException("PlayableCharacters", "All"); FieldInfo fieldInfo5 = re4.GetType("RE4Company.CharacterGrunts", throwOnError: true).GetField("waves", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingFieldException("CharacterGrunts", "waves"); Array all = (Array)fieldInfo4.GetValue(null); int[][] array = (int[][])fieldInfo5.GetValue(null); int length = all.Length; string[] names = (from object c in all select (string)name.GetValue(c)).ToArray(); if (members.Any(((string Name, string Like, string Archive, string Key) m) => names.Contains(m.Name))) { throw new InvalidOperationException("RE5 characters are already installed"); } if (Enumerable.Range(0, length).Any((int i) => (int)kind.GetValue(all.GetValue(i)) != i)) { throw new InvalidOperationException("RE4Gameplay's characters are no longer numbered by position"); } Array array2 = Array.CreateInstance(character, length + members.Count); Array.Copy(all, array2, length); int[][] array3 = new int[length + members.Count][]; for (int num = 0; num < length; num++) { array3[num] = ((num < array.Length) ? array[num] : array[0]); } for (int num2 = 0; num2 < members.Count; num2++) { int num3 = Array.IndexOf(names, members[num2].Like); if (num3 < 0) { throw new InvalidOperationException("RE4Gameplay has no character named " + members[num2].Like); } object value = all.GetValue(num3); array2.SetValue(constructorInfo.Invoke(new object[5] { length + num2, fieldInfo.GetValue(value), members[num2].Name, fieldInfo2.GetValue(value), fieldInfo3.GetValue(value) }), length + num2); int num4 = ((!((string)fieldInfo2.GetValue(value) == "pl00")) ? num3 : 0); if (num4 >= array.Length) { throw new InvalidOperationException("RE4Gameplay has no voice entry for " + members[num2].Like); } array3[length + num2] = array[num4]; } list.Add((fieldInfo4, all, array2)); list.Add((fieldInfo5, array, array3)); return list; FieldInfo Of(string field) { return character.GetField(field) ?? throw new MissingFieldException(character.Name, field); } } } public static class Shape { public static HashSet<string> ArraysWithRows(string dll, int rows) { //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_007e: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown HashSet<string> hashSet = new HashSet<string>(); ModuleDefinition val = ModuleDefinition.ReadModule(dll); try { foreach (TypeDefinition type in val.GetTypes()) { MethodDefinition val2 = ((IEnumerable<MethodDefinition>)type.Methods).FirstOrDefault((Func<MethodDefinition, bool>)((MethodDefinition m) => m.IsConstructor && m.IsStatic && m.HasBody)); if (val2 == null) { continue; } Instruction val3 = null; Enumerator<Instruction> enumerator2 = val2.Body.Instructions.GetEnumerator(); try { while (enumerator2.MoveNext()) { Instruction current2 = enumerator2.Current; if (current2.OpCode == OpCodes.Newarr) { if (val3 == null) { val3 = current2; } } else if (current2.OpCode == OpCodes.Stsfld) { FieldReference val4 = (FieldReference)current2.Operand; if (val3 != null && val4.FieldType.IsArray && Constant(val3.Previous) == rows) { hashSet.Add(((MemberReference)type).FullName + "." + ((MemberReference)val4).Name); } val3 = null; } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } return hashSet; } finally { ((IDisposable)val)?.Dispose(); } } private static int? Constant(Instruction ins) { //IL_000f: 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) //IL_0018: 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_0033: 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_0037: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_006f: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected I4, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 Code? obj; OpCode opCode; if (ins == null) { obj = null; } else { opCode = ins.OpCode; obj = ((OpCode)(ref opCode)).Code; } Code? val = obj; if (val.HasValue) { Code valueOrDefault = val.GetValueOrDefault(); if ((int)valueOrDefault >= 22) { if ((int)valueOrDefault <= 30) { opCode = ins.OpCode; return ((OpCode)(ref opCode)).Code - 22; } if ((int)valueOrDefault == 31) { return (sbyte)ins.Operand; } if ((int)valueOrDefault == 32) { return (int)ins.Operand; } } } return null; } } public static class Tables { private static readonly string[] Tunes = new string[10] { "Maximum", "Capacity", "Power", "Interval", "Reload", "PowerPrice", "SpeedPrice", "ReloadPrice", "CapacityPrice", "Far" }; private static readonly (string Type, string Field)[] Names = new(string, string)[8] { ("WeaponSpec", "All"), ("WeaponRigRules", "Banks"), ("WeaponRigRules", "Parents"), ("OriginalShop", "Purchase"), ("OriginalShop", "Power"), ("OriginalShop", "Capacity"), ("HeldWeaponRules", "lengths"), ("ShopRules", "prices") }.Concat(Tunes.Select((string f) => ("RetailTune", f: f))).ToArray(); public static Array Tune(string table, Array copied, bool tuned, int capacity, float interval, float reload) { Array array = (Array)copied.Clone(); double num = ((array.Length > 0) ? Convert.ToDouble(array.GetValue(0)) : 0.0); for (int i = 0; i < array.Length; i++) { switch (table) { case "Maximum": if (!tuned) { array.SetValue(1, i); } break; case "Capacity": { int num2 = (int)array.GetValue(i); array.SetValue((!tuned) ? capacity : ((num2 <= 0 || num2 >= 32768 || num <= 0.0) ? num2 : Math.Max(1, (int)Math.Round((double)(num2 * capacity) / num))), i); break; } case "Interval": case "Reload": { double num3 = (double)((table == "Interval") ? interval : reload) * 30.0; array.SetValue((!tuned || num <= 0.0) ? num3 : ((double)array.GetValue(i) * num3 / num), i); break; } case "Power": case "Far": if (!tuned) { array.SetValue(1.0, i); } break; default: if (!tuned) { array.SetValue(0, i); } break; } } return array; } public static int Rows(Assembly re4) { return ((Array)re4.GetType("RE4Company.WeaponSpec", throwOnError: true).GetField("All").GetValue(null)).Length; } public static double Score(int power, int pellets, int burst, int capacity, float interval) { burst = Math.Max(1, burst); double num = Math.Max(1.0, (double)capacity / (double)burst); return (double)power * (double)Math.Max(1, pellets) * (double)burst * Math.Sqrt(num / (double)Math.Max(0.05f, interval)); } public static int Price(int basePrice, double score, double baseScore, double steepness, double curve) { return (int)(Math.Round(Math.Sqrt((double)basePrice * Math.Pow(score / baseScore, steepness) * curve) / 500.0, MidpointRounding.AwayFromZero) * 500.0); } public static double Curve(IEnumerable<(double Score, int Price)> sameAmmo, double steepness, double score) { (double, double)[] source = (from p in sameAmmo where p.Price > 0 && p.Score > 0.0 select (X: Math.Log(p.Score), Y: Math.Log(p.Price))).ToArray(); return Math.Exp(source.Average(((double X, double Y) p) => p.Y) + steepness * (Math.Log(score) - source.Average(((double X, double Y) p) => p.X))); } public static double Steepness(IEnumerable<(double Score, int Price)> sameAmmo) { (double, double)[] array = (from p in sameAmmo where p.Price > 0 && p.Score > 0.0 select (X: Math.Log(p.Score), Y: Math.Log(p.Price))).ToArray(); if (array.Length < 2) { return 1.0; } double mx = array.Average(((double X, double Y) p) => p.X); double my = array.Average(((double X, double Y) p) => p.Y); double num = array.Sum(((double X, double Y) p) => (p.X - mx) * (p.X - mx)); if (!(num < 1E-06)) { return Math.Min(3.0, Math.Max(0.5, array.Sum(((double X, double Y) p) => (p.X - mx) * (p.Y - my)) / num)); } return 1.0; } public static List<(FieldInfo Field, Array Old, Array Grown)> Plan(Assembly re4, ISet<string> detected) { string[] array = Names.Select(((string Type, string Field) t) => "RE4Company." + t.Type + "." + t.Field).ToArray(); if (detected != null && !detected.SetEquals(array)) { throw new InvalidOperationException("RE4Gameplay's per-weapon tables changed (new: " + string.Join(", ", detected.Except(array)) + "; gone: " + string.Join(", ", array.Except(detected)) + "). This add-on needs an update for this RE4Gameplay version"); } Type spec = re4.GetType("RE4Company.WeaponSpec", throwOnError: true); FieldInfo name = Spec("Name"); FieldInfo capacity = Spec("Capacity"); FieldInfo power = Spec("Power"); FieldInfo fieldInfo = Spec("Price"); FieldInfo pellets = Spec("Pellets"); FieldInfo burst = Spec("Burst"); FieldInfo interval = Spec("Interval"); FieldInfo ammo = Spec("Ammo"); FieldInfo infinite = Spec("Infinite"); FieldInfo fieldInfo2 = Spec("Width"); FieldInfo fieldInfo3 = Spec("Height"); Dictionary<string, FieldInfo> fields = Names.ToDictionary(((string Type, string Field) t) => t.Type + "." + t.Field, ((string Type, string Field) t) => re4.GetType("RE4Company." + t.Type, throwOnError: true).GetField(t.Field, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingFieldException(t.Type, t.Field)); Dictionary<string, Array> old = fields.ToDictionary((KeyValuePair<string, FieldInfo> f) => f.Key, (KeyValuePair<string, FieldInfo> f) => (Array)f.Value.GetValue(null)); Array all = old["WeaponSpec.All"]; MethodInfo methodInfo = re4.GetType("RE4Company.WeaponTunes", throwOnError: true).GetMethod("Tunable") ?? throw new MissingMethodException("WeaponTunes", "Tunable"); FieldInfo fieldInfo4 = Spec("Reload"); int n = all.Length; foreach (KeyValuePair<string, Array> item in old) { if (item.Value.Length != n) { throw new InvalidOperationException($"{item.Key} has {item.Value.Length} rows, expected {n}"); } } string[] names = (from object w in all select (string)name.GetValue(w)).ToArray(); if (Guns.All.Any(((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => names.Contains(g.Name))) { throw new InvalidOperationException("RE5 guns are already installed"); } MethodInfo method = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<string, Array> grown = old.ToDictionary((KeyValuePair<string, Array> t) => t.Key, delegate(KeyValuePair<string, Array> t) { Array array3 = Array.CreateInstance(t.Value.GetType().GetElementType(), n + Guns.All.Length); Array.Copy(t.Value, array3, n); return array3; }); for (int num = 0; num < Guns.All.Length; num++) { (string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) gun = Guns.All[num]; int num2 = Array.IndexOf(names, gun.Like); if (num2 < 0) { throw new InvalidOperationException("RE4Gameplay has no weapon named " + gun.Like); } foreach (KeyValuePair<string, Array> item2 in old) { grown[item2.Key].SetValue(item2.Value.GetValue(num2), n + num); } string text = (from p in Guns.Poses where p.Name == gun.Name select p.Like).FirstOrDefault(); int num3 = ((text == null) ? num2 : Array.IndexOf(names, text)); if (num3 < 0) { throw new InvalidOperationException("RE4Gameplay has no weapon named " + text); } string[] array2 = new string[3] { "WeaponRigRules.Banks", "WeaponRigRules.Parents", "HeldWeaponRules.lengths" }; foreach (string key in array2) { grown[key].SetValue(old[key].GetValue(num3), n + num); } object copied = all.GetValue(num2); (double, int)[] sameAmmo = (from k in Enumerable.Range(0, n) where !(bool)infinite.GetValue(all.GetValue(k)) && (string)ammo.GetValue(all.GetValue(k)) == (string)ammo.GetValue(copied) select (Own(all.GetValue(k)), Listed(k))).ToArray(); double steepness = Steepness(sameAmmo); double score = Strength(copied, gun.Power, gun.Capacity); int num5 = (from p in Guns.Prices where p.Name == gun.Name select p.Price).DefaultIfEmpty(-1).First(); int num6 = ((!(gun.Name == "M92F")) ? ((num5 >= 0) ? num5 : (((bool)infinite.GetValue(copied)) ? Listed(num2) : Price(Listed(num2), score, Own(copied), steepness, Curve(sameAmmo, steepness, score)))) : 0); object obj = method.Invoke(copied, null); name.SetValue(obj, gun.Name); capacity.SetValue(obj, gun.Capacity); power.SetValue(obj, gun.Power); fieldInfo.SetValue(obj, num6); if (gun.Wide > 0) { fieldInfo2.SetValue(obj, gun.Wide); fieldInfo3.SetValue(obj, gun.High); } Spec("Motion").SetValue(obj, Spec("Motion").GetValue(all.GetValue(num3))); (string, string, object)[] changes = Guns.Changes; for (int num4 = 0; num4 < changes.Length; num4++) { (string, string, object) tuple = changes[num4]; if (tuple.Item1 == gun.Name) { Spec(tuple.Item2).SetValue(obj, tuple.Item3); } } grown["WeaponSpec.All"].SetValue(obj, n + num); grown["ShopRules.prices"].SetValue(num6, n + num); bool tuned = (bool)methodInfo.Invoke(null, new object[1] { num2 }) && !(bool)infinite.GetValue(obj); array2 = Tunes; foreach (string text2 in array2) { grown["RetailTune." + text2].SetValue(Tune(text2, (Array)old["RetailTune." + text2].GetValue(num2), tuned, (int)capacity.GetValue(obj), (float)interval.GetValue(obj), (float)fieldInfo4.GetValue(obj)), n + num); } } return (from t in Names select t.Type + "." + t.Field into k select (fields[k], old[k], grown[k])).ToList(); int Listed(int index) { if ((int)old["ShopRules.prices"].GetValue(index) <= 0) { return (int)old["OriginalShop.Purchase"].GetValue(index); } return (int)old["ShopRules.prices"].GetValue(index); } double Own(object w) { return Strength(w, (int)power.GetValue(w), (int)capacity.GetValue(w)); } FieldInfo Spec(string field) { return spec.GetField(field) ?? throw new MissingFieldException(spec.Name, field); } double Strength(object w, int p, int c) { return Score(p, (int)pellets.GetValue(w), (int)burst.GetValue(w), c, (float)interval.GetValue(w)); } } public static void Apply(List<(FieldInfo Field, Array Old, Array Grown)> plan) { int i = 0; try { for (; i < plan.Count; i++) { plan[i].Field.SetValue(null, plan[i].Grown); } } catch { while (i-- > 0) { plan[i].Field.SetValue(null, plan[i].Old); } throw; } } } public static class Guns { public const string Starter = "M92F"; public static readonly (string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High)[] All = new(string, string, int, int, string, int, int)[29] { ("M92F", "Handgun", 10, 28, "02", 0, 0), ("H&K P8", "Punisher", 9, 34, "10", 0, 0), ("SIG P226", "Handgun", 8, 34, "11", 0, 0), ("M93R", "Matilda", 10, 32, "1e", 0, 0), ("Ithaca M37", "Shotgun", 6, 18, "04", 0, 0), ("M3", "Riot Gun", 5, 27, "16", 0, 0), ("Jail Breaker", "Striker", 5, 16, "17", 5, 2), ("Hydra", "Striker", 4, 25, "19", 0, 0), ("VZ61", "TMP", 50, 14, "03", 0, 0), ("H&K MP5", "TMP", 45, 17, "13", 6, 2), ("AK-74", "TMP", 30, 25, "1d", 8, 2), ("SIG 556", "TMP", 40, 22, "09", 8, 2), ("S75", "Rifle", 6, 110, "05", 0, 0), ("Dragunov SVD", "Semi-auto Rifle", 7, 95, "20", 0, 0), ("H&K PSG-1", "Semi-auto Rifle", 5, 88, "1c", 0, 0), ("S&W M29", "Broken Butterfly", 6, 380, "0b", 0, 0), ("L. Hawk", "Killer7", 5, 355, "1a", 0, 0), ("S&W M500", "Broken Butterfly", 5, 530, "1b", 0, 0), ("Gatling Gun", "Chicago Typewriter", 999, 110, "15", 8, 3), ("RPG-7 NVS", "Rocket Launcher", 1, 1500, "35", 0, 0), ("Grenade Launcher", "Rocket Launcher", 12, 280, "0c", 6, 2), ("Px4", "Handgun", 15, 30, "1f", 0, 0), ("Samurai Edge", "Blacktail", 15, 38, "29", 0, 0), ("Samurai Edge (Barry)", "Punisher", 30, 50, "12", 0, 0), ("Longbow", "Krauser Bow", 1, 150, "0f", 0, 0), ("Flamethrower", "Chicago Typewriter", 100, 5, "21", 8, 2), ("L.T.D.", "Rocket Launcher", 999, 6000, "34", 0, 0), ("Stun Rod", "Handgun", 999, 110, "22", 6, 1), ("Proximity Bomb", "Handgun", 5, 800, "0a", 3, 3) }; public static readonly (string Name, string Field, object Value)[] Changes = new(string, string, object)[18] { ("Grenade Launcher", "Mode", "rocket round"), ("Grenade Launcher", "Ammo", "Grenade rounds"), ("Grenade Launcher", "Interval", 0.6f), ("Proximity Bomb", "Mode", "rocket"), ("Proximity Bomb", "Ammo", "Rockets"), ("Proximity Bomb", "Interval", 1.5f), ("Flamethrower", "Range", 7f), ("Flamethrower", "Infinite", false), ("Flamethrower", "Ammo", "Rockets"), ("M93R", "Interval", 0.4f), ("L.T.D.", "Mode", "beam"), ("L.T.D.", "Infinite", true), ("L.T.D.", "Ammo", "Energy"), ("L.T.D.", "Interval", 15f), ("Stun Rod", "Range", 2.5f), ("Stun Rod", "Infinite", true), ("Stun Rod", "Ammo", "Energy"), ("Stun Rod", "Interval", 0.9f) }; public static readonly (string Kind, float Damage, float Stun, bool Sparks, string Grenade, string Does, int Price)[] Rounds = new(string, float, float, bool, string, string, int)[6] { ("Explosive rounds", 1f, 0f, false, null, "Bursts on impact.", 4800), ("Acid rounds", 1.5f, 0f, false, null, "Bursts on impact with the strongest blast.", 2400), ("Nitrogen rounds", 0.25f, 8f, false, null, "A weak blast that freezes enemies in place for 8 seconds.", 4800), ("Flash rounds", 0f, 0f, false, "Flash grenade", "Blinds and stuns enemies like a flash grenade.", 600), ("Flame rounds", 0f, 0f, false, "Incendiary grenade", "Sets the ground on fire like an incendiary grenade.", 2400), ("Electric rounds", 0.5f, 4f, true, null, "A blast that shocks enemies in place for 4 seconds.", 1200) }; public static readonly (string Kind, string It, float R, float G, float B)[] RoundLooks = new(string, string, float, float, float)[6] { ("Explosive rounds", "0206", 0.92f, 0.5f, 0.12f), ("Acid rounds", "0207", 0.45f, 0.72f, 0.2f), ("Nitrogen rounds", "0208", 0.8f, 0.84f, 0.9f), ("Flame rounds", "020e", 0.88f, 0.16f, 0.12f), ("Flash rounds", "020f", 0.3f, 0.36f, 0.85f), ("Electric rounds", "0210", 0.42f, 0.72f, 1f) }; public const string RoundsAmmo = "Grenade rounds"; public const string RoundsLoaded = "re5gameplay.round:"; public const string RoundsLike = "Mine darts"; public const int RoundsStack = 12; public const int RoundsSold = 12; public const int RoundsFound = 12; public const string Flame = "Flamethrower"; public static readonly (string Name, float Stun) Rod = (Name: "Stun Rod", Stun: 4f); private const string Hello = "re5gameplay "; public static readonly (string Name, float Reach, float Arm, float Trigger) Bomb = (Name: "Proximity Bomb", Reach: 2.5f, Arm: 2f, Trigger: 2.5f); public static readonly (string Name, int[] Bones) Carried = (Name: "Flamethrower", Bones: new int[1] { 20 }); public static readonly (string Name, string Like)[] Poses = new(string, string)[3] { ("Flamethrower", "Striker"), ("Grenade Launcher", "Striker"), ("Hydra", "Shotgun") }; public static readonly (string Name, float Radius, float Delay, float Reach) Strike = (Name: "L.T.D.", Radius: 20f, Delay: 1f, Reach: 300f); public static readonly (string Name, double Ahead, double Under, double Side)[] Holds = new(string, double, double, double)[12] { ("H&K MP5", 0.42, 0.06, -0.025), ("AK-74", 0.42, 0.06, -0.025), ("SIG 556", 0.42, 0.065, -0.025), ("Dragunov SVD", 0.46, 0.075, -0.055), ("M3", 0.44, 0.08, -0.025), ("Ithaca M37", 0.44, 0.075, -0.025), ("Jail Breaker", 0.38, 0.07, -0.025), ("M93R", 0.27, -0.015, -0.085), ("Flamethrower", 0.5, -0.03, -0.025), ("Hydra", 0.36, -0.01, -0.025), ("Grenade Launcher", 0.47, 0.0, -0.025), ("Gatling Gun", 0.49, 0.064, -0.04) }; public static readonly string[] Foregrips = new string[5] { "Jail Breaker", "M93R", "Flamethrower", "Grenade Launcher", "Gatling Gun" }; public static readonly (string Name, float X, float Y, float Z)[] Fists = new(string, float, float, float)[2] { ("M93R", 0f, 0.6f, -0.8f), ("Gatling Gun", 1f, 0f, 0f) }; public static readonly string[] Steady = new string[3] { "Flamethrower", "M93R", "Gatling Gun" }; public static readonly (string Name, float Seconds, float Tick, int Power) Burn = (Name: "Flamethrower", Seconds: 5f, Tick: 0.5f, Power: 4); public static readonly string[] Charged = new string[1] { "Flamethrower" }; public static readonly string[] Uncounted = new string[1] { "Stun Rod" }; public static readonly string[] Hip = new string[1] { "Gatling Gun" }; public static readonly (string Name, float Degrees)[] Kicks = new(string, float)[1] { ("M93R", 5f) }; public static readonly (string Name, string Texture, double Above, string Lowered, double Sink) Removed = (Name: "RPG-7 NVS", Texture: "wp0d01", Above: 0.05, Lowered: "wp3500", Sink: 5.0); public static readonly (string Name, int Start, int Loop, int Stop)[] Loops = new(string, int, int, int)[2] { ("Gatling Gun", 4, 5, 6), ("Flamethrower", -1, 3, 5) }; public static readonly (string Name, float Spin) Gatling = (Name: "Gatling Gun", Spin: 1f); public static readonly (string Name, int Bone) Spinning = (Name: "Gatling Gun", Bone: 22); public static readonly (string Name, double Low, double High, double Up, double Down) Whirr = (Name: "Gatling Gun", Low: 45.0, High: 150.0, Up: 0.9, Down: 1.3); public static readonly (string Name, int Rounds)[] Bursts = new(string, int)[1] { ("M93R", 3) }; public const double BurstGap = 0.06; public static readonly (string Name, int[] Sounds)[] Reloads = new(string, int[])[23] { ("M92F", new int[2] { 5, 8 }), ("H&K P8", new int[3] { 5, 6, 7 }), ("SIG P226", new int[3] { 5, 6, 7 }), ("M93R", new int[3] { 5, 6, 7 }), ("Ithaca M37", new int[3] { 4, 6, 7 }), ("M3", new int[3] { 4, 5, 6 }), ("Jail Breaker", new int[3] { 5, 6, 7 }), ("Hydra", new int[3] { 6, 8, 9 }), ("VZ61", new int[3] { 4, 5, 7 }), ("H&K MP5", new int[3] { 4, 5, 7 }), ("AK-74", new int[3] { 5, 6, 8 }), ("SIG 556", new int[3] { 4, 6, 7 }), ("S75", new int[3] { 4, 5, 6 }), ("Dragunov SVD", new int[3] { 4, 5, 6 }), ("H&K PSG-1", new int[3] { 4, 5, 6 }), ("S&W M29", new int[3] { 5, 6, 8 }), ("L. Hawk", new int[3] { 5, 6, 7 }), ("S&W M500", new int[3] { 6, 7, 8 }), ("RPG-7 NVS", new int[3] { 5, 6, 7 }), ("Grenade Launcher", new int[3] { 5, 6, 7 }), ("Px4", new int[3] { 5, 6, 7 }), ("Samurai Edge", new int[2] { 5, 8 }), ("Samurai Edge (Barry)", new int[2] { 5, 8 }) }; public static readonly (string Name, int Price)[] Prices = new(string, int)[6] { ("Grenade Launcher", 50000), ("RPG-7 NVS", 75000), ("Flamethrower", 90000), ("L.T.D.", 1000000), ("Stun Rod", 15000), ("Proximity Bomb", 20000) }; public static readonly (string Name, int[] Parts, double Lift) Bow = (Name: "Longbow", Parts: new int[4] { 5, 6, 7, 8 }, Lift: 0.117); public static readonly (string Name, double Near, double Far, double Side, double Up, double HalfWide, double HalfHigh)[] Sights = new(string, double, double, double, double, double, double)[3] { ("SIG 556", 0.13, 0.139, -0.0215, 0.189, 0.015, 0.0135), ("H&K MP5", 0.199, 0.202, -0.024, 0.2035, 0.0115, 0.009), ("M93R", 0.146, 0.242, -0.023, 0.132, 0.009, 0.009) }; public const double SightRim = 0.012; public const string NightVision = "RPG-7 NVS"; public static readonly (string Name, string Like)[] Scopes = new(string, string)[2] { ("RPG-7 NVS", "Mine Thrower"), ("L.T.D.", "Mine Thrower") }; public static string Marker => "re5gameplay " + All.Length; public static bool IsRound(string kind) { return Array.Exists(Rounds, ((string Kind, float Damage, float Stun, bool Sparks, string Grenade, string Does, int Price) r) => r.Kind == kind); } public static string Loaded(IEnumerable<string> seen) { string text = seen?.LastOrDefault((string s) => s.StartsWith("re5gameplay.round:", StringComparison.Ordinal))?.Substring("re5gameplay.round:".Length); if (!IsRound(text)) { return Rounds[0].Kind; } return text; } public static string Next(string loaded, Func<string, int> carried) { int num = Array.FindIndex(Rounds, ((string Kind, float Damage, float Stun, bool Sparks, string Grenade, string Does, int Price) r) => r.Kind == loaded); for (int num2 = 1; num2 < Rounds.Length; num2++) { if (carried(Rounds[(num + num2) % Rounds.Length].Kind) > 0) { return Rounds[(num + num2) % Rounds.Length].Kind; } } return null; } public static bool RoundsInCrate(int roll) { return roll >= 99; } public static int Known(string hello) { if (hello == null || !hello.StartsWith("re5gameplay ") || !int.TryParse(hello.Substring("re5gameplay ".Length), out var result) || result <= 0) { return 0; } return Math.Min(result, All.Length); } public static double BurstFrame(double t, int rounds, double interval, int maxFrame) { double num = (double)(rounds - 1) * 0.06; if (t < 0.0 || t >= interval || interval <= num) { return -1.0; } return ((t < num) ? (t % 0.06) : (t - num)) * (double)maxFrame / (interval - num); } public static float KickAngle(double t, float degrees, int rounds, double interval) { if (t < 0.0 || t >= interval * 0.75) { return 0f; } double num = 0.0; for (int i = 0; i < rounds; i++) { double num2 = t - (double)i * 0.06; if (!(num2 < 0.0)) { num += ((num2 < 0.025) ? (num2 / 0.025) : Math.Exp((0.0 - (num2 - 0.025)) / 0.06)); } } double num3 = Math.Min(1.0, Math.Max(0.0, (interval * 0.75 - t) / (interval * 0.25))); return (float)((double)degrees * Math.Min(num, 2.2) * num3 * num3 * (3.0 - 2.0 * num3)); } public static (double X, double Y)? OnGlass(double eyeX, double eyeY, double eyeZ, double lookX, double lookY, double lookZ, double halfWide, double halfHigh) { if (lookZ < 0.5 || eyeZ >= 0.0) { return null; } double num = eyeX - lookX * eyeZ / lookZ; double num2 = eyeY - lookY * eyeZ / lookZ; if (!(Math.Abs(num) < halfWide) || !(Math.Abs(num2) < halfHigh)) { return null; } return (num, num2); } } public static class Cast { public static readonly (string Name, string Like, string Archive, string Key)[] All = new(string, string, string, string)[2] { ("Chris", "Leon", "uPl00ChrisNormal", "chris"), ("Sheva", "Ada", "uPl01ShebaNormal", "sheva") }; public const double Leon = 180.0; public static readonly (string Name, double Tall)[] Heights = new(string, double)[2] { ("Chris", 185.0), ("Sheva", 165.0) }; public static readonly (string Name, string Letter)[] Voices = new(string, string)[2] { ("Chris", "c"), ("Sheva", "s") }; public static readonly (string Arrow, int Line)[] Calls = new(string, int)[4] { ("Up", 16), ("Down", 27), ("Left", 41), ("Right", 49) }; public const int CallSound = 101; } public static class Re5Folder { public const string ConfigFile = "nod45.re5gameplay.cfg"; public const string Setting = "InstallFolder"; public const string Cache = "RE5Gameplay"; public static string Archives(string configured, string gameRoot) { return (from folder in new string[2] { configured, Path.Combine(gameRoot, "..", "Resident Evil 5") } where !string.IsNullOrEmpty(folder) select Path.Combine(folder, "nativePC_MT", "Image", "Archive")).FirstOrDefault(Directory.Exists); } public static string Configured(string configFolder) { string path = Path.Combine(configFolder, "nod45.re5gameplay.cfg"); if (!File.Exists(path)) { return ""; } string[] array = File.ReadAllLines(path); foreach (string text in array) { if (text.TrimStart().StartsWith("InstallFolder", StringComparison.Ordinal) && text.Contains("=")) { return text.Substring(text.IndexOf('=') + 1).Trim(); } } return ""; } } public static class Bundle { public const string FileName = "RE5Gameplay.assets"; private const string Stamp = "stamp.txt"; private const string Here = "{cache}"; private static string Quoted(string folder) { return folder.Replace("\\", "\\\\"); } public static void Pack(string cache, string file) { File.Delete(file); using ZipArchive zipArchive = ZipFile.Open(file, ZipArchiveMode.Create); string[] files = Directory.GetFiles(cache, "*", SearchOption.AllDirectories); foreach (string text in files) { using Stream stream = zipArchive.CreateEntry(text.Substring(cache.Length + 1).Replace('\\', '/'), CompressionLevel.Optimal).Open(); byte[] array = (text.EndsWith(".json", StringComparison.Ordinal) ? Encoding.UTF8.GetBytes(File.ReadAllText(text).Replace(Quoted(cache), "{cache}")) : File.ReadAllBytes(text)); stream.Write(array, 0, array.Length); } } public static bool Unpack(string file, string cache) { if (!File.Exists(file)) { return false; } using ZipArchive zipArchive = ZipFile.OpenRead(file); string text; using (StreamReader streamReader = new StreamReader((zipArchive.GetEntry("stamp.txt") ?? throw new InvalidDataException("RE5Gameplay.assets has no stamp.txt")).Open())) { text = streamReader.ReadToEnd(); } string path = Path.Combine(cache, "stamp.txt"); if (File.Exists(path) && File.ReadAllText(path) == text) { return false; } Directory.CreateDirectory(cache); File.Delete(path); string value = Path.GetFullPath(cache) + Path.DirectorySeparatorChar; foreach (ZipArchiveEntry entry in zipArchive.Entries) { string fullPath = Path.GetFullPath(Path.Combine(cache, entry.FullName)); if (entry.FullName == "stamp.txt" || entry.Name.Length == 0 || !fullPath.StartsWith(value, StringComparison.Ordinal)) { continue; } Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); if (!fullPath.EndsWith(".json", StringComparison.Ordinal)) { entry.ExtractToFile(fullPath, overwrite: true); continue; } using StreamReader streamReader2 = new StreamReader(entry.Open()); File.WriteAllText(fullPath, streamReader2.ReadToEnd().Replace("{cache}", Quoted(cache))); } File.WriteAllText(path, text); return true; } } public static class Slots { public const int Rows = 3; public const string Mark = "re5gameplay.slots"; public const string Stash = "re5gameplay.resting:"; public static int Columns(int caseWidth) { return 3 + ((caseWidth >= 15) ? 3 : ((caseWidth >= 14) ? 2 : ((caseWidth >= 12) ? 1 : 0))); } public static int ShownColumns(int width) { if (width < 10) { return width; } return Columns(width); } public static int ShownRows(int height) { if (height < 6) { return height; } return 3; } public static string Write(IEnumerable<(string Kind, int Count, int X, int Y, bool Rotated, bool Locked, bool Scope)> items) { List<string> list = new List<string>(); foreach (var item in items) { list.Add(string.Join("|", item.Kind, item.Count.ToString(CultureInfo.InvariantCulture), item.X.ToString(CultureInfo.InvariantCulture), item.Y.ToString(CultureInfo.InvariantCulture), item.Rotated ? "1" : "0", item.Locked ? "1" : "0", item.Scope ? "1" : "0")); } return string.Join(";", list); } public static List<(string Kind, int Count, int X, int Y, bool Rotated, bool Locked, bool Scope)> Read(string text) { List<(string, int, int, int, bool, bool, bool)> list = new List<(string, int, int, int, bool, bool, bool)>(); string[] array = (text ?? "").Split(';'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('|'); if ((array2.Length == 6 || array2.Length == 7) && array2[0].Length > 0 && int.TryParse(array2[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && result > 0 && int.TryParse(array2[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) && int.TryParse(array2[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result3)) { list.Add((array2[0], result, result2, result3, array2[4] == "1", array2[5] == "1", array2.Length == 7 && array2[6] == "1")); } } return list; } } }
plugins/RE5Gameplay.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using RE4Company; using RE5Arsenal.Re5; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; [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("RE5Gameplay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RE5Gameplay")] [assembly: AssemblyTitle("RE5Gameplay")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 RE5Arsenal { [BepInPlugin("nod45.re5gameplay", "RE5Gameplay", "0.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private readonly struct BatPose { public readonly float Turn; public readonly float Reach; public readonly float Lift; public readonly float Yaw; public readonly float Rise; public BatPose(float turn, float reach, float lift, float yaw, float rise) { Turn = turn; Reach = reach; Lift = lift; Yaw = yaw; Rise = rise; } public static BatPose Lerp(BatPose a, BatPose b, float t) { return new BatPose(Mathf.Lerp(a.Turn, b.Turn, t), Mathf.Lerp(a.Reach, b.Reach, t), Mathf.Lerp(a.Lift, b.Lift, t), Mathf.Lerp(a.Yaw, b.Yaw, t), Mathf.Lerp(a.Rise, b.Rise, t)); } } private sealed class Loop { public int Weapon; public AudioClip Start; public AudioClip Hum; public AudioClip Stop; public readonly Dictionary<ulong, (AudioSource Once, AudioSource Hum)> Sources = new Dictionary<ulong, (AudioSource, AudioSource)>(); public readonly HashSet<ulong> On = new HashSet<ulong>(); } private static readonly Dictionary<int, Vector3> fists = new Dictionary<int, Vector3>(); private static readonly HashSet<int> hip = new HashSet<int>(); private static bool batBroken; private static readonly BatPose BatRest = new BatPose(-45f, 0.52f, 0f, -160f, 55f); private static readonly (float At, BatPose Pose)[] BatSwing = new(float, BatPose)[6] { (0f, BatRest), (0.18f, new BatPose(-75f, 0.5f, 0.02f, -175f, 50f)), (0.45f, new BatPose(0f, 0.62f, -0.35f, 0f, 2f)), (0.65f, new BatPose(105f, 0.38f, -0.12f, 150f, 40f)), (0.8f, new BatPose(105f, 0.38f, -0.12f, 150f, 40f)), (1f, BatRest) }; private const float BatGap = 0.13f; private static readonly Vector3 LeftFistBar = new Vector3(0f, 0f, -1f); private static readonly Dictionary<int, (int Rounds, int Frames)> bursts = new Dictionary<int, (int, int)>(); private static readonly Dictionary<ulong, (float Real, float Told)> pulls = new Dictionary<ulong, (float, float)>(); private const float ShotStamp = -1000f; private static readonly Dictionary<int, (float Degrees, int Rounds)> kicks = new Dictionary<int, (float, int)>(); private static bool kickBroken; private static readonly Dictionary<float, int> kickRounds = new Dictionary<float, int>(); internal static (GameObject Weapon, Vector3 Pivot, Quaternion Tip, int Frame) lastKick; private const string Call = "re5gameplay.call"; private const float CallPause = 1f; private static readonly Dictionary<ulong, float> nextCall = new Dictionary<ulong, float>(); private static readonly HashSet<string> callers = new HashSet<string>(); private static float nextLocalCall; private const string BurnCall = "re5gameplay.burn"; private const string ChargeCall = "re5gameplay.charge"; private static int burner = -1; private static readonly HashSet<int> charged = new HashSet<int>(); private static readonly Dictionary<EnemyAI, (ulong Client, float Until, float Next, float Told)> burning = new Dictionary<EnemyAI, (ulong, float, float, float)>(); private static readonly Dictionary<ulong, (ParticleSystem Fire, float Until)> fires = new Dictionary<ulong, (ParticleSystem, float)>(); private static bool burnBroken; private static bool chargeBroken; private static readonly List<Loop> loops = new List<Loop>(); private static readonly Dictionary<ulong, float> lastShot = new Dictionary<ulong, float>(); private static int gatling = -1; private static float spunSince = -1f; private const float BarrelTurns = 1800f; private static readonly List<(GameObject Gun, Transform Axle, float Speed)> spinners = new List<(GameObject, Transform, float)>(); private static bool barrelsBroken; private const string Re4Id = "re4company.overhaul"; private const string BuiltFor = "0.33.2"; private static readonly Harmony Patcher = new Harmony("nod45.re5gameplay"); private static int baseCount; private static int[] templates = Array.Empty<int>(); private static int[] poses = Array.Empty<int>(); private static string archives; private static string cache; private static readonly Dictionary<int, string> motions = new Dictionary<int, string>(); private static readonly Dictionary<int, (string Right, string Left, string Wrap)> weaponHands = new Dictionary<int, (string, string, string)>(); private static bool firstPersonWrap; private static FieldInfo firstPersonCharacter; private static string[] everydayParts; private static readonly HashSet<int> wraps = new HashSet<int>(); private static readonly HashSet<int> steady = new HashSet<int>(); private static readonly Dictionary<int, Vector3> holds = new Dictionary<int, Vector3>(); private static readonly Dictionary<int, int> scopes = new Dictionary<int, int>(); private static readonly HashSet<int> reloadSounds = new HashSet<int>(); private static bool reloading; private static readonly Dictionary<int, float> tops = new Dictionary<int, float>(); private static FieldInfo firstPersonRoot; private static FieldInfo firstPersonWeapon; private static FieldInfo firstPersonIndex; private static readonly HashSet<(int Weapon, bool FirstPerson)> viewsReported = new HashSet<(int, bool)>(); private static ManualLogSource log; private static int flame = -1; private static readonly List<(GameObject Weapon, ParticleSystem Jet)> jets = new List<(GameObject, ParticleSystem)>(); private static MethodInfo findPlayer; private static int bomb = -1; private static readonly List<object> laid = new List<object>(); private static readonly List<GameObject> discs = new List<GameObject>(); private static Type projectile; private static Type enemy; private static FieldInfo shots; private static FieldInfo enemyDead; private static FieldInfo inOrbit; private static PropertyInfo round; private static MethodInfo model; private static float bombsChecked; private const string BombLaid = "re5gameplay.bomb"; private static AudioClip thud; private static int rod = -1; private static readonly List<(GameObject Knife, GameObject Rod)> knives = new List<(GameObject, GameObject)>(); private static float rodSwungAt = -10f; private static Material spark; private static MethodInfo combatOrigin; private static MethodInfo stagger; private static MethodInfo clone; private static PropertyInfo networkId; private const string Shock = "re5gameplay.shock"; private const string LobbyHello = "re5gameplay.hello"; private const string LobbyNote = "re5gameplay.note"; private static readonly Dictionary<ulong, int> known = new Dictionary<ulong, int>(); private static int hostKnows; private static bool hostWarned; private static readonly Dictionary<int, Vector3> dots = new Dictionary<int, Vector3>(); private static readonly Dictionary<int, Vector2> openings = new Dictionary<int, Vector2>(); private const string DotName = "RE5 red dot"; private static Material dotRed; private static readonly Dictionary<string, string> scopeArt = new Dictionary<string, string>(); private static int nightScope = -1; private static GameObject night; private static PropertyInfo scoped; private static readonly Dictionary<int, float> statures = new Dictionary<int, float>(); private static readonly Dictionary<int, float> toResize = new Dictionary<int, float>(); private static int shotRounds; private const float NightGain = 1.5f; private const float NightLift = 0.8f; private static readonly Vector3 KnifeHandle = new Vector3(-0.095f, -0.02f, -0.03f); private static readonly Vector3 KnifeBlade = new Vector3(-0.43f, 0f, -0.9f); private static readonly Vector3 RodHandle = new Vector3(-0.085f, -0.03f, 0f); private static readonly Vector3 RodAxis = new Vector3(0f, 0f, -1f); private static Material flameLook; private static int reloadsLogged; private const float SightClearance = 0.015f; private static readonly HashSet<(int, bool, bool)> handsReported = new HashSet<(int, bool, bool)>(); private static WeaponSpec launcher; private static int launcherIndex; private static IList flying; private static FieldInfo shotClient; private static FieldInfo shotMode; private static FieldInfo shotPower; private static FieldInfo shotPosition; private static FieldInfo shotVelocity; private static FieldInfo shotExpires; private static FieldInfo shotFuse; private static MethodInfo burst; private static FieldInfo hudBullets; private static Image grenadeIcon; private static readonly Dictionary<string, Sprite> grenadeSprites = new Dictionary<string, Sprite>(); private static bool grenadeHudBroken; private static (ulong Client, string Text)? roundNote; private static int roundsLogged; private static bool roundsBroken; private static readonly List<object> aside = new List<object>(); private static bool localSlots; private static MethodInfo characterFor; private static FieldInfo menuGrid; private static FieldInfo menuPieces; private static FieldInfo menuRoot; private static float charactersChecked; private const string StrikeCall = "re5gameplay.strike"; private static int ltd = -1; private static readonly List<(Vector3 Point, ulong Client, int Power, WeaponShot Shot, float At)> strikes = new List<(Vector3, ulong, int, WeaponShot, float)>(); private static Material beamRed; private static LineRenderer aimLaser; private static GameObject redSight; private static Text enemyName; private static readonly Color sightRed = new Color(1f, 0.3f, 0.25f, 0.95f); private static GameObject viewfinder; private static RectTransform lockBox; private static Text lockText; private static Text readout; private static bool scopeHidden; private static FieldInfo scopeRootField; private static FieldInfo nextShot; private static FieldInfo hudArt; private static RectTransform charge; private static Image chargeFill; private static readonly int[] AmmoDigits = new int[3] { 11, 10, 23 }; private const int EmptyMark = 63; private static readonly Vector2 CircleOffset = new Vector2(-3f, -2f); private const int CircleUnit = 2; private static readonly int[] BallUnits = new int[2] { 26, 48 }; private static FieldInfo hudPicture; private static readonly HashSet<int> uncounted = new HashSet<int>(); private void BatPatches() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_0100: 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: Expected O, but got Unknown //IL_0122: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown (string, float, float, float)[] array = Guns.Fists; for (int i = 0; i < array.Length; i++) { (string Name, float X, float Y, float Z) fist = array[i]; fists[baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == fist.Name)] = new Vector3(fist.X, fist.Y, fist.Z); } string[] array2 = Guns.Hip; foreach (string name in array2) { hip.Add(baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == name)); } Harmony patcher = Patcher; if (hip.Count > 0) { patcher.Patch((MethodBase)AccessTools.Method(typeof(Re4Rig), "Player", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "HipBefore", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "HipAfter", (Type[])null), (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(SourceGripAim), "Actor", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "NoHipAim", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } patcher.Patch((MethodBase)AccessTools.Method(typeof(HeldWeaponPlacement), "Support", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "UprightFist", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (rod >= 0 && tops.ContainsKey(rod)) { patcher.Patch((MethodBase)AccessTools.Method(typeof(Re4Rig), "Player", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "HoldBat", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(SourceGripAim), "Actor", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "NoRodAim", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(AimLaser), "Tick", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "NoRodLaser", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Assets), "Weapon", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RodInFist", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void UprightFist(Re4Rig rig, GameObject weapon, ActorPose pose) { //IL_005c: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)weapon == (Object)null) && pose != null && pose.Armed && !pose.Acting && !pose.Climbing && fists.TryGetValue(pose.Weapon, out var value) && (pose.Aiming || WeaponSpec.All[pose.Weapon].Motion != 0)) { Transform val = rig.Bone((HeldWeaponRules.For(pose.Weapon).GripBone == 16) ? 10 : 16); if (!((Object)(object)val == (Object)null)) { val.rotation = Quaternion.FromToRotation(val.rotation * LeftFistBar, weapon.transform.TransformDirection(value)) * val.rotation; } } } private static void HipBefore(ActorPose pose, out bool __state) { __state = pose != null && pose.Aiming && hip.Contains(pose.Weapon); if (__state) { pose.Aiming = false; } } private static Exception HipAfter(ActorPose pose, bool __state, Exception __exception) { if (__state) { pose.Aiming = true; } return __exception; } private static bool NoHipAim(ActorPose pose) { if (pose != null) { return !hip.Contains(pose.Weapon); } return true; } private static bool NoRodAim(ActorPose pose) { if (pose != null) { return pose.Weapon != rod; } return true; } private static void NoRodLaser(Controller controller, ref GameObject weapon) { if (controller != null && controller.State.Weapon == rod) { weapon = null; } } private static void RodInFist(int index, GameObject __result) { //IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0057: 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) if (index == rod && !((Object)(object)__result == (Object)null) && __result.transform.childCount != 0) { Transform child = __result.transform.GetChild(0); child.localRotation = Quaternion.FromToRotation(RodAxis, KnifeBlade); child.localPosition = KnifeHandle - child.localRotation * RodHandle; child.localScale = Vector3.one; } } private static void HoldBat(Re4Rig __instance, ActorPose pose, GameObject weapon) { //IL_00d5: 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) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0133: 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_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_0148: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: 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) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) if (batBroken || rod < 0 || pose == null || (Object)(object)weapon == (Object)null || pose.Weapon != rod || !pose.Armed || pose.Climbing) { return; } bool flag = pose.Acting && pose.Action == "knife"; if (pose.Acting && !flag) { return; } try { Transform transform = ((Component)__instance).transform; Transform val = __instance.Bone(7); Transform val2 = __instance.Bone(8); Transform val3 = __instance.Bone(10); Transform val4 = __instance.Bone(13); Transform val5 = __instance.Bone(16); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { return; } Vector3 val6 = transform.InverseTransformPoint(val.position); Vector3 val7 = transform.InverseTransformPoint(val4.position); float num = (Vector3.Distance(val.position, val2.position) + Vector3.Distance(val2.position, val3.position)) / Mathf.Max(0.0001f, transform.lossyScale.x); Vector3 val8 = Vector3.ProjectOnPlane(val6 - val7, Vector3.up); Vector3 across = ((Vector3)(ref val8)).normalized; Vector3 ahead = Vector3.Cross(across, Vector3.up); Vector3 val9 = (val6 + val7) * 0.5f; BatPose batPose = BatRest; if (flag) { float num2 = Mathf.Clamp01(pose.Age / Mathf.Max(0.05f, pose.Duration)); int i; for (i = 1; i < BatSwing.Length - 1 && num2 > BatSwing[i].At; i++) { } float num3 = Mathf.InverseLerp(BatSwing[i - 1].At, BatSwing[i].At, num2); batPose = BatPose.Lerp(BatSwing[i - 1].Pose, BatSwing[i].Pose, num3 * num3 * (3f - 2f * num3)); } Vector3 val10 = val9 + Vector3.up * batPose.Lift * num + Round(batPose.Turn) * batPose.Reach * num; val8 = Round(batPose.Yaw) * Mathf.Cos(batPose.Rise * (MathF.PI / 180f)) + Vector3.up * Mathf.Sin(batPose.Rise * (MathF.PI / 180f)); Vector3 normalized = ((Vector3)(ref val8)).normalized; Vector3 val11 = transform.TransformDirection(normalized); Quaternion rotation = val3.rotation; val8 = KnifeBlade; Quaternion val12 = Quaternion.FromToRotation(rotation * ((Vector3)(ref val8)).normalized, val11) * val3.rotation; Quaternion val13 = Quaternion.FromToRotation(val5.rotation * LeftFistBar, val11) * val5.rotation; __instance.Arm(true, val10 + normalized * 0.13f * 0.5f * num, val6 + (Vector3.down + across * 0.6f - ahead * 0.2f) * num, val12); __instance.Arm(false, val10 - normalized * 0.13f * 0.5f * num, val7 + (Vector3.down - across * 0.6f - ahead * 0.2f) * num, val13); weapon.transform.rotation = val3.rotation; weapon.transform.position = val3.position; Vector3 Round(float degrees) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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) return ahead * Mathf.Cos(degrees * (MathF.PI / 180f)) - across * Mathf.Sin(degrees * (MathF.PI / 180f)); } } catch (Exception ex) { batBroken = true; log.LogWarning((object)("Stun Rod not held as a bat: " + ex.Message)); } } private void BurstPatches() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown (string, int)[] array = Guns.Bursts; for (int i = 0; i < array.Length; i++) { (string Name, int Rounds) burst = array[i]; int num = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == burst.Name); if (!steady.Contains(num)) { bursts[num] = (burst.Rounds, OriginalMotion.Clip(WeaponSpec.All[num].AnimationBank + "_fire").MaxFrame); } } Harmony patcher = Patcher; patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RetimeBursts", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); (string, float)[] array2 = Guns.Kicks; for (int i = 0; i < array2.Length; i++) { (string Name, float Degrees) kick = array2[i]; int key = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == kick.Name); kicks[key] = (kick.Degrees, (from b in Guns.Bursts where b.Name == kick.Name select b.Rounds).DefaultIfEmpty(1).First()); } if (kicks.Count > 0) { patcher.Patch((MethodBase)AccessTools.Method(typeof(SourceGripAim), "Actor", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Kick", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void KickRounds(float stamp, int rounds) { if (kickRounds.Count > 32) { kickRounds.Clear(); } kickRounds[stamp] = rounds; } private static void Kick(Re4Rig rig, GameObject weapon, ActorPose pose) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0105: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0136: 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_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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) if (kickBroken || (Object)(object)weapon == (Object)null || pose == null || pose.ShotAt > -1000f || !kicks.TryGetValue(pose.Weapon, out (float, int) value)) { return; } try { float num = Time.time - (-1000f - pose.ShotAt); int value2; float num2 = Guns.KickAngle(interval: WeaponSpec.All[pose.Weapon].Interval, t: num, degrees: value.Item1, rounds: kickRounds.TryGetValue(pose.ShotAt, out value2) ? value2 : value.Item2); if (num2 <= 0f) { return; } Transform val = rig.Bone(HeldWeaponRules.For(pose.Weapon).GripBone); Transform val2 = rig.Bone((HeldWeaponRules.For(pose.Weapon).GripBone == 16) ? 10 : 16); Transform val3 = rig.Bone((HeldWeaponRules.For(pose.Weapon).GripBone == 16) ? 8 : 14); if (!((Object)(object)val == (Object)null)) { Quaternion val4 = Quaternion.AngleAxis(0f - num2, weapon.transform.right); Vector3 position = val.position; Vector3 val5 = (((Object)(object)val2 != (Object)null) ? (position + val4 * (val2.position - position)) : Vector3.zero); Quaternion val6 = (((Object)(object)val2 != (Object)null) ? (val4 * val2.rotation) : Quaternion.identity); weapon.transform.position = position + val4 * (weapon.transform.position - position); weapon.transform.rotation = val4 * weapon.transform.rotation; val.rotation = val4 * val.rotation; object? obj = firstPersonWeapon?.GetValue(null); if ((Object)(object)weapon == (Object)((obj is GameObject) ? obj : null)) { lastKick = (Weapon: weapon, Pivot: position, Tip: val4, Frame: Time.frameCount); } if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && pose.Aiming && HeldWeaponRules.SupportIK(pose.Weapon)) { rig.Arm(HeldWeaponRules.For(pose.Weapon).GripBone == 16, ((Component)rig).transform.InverseTransformPoint(val5), ((Component)rig).transform.InverseTransformPoint(val3.position), val6); } } } catch (Exception ex) { kickBroken = true; log.LogWarning((object)("Gun kick stopped: " + ex.Message)); } } private static void RetimeBursts() { if (bursts.Count == 0 || !Session.Connected || (Object)(object)StartOfRound.Instance == (Object)null) { return; } try { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null) { continue; } ulong actualClientId = val.actualClientId; ActorPose val2 = Presentation.Get(actualClientId); if (!val2.Armed || !bursts.TryGetValue(val2.Weapon, out (int, int) value)) { pulls.Remove(actualClientId); continue; } if (!pulls.TryGetValue(actualClientId, out (float, float) value2) || val2.ShotAt != value2.Item2) { value2.Item1 = val2.ShotAt; } double num = Guns.BurstFrame(Time.time - value2.Item1, value.Item1, WeaponSpec.All[val2.Weapon].Interval, value.Item2); value2.Item2 = (val2.ShotAt = ((num < 0.0) ? (-10f) : (Time.time - (float)num / 30f))); pulls[actualClientId] = value2; } } catch (Exception ex) { bursts.Clear(); log.LogWarning((object)("Burst animation left to RE4Gameplay: " + ex.Message)); } } private static void LoadCalls(string member, Converter.Suit suit) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 Dictionary<string, AudioClip> value = Traverse.Create(typeof(Assets)).Field<Dictionary<string, AudioClip>>("sounds").Value; int num = 0; for (int i = 0; i < Cast.Calls.Length; i++) { string text = Converter.CallFile(suit, i); if (!File.Exists(text)) { continue; } UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, (AudioType)14); try { audioClip.SendWebRequest(); Stopwatch stopwatch = Stopwatch.StartNew(); while (!audioClip.isDone && stopwatch.ElapsedMilliseconds < 5000) { Thread.Sleep(1); } if ((int)audioClip.result != 1) { log.LogWarning((object)(member + "'s call " + Cast.Calls[i].Arrow + " not loaded: " + audioClip.error)); } else { value[$"{suit.Voice}_{101 + i:000}"] = DownloadHandlerAudioClip.GetContent(audioClip); num++; } } finally { ((IDisposable)audioClip)?.Dispose(); } } if (num == Cast.Calls.Length) { callers.Add(member); } log.LogInfo((object)string.Format("{0}: {1} of {2} RE5 partner calls (hold {3} + arrow keys).", member, num, Cast.Calls.Length, ModBindings.Label("Voice"))); } private void CallPatches() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown Harmony patcher = Patcher; patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AskForCall", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Session), "Process", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "RelayCall", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Session), "Apply", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SayCall", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static string CallerOf(PlayerControllerB player) { string text = PlayableCharacters.For(player)?.Name; if (text == null || !callers.Contains(text)) { return null; } return text; } private static void AskForCall() { //IL_00ca: 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) try { Controller instance = Controller.Instance; Keyboard current = Keyboard.current; if (instance != null && current != null && !instance.MenuOpen && instance.Ready && ModBindings.Held("Voice") && !((Object)(object)Controller.Player == (Object)null) && CallerOf(Controller.Player) != null) { int num = Array.FindIndex((KeyControl[])(object)new KeyControl[4] { current.upArrowKey, current.downArrowKey, current.leftArrowKey, current.rightArrowKey }, (KeyControl k) => ((ButtonControl)k).wasPressedThisFrame); if (num >= 0 && !(Time.unscaledTime < nextLocalCall)) { nextLocalCall = Time.unscaledTime + 1f; Session.Request("re5gameplay.call", num, default(Vector3), ""); } } } catch (Exception ex) { log.LogWarning((object)("Partner call not sent: " + ex.Message)); } } private static void RelayCall(Session __instance, ulong client, Packet request) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_00ac: 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_00c0: Expected O, but got Unknown if (request.Op != "re5gameplay.call") { return; } try { PlayerControllerB val = (PlayerControllerB)findPlayer.Invoke(null, new object[1] { client }); if ((Object)(object)val == (Object)null || val.isPlayerDead || CallerOf(val) == null || request.Index < 0 || request.Index >= Cast.Calls.Length || (nextCall.TryGetValue(client, out var value) && Time.unscaledTime < value)) { return; } nextCall[client] = Time.unscaledTime + 1f; Packet val2 = new Packet { Op = "re5gameplay.call", Client = client, Index = request.Index }; ulong? num = Controller.Player?.actualClientId; if (num.HasValue) { __instance.Deliver(num.Value, val2); } foreach (KeyValuePair<ulong, int> item in known) { if (item.Value > 0 && item.Key != num) { __instance.Deliver(item.Key, val2); } } } catch (Exception ex) { log.LogWarning((object)("Partner call not relayed: " + ex.Message)); } } private static void SayCall(Packet p) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (p.Op != "re5gameplay.call") { return; } try { PlayerControllerB val = (PlayerControllerB)findPlayer.Invoke(null, new object[1] { p.Client }); PlayableCharacter val2 = (((Object)(object)val == (Object)null) ? null : PlayableCharacters.For(val)); if (val2 != null && CallerOf(val) != null && p.Index >= 0 && p.Index < Cast.Calls.Length) { Assets.Play(val2.Bank, 101 + p.Index, ((Component)val).transform.position, 0.4f, (Object)(object)val == (Object)(object)Controller.Player); } } catch (Exception ex) { log.LogWarning((object)("Partner call not played: " + ex.Message)); } } private void FlamePatches() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown burner = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == Guns.Burn.Name); string[] array = Guns.Charged; foreach (string name in array) { charged.Add(baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == name)); } Harmony patcher = Patcher; patcher.Patch((MethodBase)AccessTools.Method(typeof(DamageScale), "Hit", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Ignite", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Burn", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Fire", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "NoOldCharge", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Session), "Apply", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SeeFire", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Session), "Process", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "Charge", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ItemCharger), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ChargerReady", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ItemCharger), "ChargeItem", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ChargeHeldWeapon", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Ignite(ulong client, EnemyAI enemy) { if (!burnBroken && burner >= 0 && !((Object)(object)enemy == (Object)null) && !enemy.isEnemyDead && WeaponShots.Current?.Weapon == burner) { float time = Time.time; (ulong, float, float, float) value; (ulong, float, float, float) tuple = (burning.TryGetValue(enemy, out value) ? value : (client, 0f, time + Guns.Burn.Tick, -10f)); burning[enemy] = (client, time + Guns.Burn.Seconds, tuple.Item3, tuple.Item4); } } private static void Burn() { //IL_00aa: 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) //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) //IL_00e0: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (burning.Count == 0 || burnBroken) { return; } try { if (!Session.Connected || !Session.Host) { burning.Clear(); return; } float time = Time.time; foreach (EnemyAI item in burning.Keys.ToList()) { (ulong, float, float, float) value = burning[item]; if ((Object)(object)item == (Object)null || item.isEnemyDead || time >= value.Item2) { burning.Remove(item); continue; } if (value.Item2 - value.Item4 > 1f) { Session.Instance.Broadcast(new Packet { Op = "re5gameplay.burn", Client = ((NetworkBehaviour)item).NetworkObjectId, Amount = (int)((value.Item2 - time) * 1000f) }); value.Item4 = value.Item2; } if (time >= value.Item3) { value.Item3 += Guns.Burn.Tick; DamageScale.Hit(value.Item1, item, Guns.Burn.Power, Vector3.up); } burning[item] = value; } } catch (Exception ex) { burnBroken = true; burning.Clear(); log.LogWarning((object)("Burning stopped: " + ex.Message)); } } private static void SeeFire(Packet p) { if (p.Op != "re5gameplay.burn" || burnBroken) { return; } try { float item = Time.time + (float)p.Amount / 1000f; NetworkObject value2; if (fires.TryGetValue(p.Client, out (ParticleSystem, float) value) && (Object)(object)value.Item1 != (Object)null) { fires[p.Client] = (value.Item1, item); } else if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(p.Client, out value2)) { EnemyAI component = ((Component)value2).GetComponent<EnemyAI>(); if (!((Object)(object)component == (Object)null)) { ParticleSystem item2 = OnFire(component); fires[p.Client] = (item2, item); ((MonoBehaviour)component).StartCoroutine(BurnOut(p.Client)); } } } catch (Exception ex) { log.LogWarning((object)("Fire not shown on an enemy: " + ex.Message)); } } private static ParticleSystem OnFire(EnemyAI enemy) { //IL_0008: 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) //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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0088: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00ee: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01d1: 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) Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(((Component)enemy).transform.position + Vector3.up, Vector3.one); Renderer[] componentsInChildren = ((Component)enemy).GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { if (val2.enabled && !(val2 is ParticleSystemRenderer)) { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } GameObject val3 = new GameObject("RE5 burning"); val3.transform.SetParent(((Component)enemy).transform, false); val3.transform.position = ((Bounds)(ref val)).center; ParticleSystem val4 = val3.AddComponent<ParticleSystem>(); MainModule main = val4.main; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.4f, 0.8f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.4f, 1.2f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.25f, 0.55f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.3f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = 150; EmissionModule emission = val4.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(45f); ShapeModule shape = val4.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = Vector3.Scale(((Bounds)(ref val)).size, new Vector3(0.7f, 0.8f, 0.7f)); SizeOverLifetimeModule sizeOverLifetime = val4.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.6f), new Keyframe(0.4f, 1f), new Keyframe(1f, 0f) })); ParticleSystemRenderer component = val3.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).sharedMaterial = FlameMaterial(); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; val4.Play(); return val4; } private static IEnumerator BurnOut(ulong id) { (ParticleSystem, float) value; while (fires.TryGetValue(id, out value) && (Object)(object)value.Item1 != (Object)null && Time.time < value.Item2) { EnemyAI componentInParent = ((Component)value.Item1).GetComponentInParent<EnemyAI>(); if ((Object)(object)componentInParent == (Object)null || componentInParent.isEnemyDead) { break; } yield return null; } if (fires.TryGetValue(id, out (ParticleSystem, float) value2) && (Object)(object)value2.Item1 != (Object)null) { value2.Item1.Stop(true, (ParticleSystemStopBehavior)1); Object.Destroy((Object)(object)((Component)value2.Item1).gameObject, 1f); } fires.Remove(id); } private static bool HoldingCharged(out int weapon) { Controller instance = Controller.Instance; weapon = ((instance != null && instance.Ready && instance.Armed) ? instance.State.Weapon : (-1)); if (weapon >= 0 && charged.Contains(weapon)) { return instance.State.Owns(weapon); } return false; } private static void ChargerReady(ItemCharger __instance) { if (!chargeBroken && (Object)(object)__instance.triggerScript != (Object)null && HoldingCharged(out var _)) { __instance.triggerScript.interactable = true; } } private static bool ChargeHeldWeapon(ItemCharger __instance) { if (chargeBroken || !HoldingCharged(out var weapon)) { return true; } try { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; __instance.PlayChargeItemEffectServerRpc((int)localPlayerController.playerClientId); ((MonoBehaviour)__instance).StartCoroutine(ChargeAfterZap(__instance, weapon)); } catch (Exception ex) { chargeBroken = true; log.LogWarning((object)("Charger not used for the weapon: " + ex.Message)); } return false; } private static IEnumerator ChargeAfterZap(ItemCharger charger, int weapon) { charger.zapAudio.Play(); yield return (object)new WaitForSeconds(0.75f); charger.chargeStationAnimator.SetTrigger("zap"); Session.Request("re5gameplay.charge", weapon, default(Vector3), ""); } private static void Charge(Session __instance, ulong client, Packet request) { //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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0087: Expected O, but got Unknown if (request.Op != "re5gameplay.charge") { return; } try { int index = request.Index; if (charged.Contains(index) && __instance.Players.TryGetValue(client, out var value) && value.Owns(index)) { value.Loaded[index] = value.Capacity(index); __instance.Broadcast(new Packet { Op = "weaponammo", Client = client, Index = index, Loaded = value.Loaded[index] }); __instance.Reply(client, WeaponSpec.All[index].Name + " charged", 0, 0f); } } catch (Exception ex) { log.LogWarning((object)("Weapon not charged: " + ex.Message)); } } private static void NoOldCharge(ulong client, WeaponSpec weapon) { try { int num = Array.IndexOf(WeaponSpec.All, weapon); if (charged.Contains(num) && Session.Instance.Players.TryGetValue(client, out var value) && value.Loaded[num] > value.Capacity(num)) { value.Loaded[num] = value.Capacity(num); } } catch (Exception ex) { log.LogWarning((object)("Old charge not capped: " + ex.Message)); } } private void LoopPatches() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown gatling = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == Guns.Gatling.Name); Harmony patcher = Patcher; patcher.Patch((MethodBase)AccessTools.Method(typeof(Controller), "SendCombat", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "SpinFirst", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Assets), "Play", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "NoFlameShot", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "PlayLoops", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(Assets), "Weapon", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AddBarrels", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ArsenalCombat), "Tick", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SpinBarrels", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool LoadLoops() { if (loops.Count > 0) { return true; } (string, int, int, int)[] array = Guns.Loops; for (int i = 0; i < array.Length; i++) { (string Name, int Start, int Loop, int Stop) row = array[i]; int num = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == row.Name); string bank = WeaponSpec.All[num].Sound; Loop loop = new Loop { Weapon = num, Start = Part(0), Hum = Part(1), Stop = Part(2) }; if ((Object)(object)loop.Hum != (Object)null) { loops.Add(loop); } AudioClip Part(int part) { if (!File.Exists($"{bank}_{101 + part:000}.wav")) { return null; } return Assets.Sound(bank, 101 + part); } } return loops.Count > 0; } private static bool SpinFirst(string op) { if (op != "fire" || gatling < 0 || Controller.Instance == null || Controller.Instance.State.Weapon != gatling) { return true; } if (spunSince >= 0f) { return Time.time - spunSince >= Guns.Gatling.Spin; } return false; } private static bool NoFlameShot(string bank, int index) { if (flame < 0 || loops.Count == 0) { return true; } WeaponSpec val = WeaponSpec.All[flame]; if (bank == val.Sound && index == val.ShotSound) { return !loops.Any((Loop l) => l.Weapon == flame); } return true; } private static void PlayLoops() { try { Controller instance = Controller.Instance; spunSince = ((instance == null || !instance.Ready || !instance.Armed || !instance.Aiming || instance.State.Weapon != gatling) ? (-1f) : ((spunSince < 0f) ? Time.time : spunSince)); if (gatling < 0 || !Session.Connected || (Object)(object)StartOfRound.Instance == (Object)null || !LoadLoops()) { return; } ulong num = (ulong)(((long?)Controller.Player?.actualClientId) ?? (-1L)); foreach (Loop loop in loops) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null) { continue; } ulong actualClientId = val.actualClientId; ActorPose val2 = Presentation.Get(actualClientId); float value; bool flag = val.isPlayerControlled && !val.isPlayerDead && val2.Armed && val2.Weapon == loop.Weapon && ((loop.Weapon != flame) ? val2.Aiming : (lastShot.TryGetValue(actualClientId, out value) && Time.time - value < WeaponSpec.All[flame].Interval * 2.5f + 0.05f)); if (flag == loop.On.Contains(actualClientId)) { continue; } (AudioSource, AudioSource) tuple = Sources(loop, val, actualClientId == num); if (flag) { loop.On.Add(actualClientId); float num2 = 0f; if ((Object)(object)loop.Start != (Object)null) { tuple.Item1.Stop(); tuple.Item1.PlayOneShot(loop.Start); num2 = loop.Start.length * 0.9f; } tuple.Item2.clip = loop.Hum; tuple.Item2.PlayDelayed(num2); } else { loop.On.Remove(actualClientId); tuple.Item2.Stop(); tuple.Item1.Stop(); if ((Object)(object)loop.Stop != (Object)null) { tuple.Item1.PlayOneShot(loop.Stop); } } } } } catch (Exception ex) { foreach (Loop loop2 in loops) { foreach (var value2 in loop2.Sources.Values) { if ((Object)(object)value2.Hum != (Object)null) { value2.Hum.Stop(); } } } loops.Clear(); gatling = -1; log.LogWarning((object)("Gun loop sounds stopped: " + ex.Message)); } } private static (AudioSource Once, AudioSource Hum) Sources(Loop loop, PlayerControllerB player, bool local) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (loop.Sources.TryGetValue(player.actualClientId, out (AudioSource, AudioSource) value) && (Object)(object)value.Item2 != (Object)null && (Object)(object)value.Item1 != (Object)null) { Place(value.Item1, local, player); Place(value.Item2, local, player); return value; } GameObject val = new GameObject("RE5 gun loop " + WeaponSpec.All[loop.Weapon].Name); val.transform.SetParent(((Component)player).transform, false); val.transform.localPosition = Vector3.up * 1.3f; (AudioSource, AudioSource) tuple = (val.AddComponent<AudioSource>(), val.AddComponent<AudioSource>()); tuple.Item2.loop = true; AudioSource[] array = (AudioSource[])(object)new AudioSource[2] { tuple.Item1, tuple.Item2 }; foreach (AudioSource obj in array) { obj.playOnAwake = false; obj.volume = 0.5f; obj.dopplerLevel = 0f; obj.spatialize = false; obj.minDistance = 2f; obj.maxDistance = 35f; obj.rolloffMode = (AudioRolloffMode)1; Place(obj, local, player); } loop.Sources[player.actualClientId] = tuple; return tuple; } private static void Place(AudioSource source, bool local, PlayerControllerB player) { source.spatialBlend = (local ? 0f : 1f); if (local && (Object)(object)player.itemAudio != (Object)null) { source.outputAudioMixerGroup = player.itemAudio.outputAudioMixerGroup; } } private static void AddBarrels(int index, GameObject __result) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00b7: 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_00c0: 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) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (barrelsBroken || index != gatling || (Object)(object)__result == (Object)null || __result.transform.childCount == 0) { return; } string text = WeaponSpec.All[gatling].Model + "_barrel"; if (!File.Exists(text + ".r4m")) { return; } try { Transform child = __result.transform.GetChild(0); GameObject val = (GameObject)model.Invoke(null, new object[1] { text }); SkinnedMeshRenderer componentInChildren = val.GetComponentInChildren<SkinnedMeshRenderer>(); object obj = ((componentInChildren != null) ? componentInChildren.sharedMesh : null); if (obj == null) { MeshFilter componentInChildren2 = val.GetComponentInChildren<MeshFilter>(); obj = ((componentInChildren2 != null) ? componentInChildren2.sharedMesh : null); } Mesh val2 = (Mesh)obj; Vector3 val3; if (!((Object)(object)val2 != (Object)null)) { val3 = Vector3.zero; } else { Bounds bounds = val2.bounds; val3 = ((Bounds)(ref bounds)).center; } Vector3 val4 = val3; Transform transform = new GameObject("RE5 barrels").transform; transform.SetParent(child, false); transform.localPosition = new Vector3(0f, val4.y, val4.z); val.transform.SetParent(transform, false); val.transform.localPosition = new Vector3(0f, 0f - val4.y, 0f - val4.z); spinners.RemoveAll(((GameObject Gun, Transform Axle, float Speed) s) => (Object)(object)s.Gun == (Object)null); spinners.Add((__result, transform, 0f)); } catch (Exception ex) { barrelsBroken = true; log.LogWarning((object)("Gatling Gun barrels not added: " + (ex.InnerException ?? ex).Message)); } } private static void SpinBarrels() { //IL_00ba: 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_00ca: 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_0171: Unknown result type (might be due to invalid IL or missing references) if (spinners.Count == 0 || (Object)(object)StartOfRound.Instance == (Object)null) { return; } try { for (int num = spinners.Count - 1; num >= 0; num--) { GameObject val; Transform val2; float num2; (val, val2, num2) = spinners[num]; if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { spinners.RemoveAt(num); } else if (val.activeInHierarchy) { bool flag = false; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (!((Object)(object)val3 == (Object)null) && val3.isPlayerControlled && !val3.isPlayerDead) { Vector3 val4 = ((Component)val3).transform.position - val.transform.position; if (!(((Vector3)(ref val4)).sqrMagnitude > 9f)) { ActorPose val5 = Presentation.Get(val3.actualClientId); flag |= val5.Armed && val5.Weapon == gatling && val5.Aiming; } } } float num3 = 1800f / Mathf.Max(0.1f, Guns.Gatling.Spin); num2 = Mathf.MoveTowards(num2, flag ? 1800f : 0f, num3 * (flag ? 1f : 0.5f) * Time.deltaTime); val2.Rotate(Vector3.right, num2 * Time.deltaTime, (Space)1); spinners[num] = (val, val2, num2); } } } catch (Exception ex) { spinners.Clear(); log.LogWarning((object)("Gatling Gun barrels stopped: " + ex.Message)); } } private void Awake() { log = ((BaseUnityPlugin)this).Logger; if (!Plugin.Active) { ((BaseUnityPlugin)this).Logger.LogError((object)"RE4Gameplay did not start; RE5 guns not set up."); return; } string text = Chainloader.PluginInfos["re4company.overhaul"].Metadata.Version.ToString(); if (text != "0.33.2") { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Built for RE4Gameplay 0.33.2, found " + text + ". RE5 guns may misbehave.")); } WeaponSpec[] all = WeaponSpec.All; baseCount = Array.FindIndex(all, (WeaponSpec w) => w.Name == Guns.All[0].Name); if (baseCount < 0 || all.Length != baseCount + Guns.All.Length) { ((BaseUnityPlugin)this).Logger.LogError((object)"RE4Gameplay's weapon tables do not contain the RE5 guns. RE5Gameplay.Preload.dll must be in BepInEx/patchers; see its messages earlier in this log."); return; } templates = Guns.All.Select(((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => Array.FindIndex(all, (WeaponSpec w) => w.Name == g.Like)).ToArray(); poses = Guns.All.Select(((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g, int i) => (from p in Guns.Poses where p.Name == g.Name select Array.FindIndex(all, (WeaponSpec w) => w.Name == p.Like)).DefaultIfEmpty(templates[i]).First()).ToArray(); flame = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == "Flamethrower"); bomb = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == Guns.Bomb.Name); rod = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == Guns.Rod.Name); (string, double, double, double)[] array = Guns.Holds; for (int num = 0; num < array.Length; num++) { (string Name, double Ahead, double Under, double Side) hold = array[num]; int num2 = Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == hold.Name); if (num2 >= 0) { holds[baseCount + num2] = new Vector3((float)hold.Side, (float)hold.Under - 0.04f, (float)hold.Ahead); } } string[] foregrips = Guns.Foregrips; foreach (string name in foregrips) { wraps.Add(baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == name)); } foregrips = Guns.Steady; foreach (string name2 in foregrips) { steady.Add(baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == name2)); } (string, string)[] array2 = Guns.Scopes; for (int num = 0; num < array2.Length; num++) { (string Name, string Like) scope = array2[num]; int num3 = Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == scope.Name); int num4 = Array.FindIndex(all, (WeaponSpec w) => w.Name == scope.Like); if (num3 >= 0 && num4 >= 0) { scopes[baseCount + num3] = num4; string text2 = "scopes/" + WeaponSpec.All[baseCount + num3].AnimationBank; string text3 = "scopes/" + WeaponSpec.All[num4].AnimationBank; scopeArt[text2 + "_154_0"] = text3 + "_154_0"; scopeArt[text2 + "_160_0_cutout"] = text3 + ((num4 == 15) ? "_159_0" : "_160_0_cutout"); } } nightScope = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == "RPG-7 NVS"); if (!CompiledCodeSeesTables()) { ((BaseUnityPlugin)this).Logger.LogError((object)"Parts of RE4Gameplay still use its old weapon tables; RE5 guns will misbehave. Please report this log."); } Step("item models", Items); Step("case artwork", Artwork); Step("hand models", Hands); Step("rule patches", Patches); Step("RE5 inventory", SlotPatches); Step("grenade ammo", RoundPatches); Step("gun models", Models); Step("characters", Characters); Step("partner calls", CallPatches); Step("L.T.D. strike", StrikePatches); Step("gun loop sounds", LoopPatches); Step("burst animation", BurstPatches); Step("Stun Rod bat", BatPatches); Step("Flamethrower burning and charging", FlamePatches); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{Guns.All.Length} RE5 guns ready in RE4Gameplay {text} (weapons {baseCount}-{all.Length - 1})."); } private static bool CompiledCodeSeesTables() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) try { int num = WeaponSpec.All.Length - 1; return new Loadout().Loaded.Length == WeaponSpec.All.Length && ShopRules.Price(num) == WeaponSpec.All[num].Price && WeaponSpec.All[num].AnimationBank == WeaponSpec.All[templates[^1]].AnimationBank; } catch (IndexOutOfRangeException) { return false; } } private static Type Internal(string name) { return typeof(WeaponSpec).Assembly.GetType("RE4Company." + name, throwOnError: true); } private void Step(string name, Action action) { try { action(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"RE5 {name} failed: {arg}"); } } private static string Like(int gun) { return WeaponSpec.All[templates[gun]].Name; } private static void Items() { //IL_005e: 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_0079: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown ItemCatalog.Get("Handgun"); Dictionary<string, ItemModel> value = Traverse.Create(typeof(ItemCatalog)).Field<Dictionary<string, ItemModel>>("items").Value; for (int i = 0; i < Guns.All.Length; i++) { if (!value.TryGetValue(Like(i), out var value2)) { value2 = value["Handgun"]; } value[Guns.All[i].Name] = new ItemModel { kind = Guns.All[i].Name, inventory = value2.inventory, world = value2.world, source = value2.source, worldHeight = value2.worldHeight }; } ItemModel val = value["Mine darts"]; (string, float, float, bool, string, string, int)[] rounds = Guns.Rounds; for (int j = 0; j < rounds.Length; j++) { (string, float, float, bool, string, string, int) tuple = rounds[j]; value[tuple.Item1] = new ItemModel { kind = tuple.Item1, inventory = val.inventory, world = val.world, source = val.source, worldHeight = val.worldHeight }; } } private static void Artwork() { //IL_0052: 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) //IL_006d: 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_0085: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown CaseArtwork.Get("Handgun"); Dictionary<string, CaseArtworkEntry> value = Traverse.Create(typeof(CaseArtwork)).Field<Dictionary<string, CaseArtworkEntry>>("entries").Value; for (int i = 0; i < Guns.All.Length; i++) { if (value.TryGetValue(Like(i), out var value2)) { value[Guns.All[i].Name] = new CaseArtworkEntry { kind = Guns.All[i].Name, file = value2.file, width = value2.width, height = value2.height, pixelsPerCell = value2.pixelsPerCell, padding = value2.padding }; } } if (value.TryGetValue("Mine darts", out var value3)) { (string, float, float, bool, string, string, int)[] rounds = Guns.Rounds; for (int j = 0; j < rounds.Length; j++) { (string, float, float, bool, string, string, int) tuple = rounds[j]; value[tuple.Item1] = new CaseArtworkEntry { kind = tuple.Item1, file = value3.file, width = value3.width, height = value3.height, pixelsPerCell = value3.pixelsPerCell, padding = value3.padding }; } } } private void Models() { //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) archives = Re5Folder.Archives(((BaseUnityPlugin)this).Config.Bind<string>("RE5", "InstallFolder", "", "Your Resident Evil 5 folder (the one containing nativePC_MT). Leave empty to look next to Lethal Company in the same Steam library.").Value, Paths.GameRootPath); cache = Path.Combine(Paths.CachePath, "RE5Gameplay"); Dictionary<string, Converter.Files> dictionary = Converter.Run(archives, cache, (Func<string, (int Wide, int High)>)delegate(string name) { WeaponSpec val2 = Array.Find(WeaponSpec.All, (WeaponSpec w) => w.Name == name); return (Wide: val2.Width, High: val2.Height); }, (Action<string>)((BaseUnityPlugin)this).Logger.LogWarning); Dictionary<string, ItemModel> value = Traverse.Create(typeof(ItemCatalog)).Field<Dictionary<string, ItemModel>>("items").Value; Dictionary<string, CaseArtworkEntry> value2 = Traverse.Create(typeof(CaseArtwork)).Field<Dictionary<string, CaseArtworkEntry>>("entries").Value; for (int num = 0; num < Guns.All.Length; num++) { string item = Guns.All[num].Name; if (dictionary.TryGetValue(item, out var value3)) { WeaponSpec val = WeaponSpec.All[baseCount + num]; val.Model = value3.Model; val.Icon = "re5arsenal/" + Guns.All[num].Wp; val.Sound = value3.Sound; val.ShotSound = 1; if (File.Exists(Converter.ReloadFile(value3))) { reloadSounds.Add(baseCount + num); } if (item != Guns.Bow.Name) { tops[baseCount + num] = Converter.Top(value3.Model + ".r4m"); } value[item].world = value3.Model; value[item].inventory = value3.Case; value2[item] = new CaseArtworkEntry { kind = item, file = value3.Icon, width = val.Width, height = val.Height, pixelsPerCell = 96, padding = 2 }; } } foreach (KeyValuePair<string, Converter.Files> item2 in Converter.Boxes(cache)) { if (value.TryGetValue(item2.Key, out var value4)) { value4.world = item2.Value.Model; value4.inventory = item2.Value.Case; value2[item2.Key] = new CaseArtworkEntry { kind = item2.Key, file = item2.Value.Icon, width = 2, height = 1, pixelsPerCell = 96, padding = 2 }; } } (string, double, double, double, double, double, double)[] sights = Guns.Sights; for (int num2 = 0; num2 < sights.Length; num2++) { (string Name, double Near, double Far, double Side, double Up, double HalfWide, double HalfHigh) sight = sights[num2]; int key = baseCount + Array.FindIndex(Guns.All, ((string Name, string Like, int Capacity, int Power, string Wp, int Wide, int High) g) => g.Name == sight.Name); if (tops.ContainsKey(key)) { tops[key] = (float)sight.Up - 0.015f; openings[key] = new Vector2((float)sight.HalfWide, (float)sight.HalfHigh); dots[key] = new Vector3((float)sight.Side, (float)sight.Up, (float)(sight.Near + sight.Far) / 2f); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)((dictionary.Count == Guns.All.Length) ? "RE5 gun models, gunshots and inventory pictures in use." : ((archives == null) ? $"Resident Evil 5 not found; {Guns.All.Length - dictionary.Count} guns use RE4 stand-ins. Set InstallFolder in this mod's config if it is installed." : $"{Guns.All.Length - dictionary.Count} guns use RE4 stand-ins; see the warnings above."))); } private void Characters() { Dictionary<string, Converter.Suit> dictionary = Converter.RunCast(archives, cache, Path.Combine(Plugin.AssetPath, "models"), (Action<string>)((BaseUnityPlugin)this).Logger.LogWarning); int[][] value = Traverse.Create(typeof(CharacterGrunts)).Field<int[][]>("waves").Value; Traverse<WeaponHandBinding[]> val = HandBindings(); (string, string, string, string)[] all = Cast.All; for (int i = 0; i < all.Length; i++) { (string Name, string Like, string Archive, string Key) member = all[i]; PlayableCharacter who = Array.Find(PlayableCharacters.All, (PlayableCharacter c) => c.Name == member.Name); if (who == null) { continue; } if (!dictionary.TryGetValue(member.Name, out var suit)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)(member.Name + " looks like " + member.Like + " until the RE5 body can be converted.")); continue; } motions[who.Kind] = who.Bank; (string, double)[] heights = Cast.Heights; for (int num = 0; num < heights.Length; num++) { (string, double) tuple = heights[num]; if (tuple.Item1 == member.Name) { statures[who.Kind] = (float)(tuple.Item2 / 180.0); } } string wrap = (File.Exists(suit.GripWrap + ".r4m") ? suit.GripWrap : suit.GripLeft); weaponHands[who.Kind] = (suit.GripRight, suit.GripLeft, wrap); Set("Key", suit.Body); Set("Parts", suit.Parts); Set("Bank", suit.Voice); value[who.Kind] = new int[2] { 1, 2 }; LoadCalls(member.Name, suit); val.Value = val.Value.Concat(Enumerable.Range(0, WeaponSpec.All.Length).Select((Func<int, WeaponHandBinding>)((int weapon) => new WeaponHandBinding { character = suit.Body, weapon = weapon, right = suit.GripRight, left = (wraps.Contains(weapon) ? wrap : suit.GripLeft) }))).ToArray(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{member.Name} ready (character {who.Kind}, RE5 body on {member.Like}'s skeleton)."); void Set(string field, object value2) { AccessTools.Field(typeof(PlayableCharacter), field).SetValue(who, value2); } } } private static void OwnHeight(GameObject root) { //IL_0036: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)root == (Object)null) && toResize.TryGetValue(((Object)root).GetInstanceID(), out var value)) { toResize.Remove(((Object)root).GetInstanceID()); Transform transform = root.transform; transform.localScale *= value; Transform transform2 = root.transform; transform2.localPosition *= value; } } private static void KeepMotions(PlayableCharacter character, GameObject __result) { if (statures.TryGetValue(character.Kind, out var value)) { toResize[((Object)__result).GetInstanceID()] = value; } if (motions.TryGetValue(character.Kind, out var value2)) { Re4Rig[] componentsInChildren = __result.GetComponentsInChildren<Re4Rig>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].MotionBank = value2; } } } private static void FirstPersonHands(PlayableCharacter who) { if (weaponHands.TryGetValue(who.Kind, out (string, string, string) value)) { everydayParts = (string[])who.Parts.Clone(); firstPersonWrap = wraps.Contains(Controller.Instance?.State.Weapon ?? (-1)); who.Parts[1] = value.Item1; who.Parts[2] = (firstPersonWrap ? value.Item3 : value.Item2); } } private static void RegripFirstPerson() { Controller instance = Controller.Instance; if (instance != null && !(firstPersonCharacter == null) && weaponHands.Count != 0) { PlayableCharacter val = PlayableCharacters.For(Controller.Player); if (val != null && weaponHands.ContainsKey(val.Kind) && wraps.Contains(instance.State.Weapon) != firstPersonWrap) { firstPersonCharacter.SetValue(null, ""); } } } private static void EverydayHands(PlayableCharacter who) { if (everydayParts != null) { Array.Copy(everydayParts, who.Parts, everydayParts.Length); everydayParts = null; } } private static Traverse<WeaponHandBinding[]> HandBindings() { Traverse<WeaponHandBinding[]> obj = Traverse.Create(Internal("WeaponHands")).Field<WeaponHandBinding[]>("bindings"); string path = Path.Combine(Plugin.AssetPath, "weapon_hands.json"); Traverse<WeaponHandBinding[]> val = obj; if (val.Value == null) { WeaponHandBinding[] array = (val.Value = (File.Exists(path) ? UiDataJson.Read<WeaponHandCatalog>(File.ReadAllText(path), "weapon hands").bindings : Array.Empty<WeaponHandBinding>())); } return obj; } private static void Hands() { Traverse<WeaponHandBinding[]> obj = HandBindings(); WeaponHandBinding[] value = obj.Value; obj.Value = value.Concat(from b in value from i in Enumerable.Range(0, Guns.All.Length) where b.weapon == poses[i] select new WeaponHandBinding { character = b.character, right = b.right, left = b.left, weapon = baseCount + i }).ToArray(); } private void Patches() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_00d5: 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_00f7: Expected O, but got Unknown //IL_00f7: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0177: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0214: 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_0236: Expected O, but got Unknown //IL_0236: Expected O, but got Unknown //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_02f0: Expected O, but got Unknown //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Expected O, but got Unknown //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Expected O, but got Unknown //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Expected O, but got Unknown //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Expected O, but got Unknown //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Expected O, but got Unknown //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Expected O, but got Unknown //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0886: Expected O, but got Unknown //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Expected O, but got Unknown //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Expected O, but got Unknown //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Expected O, but got Unknown //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0967: Unknown result type (might be due to invalid IL or missing references) //IL_0972: Expected O, but got Unknown //IL_0972: Expected O, but got Unknown //IL_099b: Unknown result type (might be due to invalid IL or missing references) //IL_09a8: Expected O, but got Unknown //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_09de: Expected O, but got Unknown //IL_0a06: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Expected O, but got Unknown //IL_0a68: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Expected O, but got Unknown //IL_0a9b: Unknown result type (might be due to invalid IL or missing references) //IL_0ab2: Unknown result type (might be due to invalid IL or missing references) //IL_0abd: Expected O, but got Unknown //IL_0abd: Expected O, but got Unknown //IL_0ae5: Unknown result type (might be due to invalid IL or missing references) //IL_0af3: Expected O, but got Unknown Harmony patcher = Patcher; HarmonyMethod val = new HarmonyMethod(typeof(Plugin), "RemapWeapon", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin), "RemapIndex", (Type[])null); HarmonyMethod val3 = new HarmonyMethod(typeof(Plugin), "RemapScope", (Type[])null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ScopeRules), "Supported", (Type[])null, (Type[])null), val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(ScopeRules), "Maximum", (Type[])null, (Type[])null), val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(MotionRules), "Grip", (Type[])null, (Type[])null), val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(HeldWeaponRules), "For", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "CopiedProfile", (Type[])null), new HarmonyMethod(typeof(Plugin), "OwnForeEnd", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessTools.Method(typeof(HeldWeaponRules), "SupportIK", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ReachForeEnd", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patcher.Patch((MethodBase)AccessToo