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 LukesWeapons v0.1.1
LukesWeapons.dll
Decompiled 5 hours 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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using ModMenu; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; 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("LukesWeapons")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+280b27fb7a6717f4036802db103ed6d7d925c6c5")] [assembly: AssemblyProduct("LukesWeapons")] [assembly: AssemblyTitle("LukesWeapons")] [assembly: AssemblyVersion("0.1.1.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 HazardPay { internal static class Overrides { private class Slot { public RuntimeAnimatorController Base; public AnimatorOverrideController Ours; public WeaponKind Kind; } private struct Param { public string Name; public AnimatorControllerParameterType Type; public float F; public int I; public bool B; } private struct Layer { public int Hash; public float Time; public float Weight; } private static readonly Dictionary<Animator, Slot> Active = new Dictionary<Animator, Slot>(); private static readonly Dictionary<(WeaponKind, RuntimeAnimatorController), AnimatorOverrideController> Cache = new Dictionary<(WeaponKind, RuntimeAnimatorController), AnimatorOverrideController>(); private static readonly List<Animator> Gone = new List<Animator>(); private static readonly List<KeyValuePair<AnimationClip, AnimationClip>> Pairs = new List<KeyValuePair<AnimationClip, AnimationClip>>(); private static readonly List<Param> Params = new List<Param>(); private static readonly List<Layer> Layers = new List<Layer>(); internal static int Count => Active.Count; internal static void Tick() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { if (Active.Count > 0) { Clear(); } return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null || (Object)(object)val.playerBodyAnimator == (Object)null) { continue; } WeaponKind? weaponKind = Wanted(val); Animator playerBodyAnimator = val.playerBodyAnimator; Active.TryGetValue(playerBodyAnimator, out var value); if (!weaponKind.HasValue) { if (value != null) { Leave(playerBodyAnimator, value); } } else { if (value != null && value.Kind == weaponKind.Value && (Object)(object)playerBodyAnimator.runtimeAnimatorController == (Object)(object)value.Ours) { continue; } if (value != null) { RuntimeAnimatorController runtimeAnimatorController = playerBodyAnimator.runtimeAnimatorController; RuntimeAnimatorController to = (((Object)(object)runtimeAnimatorController == (Object)(object)value.Ours) ? value.Base : runtimeAnimatorController); Active.Remove(playerBodyAnimator); if ((Object)(object)runtimeAnimatorController == (Object)(object)value.Ours) { Swap(playerBodyAnimator, to); } } Enter(playerBodyAnimator, weaponKind.Value); } } Gone.Clear(); foreach (KeyValuePair<Animator, Slot> item in Active) { if ((Object)(object)item.Key == (Object)null) { Gone.Add(item.Key); } } foreach (Animator item2 in Gone) { Active.Remove(item2); } } private static WeaponKind? Wanted(PlayerControllerB p) { if (p.isPlayerDead || (!p.isPlayerControlled && !p.isTestingPlayer)) { return null; } HazardItem hazardItem = p.currentlyHeldObjectServer as HazardItem; if ((Object)(object)hazardItem == (Object)null || ((GrabbableObject)hazardItem).isPocketed || !((GrabbableObject)hazardItem).isHeld || !hazardItem.AnimKind.HasValue) { return null; } WeaponKind value = hazardItem.AnimKind.Value; if (Assets.ClipsFor(value).Count <= 0) { return null; } return value; } private static void Enter(Animator anim, WeaponKind kind) { RuntimeAnimatorController runtimeAnimatorController = anim.runtimeAnimatorController; if (!((Object)(object)runtimeAnimatorController == (Object)null)) { AnimatorOverrideController val = Build(kind, runtimeAnimatorController); if (!((Object)(object)val == (Object)null)) { Active[anim] = new Slot { Base = runtimeAnimatorController, Ours = val, Kind = kind }; Swap(anim, (RuntimeAnimatorController)(object)val); } } } private static void Leave(Animator anim, Slot slot) { Active.Remove(anim); if ((Object)(object)anim != (Object)null && (Object)(object)anim.runtimeAnimatorController == (Object)(object)slot.Ours) { Swap(anim, slot.Base); } } internal static void Clear() { foreach (KeyValuePair<Animator, Slot> item in Active) { if ((Object)(object)item.Key != (Object)null) { Leave(item.Key, item.Value); } } Active.Clear(); } internal static void Reset() { Clear(); Cache.Clear(); } private static AnimatorOverrideController Build(WeaponKind kind, RuntimeAnimatorController baseCtl) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (Cache.TryGetValue((kind, baseCtl), out var value) && (Object)(object)value != (Object)null) { return value; } Dictionary<string, AnimationClip> dictionary = Assets.ClipsFor(kind); AnimatorOverrideController val = new AnimatorOverrideController(baseCtl) { name = $"HazardPay.{kind}.{((Object)baseCtl).name}" }; Pairs.Clear(); val.GetOverrides(Pairs); int num = 0; for (int i = 0; i < Pairs.Count; i++) { AnimationClip key = Pairs[i].Key; if ((Object)(object)key != (Object)null && dictionary.TryGetValue(((Object)key).name, out var value2)) { Pairs[i] = new KeyValuePair<AnimationClip, AnimationClip>(key, value2); num++; } } if (num == 0) { Plugin.Log.LogWarning((object)$"HazardPay: none of the {kind} clips match a state in {((Object)baseCtl).name}."); return null; } val.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)Pairs); Cache[(kind, baseCtl)] = val; Plugin.Log.LogInfo((object)$"HazardPay: {kind} override built on {((Object)baseCtl).name} ({num} of {dictionary.Count} clips)."); return val; } internal static void Swap(Animator anim, RuntimeAnimatorController to) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected I4, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Invalid comparison between Unknown and I4 //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)anim == (Object)null || (Object)(object)to == (Object)null || (Object)(object)anim.runtimeAnimatorController == (Object)(object)to) { return; } Params.Clear(); Layers.Clear(); bool flag = ((Behaviour)anim).isActiveAndEnabled && (Object)(object)anim.runtimeAnimatorController != (Object)null; if (flag) { AnimatorControllerParameter[] parameters = anim.parameters; foreach (AnimatorControllerParameter val in parameters) { Param item = new Param { Name = val.name, Type = val.type }; AnimatorControllerParameterType type = val.type; if ((int)type != 1) { if ((int)type == 3) { item.I = anim.GetInteger(val.nameHash); } else { item.B = anim.GetBool(val.nameHash); } } else { item.F = anim.GetFloat(val.nameHash); } Params.Add(item); } for (int j = 0; j < anim.layerCount; j++) { AnimatorStateInfo val2 = (anim.IsInTransition(j) ? anim.GetNextAnimatorStateInfo(j) : anim.GetCurrentAnimatorStateInfo(j)); Layers.Add(new Layer { Hash = ((AnimatorStateInfo)(ref val2)).fullPathHash, Time = ((AnimatorStateInfo)(ref val2)).normalizedTime, Weight = anim.GetLayerWeight(j) }); } } anim.runtimeAnimatorController = to; if (!flag) { return; } foreach (Param item2 in Params) { AnimatorControllerParameterType type = item2.Type; switch (type - 1) { case 0: anim.SetFloat(item2.Name, item2.F); continue; case 2: anim.SetInteger(item2.Name, item2.I); continue; case 3: anim.SetBool(item2.Name, item2.B); continue; case 1: continue; } if ((int)type == 9 && item2.B) { anim.SetTrigger(item2.Name); } } for (int k = 0; k < Layers.Count && k < anim.layerCount; k++) { anim.SetLayerWeight(k, Layers[k].Weight); if (Layers[k].Hash != 0) { anim.Play(Layers[k].Hash, k, Layers[k].Time); } } } } internal sealed class WeaponAnim { internal const string Fire = "Fire"; internal const string Empty = "Empty"; internal const string Safety = "Safety"; internal const string Reload = "Reload"; internal const string ReloadEmpty = "ReloadEmpty"; internal const string Reloading = "Reloading"; internal const string Aim = "Aim"; internal const string Pump = "Pump"; internal const string ShellIn = "ShellIn"; internal const string Bolt = "Bolt"; internal const string RoundIn = "RoundIn"; internal const string ClipIn = "ClipIn"; internal const string Charge = "Charge"; internal const string Charging = "Charging"; internal const string Overheat = "Overheat"; private readonly Animator _a; private readonly HashSet<string> _has = new HashSet<string>(); private readonly Dictionary<string, bool> _bools = new Dictionary<string, bool>(); private readonly Dictionary<string, float> _floats = new Dictionary<string, float>(); private WeaponAnim(Animator a) { _a = a; AnimatorControllerParameter[] parameters = a.parameters; foreach (AnimatorControllerParameter val in parameters) { _has.Add(val.name); } } internal static WeaponAnim Find(Transform item) { if ((Object)(object)item == (Object)null) { return null; } Transform val = item.Find("Model"); Animator componentInChildren = ((Component)(((Object)(object)val != (Object)null) ? val : item)).GetComponentInChildren<Animator>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.runtimeAnimatorController == (Object)null) { return null; } componentInChildren.cullingMode = (AnimatorCullingMode)0; return new WeaponAnim(componentInChildren); } private bool Ready(string name) { if ((Object)(object)_a != (Object)null && ((Behaviour)_a).isActiveAndEnabled) { return _has.Contains(name); } return false; } internal void Trigger(string name) { if (Ready(name)) { _a.SetTrigger(name); } } internal void Bool(string name, bool value) { if (Ready(name) && (!_bools.TryGetValue(name, out var value2) || value2 != value)) { _bools[name] = value; _a.SetBool(name, value); } } internal void Float(string name, float value) { if (Ready(name) && (!_floats.TryGetValue(name, out var value2) || !(Mathf.Abs(value2 - value) < 0.001f))) { _floats[name] = value; _a.SetFloat(name, value); } } internal void Forget() { _bools.Clear(); _floats.Clear(); } } internal static class Ammo { private struct Source { public int Slot; public AmmoBox Box; public GunAmmo Vanilla; public int Rounds; } private static List<Source> Sources(PlayerControllerB holder, AmmoKind kind) { List<Source> list = new List<Source>(); if ((Object)(object)holder == (Object)null || holder.ItemSlots == null || kind == AmmoKind.None) { return list; } for (int i = 0; i < holder.ItemSlots.Length; i++) { GrabbableObject val = holder.ItemSlots[i]; if (val is AmmoBox ammoBox && ammoBox.Kind == kind && ammoBox.Rounds > 0 && !((GrabbableObject)ammoBox).deactivated) { list.Add(new Source { Slot = i, Box = ammoBox, Rounds = ammoBox.Rounds }); } else if (kind == AmmoKind.Shells) { GunAmmo val2 = (GunAmmo)(object)((val is GunAmmo) ? val : null); if (val2 != null && val2.ammoType == 1410 && !((GrabbableObject)val2).deactivated) { list.Add(new Source { Slot = i, Vanilla = val2, Rounds = 1 }); } } } list.Sort((Source a, Source b) => b.Rounds.CompareTo(a.Rounds)); return list; } internal static int Count(PlayerControllerB holder, AmmoKind kind) { int num = 0; foreach (Source item in Sources(holder, kind)) { num += item.Rounds; } return num; } internal static int Take(PlayerControllerB holder, AmmoKind kind, int want) { if (!Net.IsHost || want <= 0) { return 0; } int num = 0; foreach (Source item in Sources(holder, kind)) { if (num >= want) { break; } int num2 = Math.Min(want - num, item.Rounds); num += num2; if ((Object)(object)item.Box != (Object)null) { item.Box.Rounds -= num2; Net.BroadcastState(item.Box); if (item.Box.Rounds <= 0) { Net.Consume(holder, item.Slot); } } else { Net.Consume(holder, item.Slot); } } return num; } internal static bool Give(PlayerControllerB holder, AmmoKind kind, int rounds) { if (!Net.IsHost || rounds <= 0) { return rounds == 0; } AmmoBox ammoBox = null; if (holder?.ItemSlots != null) { GrabbableObject[] itemSlots = holder.ItemSlots; for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i] is AmmoBox ammoBox2 && ammoBox2.Kind == kind && !((GrabbableObject)ammoBox2).deactivated && ((Object)(object)ammoBox == (Object)null || ammoBox2.Rounds > ammoBox.Rounds)) { ammoBox = ammoBox2; } } } if ((Object)(object)ammoBox == (Object)null) { return false; } ammoBox.Rounds += rounds; Net.BroadcastState(ammoBox); return true; } } internal static class Assets { private static AssetBundle _bundle; internal static readonly Dictionary<WeaponKind, (string vanilla, string ours)[]> ClipMap = new Dictionary<WeaponKind, (string, string)[]> { [WeaponKind.Bat] = new(string, string)[4] { ("HoldLungApparatice", "HP_Bat_Hold"), ("ShovelReelUp", "HP_Bat_WindUp"), ("HitShovel", "HP_Bat_Swing"), ("HitShovelCollide", "HP_Bat_SwingImpact") }, [WeaponKind.Handgun] = new(string, string)[5] { ("HoldOneHandedItem", "HP_Handgun_Hold"), ("ShotgunHold", "HP_Handgun_Aim"), ("ShotgunShoot", "HP_Handgun_Fire"), ("ShotgunReloadOneShell", "HP_Handgun_Reload"), ("ShotgunReloadSecondShell", "HP_Handgun_ReloadEmpty") } }; private static readonly Dictionary<WeaponKind, Dictionary<string, AnimationClip>> Clips = new Dictionary<WeaponKind, Dictionary<string, AnimationClip>>(); internal static bool HasBundle => (Object)(object)_bundle != (Object)null; internal static void Load() { try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HazardPay.hazardpay"); _bundle = ((stream != null) ? AssetBundle.LoadFromStream(stream) : null); } catch (Exception arg) { Plugin.Log.LogError((object)$"HazardPay: the art bundle failed to load: {arg}"); _bundle = null; } foreach (KeyValuePair<WeaponKind, (string, string)[]> item3 in ClipMap) { Dictionary<string, AnimationClip> dictionary = new Dictionary<string, AnimationClip>(); (string, string)[] value = item3.Value; for (int i = 0; i < value.Length; i++) { (string, string) tuple = value[i]; string item = tuple.Item1; string item2 = tuple.Item2; AnimationClip val = Assets.Load<AnimationClip>(item2); if ((Object)(object)val != (Object)null) { dictionary[item] = val; } else if ((Object)(object)_bundle != (Object)null) { Plugin.Log.LogWarning((object)$"HazardPay: player clip {item2} not in the art bundle; {item3.Key} plays the vanilla {item}."); } } Clips[item3.Key] = dictionary; } if ((Object)(object)_bundle == (Object)null) { Plugin.Log.LogInfo((object)"HazardPay: no art bundle yet; using placeholder meshes and the vanilla clips."); return; } int num = 0; foreach (Dictionary<string, AnimationClip> value2 in Clips.Values) { num += value2.Count; } Plugin.Log.LogInfo((object)$"HazardPay: art bundle loaded ({_bundle.GetAllAssetNames().Length} assets, {num} player clips)."); } internal static T Load<T>(string name) where T : Object { if ((Object)(object)_bundle == (Object)null || string.IsNullOrEmpty(name)) { return default(T); } try { return _bundle.LoadAsset<T>(name); } catch (Exception) { return default(T); } } internal static Dictionary<string, AnimationClip> ClipsFor(WeaponKind k) { if (!Clips.TryGetValue(k, out var value)) { return new Dictionary<string, AnimationClip>(); } return value; } internal static string PrefabName(WeaponKind k) { return "HP_" + k; } internal static string PrefabName(AmmoKind k) { return "HP_" + k.ToString() + "Ammo"; } internal static Sprite Icon(string prefabName) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Sprite val = Assets.Load<Sprite>(prefabName + "_Icon"); if ((Object)(object)val != (Object)null) { return val; } Texture2D val2 = Assets.Load<Texture2D>(prefabName + "_Icon"); if (!((Object)(object)val2 != (Object)null)) { return null; } return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); } internal static AudioClip Sound(string name, AudioClip fallback) { return Assets.Load<AudioClip>(name) ?? fallback; } internal static AudioClip[] Sounds(string prefix, int count, AudioClip[] fallback) { List<AudioClip> list = new List<AudioClip>(); for (int i = 1; i <= count; i++) { AudioClip val = Assets.Load<AudioClip>(prefix + i); if ((Object)(object)val != (Object)null) { list.Add(val); } } AudioClip[] array; if (list.Count <= 0) { array = fallback; if (array == null) { return (AudioClip[])(object)new AudioClip[0]; } } else { array = list.ToArray(); } return array; } } internal static class Catalog { internal static readonly WeaponKind[] Weapons = new WeaponKind[2] { WeaponKind.Bat, WeaponKind.Handgun }; internal static readonly AmmoKind[] Ammo = new AmmoKind[1] { AmmoKind.Pistol }; internal static readonly WeaponKind[] Later = new WeaponKind[3] { WeaponKind.Pump, WeaponKind.Sniper, WeaponKind.Railgun }; internal static readonly AmmoKind[] AmmoLater = new AmmoKind[2] { AmmoKind.Shells, AmmoKind.Rifle }; internal static string Name(WeaponKind k) { return k switch { WeaponKind.Bat => "Metal bat", WeaponKind.Handgun => "Handgun", WeaponKind.Pump => "Pump shotgun", WeaponKind.Sniper => "Sniper rifle", WeaponKind.Railgun => "Railgun", _ => k.ToString(), }; } internal static string Name(AmmoKind k) { return k switch { AmmoKind.Shells => "Shell box", AmmoKind.Pistol => "Pistol ammo", AmmoKind.Rifle => "Rifle ammo", _ => k.ToString(), }; } internal static string Word(WeaponKind k) { return k switch { WeaponKind.Bat => "bat", WeaponKind.Handgun => "handgun", WeaponKind.Pump => "pump", WeaponKind.Sniper => "sniper", WeaponKind.Railgun => "railgun", _ => null, }; } internal static string Word(AmmoKind k) { return k switch { AmmoKind.Shells => "shells", AmmoKind.Pistol => "pistol-ammo", AmmoKind.Rifle => "rifle-ammo", _ => null, }; } internal static float Weight(WeaponKind k) { return k switch { WeaponKind.Bat => 1.07f, WeaponKind.Handgun => 1.03f, WeaponKind.Pump => 1.14f, WeaponKind.Sniper => 1.16f, WeaponKind.Railgun => 1.3f, _ => 1f, }; } internal static AmmoKind AmmoFor(WeaponKind k) { return k switch { WeaponKind.Handgun => AmmoKind.Pistol, WeaponKind.Pump => AmmoKind.Shells, WeaponKind.Sniper => AmmoKind.Rifle, _ => AmmoKind.None, }; } internal static string Info(WeaponKind k) { return k switch { WeaponKind.Bat => "METAL BAT\n\nAluminium, taped grip, one dent. Hold [LMB] to wind up and let go to swing. A full wind-up hits twice as hard and stuns small and medium monsters for a moment.\n\n", WeaponKind.Handgun => "HANDGUN\n\nCompany sidearm, semi-automatic, 10 rounds + 1. [LMB] fire, [RMB] aim, [E] reload, [Q] safety. Comes loaded with the safety on. Buy pistol ammo to reload. Every shot is loud: monsters hear it.\n\n", WeaponKind.Pump => "PUMP SHOTGUN\n\nRiot pump, 6 shells. [LMB] fire, [RMB] aim, [E] load shells one at a time (again to stop), [Q] safety. Loads shell boxes and the Company's own shotgun shells. Brutal up close, weak past 20 m.\n\n", WeaponKind.Sniper => "SNIPER RIFLE\n\nBolt action, 5 rounds. [RMB] scope, [LMB] fire, [E] load (a clip of 5 when empty), [Q] safety. Dead accurate scoped. The loudest gun you can buy, and others see the scope glint.\n\n", WeaponKind.Railgun => "RAILGUN\n\nArc rail, two-handed, 32 lb. Hold [LMB] to charge, let go to fire. The beam goes through three targets and a thin wall. 4 shots a battery: charge it on the ship. Don't hold a full charge: it overheats.\n\n", _ => Name(k).ToUpperInvariant() + "\n\n", }; } internal static string Info(AmmoKind k) { return $"{Name(k).ToUpperInvariant()}\n\nA box of {Rules.BoxRounds(k)} rounds. Carry it to reload; the fullest box is used first.\n\n"; } } internal static class Effects { private static Material _tracerMat; private static bool _triedMat; private static Material _beamMat; private static bool _triedBeam; internal static void MuzzleFlash(Vector3 pos, Transform parent) { //IL_0013: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown if (!((Object)(object)Runner.Instance == (Object)null)) { GameObject val = new GameObject("HazardPay.Flash"); val.transform.position = pos; Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = new Color(1f, 0.8f, 0.5f); obj.range = 6f; obj.shadows = (LightShadows)0; HDAdditionalLightData obj2 = val.AddComponent<HDAdditionalLightData>(); obj2.SetIntensity(800f, (LightUnit)0); obj2.SetRange(6f); obj2.EnableShadows(false); Object.Destroy((Object)val, 0.05f); } } internal static void Tracer(Vector3 from, Vector3 to) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown Material val = TracerMaterial(); if (!((Object)(object)val == (Object)null) && !((Object)(object)Runner.Instance == (Object)null)) { GameObject val2 = new GameObject("HazardPay.Tracer"); LineRenderer obj = val2.AddComponent<LineRenderer>(); ((Renderer)obj).sharedMaterial = val; obj.positionCount = 2; obj.SetPosition(0, from); obj.SetPosition(1, to); obj.startWidth = 0.012f; obj.endWidth = 0.006f; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; Object.Destroy((Object)val2, 0.06f); } } internal static void Beam(Vector3 from, Vector3 to) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Material val = BeamMaterial(); if (!((Object)(object)val == (Object)null) && !((Object)(object)Runner.Instance == (Object)null)) { GameObject val2 = new GameObject("HazardPay.Beam"); LineRenderer val3 = val2.AddComponent<LineRenderer>(); ((Renderer)val3).sharedMaterial = val; val3.positionCount = 2; val3.SetPosition(0, from); val3.SetPosition(1, to); val3.startWidth = 0.06f; val3.endWidth = 0.04f; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; ((MonoBehaviour)Runner.Instance).StartCoroutine(FadeLine(val3, 0.15f)); Object.Destroy((Object)val2, 0.2f); } } private static IEnumerator FadeLine(LineRenderer lr, float seconds) { float t0 = Time.time; float w0 = lr.startWidth; float w1 = lr.endWidth; while ((Object)(object)lr != (Object)null && Time.time - t0 < seconds) { float num = 1f - (Time.time - t0) / seconds; lr.startWidth = w0 * num; lr.endWidth = w1 * num; yield return null; } } private static Material BeamMaterial() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (_triedBeam) { return _beamMat; } _triedBeam = true; Shader val = Shader.Find("HDRP/Unlit"); if ((Object)(object)val == (Object)null) { return null; } _beamMat = new Material(val) { name = "HazardPay.Beam" }; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.75f, 0.88f, 1f, 1f); _beamMat.SetColor("_UnlitColor", val2); _beamMat.color = val2; return _beamMat; } internal static void Impact(HitInfo h) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (h.Kind != 0) { return; } StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && instance.footstepSurfaces != null && h.Surface >= 0 && h.Surface < instance.footstepSurfaces.Length) { AudioClip hitSurfaceSFX = instance.footstepSurfaces[h.Surface].hitSurfaceSFX; if (!((Object)(object)hitSurfaceSFX == (Object)null) && !((Object)(object)Runner.Instance == (Object)null)) { ((MonoBehaviour)Runner.Instance).StartCoroutine(PlayAt(hitSurfaceSFX, h.Point, 0.8f)); } } } private static IEnumerator PlayAt(AudioClip clip, Vector3 pos, float volume) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) GameObject go = new GameObject("HazardPay.Impact"); go.transform.position = pos; AudioSource obj = go.AddComponent<AudioSource>(); obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1f; obj.maxDistance = 25f; obj.outputAudioMixerGroup = Registry.Mixer; obj.pitch = Random.Range(0.9f, 1.1f); obj.PlayOneShot(clip, volume); yield return (object)new WaitForSeconds(clip.length + 0.1f); Object.Destroy((Object)(object)go); } private static Material TracerMaterial() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0073: 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) if (_triedMat) { return _tracerMat; } _triedMat = true; Shader val = Shader.Find("HDRP/Unlit"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"HazardPay: no HDRP/Unlit shader, so no tracers."); return null; } _tracerMat = new Material(val) { name = "HazardPay.Tracer" }; Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.85f, 0.55f, 0.6f); _tracerMat.SetColor("_UnlitColor", val2); _tracerMat.color = val2; return _tracerMat; } } internal static class Hits { private enum Target { None, World, Enemy, Player, Other } internal const int Mask = 1084754249; private const int RoomLayer = 8; private const int CollidersLayer = 11; private static readonly Dictionary<EnemyType, int> PrefabHp = new Dictionary<EnemyType, int>(); internal static List<HitInfo> Bullet(GrabbableObject gun, PlayerControllerB shooter, Vector3 origin, Vector3 dir, float range, int force, int playerDamage) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) List<HitInfo> list = new List<HitInfo>(); foreach (RaycastHit item in from h in Physics.RaycastAll(origin, dir, range, 1084754249, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && !Own(((RaycastHit)(ref current)).transform, shooter, gun)) { Target target = Classify(current, shooter); switch (target) { case Target.World: list.Add(WorldHit(current)); goto end_IL_009c; default: Apply(current, target, force, dir, shooter, playerDamage, (CauseOfDeath)7, Vector3.zero, -1, null, list); goto end_IL_009c; case Target.None: break; } } continue; end_IL_009c: break; } if (list.Count == 0) { list.Add(new HitInfo { Kind = 0, Point = origin + dir * range, Normal = -dir, Surface = -2 }); } return list; } internal static List<HitInfo> BatSweep(BatItem bat, PlayerControllerB swinger, bool full, Vector3 eye, Vector3 fwd, Vector3 right) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) List<HitInfo> list = new List<HitInfo>(); int force = Rules.BatForce(full); int playerDamage = Rules.BatPlayerDamage(full); bool flag = full && Settings.Current.BatStun; List<RaycastHit> list2 = (from h in Physics.SphereCastAll(eye + right * 0.4f, 0.9f, fwd, 1.9f, 1084754249, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref h)).distance select h).ToList(); HashSet<EnemyAI> hashSet = new HashSet<EnemyAI>(); bool flag2 = false; bool flag3 = false; StartOfRound instance = StartOfRound.Instance; RaycastHit val = default(RaycastHit); foreach (RaycastHit item in list2) { RaycastHit current = item; if ((Object)(object)((RaycastHit)(ref current)).collider == (Object)null || Own(((RaycastHit)(ref current)).transform, swinger, (GrabbableObject)(object)bat)) { continue; } Target target = Classify(current, swinger); switch (target) { case Target.World: if (!flag3 && list.Count == 0) { list.Add(WorldHit(current)); } flag3 = true; continue; case Target.None: continue; } if (((RaycastHit)(ref current)).point != Vector3.zero && Physics.Linecast(eye, ((RaycastHit)(ref current)).point, ref val, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { continue; } if (target == Target.Enemy) { EnemyAI val2 = ((Component)((RaycastHit)(ref current)).transform).GetComponent<EnemyAICollisionDetect>()?.mainScript; if ((Object)(object)val2 == (Object)null || val2.isEnemyDead || hashSet.Contains(val2) || (instance.hangarDoorsClosed && val2.isInsidePlayerShip != swinger.isInHangarShipRoom)) { continue; } hashSet.Add(val2); } if (target == Target.Player) { if (flag2) { continue; } flag2 = true; } Apply(current, target, force, fwd, swinger, playerDamage, (CauseOfDeath)1, fwd * 3f, 1, flag ? ((Action<EnemyAI>)delegate(EnemyAI e) { StunIfSmall(e, swinger); }) : null, list); } return list; } internal static List<HitInfo> Cone(GrabbableObject gun, PlayerControllerB shooter, Vector3 origin, Vector3 dir) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_009f: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) List<HitInfo> list = new List<HitInfo>(); StartOfRound instance = StartOfRound.Instance; RaycastHit h = default(RaycastHit); if (Physics.Raycast(origin, dir, ref h, 30f, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { list.Add(WorldHit(h)); } float num = Mathf.Cos(0.12217305f); Collider[] array = Physics.OverlapSphere(origin, 30f, 1084754249, (QueryTriggerInteraction)2); List<(float, Collider, Target)> list2 = new List<(float, Collider, Target)>(); HashSet<EnemyAI> hashSet = new HashSet<EnemyAI>(); HashSet<PlayerControllerB> hashSet2 = new HashSet<PlayerControllerB>(); HashSet<Transform> hashSet3 = new HashSet<Transform>(); Collider[] array2 = array; Bounds bounds; foreach (Collider val in array2) { if ((Object)(object)val == (Object)null || Own(((Component)val).transform, shooter, gun)) { continue; } Vector3 val2 = val.ClosestPoint(origin); if (val2 == origin) { bounds = val.bounds; val2 = ((Bounds)(ref bounds)).center; } Vector3 val3 = val2 - origin; float magnitude = ((Vector3)(ref val3)).magnitude; if (!(magnitude < 0.01f) && !(Vector3.Dot(val3 / magnitude, dir) < num)) { Target target = ClassifyCollider(val, shooter); if (target != Target.None && target != Target.World) { list2.Add((magnitude, val, target)); } } } int num2 = 0; RaycastHit val4 = default(RaycastHit); foreach (var item4 in list2.OrderBy<(float, Collider, Target), float>(((float d, Collider c, Target t) x) => x.d)) { float item = item4.Item1; Collider item2 = item4.Item2; Target item3 = item4.Item3; bounds = item2.bounds; Vector3 center = ((Bounds)(ref bounds)).center; if (Physics.Linecast(origin, center, ref val4, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { continue; } switch (item3) { case Target.Enemy: { EnemyAI val5 = ((Component)item2).GetComponent<EnemyAICollisionDetect>()?.mainScript; if ((Object)(object)val5 == (Object)null || val5.isEnemyDead || !hashSet.Add(val5) || num2 >= 4) { continue; } num2++; break; } case Target.Player: if (!hashSet2.Add(((Component)item2).GetComponent<PlayerControllerB>())) { continue; } break; default: if (!hashSet3.Add(((Component)item2).transform)) { continue; } break; } int num3 = Rules.PumpForce(item); if (num3 > 0) { Transform transform = ((Component)item2).transform; Vector3 normal = -dir; Vector3 val6 = center - origin; Apply(transform, center, normal, item3, num3, ((Vector3)(ref val6)).normalized, shooter, Rules.PumpPlayerDamage(item), (CauseOfDeath)7, Vector3.zero, -1, null, list); } } if (list.Count == 0) { list.Add(new HitInfo { Kind = 0, Point = origin + dir * 30f, Normal = -dir, Surface = -2 }); } return list; } internal static List<HitInfo> Beam(GrabbableObject gun, PlayerControllerB shooter, Vector3 origin, Vector3 dir) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_0128: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) List<HitInfo> list = new List<HitInfo>(); StartOfRound instance = StartOfRound.Instance; IOrderedEnumerable<RaycastHit> orderedEnumerable = from h in Physics.RaycastAll(origin, dir, 80f, 1084754249, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref h)).distance select h; HashSet<EnemyAI> hashSet = new HashSet<EnemyAI>(); HashSet<PlayerControllerB> hashSet2 = new HashSet<PlayerControllerB>(); int num = 0; int num2 = 0; Vector3 point = origin + dir * 80f; Collider val = null; foreach (RaycastHit item in orderedEnumerable) { RaycastHit current = item; if ((Object)(object)((RaycastHit)(ref current)).collider == (Object)null || Own(((RaycastHit)(ref current)).transform, shooter, gun)) { continue; } Target target = Classify(current, shooter); if (target == Target.None) { continue; } switch (target) { case Target.World: { if ((Object)(object)((RaycastHit)(ref current)).collider == (Object)(object)val) { continue; } bool num3 = ((RaycastHit)(ref current)).collider is TerrainCollider || ((Object)(object)instance.elevatorTransform != (Object)null && ((RaycastHit)(ref current)).transform.IsChildOf(instance.elevatorTransform)) || num2 >= 1 || Thickness(current, dir) > 0.6f; list.Add(WorldHit(current)); if (num3) { point = ((RaycastHit)(ref current)).point; goto end_IL_01d2; } num2++; val = ((RaycastHit)(ref current)).collider; continue; } case Target.Enemy: { EnemyAI val2 = ((Component)((RaycastHit)(ref current)).transform).GetComponent<EnemyAICollisionDetect>()?.mainScript; if ((Object)(object)val2 == (Object)null || val2.isEnemyDead || !hashSet.Add(val2)) { continue; } break; } case Target.Player: if (!hashSet2.Add(((Component)((RaycastHit)(ref current)).transform).GetComponent<PlayerControllerB>())) { continue; } break; } Apply(current, target, Rules.RailForce(num), dir, shooter, 100, (CauseOfDeath)3, Vector3.zero, -1, null, list); num++; if (num >= 3) { point = ((RaycastHit)(ref current)).point; break; } continue; end_IL_01d2: break; } list.Add(new HitInfo { Kind = 0, Point = point, Normal = -dir, Surface = -2 }); return list; } private static float Thickness(RaycastHit h, Vector3 dir) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) float num = 0.65000004f; Ray val = default(Ray); ((Ray)(ref val))..ctor(((RaycastHit)(ref h)).point + dir * num, -dir); RaycastHit val2 = default(RaycastHit); if (!((RaycastHit)(ref h)).collider.Raycast(val, ref val2, num)) { return float.MaxValue; } return num - ((RaycastHit)(ref val2)).distance; } private static Target ClassifyCollider(Collider c, PlayerControllerB shooter) { Transform transform = ((Component)c).transform; if ((Object)(object)((Component)transform).GetComponent<EnemyAICollisionDetect>() != (Object)null) { return Target.Enemy; } PlayerControllerB component = ((Component)transform).GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null) { if (!((Object)(object)component == (Object)(object)shooter) && !component.isPlayerDead && component.isPlayerControlled) { return Target.Player; } return Target.None; } if (((Component)transform).GetComponent<IHittable>() != null) { return Target.Other; } return Target.None; } private static void StunIfSmall(EnemyAI e, PlayerControllerB by) { if (!((Object)(object)e == (Object)null) && !e.isEnemyDead && !((Object)(object)e.enemyType == (Object)null) && e.enemyType.canBeStunned && Rules.BatStuns(full: true, PrefabHpOf(e))) { Net.StunEnemy(e, 0.6f, by); } } internal static int PrefabHpOf(EnemyAI e) { EnemyType enemyType = e.enemyType; if ((Object)(object)enemyType == (Object)null) { return e.enemyHP; } if (PrefabHp.TryGetValue(enemyType, out var value)) { return value; } EnemyAI val = (((Object)(object)enemyType.enemyPrefab != (Object)null) ? enemyType.enemyPrefab.GetComponentInChildren<EnemyAI>(true) : null); value = (((Object)(object)val != (Object)null) ? val.enemyHP : e.enemyHP); PrefabHp[enemyType] = value; return value; } private static Target Classify(RaycastHit h, PlayerControllerB shooter) { GameObject gameObject = ((Component)((RaycastHit)(ref h)).collider).gameObject; if ((Object)(object)((Component)((RaycastHit)(ref h)).transform).GetComponent<EnemyAICollisionDetect>() != (Object)null) { return Target.Enemy; } PlayerControllerB component = ((Component)((RaycastHit)(ref h)).transform).GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null) { if (!((Object)(object)component == (Object)(object)shooter) && !component.isPlayerDead && component.isPlayerControlled) { return Target.Player; } return Target.None; } if (((Component)((RaycastHit)(ref h)).transform).GetComponent<IHittable>() != null) { return Target.Other; } if (((RaycastHit)(ref h)).collider.isTrigger) { return Target.None; } if (gameObject.layer != 8 && gameObject.layer != 11 && gameObject.layer != 0) { return Target.None; } return Target.World; } private static bool Own(Transform t, PlayerControllerB shooter, GrabbableObject item) { if ((Object)(object)t == (Object)null) { return true; } if ((Object)(object)item != (Object)null && t.IsChildOf(((Component)item).transform)) { return true; } if ((Object)(object)shooter != (Object)null) { if (!((Object)(object)t == (Object)(object)((Component)shooter).transform)) { return t.IsChildOf(((Component)shooter).transform); } return true; } return false; } private static void Apply(RaycastHit h, Target target, int force, Vector3 dir, PlayerControllerB by, int playerDamage, CauseOfDeath cause, Vector3 shove, int hitId, Action<EnemyAI> onEnemy, List<HitInfo> result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Apply(((RaycastHit)(ref h)).transform, (((RaycastHit)(ref h)).point == Vector3.zero) ? ((RaycastHit)(ref h)).transform.position : ((RaycastHit)(ref h)).point, (((RaycastHit)(ref h)).normal == Vector3.zero) ? (-dir) : ((RaycastHit)(ref h)).normal, target, force, dir, by, playerDamage, cause, shove, hitId, onEnemy, result); } private static void Apply(Transform tr, Vector3 point, Vector3 normal, Target target, int force, Vector3 dir, PlayerControllerB by, int playerDamage, CauseOfDeath cause, Vector3 shove, int hitId, Action<EnemyAI> onEnemy, List<HitInfo> result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) HitInfo item = new HitInfo { Point = point, Normal = normal, Surface = -1 }; try { switch (target) { case Target.Player: { PlayerControllerB component2 = ((Component)tr).GetComponent<PlayerControllerB>(); item.Kind = 2; Net.HurtPlayer(component2, Rules.PlayerDamage(playerDamage, Settings.FriendlyFire), dir, cause, shove); break; } case Target.Enemy: { item.Kind = 1; EnemyAICollisionDetect component3 = ((Component)tr).GetComponent<EnemyAICollisionDetect>(); if (((IHittable)component3).Hit(force, dir, by, true, hitId)) { onEnemy?.Invoke(component3.mainScript); } break; } default: { item.Kind = 3; IHittable component = ((Component)tr).GetComponent<IHittable>(); if (component != null) { component.Hit(force, dir, by, true, hitId); } break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("HazardPay: hitting " + ((Object)tr).name + " failed: " + ex.Message)); } result.Add(item); } private static HitInfo WorldHit(RaycastHit h) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) short surface = -1; FootstepSurface[] array = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.footstepSurfaces : null); string tag = ((Component)((RaycastHit)(ref h)).collider).gameObject.tag; if (array != null) { for (short num = 0; num < array.Length; num++) { if (array[num] != null && array[num].surfaceTag == tag) { surface = num; break; } } } return new HitInfo { Kind = 0, Point = ((RaycastHit)(ref h)).point, Normal = ((RaycastHit)(ref h)).normal, Surface = surface }; } internal static Vector3 Spread(Vector3 dir, float degrees) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (degrees <= 0f) { return dir; } Quaternion val = Quaternion.AngleAxis(Random.Range(0f, 360f), dir); float num = Random.Range(0f, degrees); Vector3 val2 = Vector3.Cross(dir, Vector3.up); val2 = val * Quaternion.AngleAxis(num, (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? Vector3.Cross(dir, Vector3.up) : Vector3.right) * dir; return ((Vector3)(ref val2)).normalized; } } internal static class MenuHooks { internal const string ModMenuGuid = "daniel.lethalcompany.modmenu"; private const string Tab = "Luke's Weapons"; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { WeaponKind[] weapons = Catalog.Weapons; MenuApi.Choice("Luke's Weapons", "Spawn weapon", weapons.Select(Catalog.Name).ToArray(), (Func<int, string>)((int i) => Registry.Spawn(Registry.WeaponPrefabs.TryGetValue(weapons[i], out var value) ? value : null, Player(), Catalog.Name(weapons[i]))), true, true, (Func<string>)(() => Registry.Built ? NoPlayer() : "items not built"), (string)null); AmmoKind[] ammo = Catalog.Ammo; MenuApi.Choice("Luke's Weapons", "Spawn ammo", ammo.Select(Catalog.Name).ToArray(), (Func<int, string>)((int i) => Registry.Spawn(Registry.AmmoPrefabs.TryGetValue(ammo[i], out value) ? value : null, Player(), Catalog.Name(ammo[i]))), true, true, (Func<string>)(() => Registry.Built ? NoPlayer() : "items not built"), (string)null); MenuApi.Choice("Luke's Weapons", "Friendly fire", new string[3] { "On", "Reduced", "Off" }, (Func<int, string>)delegate(int i) { Plugin.FriendlyFireMode.Value = (FriendlyFire)i; Net.BroadcastConfig(); FriendlyFire friendlyFire = (FriendlyFire)i; return "friendly fire " + friendlyFire; }, true, false, (Func<string>)null, "every player"); MenuApi.Toggle("Luke's Weapons", "Bat full swing stuns", (Func<bool>)(() => Plugin.BatStun.Value), (Func<bool, string>)delegate(bool v) { Plugin.BatStun.Value = v; Net.BroadcastConfig(); return (!v) ? "bat stun off" : "bat stun on"; }, true, false, (Func<string>)null, "every player"); MenuApi.Toggle("Luke's Weapons", "Right click toggles aim", (Func<bool>)(() => Plugin.AimHoldToggle.Value), (Func<bool, string>)delegate(bool v) { Plugin.AimHoldToggle.Value = v; return (!v) ? "aim is held" : "aim toggles"; }, false, false, (Func<string>)null, "just you"); } private static PlayerControllerB Player() { return GameNetworkManager.Instance.localPlayerController; } private static string NoPlayer() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { if (!val.isPlayerDead) { return null; } return "you're dead"; } return "not in a game"; } } internal struct HitInfo { public const byte World = 0; public const byte Enemy = 1; public const byte Player = 2; public const byte Other = 3; public byte Kind; public Vector3 Point; public Vector3 Normal; public short Surface; public void Write(FastBufferWriter w) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) ((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref Kind, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe(ref Point); ((FastBufferWriter)(ref w)).WriteValueSafe(ref Normal); ((FastBufferWriter)(ref w)).WriteValueSafe<short>(ref Surface, default(ForPrimitives)); } public static HitInfo Read(FastBufferReader r) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) HitInfo result = default(HitInfo); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref result.Kind, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Point); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Normal); ((FastBufferReader)(ref r)).ReadValueSafe<short>(ref result.Surface, default(ForPrimitives)); return result; } } internal static class Net { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnFire; public static HandleNamedMessageDelegate <1>__OnSwing; public static HandleNamedMessageDelegate <2>__OnSafety; public static HandleNamedMessageDelegate <3>__OnReload; public static HandleNamedMessageDelegate <4>__OnReloadStop; public static HandleNamedMessageDelegate <5>__OnPose; public static HandleNamedMessageDelegate <6>__OnOverheat; public static HandleNamedMessageDelegate <7>__OnShot; public static HandleNamedMessageDelegate <8>__OnSwung; public static HandleNamedMessageDelegate <9>__OnReloading; public static HandleNamedMessageDelegate <10>__OnPosed; public static HandleNamedMessageDelegate <11>__OnOverheated; public static HandleNamedMessageDelegate <12>__OnState; public static HandleNamedMessageDelegate <13>__OnHurt; public static HandleNamedMessageDelegate <14>__OnStun; public static HandleNamedMessageDelegate <15>__OnConsume; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__30_0; public static HandleNamedMessageDelegate <>9__30_1; public static Func<HazardItem, bool> <>9__35_0; public static Func<ulong, bool> <>9__80_0; internal void <Tick>b__30_0(ulong sender, FastBufferReader r) { SendConfig(sender); SendAllStates(sender); } internal void <Tick>b__30_1(ulong s, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _gotHello = true; Settings.FromHost(Settings.Values.Read(r)); } internal bool <SendAllStates>b__35_0(HazardItem i) { if ((Object)(object)i != (Object)null && (Object)(object)((NetworkBehaviour)i).NetworkObject != (Object)null && ((NetworkBehaviour)i).NetworkObject.IsSpawned) { return i.HasState; } return false; } internal bool <Clients>b__80_0(ulong c) { return c != 0; } } private const string P = "daniel.hazardpay."; private const string MsgHello = "daniel.hazardpay.hello"; private const string MsgConfig = "daniel.hazardpay.config"; private const string MsgState = "daniel.hazardpay.state"; private const string MsgFire = "daniel.hazardpay.fire"; private const string MsgShot = "daniel.hazardpay.shot"; private const string MsgSwing = "daniel.hazardpay.swing"; private const string MsgSwung = "daniel.hazardpay.swung"; private const string MsgSafety = "daniel.hazardpay.safety"; private const string MsgReload = "daniel.hazardpay.reload"; private const string MsgReloading = "daniel.hazardpay.reloading"; private const string MsgHurt = "daniel.hazardpay.hurt"; private const string MsgStun = "daniel.hazardpay.stun"; private const string MsgConsume = "daniel.hazardpay.consume"; private const string MsgReloadStop = "daniel.hazardpay.reloadstop"; private const string MsgPose = "daniel.hazardpay.pose"; private const string MsgPosed = "daniel.hazardpay.posed"; private const string MsgOverheat = "daniel.hazardpay.overheat"; private const string MsgOverheated = "daniel.hazardpay.overheated"; private static readonly string[] All = new string[18] { "daniel.hazardpay.hello", "daniel.hazardpay.config", "daniel.hazardpay.state", "daniel.hazardpay.fire", "daniel.hazardpay.shot", "daniel.hazardpay.swing", "daniel.hazardpay.swung", "daniel.hazardpay.safety", "daniel.hazardpay.reload", "daniel.hazardpay.reloading", "daniel.hazardpay.hurt", "daniel.hazardpay.stun", "daniel.hazardpay.consume", "daniel.hazardpay.reloadstop", "daniel.hazardpay.pose", "daniel.hazardpay.posed", "daniel.hazardpay.overheat", "daniel.hazardpay.overheated" }; private static bool _registered; private static NetworkManager _nm; private static float _nextAsk; private static int _asks; private static bool _gotHello; private static readonly Dictionary<ulong, (int a, int b)> Pending = new Dictionary<ulong, (int, int)>(); internal static readonly Dictionary<GunItem, (ulong holder, float at)> HostReloads = new Dictionary<GunItem, (ulong, float)>(); public static bool IsHost { get { if ((Object)(object)NetworkManager.Singleton != (Object)null) { return NetworkManager.Singleton.IsServer; } return false; } } public static bool Online { get { if ((Object)(object)NetworkManager.Singleton != (Object)null) { return NetworkManager.Singleton.IsListening; } return false; } } public static void Tick() { //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_01c3: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //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_0148: Expected O, but got Unknown //IL_0163: 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_016e: Expected O, but got Unknown //IL_029c: 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_02a7: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { if (_registered) { Reset(); } return; } if (_registered && (Object)(object)singleton == (Object)(object)_nm) { AskIfNeeded(singleton); return; } if (_registered) { Reset(); } CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; if (singleton.IsServer) { object obj = <>c.<>9__30_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader r) { SendConfig(sender); SendAllStates(sender); }; <>c.<>9__30_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.hello", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<0>__OnFire; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnFire; <>O.<0>__OnFire = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.fire", (HandleNamedMessageDelegate)obj2); object obj3 = <>O.<1>__OnSwing; if (obj3 == null) { HandleNamedMessageDelegate val3 = OnSwing; <>O.<1>__OnSwing = val3; obj3 = (object)val3; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.swing", (HandleNamedMessageDelegate)obj3); object obj4 = <>O.<2>__OnSafety; if (obj4 == null) { HandleNamedMessageDelegate val4 = OnSafety; <>O.<2>__OnSafety = val4; obj4 = (object)val4; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.safety", (HandleNamedMessageDelegate)obj4); object obj5 = <>O.<3>__OnReload; if (obj5 == null) { HandleNamedMessageDelegate val5 = OnReload; <>O.<3>__OnReload = val5; obj5 = (object)val5; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.reload", (HandleNamedMessageDelegate)obj5); object obj6 = <>O.<4>__OnReloadStop; if (obj6 == null) { HandleNamedMessageDelegate val6 = OnReloadStop; <>O.<4>__OnReloadStop = val6; obj6 = (object)val6; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.reloadstop", (HandleNamedMessageDelegate)obj6); object obj7 = <>O.<5>__OnPose; if (obj7 == null) { HandleNamedMessageDelegate val7 = OnPose; <>O.<5>__OnPose = val7; obj7 = (object)val7; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.pose", (HandleNamedMessageDelegate)obj7); object obj8 = <>O.<6>__OnOverheat; if (obj8 == null) { HandleNamedMessageDelegate val8 = OnOverheat; <>O.<6>__OnOverheat = val8; obj8 = (object)val8; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.overheat", (HandleNamedMessageDelegate)obj8); } else { object obj9 = <>c.<>9__30_1; if (obj9 == null) { HandleNamedMessageDelegate val9 = delegate(ulong s, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _gotHello = true; Settings.FromHost(Settings.Values.Read(r)); }; <>c.<>9__30_1 = val9; obj9 = (object)val9; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.config", (HandleNamedMessageDelegate)obj9); object obj10 = <>O.<7>__OnShot; if (obj10 == null) { HandleNamedMessageDelegate val10 = OnShot; <>O.<7>__OnShot = val10; obj10 = (object)val10; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.shot", (HandleNamedMessageDelegate)obj10); object obj11 = <>O.<8>__OnSwung; if (obj11 == null) { HandleNamedMessageDelegate val11 = OnSwung; <>O.<8>__OnSwung = val11; obj11 = (object)val11; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.swung", (HandleNamedMessageDelegate)obj11); object obj12 = <>O.<9>__OnReloading; if (obj12 == null) { HandleNamedMessageDelegate val12 = OnReloading; <>O.<9>__OnReloading = val12; obj12 = (object)val12; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.reloading", (HandleNamedMessageDelegate)obj12); object obj13 = <>O.<10>__OnPosed; if (obj13 == null) { HandleNamedMessageDelegate val13 = OnPosed; <>O.<10>__OnPosed = val13; obj13 = (object)val13; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.posed", (HandleNamedMessageDelegate)obj13); object obj14 = <>O.<11>__OnOverheated; if (obj14 == null) { HandleNamedMessageDelegate val14 = OnOverheated; <>O.<11>__OnOverheated = val14; obj14 = (object)val14; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.overheated", (HandleNamedMessageDelegate)obj14); } object obj15 = <>O.<12>__OnState; if (obj15 == null) { HandleNamedMessageDelegate val15 = OnState; <>O.<12>__OnState = val15; obj15 = (object)val15; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.state", (HandleNamedMessageDelegate)obj15); object obj16 = <>O.<13>__OnHurt; if (obj16 == null) { HandleNamedMessageDelegate val16 = OnHurt; <>O.<13>__OnHurt = val16; obj16 = (object)val16; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.hurt", (HandleNamedMessageDelegate)obj16); object obj17 = <>O.<14>__OnStun; if (obj17 == null) { HandleNamedMessageDelegate val17 = OnStun; <>O.<14>__OnStun = val17; obj17 = (object)val17; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.stun", (HandleNamedMessageDelegate)obj17); object obj18 = <>O.<15>__OnConsume; if (obj18 == null) { HandleNamedMessageDelegate val18 = OnConsume; <>O.<15>__OnConsume = val18; obj18 = (object)val18; } customMessagingManager.RegisterNamedMessageHandler("daniel.hazardpay.consume", (HandleNamedMessageDelegate)obj18); _registered = true; _nm = singleton; _nextAsk = 0f; _asks = 0; _gotHello = false; if (singleton.IsServer) { Registry.ApplyPrices(Settings.FromConfig()); } AskIfNeeded(singleton); } private static void AskIfNeeded(NetworkManager nm) { if (!nm.IsServer && nm.IsConnectedClient && !_gotHello && !(Time.unscaledTime < _nextAsk)) { _nextAsk = Time.unscaledTime + 3f; _asks++; Plugin.Log.LogInfo((object)$"HazardPay: asking the host for its settings (try {_asks})."); Send("daniel.hazardpay.hello", 0uL, null); } } private static void Reset() { CustomMessagingManager val = (((Object)(object)_nm != (Object)null) ? _nm.CustomMessagingManager : null); if (val != null) { string[] all = All; foreach (string text in all) { try { val.UnregisterNamedMessageHandler(text); } catch (Exception) { } } } _registered = false; _nm = null; _gotHello = false; Pending.Clear(); Settings.Reset(); HostReloads.Clear(); } public static void BroadcastConfig() { if (!IsHost) { return; } Registry.ApplyPrices(Settings.FromConfig()); foreach (ulong item in Clients()) { SendConfig(item); } } private static void SendConfig(ulong client) { Settings.Values v = Settings.FromConfig(); Send("daniel.hazardpay.config", client, delegate(FastBufferWriter w) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) v.Write(w); }); } private static void SendAllStates(ulong client) { List<HazardItem> list = (from i in Object.FindObjectsOfType<HazardItem>() where (Object)(object)i != (Object)null && (Object)(object)((NetworkBehaviour)i).NetworkObject != (Object)null && ((NetworkBehaviour)i).NetworkObject.IsSpawned && i.HasState select i).ToList(); if (list.Count != 0) { SendStates(list, new List<ulong> { client }); Plugin.Log.LogInfo((object)$"HazardPay: sent {list.Count} item state(s) to client {client}."); } } public static void BroadcastState(HazardItem item) { if (IsHost && !((Object)(object)item == (Object)null)) { List<ulong> list = Clients(); if (list.Count > 0) { SendStates(new List<HazardItem> { item }, list); } } } private static void SendStates(List<HazardItem> items, List<ulong> targets) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8 + items.Count * 16, (Allocator)2, 65536); try { int count = items.Count; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives)); foreach (HazardItem item in items) { item.GetState(out var a, out var b); ulong networkObjectId = ((NetworkBehaviour)item).NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref a, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref b, default(ForPrimitives)); } singleton.CustomMessagingManager.SendNamedMessage("daniel.hazardpay.state", (IReadOnlyList<ulong>)targets, val, (NetworkDelivery)4); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private static void OnState(ulong sender, FastBufferReader r) { //IL_000e: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (IsHost) { return; } int num = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num, default(ForPrimitives)); ulong num2 = default(ulong); int num3 = default(int); int num4 = default(int); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num4, default(ForPrimitives)); HazardItem hazardItem = Net.Find<HazardItem>(num2); if ((Object)(object)hazardItem != (Object)null) { hazardItem.SetState(num3, num4); } else { Pending[num2] = (num3, num4); } } } internal static bool TakePending(HazardItem item, out int a, out int b) { a = (b = 0); if ((Object)(object)item == (Object)null || (Object)(object)((NetworkBehaviour)item).NetworkObject == (Object)null || !Pending.TryGetValue(((NetworkBehaviour)item).NetworkObjectId, out (int, int) value)) { return false; } Pending.Remove(((NetworkBehaviour)item).NetworkObjectId); (a, b) = value; return true; } public static void RequestFire(GunItem gun, ushort shotId, Vector3 origin, Vector3 dir, bool aimed) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (IsHost) { HostFire(gun, shotId, origin, dir, aimed, 0uL); return; } Send("daniel.hazardpay.fire", 0uL, delegate(FastBufferWriter w) { //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_0028: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<ushort>(ref shotId, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe(ref origin); ((FastBufferWriter)(ref w)).WriteValueSafe(ref dir); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref aimed, default(ForPrimitives)); }); } private static void OnFire(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0053: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); ushort shotId = default(ushort); ((FastBufferReader)(ref r)).ReadValueSafe<ushort>(ref shotId, default(ForPrimitives)); Vector3 origin = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref origin); Vector3 dir = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref dir); bool aimed = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref aimed, default(ForPrimitives)); HostFire(Net.Find<GunItem>(id), shotId, origin, dir, aimed, sender); } private static void HostFire(GunItem gun, ushort shotId, Vector3 origin, Vector3 dir, bool aimed, ulong sender) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009e: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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) PlayerControllerB val = HeldBySender((GrabbableObject)(object)gun, sender); if ((Object)(object)val == (Object)null) { return; } string text = gun.HostCanFire(); if (text != null) { Plugin.Log.LogInfo((object)$"HazardPay: shot refused ({gun.Kind}, {text})."); BroadcastState(gun); return; } if (Vector3.Distance(origin, ((Component)val.gameplayCamera).transform.position) > 3f) { origin = ((Component)val.gameplayCamera).transform.position; } dir = ((((Vector3)(ref dir)).sqrMagnitude > 0.001f) ? ((Vector3)(ref dir)).normalized : ((Component)val.gameplayCamera).transform.forward); List<HitInfo> list = gun.HostShoot(val, origin, dir, aimed); gun.HostAfterShot(); List<ulong> list2 = Clients(); if (list2.Count > 0) { FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(64 + list.Count * 32, (Allocator)2, 8192); try { ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref sender, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ushort>(ref shotId, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref origin); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref aimed, default(ForPrimitives)); gun.GetState(out var a, out var b); ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref a, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref b, default(ForPrimitives)); byte b2 = (byte)list.Count; ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b2, default(ForPrimitives)); foreach (HitInfo item in list) { item.Write(val2); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("daniel.hazardpay.shot", (IReadOnlyList<ulong>)list2, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } } gun.OnShot(sender, shotId, origin, aimed, list); } private static void OnShot(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00d7: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); ulong shooter = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref shooter, default(ForPrimitives)); ushort shotId = default(ushort); ((FastBufferReader)(ref r)).ReadValueSafe<ushort>(ref shotId, default(ForPrimitives)); Vector3 origin = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref origin); bool aimed = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref aimed, default(ForPrimitives)); int a = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref a, default(ForPrimitives)); int b = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref b, default(ForPrimitives)); byte b2 = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b2, default(ForPrimitives)); List<HitInfo> list = new List<HitInfo>(b2); for (int i = 0; i < b2; i++) { list.Add(HitInfo.Read(r)); } GunItem gunItem = Net.Find<GunItem>(id); if (!((Object)(object)gunItem == (Object)null)) { gunItem.SetState(a, b); gunItem.OnShot(shooter, shotId, origin, aimed, list); } } public static void RequestSafety(GunItem gun, bool on) { if (IsHost) { HostSafety(gun, on, 0uL); return; } Send("daniel.hazardpay.safety", 0uL, delegate(FastBufferWriter w) { //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_0028: 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) ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref on, default(ForPrimitives)); }); } private static void OnSafety(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); HostSafety(Net.Find<GunItem>(id), flag, sender); } private static void HostSafety(GunItem gun, bool on, ulong sender) { if (!((Object)(object)HeldBySender((GrabbableObject)(object)gun, sender) == (Object)null)) { gun.SafetyOn = on; BroadcastState(gun); } } public static void RequestReload(GunItem gun) { if (IsHost) { HostReload(gun, 0uL); return; } Send("daniel.hazardpay.reload", 0uL, delegate(FastBufferWriter w) { //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) ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); }); } private static void OnReload(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); HostReload(Net.Find<GunItem>(id), sender); } private static void HostReload(GunItem gun, ulong sender) { PlayerControllerB val = HeldBySender((GrabbableObject)(object)gun, sender); if (!((Object)(object)val == (Object)null) && !HostReloads.ContainsKey(gun)) { int spare = Ammo.Count(val, gun.AmmoType); float num = gun.HostReloadSeconds(spare); if (num <= 0f) { BroadcastState(gun); } else { StartReloadStep(gun, sender, num); } } } private static void StartReloadStep(GunItem gun, ulong sender, float seconds) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) bool empty = gun.Rounds == 0; HostReloads[gun] = (sender, Time.time + seconds); List<ulong> list = Clients(); if (list.Count > 0) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref seconds, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref empty, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("daniel.hazardpay.reloading", (IReadOnlyList<ulong>)list, val, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } gun.OnReloading(seconds, empty); } internal static void TickReloads() { if (HostReloads.Count == 0) { return; } foreach (KeyValuePair<GunItem, (ulong, float)> item in HostReloads.ToList()) { GunItem key = item.Key; if ((Object)(object)key == (Object)null) { HostReloads.Remove(key); continue; } PlayerControllerB playerHeldBy = ((GrabbableObject)key).playerHeldBy; if ((Object)(object)playerHeldBy == (Object)null || playerHeldBy.actualClientId != item.Value.Item1 || ((GrabbableObject)key).isPocketed) { HostReloads.Remove(key); key.OnReloadCancelled(); BroadcastState(key); } else if (!(Time.time < item.Value.Item2)) { HostReloads.Remove(key); key.HostFinishReload(playerHeldBy); BroadcastState(key); float num = key.HostNextReloadSeconds(Ammo.Count(playerHeldBy, key.AmmoType)); if (num > 0f) { StartReloadStep(key, item.Value.Item1, num); } } } } public static void RequestReloadStop(GunItem gun) { if (IsHost) { HostReloadStop(gun, 0uL); return; } Send("daniel.hazardpay.reloadstop", 0uL, delegate(FastBufferWriter w) { //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) ulong networkObjectId = ((NetworkBehaviour)gun).NetworkObjectId; ((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); }); } private static void OnReloadStop(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); HostReloadStop(Net.Find<GunItem>(id), sender); } private static void HostReloadStop(GunItem gun, ulong sender) { if (!((Object)(object)gun == (Object)null) && Hos