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 Buckshot Roulette v0.1.4
plugins/BuckshotRoulette/BuckshotRoulette.dll
Decompiled a week 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.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BuckshotRoulette.Core; using BuckshotRoulette.Dealer; using BuckshotRoulette.Items; using BuckshotRoulette.Logic; using BuckshotRoulette.Shells; using BuckshotRoulette.Valuables; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using REPOLib.Objects.Sdk; using Strobotnik.Klattersynth; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BuckshotRoulette")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9a0dd3333ac3f69b627418cb94a0227e3c9365f2")] [assembly: AssemblyProduct("BuckshotRoulette")] [assembly: AssemblyTitle("BuckshotRoulette")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 BuckshotRoulette { [BepInPlugin("local.buckshotroulette", "BuckshotRoulette", "0.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log { get; private set; } internal static Plugin Instance { get; private set; } private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Settings.Bind(((BaseUnityPlugin)this).Config); new Harmony("local.buckshotroulette").PatchAll(typeof(Plugin).Assembly); EffectsHost.Create(((Component)this).gameObject); AdrenalineTime.Create(((Component)this).gameObject); ShellPool.Register(); ((Component)this).gameObject.AddComponent<ShellPoolCallbacks>(); GunFx.Load(); CustomValuables.RegisterAll(); try { DealerFactory.RegisterAll(); } catch (Exception arg) { Log.LogError((object)$"Не удалось собрать дилера: {arg}"); } ShopItems.RegisterAll(); Log.LogInfo((object)"BuckshotRoulette 0.1.4 загружен"); } } } namespace BuckshotRoulette.Logic { public sealed class AdrenalineWindow { public const double Duration = 10.0; public const float WorldScale = 0.1f; private readonly Dictionary<int, double> _until = new Dictionary<int, double>(); public int Count => _until.Count; public IEnumerable<int> PlayerIds => _until.Keys; public int[] Players => _until.Keys.ToArray(); public double[] Deadlines => _until.Values.ToArray(); public double Remaining(int player, double now) { if (!_until.TryGetValue(player, out var value)) { return 0.0; } return Math.Max(0.0, value - now); } public bool Contains(int player, double now) { return Remaining(player, now) > 0.0; } public bool TryStart(int player, double now) { if (player <= 0 || !Finite(now) || Contains(player, now)) { return false; } _until[player] = now + 10.0; return true; } public bool Remove(int player) { return _until.Remove(player); } public void Clear() { _until.Clear(); } public bool Expire(double now) { bool flag = false; int[] array = (from pair in _until where pair.Value <= now select pair.Key).ToArray(); foreach (int key in array) { flag |= _until.Remove(key); } return flag; } public bool Apply(int[] players, double[] deadlines, double now) { if (!Finite(now) || players == null || deadlines == null || players.Length != deadlines.Length || players.Length > 64) { return false; } Dictionary<int, double> dictionary = new Dictionary<int, double>(); for (int i = 0; i < players.Length; i++) { if (players[i] <= 0 || !Finite(deadlines[i]) || deadlines[i] > now + 10.0 + 0.5 || dictionary.ContainsKey(players[i])) { return false; } dictionary.Add(players[i], deadlines[i]); } _until.Clear(); foreach (KeyValuePair<int, double> item in dictionary) { if (item.Value > now) { _until.Add(item.Key, item.Value); } } return true; } public static float ForceMultiplier(float compensation, bool impulse) { if (!impulse) { return compensation * compensation; } return compensation; } private static bool Finite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } } public sealed class HacksawBoost { public bool Active { get; private set; } public bool Arm() { if (Active) { return false; } Active = true; return true; } public int Consume(int damage) { if (!Active) { return damage; } Active = false; return damage * 2; } } public static class Heal { public static int PercentOfMax(int maxHealth, int percent) { return (int)Math.Ceiling((double)(maxHealth * percent) / 100.0); } } public static class Medicine { public static int RollDelta(int maxHealth, Random rng) { if (rng.Next(2) != 0) { return -Heal.PercentOfMax(maxHealth, 10); } return Heal.PercentOfMax(maxHealth, 20); } } public sealed class JammerCharges { public const int Capacity = 3; public const double CooldownSeconds = 1.5; private double _readyAt = double.NegativeInfinity; public int Remaining { get; private set; } public int SavedPercent => Remaining * 100 / 3; public JammerCharges(int savedPercent) { int num = Math.Min(100, Math.Max(0, savedPercent)); Remaining = (int)Math.Round((double)(num * 3) / 100.0, MidpointRounding.AwayFromZero); } public bool TryUse(double time) { if (Remaining == 0 || double.IsNaN(time) || double.IsInfinity(time) || time < _readyAt) { return false; } Remaining--; _readyAt = time + 1.5; return true; } } public static class PhoneSpeech { private static readonly Regex Markup = new Regex("<[^>]*>"); private static readonly Regex Words = new Regex("[\\p{L}\\p{M}]+"); private static readonly Dictionary<string, string> StressedNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { ["дилер"] = "Ди\u0301лер", ["охотник"] = "Охо\u0301тник", ["тяжеловес"] = "Тяжелове\u0301с", ["рыцарь"] = "Ры\u0301царь", ["мантия"] = "Ма\u0301нтия", ["малыш"] = "Малы\u0301ш", ["теневой"] = "Тенево\u0301й", ["ребенок"] = "Ребёнок", ["голова"] = "Голова\u0301", ["мясо"] = "Мя\u0301со", ["клоун"] = "Кло\u0301ун", ["невидимка"] = "Невиди\u0301мка", ["менталист"] = "Ментали\u0301ст", ["паразит"] = "Парази\u0301т", ["попрыгун"] = "Попрыгу\u0301н", ["плевун"] = "Плеву\u0301н" }; public static string Prepare(string name) { if (string.IsNullOrWhiteSpace(name)) { return string.Empty; } string input = Markup.Replace(name, string.Empty).Trim(); string value; return Words.Replace(input, (Match match) => (!StressedNames.TryGetValue(match.Value, out value)) ? match.Value : value); } public static string ForName(string name) { string text = Prepare(name); if (text.Length == 0) { return string.Empty; } bool flag = false; string text2 = text; foreach (char c in text2) { if (c >= 'Ѐ' && c <= 'ӿ') { flag = true; break; } } return (flag ? "Ря\u0301дом. " : "Nearby. ") + text + "."; } } public static class Retreat { public static float Distance(float distanceToSource) { return distanceToSource * 0.5f; } public static Vector3? Target(Vector3 enemy, Vector3 source) { float num = enemy.X - source.X; float num2 = enemy.Z - source.Z; float num3 = MathF.Sqrt(num * num + num2 * num2); if (num3 < 0.0001f) { return null; } float num4 = Distance(num3); return new Vector3(enemy.X + num / num3 * num4, enemy.Y, enemy.Z + num2 / num3 * num4); } } public enum Shell { Blank, Live } public sealed class ShellMagazine : IEnumerable<Shell>, IEnumerable { private readonly Queue<Shell> _queue; public int Live { get; private set; } public int Blank { get; private set; } public int Remaining => Live + Blank; public bool IsEmpty => Remaining == 0; public double LiveChance { get { if (Remaining != 0) { return (double)Live / (double)Remaining; } return 0.0; } } public ShellMagazine(IEnumerable<Shell> shells) { _queue = new Queue<Shell>(shells); foreach (Shell item in _queue) { if (item == Shell.Live) { Live++; } else { Blank++; } } } public static ShellMagazine Random(Random rng, int minTotal, int maxTotal) { if (minTotal < 2) { throw new ArgumentOutOfRangeException("minTotal", "нужно минимум 2 патрона: живой и холостой"); } if (maxTotal < minTotal) { throw new ArgumentOutOfRangeException("maxTotal"); } int num = rng.Next(minTotal, maxTotal + 1); int num2 = rng.Next(1, num); Shell[] array = new Shell[num]; for (int i = 0; i < num; i++) { array[i] = ((i < num2) ? Shell.Live : Shell.Blank); } for (int num3 = num - 1; num3 > 0; num3--) { int num4 = rng.Next(num3 + 1); ref Shell reference = ref array[num3]; ref Shell reference2 = ref array[num4]; Shell shell = array[num4]; Shell shell2 = array[num3]; reference = shell; reference2 = shell2; } return new ShellMagazine(array); } public Shell Fire() { if (_queue.Count == 0) { throw new InvalidOperationException("магазин пуст"); } Shell num = _queue.Dequeue(); if (num == Shell.Live) { Live--; return num; } Blank--; return num; } public string Serialize() { StringBuilder stringBuilder = new StringBuilder(_queue.Count); foreach (Shell item in _queue) { stringBuilder.Append((item == Shell.Live) ? 'L' : 'B'); } return stringBuilder.ToString(); } public static ShellMagazine Deserialize(string data) { List<Shell> list = new List<Shell>(data.Length); foreach (char c in data) { switch (c) { case 'L': list.Add(Shell.Live); break; case 'B': list.Add(Shell.Blank); break; default: throw new FormatException($"неизвестный патрон '{c}'"); } } return new ShellMagazine(list); } public IEnumerator<Shell> GetEnumerator() { return _queue.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public sealed class ShotLedger { private readonly Dictionary<long, (double Until, bool Live, bool Seen)> _entries = new Dictionary<long, (double, bool, bool)>(); private readonly List<long> _expired = new List<long>(); public int Count => _entries.Count; public static long ShotKey(int shotId) { return (uint)shotId; } public static long ShooterKey(int shooterId) { return 0x100000000L | (long)(uint)shooterId; } public bool Resolve(long key, double now, double window, Func<bool> take, out bool fresh) { Prune(now); if (_entries.TryGetValue(key, out (double, bool, bool) value)) { fresh = !value.Item3; _entries[key] = (value.Item1, value.Item2, true); return value.Item2; } bool flag = take(); _entries[key] = (now + window, flag, true); fresh = true; return flag; } public bool Forget(long key) { return _entries.Remove(key); } public bool Reserve(long key, double now, double window, Func<bool> take) { Prune(now); if (_entries.TryGetValue(key, out (double, bool, bool) value)) { return value.Item2; } bool flag = take(); _entries[key] = (now + window, flag, false); return flag; } private void Prune(double now) { foreach (KeyValuePair<long, (double, bool, bool)> entry in _entries) { if (entry.Value.Item1 <= now) { _expired.Add(entry.Key); } } foreach (long item in _expired) { _entries.Remove(item); } _expired.Clear(); } } } namespace BuckshotRoulette.Valuables { internal static class BeerAudio { private static AudioClip[] _hits; private static AudioClip _spill; public static void Configure(ValuableObject valuable) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (_hits == null) { _hits = (AudioClip[])(object)new AudioClip[2] { LoadPcm("beer_hit_1.wav"), LoadPcm("beer_hit_2.wav") }; } if (_spill == null) { _spill = LoadPcm("beer_spill.wav"); } PhysAudio val = (((Object)(object)valuable.audioPreset != (Object)null) ? Object.Instantiate<PhysAudio>(valuable.audioPreset) : ScriptableObject.CreateInstance<PhysAudio>()); ((Object)val).name = "Buckshot Beer Aluminum and Spill"; val.breakLight = Hit(0.55f); val.breakMedium = Hit(0.7f); val.breakHeavy = Hit(0.85f); Sound val2 = new Sound(); val2.Sounds = (AudioClip[])(object)new AudioClip[1] { _spill }; val2.Type = (AudioType)3; val2.Volume = 0.8f; val2.VolumeRandom = 0f; val2.Pitch = 1f; val2.PitchRandom = 0.025f; val.destroy = val2; valuable.audioPreset = val; valuable.audioPresetPitch = 1f; } private static Sound Hit(float volume) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown return new Sound { Sounds = _hits, Type = (AudioType)3, Volume = volume, VolumeRandom = 0.04f, Pitch = 1f, PitchRandom = 0.08f }; } private static AudioClip LoadPcm(string name) { string path = Path.Combine(Path.GetDirectoryName(typeof(Plugin).Assembly.Location), "Audio", name); BinaryReader file = new BinaryReader(File.OpenRead(path)); try { if (FourCc() != "RIFF") { throw new InvalidDataException("Invalid WAV: " + name); } file.ReadUInt32(); if (FourCc() != "WAVE") { throw new InvalidDataException("Invalid WAV: " + name); } ushort num = 0; ushort num2 = 0; ushort num3 = 0; int num4 = 0; byte[] array = null; while (file.BaseStream.Position + 8 <= file.BaseStream.Length) { string text = FourCc(); uint num5 = file.ReadUInt32(); long num6 = file.BaseStream.Position + num5; if (num6 > file.BaseStream.Length) { throw new InvalidDataException("Truncated WAV: " + name); } if (text == "fmt " && num5 >= 16) { num = file.ReadUInt16(); num2 = file.ReadUInt16(); num4 = file.ReadInt32(); file.ReadInt32(); file.ReadUInt16(); num3 = file.ReadUInt16(); } else if (text == "data") { array = file.ReadBytes(checked((int)num5)); } file.BaseStream.Position = num6 + (num5 & 1); } if (num != 1 || num2 != 1 || num3 != 16 || num4 != 44100 || array == null || array.Length % 2 != 0) { throw new InvalidDataException("Expected 44.1 kHz mono PCM16: " + name); } float[] array2 = new float[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)(short)(array[i * 2] | (array[i * 2 + 1] << 8)) / 32768f; } AudioClip obj = AudioClip.Create("Buckshot " + name, array2.Length, (int)num2, num4, false); obj.SetData(array2, 0); return obj; } finally { if (file != null) { ((IDisposable)file).Dispose(); } } string FourCc() { return Encoding.ASCII.GetString(file.ReadBytes(4)); } } } internal sealed class BurnerPhone : MonoBehaviour { private const float RingSeconds = 2.4f; private static Sound _ring; private PhotonView _view; private PhysGrabObject _grab; private bool _rung; private void Awake() { _view = ((Component)this).GetComponent<PhotonView>(); _grab = ((Component)this).GetComponent<PhysGrabObject>(); } private void Update() { if (!_rung && !((Object)(object)_grab == (Object)null) && _grab.grabbed && SemiFunc.IsMasterClientOrSingleplayer()) { _rung = true; int num = NearestEnemyIndex(); if (SemiFunc.IsMultiplayer()) { _view.RPC("RingRPC", (RpcTarget)0, new object[1] { num }); } else { RingRPC(num); } } } private int NearestEnemyIndex() { //IL_0099: 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) EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance == (Object)null) { return -1; } EnemyParent val = null; float num = float.MaxValue; foreach (EnemyParent item in instance.enemiesSpawned) { if (!((Object)(object)item == (Object)null) && item.Spawned && !((Object)(object)item.Enemy == (Object)null) && !((Object)(object)item.Enemy.CenterTransform == (Object)null) && (!((Object)(object)item.Enemy.Health != (Object)null) || !item.Enemy.Health.dead)) { float num2 = Vector3.Distance(((Component)this).transform.position, item.Enemy.CenterTransform.position); if (num2 < num) { num = num2; val = item; } } } Plugin.Log.LogInfo((object)(((Object)(object)val == (Object)null) ? $"Телефон: живых заспавненных монстров нет (всего в списке {instance.enemiesSpawned.Count})" : $"Телефон: ближайший монстр — {val.enemyName}, {num:F1} м")); if (!((Object)(object)val == (Object)null)) { return SemiFunc.EnemyGetIndex(val.Enemy); } return -1; } [PunRPC] private void RingRPC(int enemyIndex) { _rung = true; ((MonoBehaviour)this).StartCoroutine(RingAndSpeak(enemyIndex)); } private IEnumerator RingAndSpeak(int enemyIndex) { RingSound().Play(((Component)this).transform, 1f, 1f, 1f, 1f); yield return (object)new WaitForSecondsRealtime(2.6000001f); if (!((Object)(object)this == (Object)null)) { RobotVoice.Speak(((Component)this).transform, PhraseFor(enemyIndex)); } } private static string PhraseFor(int enemyIndex) { EnemyParent val = SemiFunc.EnemyGetFromIndex(enemyIndex)?.EnemyParent; if ((Object)(object)val == (Object)null) { return Texts.T("Монстров рядом нет", "No monsters nearby"); } return PhoneSpeech.ForName(((Object)(object)((Component)val).GetComponentInChildren<EnemyDealer>(true) != (Object)null) ? Texts.T("Дилер", "Dealer") : (((Object)(object)val.enemyNameLocalized != (Object)null) ? val.enemyNameLocalized.GetLocalizedString((Locale)null) : val.enemyName)); } private static Sound RingSound() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Sound obj = _ring; if (obj == null) { Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { RingTone.Create() }; val.Volume = 0.8f; val.VolumeRandom = 0f; val.PitchRandom = 0f; obj = (_ring = val); } return obj; } } internal enum ConsumableKind { Beer, Cigarettes, Medicine } internal sealed class ConsumableValuable : MonoBehaviour { public ConsumableKind Kind; private PhotonView _view; private PhysGrabObject _grab; private bool _used; private const float DrunkSeconds = 10f; private const float DrunkPitch = 0.82f; private const float DrunkWobble = 0.14f; private const float DrunkWobbleSpeed = 2.5f; private void Awake() { _view = ((Component)this).GetComponent<PhotonView>(); _grab = ((Component)this).GetComponent<PhysGrabObject>(); } private void Update() { if (_used || (Object)(object)_grab == (Object)null || !_grab.heldByLocalPlayer) { return; } string text = SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>"); SemiFunc.UIItemInfoText((ItemAttributes)null, Label() + " <color=#FFFFFF>[" + text + "]</color>"); if (!SemiFunc.InputDown((InputKey)2)) { return; } PlayerAvatar instance = PlayerAvatar.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.playerHealth == (Object)null)) { _used = true; Apply(instance); MarkUsedVisual(); if ((Object)(object)_view != (Object)null && _view.ViewID != 0) { _view.RPC("UsedRPC", (RpcTarget)1, new object[2] { (Kind != ConsumableKind.Medicine) ? 1 : 0, instance.photonView.ViewID }); } } } private static void DrunkVoice(PlayerAvatar player) { if ((Object)(object)player != (Object)null && (Object)(object)player.voiceChat != (Object)null) { player.voiceChat.OverridePitch(0.82f, 0.8f, 2f, 10f, 0.14f, 2.5f); } } private string Label() { return Kind switch { ConsumableKind.Beer => Texts.T("Выпить пиво", "Drink beer"), ConsumableKind.Cigarettes => Texts.T("Выкурить сигарету", "Smoke a cigarette"), _ => Texts.T("Принять лекарство", "Take medicine"), }; } private void Apply(PlayerAvatar player) { PlayerHealth playerHealth = player.playerHealth; int maxHealth = playerHealth.maxHealth; int health = playerHealth.health; switch (Kind) { case ConsumableKind.Beer: playerHealth.Heal(Heal.PercentOfMax(maxHealth, 10), true); PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart; EffectsHost.Instance.StartNausea(10f); DrunkVoice(player); HealEffect.Play(((Component)player).transform); break; case ConsumableKind.Cigarettes: playerHealth.Heal(Heal.PercentOfMax(maxHealth, 10), true); HealEffect.Play(((Component)player).transform); break; case ConsumableKind.Medicine: { int num = Medicine.RollDelta(maxHealth, new Random()); if (num > 0) { playerHealth.Heal(num, true); HealEffect.Play(((Component)player).transform); } else { playerHealth.Hurt(Mathf.Min(-num, Mathf.Max(0, playerHealth.health - 1)), false, -1, false); } break; } } Plugin.Log.LogInfo((object)$"{Kind}: HP {health} -> {playerHealth.health} (макс {maxHealth})"); } private void MarkUsedVisual() { //IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = ((Renderer)componentsInChildren[i]).materials; foreach (Material val in materials) { val.SetColor("_Color", val.GetColor("_Color") * 0.35f); val.SetColor("_EmissionColor", Color.black); } } } [PunRPC] private void UsedRPC(int healed, int userViewId) { _used = true; MarkUsedVisual(); if (Kind == ConsumableKind.Beer) { DrunkVoice(SemiFunc.PlayerAvatarGetFromPhotonID(userViewId)); } if (healed != 1 || (Object)(object)_grab == (Object)null) { return; } foreach (PhysGrabber item in _grab.playerGrabbing) { if ((Object)(object)item != (Object)null && (Object)(object)item.playerAvatar != (Object)null) { HealEffect.Play(((Component)item.playerAvatar).transform); } } } } internal static class CustomValuables { private sealed class Def { public string Name; public string Model; public float MinValue; public float MaxValue; public ConsumableKind? Kind; public bool Phone; } private const string Template = "Valuables/01 Tiny/Valuable Arctic Keycard"; private static readonly Def[] Defs = new Def[4] { new Def { Name = "Valuable Beer Can", Model = "beer_can", MinValue = 500f, MaxValue = 1000f, Kind = ConsumableKind.Beer }, new Def { Name = "Valuable Burner Phone", Model = "burner_phone", MinValue = 500f, MaxValue = 1000f, Phone = true }, new Def { Name = "Valuable Cigarette Pack", Model = "cigarette_pack", MinValue = 200f, MaxValue = 500f, Kind = ConsumableKind.Cigarettes }, new Def { Name = "Valuable Expired Medicine", Model = "expired_medicine", MinValue = 200f, MaxValue = 500f, Kind = ConsumableKind.Medicine } }; public static readonly List<PrefabRef> Registered = new List<PrefabRef>(); private static Transform _holder; public static void RegisterAll() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) HealEffect.Load(); GameObject val = Resources.Load<GameObject>("Valuables/01 Tiny/Valuable Arctic Keycard"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Шаблон ценности не найден: Valuables/01 Tiny/Valuable Arctic Keycard"); return; } _holder = new GameObject("BuckshotRoulette Prefabs").transform; ((Component)_holder).gameObject.SetActive(false); Object.DontDestroyOnLoad((Object)(object)((Component)_holder).gameObject); Def[] defs = Defs; foreach (Def def in defs) { try { PrefabRef val2 = Valuables.RegisterValuable(Build(val, def)); if (val2 != null) { Registered.Add(val2); } Plugin.Log.LogInfo((object)$"Ценность зарегистрирована: {def.Name} ({def.MinValue}..{def.MaxValue})"); } catch (Exception arg) { Plugin.Log.LogError((object)$"Не удалось собрать {def.Name}: {arg}"); } } } private static GameObject Build(GameObject template, Def def) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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) GameObject val = Object.Instantiate<GameObject>(template, _holder); ((Object)val).name = def.Name; ValuableObject component = val.GetComponent<ValuableObject>(); Value val2 = ScriptableObject.CreateInstance<Value>(); ((Object)val2).name = def.Name + " Value"; val2.valueMin = def.MinValue; val2.valueMax = def.MaxValue; component.valuePreset = val2; component.volumeType = (Type)0; if (def.Kind == ConsumableKind.Beer) { BeerAudio.Configure(component); } Transform obj = val.transform.Find("Object"); Transform val3 = obj.Find("Mesh"); PrefabUtil.ResetLocal(obj); PrefabUtil.ResetLocal(val3); MeshFilter component2 = ((Component)val3).GetComponent<MeshFilter>(); MeshRenderer component3 = ((Component)val3).GetComponent<MeshRenderer>(); ModelLoader.Model model = ModelLoader.Load(def.Model); component2.sharedMesh = model.Mesh; ((Renderer)component3).sharedMaterials = model.Materials; BoxCollider[] componentsInChildren = val.GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider obj2 in componentsInChildren) { PrefabUtil.ResetLocal(((Component)obj2).transform); Bounds bounds = model.Mesh.bounds; obj2.center = ((Bounds)(ref bounds)).center; bounds = model.Mesh.bounds; obj2.size = ((Bounds)(ref bounds)).size; MeshFilter component4 = ((Component)obj2).GetComponent<MeshFilter>(); if ((Object)(object)component4 != (Object)null) { component4.sharedMesh = model.Mesh; } } if (def.Kind.HasValue) { val.AddComponent<ConsumableValuable>().Kind = def.Kind.Value; } if (def.Phone) { val.AddComponent<BurnerPhone>(); } return val; } } internal static class HealEffect { private const string PackPath = "Items/Item Health Pack Small"; private const float PlayerHeight = 0.7f; private const float Lifetime = 4f; private static GameObject _particles; private static Sound _sound; public static void Load() { GameObject val = Resources.Load<GameObject>("Items/Item Health Pack Small"); Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("Heal Effects") : null); ItemHealthPack val3 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemHealthPack>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { Plugin.Log.LogError((object)"Эффект лечения не найден в Items/Item Health Pack Small"); return; } _particles = ((Component)val2).gameObject; _sound = val3.soundUse; } public static void Play(Transform around) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_particles == (Object)null) && !((Object)(object)around == (Object)null)) { GameObject val = Object.Instantiate<GameObject>(_particles, around); val.transform.localPosition = Vector3.up * 0.7f; val.transform.localRotation = Quaternion.identity; val.SetActive(true); ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Play(); } Object.Destroy((Object)(object)val, 4f); Sound sound = _sound; if (sound != null) { sound.Play(around.position + Vector3.up * 0.7f, 1f, 1f, 1f, 1f); } } } } internal static class RingTone { private const int SampleRate = 44100; private const float Seconds = 2.4f; public static AudioClip Create() { int num = 105840; float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 44100f; float num3 = num2 % 1.2f; if (!(num3 > 0.8f)) { float num4 = Mathf.Clamp01(num3 / 0.02f) * Mathf.Clamp01((0.8f - num3) / 0.02f); float num5 = 0.5f + 0.5f * Mathf.Sign(Mathf.Sin(num2 * MathF.PI * 2f * 20f)); float num6 = Mathf.Sin(num2 * MathF.PI * 2f * 440f) + Mathf.Sin(num2 * MathF.PI * 2f * 480f); array[i] = 0.4f * num4 * (0.35f + 0.65f * num5) * num6; } } AudioClip obj = AudioClip.Create("BuckshotRoulette Ring", num, 1, 44100, false); obj.SetData(array, 0); return obj; } } internal static class RobotVoice { private const int BaseFrequency = 170; private const float MouthLifetime = 14f; public static void Speak(Transform at, string phrase) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (!string.IsNullOrWhiteSpace(phrase)) { string text = Resolve(ref phrase); string speechText = TTSFormatting.GetSpeechText(phrase, text, (Reading)0); if (!string.IsNullOrWhiteSpace(speechText)) { GameObject val = new GameObject("BuckshotRoulette TTS Mouth"); val.SetActive(false); val.transform.SetParent(at, false); AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.volume = 1f; obj.spatialBlend = 0.85f; obj.dopplerLevel = 0f; obj.bypassReverbZones = true; obj.priority = 0; obj.minDistance = 6f; obj.maxDistance = 30f; obj.rolloffMode = (AudioRolloffMode)1; obj.outputAudioMixerGroup = MixerGroup(); AudioLowPassLogic obj2 = val.AddComponent<AudioLowPassLogic>(); obj2.ForceStart = true; obj2.AlwaysActive = true; obj2.HasCustomVolume = true; obj2.CustomVolume = 0.85f; val.GetComponent<AudioLowPassFilter>().cutoffFrequency = 22000f; Speech obj3 = val.AddComponent<Speech>(); obj3.voiceBaseFrequency = 170; obj3.msPerSpeechFrame = 16; obj3.flutter = 0; val.SetActive(true); obj3.speak(170, (VoicingSource)0, speechText, true, phrase); Object.Destroy((Object)(object)val, 14f); } } } private static string Resolve(ref string phrase) { string text = phrase; foreach (char c in text) { if (c >= 'Ѐ' && c <= 'ӿ') { return "ru-RU"; } } return TTSPronunciation.ResolveLocale(ref phrase, "en-US"); } private static AudioMixerGroup MixerGroup() { GameObject val = Resources.Load<GameObject>("TTS"); if ((Object)(object)val != (Object)null) { return val.GetComponent<AudioSource>().outputAudioMixerGroup; } Plugin.Log.LogWarning((object)"Префаб TTS не найден: голос без микшера"); return null; } } } namespace BuckshotRoulette.Shells { internal static class BuckshotFire { internal static void Execute(ItemGun gun, bool live, int shotId, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_000a: 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_0093: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (live) { ShotTag.Pending = shotId; try { gun.ShootRPC(info); return; } finally { ShotTag.Pending = 0; } } GunFx.Blank(gun.gunMuzzle); gun.StartTriggerAnimation(); if (SemiFunc.IsMasterClientOrSingleplayer()) { if (gun.investigateRadius > 0f && (Object)(object)EnemyDirector.instance != (Object)null) { EnemyDirector.instance.SetInvestigate(((Component)gun).transform.position, gun.investigateRadius, false); } PhysGrabObject component = ((Component)gun).GetComponent<PhysGrabObject>(); if ((Object)(object)component != (Object)null && (Object)(object)component.rb != (Object)null) { component.rb.AddForceAtPosition(-gun.gunMuzzle.forward * gun.gunRecoilForce, gun.gunMuzzle.position, (ForceMode)1); } ((Component)gun).GetComponent<ItemBattery>().RemoveFullBar(1); SawedOff component2 = ((Component)gun).GetComponent<SawedOff>(); if ((Object)(object)component2 != (Object)null && component2.Active) { component2.Consume(0); } } } } internal static class GunFx { private const string ShotgunPath = "Items/Item Gun Shotgun"; private static ItemGun _gun; private static Sound _pop; private static GameObject _puffPrefab; public static void Load() { GameObject val = Resources.Load<GameObject>("Items/Item Gun Shotgun"); _gun = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemGun>() : null); if ((Object)(object)_gun == (Object)null) { Plugin.Log.LogError((object)"Не найден ItemGun в Items/Item Gun Shotgun: у дробовиков не будет звука выстрела"); } } public static void Fire(Transform muzzle) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_gun == (Object)null || (Object)(object)muzzle == (Object)null) { return; } SemiFunc.CameraShakeImpactDistance(muzzle.position, 5f, 0.1f, 3f, 16f); SemiFunc.CameraShakeDistance(muzzle.position, 0.1f, 0.1f, 3f, 16f); _gun.soundShoot.Play(muzzle.position, 1f, 1f, 1f, 1f); _gun.soundShootGlobal.Play(muzzle.position, 1f, 1f, 1f, 1f); if (!((Object)(object)_gun.muzzleFlashPrefab == (Object)null)) { ItemGunMuzzleFlash component = Object.Instantiate<GameObject>(_gun.muzzleFlashPrefab, muzzle.position, muzzle.rotation, muzzle).GetComponent<ItemGunMuzzleFlash>(); if (component != null) { component.ActivateAllEffects(); } } } public static void Blank(Transform muzzle) { //IL_000b: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (!((Object)(object)muzzle == (Object)null)) { SemiFunc.CameraShakeImpactDistance(muzzle.position, 1.5f, 0.1f, 2f, 8f); if ((Object)(object)_gun != (Object)null) { _gun.soundNoAmmoClick.Play(muzzle.position, 1f, 1f, 1f, 1f); } if (_pop == null) { Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { PopClip() }; val.Volume = 0.6f; val.VolumeRandom = 0.05f; val.PitchRandom = 0.08f; _pop = val; } _pop.Play(muzzle.position, 1f, 1f, 1f, 1f); GameObject obj = Object.Instantiate<GameObject>(PuffPrefab(), muzzle.position, muzzle.rotation); obj.SetActive(true); Object.Destroy((Object)(object)obj, 2.5f); } } public static void Click(Vector3 position) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_gun != (Object)null) { _gun.soundNoAmmoClick.Play(position, 1f, 1f, 1f, 1f); } } private static AudioClip PopClip() { int num = 15435; float[] array = new float[num]; Random random = new Random(11); float num2 = 0f; for (int i = 0; i < num; i++) { float num3 = (float)i / 44100f; float num4 = Mathf.Exp((0f - num3) * 18f); num2 += ((float)random.NextDouble() * 2f - 1f - num2) * 0.08f; array[i] = 0.9f * num4 * (num2 * 3f + 0.3f * Mathf.Sin(num3 * MathF.PI * 2f * 90f)); } AudioClip obj = AudioClip.Create("BuckshotRoulette Blank Pop", num, 1, 44100, false); obj.SetData(array, 0); return obj; } private static GameObject PuffPrefab() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0043: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0190: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_puffPrefab != (Object)null) { return _puffPrefab; } _puffPrefab = new GameObject("BuckshotRoulette Blank Puff"); _puffPrefab.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_puffPrefab); ParticleSystem val = _puffPrefab.AddComponent<ParticleSystem>(); MainModule main = val.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).duration = 0.2f; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.6f, 1.2f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.4f, 1.4f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.08f, 0.2f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.55f, 0.55f, 0.55f, 0.5f), new Color(0.75f, 0.75f, 0.72f, 0.7f)); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f); EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)14) }); ShapeModule shape = val.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 12f; ((ShapeModule)(ref shape)).radius = 0.02f; SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.6f, 1f, 2.2f)); ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2); ParticleSystemRenderer component = _puffPrefab.GetComponent<ParticleSystemRenderer>(); Material val3 = FxTextures.AlphaMaterial("BuckshotRoulette Blank Puff", (Texture)(object)FxTextures.Smoke()); if ((Object)(object)val3 != (Object)null) { ((Renderer)component).sharedMaterial = val3; } else { ((Renderer)component).enabled = false; } return _puffPrefab; } } internal static class ShellPool { private static NetworkedEvent _loadEvent; private static ShellMagazine _magazine; private static LevelGenerator _level; private static readonly Random Rng = new Random(); public static int Size { get; private set; } = 5; public static void Register() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown _loadEvent = new NetworkedEvent("BuckshotRoulette.ShellPool", (Action<EventData>)OnLoadEvent); } public static void EnsureLoaded() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SyncLevel(); if (_magazine == null) { Load(showAnimation: true); } } } public static bool Take() { return Take(reloadAfter: true); } internal static bool TakeForShotgun() { return Take(reloadAfter: false); } private static bool Take(bool reloadAfter) { if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel()) { return true; } EnsureLoaded(); if (_magazine.IsEmpty) { if (!DealerIsActive()) { return true; } Load(showAnimation: true); } bool flag = _magazine.Fire() == Shell.Live; Plugin.Log.LogInfo((object)string.Format("Пул: {0}, осталось {1} боевых, {2} холостых", flag ? "БОЕВОЙ" : "холостой", _magazine.Live, _magazine.Blank)); if (reloadAfter) { ReloadIfEmpty(); } return flag; } public static void ReloadIfEmpty() { if (SemiFunc.IsMasterClientOrSingleplayer() && _magazine != null && _magazine.IsEmpty && DealerIsActive()) { Load(showAnimation: true); } } public static void ShowCurrent() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SyncLevel(); if (_magazine == null || _magazine.IsEmpty) { Load(showAnimation: true); } else { Raise(_magazine, showAnimation: true); } } } public static void OnShotgunCharged() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SyncLevel(); if (_magazine == null || _magazine.IsEmpty) { Load(showAnimation: true); } } } public static void SyncToPlayer(int actorNumber) { if (SemiFunc.IsMasterClientOrSingleplayer()) { SyncLevel(); if (_magazine != null) { Raise(_magazine, !_magazine.IsEmpty, actorNumber); } } } private static void SyncLevel() { if (!((Object)(object)_level == (Object)(object)LevelGenerator.Instance)) { _level = LevelGenerator.Instance; _magazine = null; } } private static void Load(bool showAnimation) { if (SemiFunc.IsMasterClientOrSingleplayer()) { _magazine = ShellMagazine.Random(Rng, Settings.MagazineMin.Value, Settings.MagazineMax.Value); Size = _magazine.Remaining; Plugin.Log.LogInfo((object)$"Пул: новый — {_magazine.Serialize()} ({_magazine.Live} боевых, {_magazine.Blank} холостых)"); if (showAnimation) { Raise(_magazine, showAnimation: true); } } } private static bool DealerIsActive() { return Object.FindObjectsByType<EnemyDealer>((FindObjectsSortMode)0).Any((EnemyDealer dealer) => (Object)(object)dealer != (Object)null && (Object)(object)((Component)dealer).GetComponent<Enemy>() != (Object)null && (Object)(object)((Component)dealer).GetComponent<Enemy>().EnemyParent != (Object)null && ((Component)dealer).GetComponent<Enemy>().EnemyParent.Spawned); } private static void Raise(ShellMagazine shown, bool showAnimation, int targetActorNumber = 0) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) _loadEvent.RaiseEvent((object)$"{Size}|{shown.Live}|{shown.Blank}|{showAnimation}|{targetActorNumber}", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } private static void OnLoadEvent(EventData data) { string[] array = ((string)data.CustomData).Split('|'); if (array.Length != 5 || !int.TryParse(array[0], out var result) || !int.TryParse(array[1], out var result2) || !int.TryParse(array[2], out var result3) || !bool.TryParse(array[3], out var result4) || !int.TryParse(array[4], out var result5) || result5 < 0 || result < 2 || result2 < 0 || result3 < 0 || result2 + result3 > result || (result4 && result2 + result3 == 0)) { Plugin.Log.LogWarning((object)"Получено некорректное состояние пула патронов"); return; } Size = result; bool flag = result5 == 0 || (PhotonNetwork.LocalPlayer != null && PhotonNetwork.LocalPlayer.ActorNumber == result5); if (result4 && flag) { ShellOverlay.Show(new ShellMagazine(Enumerable.Repeat(Shell.Live, result2).Concat(Enumerable.Repeat(Shell.Blank, result3)))); } BuckshotShells.ResizeAll(Size); } } internal sealed class ShellPoolCallbacks : MonoBehaviourPunCallbacks { public override void OnPlayerEnteredRoom(Player newPlayer) { ShellPool.SyncToPlayer(newPlayer.ActorNumber); } } internal sealed class ShotTag : MonoBehaviour { private static int _lastId; internal static int Pending; public int Id; public static int Next() { return ++_lastId; } } internal sealed class LaserShot : MonoBehaviour { private ShotTag _tag; private void Awake() { _tag = ((Component)this).GetComponent<ShotTag>() ?? ((Component)this).gameObject.AddComponent<ShotTag>(); } private void OnEnable() { _tag.Id = ShotTag.Next(); } private void OnDisable() { if ((Object)(object)_tag != (Object)null && _tag.Id != 0) { DealerDamagePatches.ForgetShot(_tag.Id); } } internal static void Mark(SemiLaser laser) { HurtCollider val = (((Object)(object)laser != (Object)null) ? ((Component)laser).GetComponentInChildren<HurtCollider>(true) : null); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<LaserShot>() == (Object)null) { ((Component)val).gameObject.AddComponent<LaserShot>(); } } } [HarmonyPatch(typeof(ItemGun), "ShootRPC")] internal static class ShotTagGunShot { [HarmonyPrefix] private static bool Prefix(ItemGun __instance) { if ((Object)(object)((Component)__instance).GetComponent<BuckshotShells>() != (Object)null) { return ShotTag.Pending != 0; } if (SemiFunc.IsMasterClientOrSingleplayer()) { ShotTag.Pending = ShotTag.Next(); } return true; } [HarmonyFinalizer] private static void Finalizer(ItemGun __instance) { ShotTag.Pending = 0; } } [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] internal static class ShotTagBullet { [HarmonyPostfix] private static void Postfix(ItemGun __instance) { if (ShotTag.Pending != 0 && !((Object)(object)__instance.hurtCollider == (Object)null)) { (((Component)__instance.hurtCollider).GetComponent<ShotTag>() ?? ((Component)__instance.hurtCollider).gameObject.AddComponent<ShotTag>()).Id = ShotTag.Pending; } } } [HarmonyPatch(typeof(ItemGunLaser), "Start")] internal static class ShotTagGunLaser { [HarmonyPostfix] private static void Postfix(ItemGunLaser __instance) { LaserShot.Mark(__instance.semiLaser); } } [HarmonyPatch(typeof(ItemCartLaser), "Start")] internal static class ShotTagCartLaser { [HarmonyPostfix] private static void Postfix(ItemCartLaser __instance) { LaserShot.Mark(__instance.semiLaser); } } } namespace BuckshotRoulette.Patches { [HarmonyPatch(typeof(Enemy), "Awake")] internal static class CuffedEnemyInitializationPatch { private static void Postfix(Enemy __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<CuffedEnemy>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<CuffedEnemy>(); } } } [HarmonyPatch(typeof(EnemyTriggerAttack), "OnTriggerStay")] internal static class CuffedEnemyContactAttackPatch { private static bool Prefix(EnemyTriggerAttack __instance) { if (!((Object)(object)__instance == (Object)null)) { return !CuffedEnemy.IsTargetCuffed(__instance.Enemy); } return true; } } [HarmonyPatch(typeof(EnemyRobe), "UpdateState")] internal static class CuffedRobeAttackPatch { private static void Prefix(EnemyRobe __instance, ref State __0) { if (CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__0 == 10 || (int)__0 == 7 || (int)__0 == 11)) { __0 = (State)2; } } } [HarmonyPatch(typeof(EnemyHunter), "UpdateState")] internal static class CuffedHunterStatePatch { private static void Prefix(EnemyHunter __instance, ref State __0) { if (CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__0 == 5 || (int)__0 == 6)) { __0 = (State)2; } } } [HarmonyPatch(typeof(EnemyHunter), "Update")] internal static class CuffedHunterAttackPatch { private static void Prefix(EnemyHunter __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if (SemiFunc.IsMasterClientOrSingleplayer() && CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__instance.currentState == 5 || (int)__instance.currentState == 6)) { __instance.UpdateState((State)2); } } } [HarmonyPatch(typeof(EnemyBombThrower), "UpdateState")] internal static class CuffedBombThrowerStatePatch { private static void Prefix(EnemyBombThrower __instance, ref State __0) { if (CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__0 == 8 || (int)__0 == 9)) { __0 = (State)2; } } } [HarmonyPatch(typeof(EnemyBombThrower), "Update")] internal static class CuffedBombThrowerAttackPatch { private static void Prefix(EnemyBombThrower __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 if (SemiFunc.IsMasterClientOrSingleplayer() && CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__instance.currentState == 8 || (int)__instance.currentState == 9)) { __instance.UpdateState((State)2); } } } [HarmonyPatch(typeof(EnemySlowWalker), "UpdateState")] internal static class CuffedSlowWalkerStatePatch { private static void Prefix(EnemySlowWalker __instance, ref State __0) { if (CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__0 == 7 || (int)__0 == 8 || (int)__0 == 12)) { __0 = (State)2; } } } [HarmonyPatch(typeof(EnemySlowWalker), "Update")] internal static class CuffedSlowWalkerAttackPatch { private static void Prefix(EnemySlowWalker __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if (SemiFunc.IsMasterClientOrSingleplayer() && CuffedEnemy.IsTargetCuffed(__instance.enemy) && ((int)__instance.currentState == 7 || (int)__instance.currentState == 8 || (int)__instance.currentState == 12)) { __instance.UpdateState((State)2); } } } [HarmonyPatch(typeof(SlowWalkerAttack), "SlowWalkerAttackStart")] internal static class CuffedSlowWalkerAnimationAttackPatch { private static bool Prefix(SlowWalkerAttack __instance) { return !CuffedEnemy.IsTargetCuffed(__instance.enemy); } } } namespace BuckshotRoulette.Items { internal sealed class Adrenaline : MonoBehaviour { private PhysGrabObject _grab; private PhotonView _view; private ItemAttributes _attributes; private bool _used; private float _nextRequest; private float _removeAt; private bool _destroyRequested; private static Sound _injection; private void Awake() { _grab = ((Component)this).GetComponent<PhysGrabObject>(); _view = ((Component)this).GetComponent<PhotonView>(); _attributes = ((Component)this).GetComponent<ItemAttributes>(); } private void Update() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_grab == (Object)null) { return; } if (_used) { if (!_destroyRequested && SemiFunc.IsMasterClientOrSingleplayer() && Time.unscaledTime >= _removeAt) { _destroyRequested = true; _grab.DestroyPhysGrabObject(); } return; } if (SemiFunc.IsMasterClientOrSingleplayer() && _grab.playerGrabbing.Count > 0) { _grab.TurnXYZ(Quaternion.Euler(20f, 0f, 0f), Quaternion.identity, Quaternion.identity); _grab.OverrideGrabVerticalPosition(-0.2f); } if (!_grab.heldByLocalPlayer || !SemiFunc.RunIsLevel()) { return; } string text = SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>"); SemiFunc.UIItemInfoText((ItemAttributes)null, Texts.T(text + " Ввести адреналин", text + " Inject adrenaline")); if (!(Time.unscaledTime < _nextRequest) && !((Object)(object)PlayerController.instance == (Object)null) && !(PlayerController.instance.InputDisableTimer > 0f) && SemiFunc.InputDown((InputKey)2)) { _nextRequest = Time.unscaledTime + 0.5f; if (SemiFunc.IsMultiplayer()) { _view.RPC("UseRequestRPC", (RpcTarget)2, Array.Empty<object>()); } else { Use(PlayerAvatar.instance); } } } [PunRPC] private void UseRequestRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || info.Sender == null || _used) { return; } foreach (PhysGrabber item in _grab.playerGrabbing) { PlayerAvatar val = (((Object)(object)item != (Object)null) ? item.playerAvatar : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.photonView == (Object)null) && val.photonView.OwnerActorNr == info.Sender.ActorNumber) { Use(val); break; } } } private void Use(PlayerAvatar player) { if (!_used && SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel() && !_attributes.shopItem && !((Object)(object)player == (Object)null) && !player.deadSet && !player.isDisabled && !((Object)(object)StatsManager.instance == (Object)null) && !string.IsNullOrEmpty(_attributes.instanceName) && StatsManager.instance.item.ContainsKey(_attributes.instanceName) && !((Object)(object)AdrenalineTime.Instance == (Object)null) && AdrenalineTime.Instance.TryActivate(player)) { _used = true; StatsManager.instance.ItemUpdateStatBattery(_attributes.instanceName, 0, true); StatsManager.instance.ItemRemove(_attributes.instanceName); _attributes.DisableUI(true); if (SemiFunc.IsMultiplayer()) { _view.RPC("InjectedRPC", (RpcTarget)0, Array.Empty<object>()); } else { Injected(); } Plugin.Log.LogInfo((object)("Адреналин: " + ((Object)player).name + ", 10 реальных секунд, мир ×0.1")); } } [PunRPC] private void InjectedRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (info.Sender == PhotonNetwork.MasterClient) { Injected(); } } private void Injected() { //IL_0077: 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_0031: Expected O, but got Unknown _used = true; _removeAt = Time.unscaledTime + 0.35f; _attributes.DisableUI(true); if (_injection == null) { Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { InjectionClip() }; val.Volume = 0.5f; val.PitchRandom = 0.025f; val.VolumeRandom = 0f; _injection = val; } _injection.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } private static AudioClip InjectionClip() { Random random = new Random(123); float[] array = new float[13230]; for (int i = 0; i < array.Length; i++) { float num = (float)i / 44100f; float num2 = ((float)random.NextDouble() * 2f - 1f) * 0.22f * Mathf.Exp((0f - num) * 13f); float num3 = Mathf.Sin(num * MathF.PI * 2f * 750f) * 0.4f * Mathf.Exp((0f - num) * 160f); array[i] = (num2 + num3) * Mathf.Clamp01(num / 0.001f); } AudioClip obj = AudioClip.Create("Buckshot adrenaline injection", array.Length, 1, 44100, false); obj.SetData(array, 0); return obj; } } internal static class AdrenalineItem { internal static Item Item { get; private set; } internal static void Register(Transform holder) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Resources.Load<GameObject>("Items/Item Health Pack Small"); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("Не найден шаблон адреналина"); } GameObject val = Object.Instantiate<GameObject>(obj, holder); ((Object)val).name = "Item Buckshot Adrenaline"; Object.DestroyImmediate((Object)(object)val.GetComponent<ItemHealthPack>()); string[] array = new string[3] { "Heal Effects", "Reject Effect", "Light" }; foreach (string text in array) { Transform val2 = val.transform.Find(text); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } } PrefabUtil.DisableDeadEvents(val); PrefabUtil.MakeDurableTool(val); ModelLoader.Model model = ModelLoader.Scaled(ModelLoader.Load("adrenaline"), 1.7f); Transform obj2 = val.transform.Find("Mesh"); PrefabUtil.ResetLocal(obj2); ((Component)obj2).GetComponent<MeshFilter>().sharedMesh = model.Mesh; ((Renderer)((Component)obj2).GetComponent<MeshRenderer>()).sharedMaterials = model.Materials; BoxCollider[] componentsInChildren = val.GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider obj3 in componentsInChildren) { PrefabUtil.ResetLocal(((Component)obj3).transform); Bounds bounds = model.Mesh.bounds; obj3.center = ((Bounds)(ref bounds)).center; bounds = model.Mesh.bounds; obj3.size = ((Bounds)(ref bounds)).size; MeshFilter component = ((Component)obj3).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { component.sharedMesh = model.Mesh; } } ItemAttributes component2 = val.GetComponent<ItemAttributes>(); Item val3 = Object.Instantiate<Item>(component2.item); ((Object)val3).name = "Item Buckshot Adrenaline"; val3.itemName = Texts.T("Адреналин", "Adrenaline"); val3.itemNameLocalized = null; val3.itemType = (itemType)13; Value val4 = ScriptableObject.CreateInstance<Value>(); ((Object)val4).name = "Item Buckshot Adrenaline Value"; val4.valueMin = 1250f; val4.valueMax = 2500f; val3.value = val4; component2.item = val3; component2.icon = null; component2.hasIcon = false; val.AddComponent<Adrenaline>(); if (Items.RegisterItem(component2) == null) { throw new InvalidOperationException("Адреналин не зарегистрирован"); } Item = val3; Plugin.Log.LogInfo((object)"Предмет зарегистрирован: Item Buckshot Adrenaline"); } } [HarmonyPatch] internal static class AdrenalinePatches { private static readonly Dictionary<MethodBase, MethodInfo> PhysicsCalls = BuildPhysicsCalls(); private static readonly Dictionary<short, OpCode> OpCodesByValue = (from f in typeof(OpCodes).GetFields(BindingFlags.Static | BindingFlags.Public) where f.FieldType == typeof(OpCode) select (OpCode)f.GetValue(null)).ToDictionary((OpCode o) => o.Value); private static readonly HashSet<MethodBase> Selected = new HashSet<MethodBase>(); private static Dictionary<MethodBase, MethodInfo> BuildPhysicsCalls() { Dictionary<MethodBase, MethodInfo> dictionary = new Dictionary<MethodBase, MethodInfo>(); MethodInfo[] methods = typeof(Rigidbody).GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { string text = methodInfo.Name; switch (text) { case "get_linearVelocity": case "get_velocity": text = "GetLinearVelocity"; break; case "set_linearVelocity": case "set_velocity": text = "SetLinearVelocity"; break; case "get_angularVelocity": text = "GetAngularVelocity"; break; case "set_angularVelocity": text = "SetAngularVelocity"; break; } Type[] types = new Type[1] { typeof(Rigidbody) }.Concat(from p in methodInfo.GetParameters() select p.ParameterType).ToArray(); MethodInfo method = typeof(AdrenalinePhysics).GetMethod(text, BindingFlags.Static | BindingFlags.NonPublic, null, types, null); if (method != null) { dictionary[methodInfo] = method; } } return dictionary; } private static bool OwnClock(Type type) { string name = type.Name; if (!name.StartsWith("Player", StringComparison.Ordinal) && !name.StartsWith("Camera", StringComparison.Ordinal) && !name.StartsWith("PhysGrab", StringComparison.Ordinal) && !name.StartsWith("Item", StringComparison.Ordinal)) { if (type.Namespace == "BuckshotRoulette.Items") { return !name.StartsWith("Adrenaline", StringComparison.Ordinal); } return false; } return true; } private static FieldInfo CoroutineOwner(Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo field) => field.Name == "<>4__this" && typeof(Component).IsAssignableFrom(field.FieldType) && OwnClock(field.FieldType)); } private static bool ClockMethod(MethodBase method) { if (!method.IsStatic) { if (!typeof(Component).IsAssignableFrom(method.DeclaringType) || !OwnClock(method.DeclaringType)) { return CoroutineOwner(method.DeclaringType) != null; } return true; } return false; } private static bool TimeCall(MethodBase call) { if (call.DeclaringType == typeof(Time)) { if (!(call.Name == "get_deltaTime") && !(call.Name == "get_smoothDeltaTime") && !(call.Name == "get_fixedDeltaTime") && !(call.Name == "get_time")) { return call.Name == "get_timeAsDouble"; } return true; } return false; } private static IEnumerable<MethodBase> Calls(MethodBase method) { byte[] il = method.GetMethodBody()?.GetILAsByteArray(); if (il == null) { yield break; } int size; for (int i = 0; i < il.Length; i += size) { short num = il[i++]; if (num == 254) { num = (short)(0xFE00 | il[i++]); } OpCode opCode = OpCodesByValue[num]; switch (opCode.OperandType) { case OperandType.InlineNone: size = 0; break; case OperandType.ShortInlineBrTarget: case OperandType.ShortInlineI: case OperandType.ShortInlineVar: size = 1; break; case OperandType.InlineVar: size = 2; break; case OperandType.InlineI8: case OperandType.InlineR: size = 8; break; case OperandType.InlineSwitch: size = 4 + BitConverter.ToInt32(il, i) * 4; break; default: size = 4; break; } if (opCode.OperandType == OperandType.InlineMethod) { MethodBase methodBase = null; try { methodBase = method.Module.ResolveMethod(BitConverter.ToInt32(il, i), method.DeclaringType.GetGenericArguments(), method.GetGenericArguments()); } catch (ArgumentException) { } if (methodBase != null) { yield return methodBase; } } } } private static IEnumerable<MethodBase> TargetMethods() { Selected.Clear(); foreach (Assembly assembly in new Assembly[3] { typeof(PlayerController).Assembly, typeof(AdrenalinePatches).Assembly, typeof(PhotonTransformView).Assembly }.Distinct()) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.FullName.Contains("Adrenaline") || type.ContainsGenericParameters) { continue; } bool network = type == typeof(PhotonTransformView); if (assembly != typeof(PlayerController).Assembly && assembly != typeof(AdrenalinePatches).Assembly && !network) { continue; } MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!methodInfo.IsAbstract && !methodInfo.ContainsGenericParameters && methodInfo.GetMethodBody() != null) { bool clock = ClockMethod(methodInfo); if (Calls(methodInfo).Any((MethodBase call) => PhysicsCalls.ContainsKey(call) || ((clock || network) && (TimeCall(call) || call.DeclaringType == typeof(WaitForSeconds))))) { Selected.Add(methodInfo); yield return methodInfo; } } } } } Plugin.Log.LogInfo((object)$"Адреналин: подготовлена компенсация времени/физики для {Selected.Count} методов"); } private static IEnumerable<CodeInstruction> Owner(MethodBase method) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); if (!typeof(Component).IsAssignableFrom(method.DeclaringType)) { yield return new CodeInstruction(OpCodes.Ldfld, (object)CoroutineOwner(method.DeclaringType)); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod) { List<CodeInstruction> code = instructions.ToList(); bool clock = ClockMethod(__originalMethod); bool network = __originalMethod.DeclaringType == typeof(PhotonTransformView); for (int i = 0; i < code.Count; i++) { CodeInstruction val = code[i]; if (!(val.operand is MethodBase methodBase)) { yield return val; continue; } if (PhysicsCalls.TryGetValue(methodBase, out var value)) { if (network) { string text = ((methodBase.Name == "get_linearVelocity") ? "NetworkLinearVelocity" : ((methodBase.Name == "set_linearVelocity") ? "SetNetworkLinearVelocity" : ((methodBase.Name == "get_angularVelocity") ? "NetworkAngularVelocity" : ((methodBase.Name == "set_angularVelocity") ? "SetNetworkAngularVelocity" : null)))); if (text != null) { value = typeof(AdrenalinePhysics).GetMethod(text, BindingFlags.Static | BindingFlags.NonPublic); } } val.opcode = OpCodes.Call; val.operand = value; yield return val; continue; } if (network && TimeCall(methodBase) && (methodBase.Name == "get_time" || methodBase.Name == "get_deltaTime")) { val.opcode = OpCodes.Call; val.operand = typeof(AdrenalinePhysics).GetMethod((methodBase.Name == "get_time") ? "NetworkTime" : "NetworkDelta", BindingFlags.Static | BindingFlags.NonPublic); yield return val; continue; } string helper = null; if (clock && TimeCall(methodBase)) { helper = ((methodBase.Name == "get_deltaTime") ? "Delta" : ((methodBase.Name == "get_smoothDeltaTime") ? "SmoothDelta" : ((methodBase.Name == "get_fixedDeltaTime") ? "FixedDelta" : ((methodBase.Name == "get_time") ? "ClockFloat" : "ClockTime")))); } else if (clock && val.opcode == OpCodes.Newobj && methodBase.DeclaringType == typeof(WaitForSeconds) && i + 1 < code.Count && code[i + 1].opcode == OpCodes.Stfld && code[i + 1].operand is FieldInfo fieldInfo && fieldInfo.FieldType == typeof(object)) { helper = "Wait"; } if (helper == null) { yield return val; continue; } List<CodeInstruction> list = Owner(__originalMethod).ToList(); list[0] = new CodeInstruction(val) { opcode = list[0].opcode, operand = list[0].operand }; foreach (CodeInstruction item in list) { yield return item; } yield return new CodeInstruction(OpCodes.Call, (object)typeof(AdrenalineTime).GetMethod(helper, BindingFlags.Static | BindingFlags.NonPublic)); } } } internal static class AdrenalinePhysics { private sealed class Body { public float Factor = 1f; public float Drag; public float AngularDrag; public float MaxAngular; public bool ParametersApplied; } private static readonly Dictionary<Rigidbody, Body> Bodies = new Dictionary<Rigidbody, Body>(); private static readonly List<Rigidbody> Removed = new List<Rigidbody>(); internal static float Factor(Rigidbody rb) { //IL_0082: 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_0094: 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_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rb == (Object)null) { return 1f; } float num = ((AdrenalineTime.Active && AdrenalineTime.NormalBody(rb)) ? AdrenalineTime.Compensation : 1f); if (!Bodies.TryGetValue(rb, out var value)) { if (num == 1f) { return 1f; } value = new Body(); Bodies.Add(rb, value); } if (!Mathf.Approximately(value.Factor, num)) { RestoreParameters(rb, value); if (!rb.isKinematic) { float num2 = num / value.Factor; rb.linearVelocity *= num2; rb.angularVelocity *= num2; Vector3 accumulatedForce = rb.GetAccumulatedForce(); Vector3 accumulatedTorque = rb.GetAccumulatedTorque(); rb.AddForce(accumulatedForce * (num2 * num2 - 1f), (ForceMode)0); rb.AddTorque(accumulatedTorque * (num2 * num2 - 1f), (ForceMode)0); } value.Factor = num; } return num; } internal static void RestoreStepParameters() { foreach (KeyValuePair<Rigidbody, Body> body in Bodies) { if ((Object)(object)body.Key != (Object)null) { RestoreParameters(body.Key, body.Value); } } } private static void RestoreParameters(Rigidbody rb, Body body) { if (body.ParametersApplied) { if (Mathf.Approximately(rb.linearDamping, body.Drag * body.Factor)) { rb.linearDamping = body.Drag; } if (Mathf.Approximately(rb.angularDamping, body.AngularDrag * body.Factor)) { rb.angularDamping = body.AngularDrag; } if (Mathf.Approximately(rb.maxAngularVelocity, body.MaxAngular * body.Factor)) { rb.maxAngularVelocity = body.MaxAngular; } body.ParametersApplied = false; } } internal static void BeforeSimulation() { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) Removed.Clear(); foreach (KeyValuePair<Rigidbody, Body> body in Bodies) { if ((Object)(object)body.Key == (Object)null) { Removed.Add(body.Key); } } foreach (Rigidbody item in Removed) { Bodies.Remove(item); } foreach (KeyValuePair<Rigidbody, Body> body2 in Bodies) { Rigidbody key = body2.Key; Body value = body2.Value; float num = Factor(key); if (num != 1f && !key.isKinematic && !key.IsSleeping()) { value.Drag = key.linearDamping; value.AngularDrag = key.angularDamping; value.MaxAngular = key.maxAngularVelocity; key.linearDamping = value.Drag * num; key.angularDamping = value.AngularDrag * num; key.maxAngularVelocity = value.MaxAngular * num; value.ParametersApplied = true; if (key.useGravity) { key.AddForce(Physics.gravity * (num * num - 1f), (ForceMode)5); } } } } internal static void RestoreAll() { //IL_0055: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Rigidbody, Body> body in Bodies) { Rigidbody key = body.Key; Body value = body.Value; if (!((Object)(object)key == (Object)null)) { RestoreParameters(key, value); if (!key.isKinematic && value.Factor != 1f) { key.linearVelocity /= value.Factor; key.angularVelocity /= value.Factor; float num = 1f / (value.Factor * value.Factor); key.AddForce(key.GetAccumulatedForce() * (num - 1f), (ForceMode)0); key.AddTorque(key.GetAccumulatedTorque() * (num - 1f), (ForceMode)0); } } } Bodies.Clear(); } private static float ForceScale(Rigidbody rb, ForceMode mode) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 return AdrenalineWindow.ForceMultiplier(Factor(rb), (int)mode == 1 || (int)mode == 2); } internal static Vector3 GetLinearVelocity(Rigidbody rb) { //IL_0008: 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) float num = Factor(rb); return rb.linearVelocity / num; } internal static void SetLinearVelocity(Rigidbody rb, Vector3 value) { //IL_0001: 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) rb.linearVelocity = value * Factor(rb); } internal static Vector3 GetAngularVelocity(Rigidbody rb) { //IL_0008: 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) float num = Factor(rb); return rb.angularVelocity / num; } internal static void SetAngularVelocity(Rigidbody rb, Vector3 value) { //IL_0001: 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) rb.angularVelocity = value * Factor(rb); } internal static Vector3 GetPointVelocity(Rigidbody rb, Vector3 point) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) float num = Factor(rb); return rb.GetPointVelocity(point) / num; } internal static Vector3 GetRelativePointVelocity(Rigidbody rb, Vector3 point) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) float num = Factor(rb); return rb.GetRelativePointVelocity(point) / num; } internal static Vector3 NetworkLinearVelocity(Rigidbody rb) { //IL_0008: 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) Factor(rb); return rb.linearVelocity * Time.timeScale; } internal static Vector3 NetworkAngularVelocity(Rigidbody rb) { //IL_0008: 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) Factor(rb); return rb.angularVelocity * Time.timeScale; } internal static void SetNetworkLinearVelocity(Rigidbody rb, Vector3 value) { //IL_0008: 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) Factor(rb); rb.linearVelocity = value / Mathf.Max(Time.timeScale, 0.0001f); } internal static void SetNetworkAngularVelocity(Rigidbody rb, Vector3 value) { //IL_0008: 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) Factor(rb); rb.angularVelocity = value / Mathf.Max(Time.timeScale, 0.0001f); } internal static float NetworkTime() { return Time.unscaledTime; } internal static float NetworkDelta() { return Time.unscaledDeltaTime; } internal static void AddForce(Rigidbody rb, Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddForce(rb, value, (ForceMode)0); } internal static void AddForce(Rigidbody rb, Vector3 value, ForceMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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) rb.AddForce(value * ForceScale(rb, mode), mode); } internal static void AddRelativeForce(Rigidbody rb, Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddRelativeForce(rb, value, (ForceMode)0); } internal static void AddRelativeForce(Rigidbody rb, Vector3 value, ForceMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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) rb.AddRelativeForce(value * ForceScale(rb, mode), mode); } internal static void AddTorque(Rigidbody rb, Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddTorque(rb, value, (ForceMode)0); } internal static void AddTorque(Rigidbody rb, Vector3 value, ForceMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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) rb.AddTorque(value * ForceScale(rb, mode), mode); } internal static void AddRelativeTorque(Rigidbody rb, Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddRelativeTorque(rb, value, (ForceMode)0); } internal static void AddRelativeTorque(Rigidbody rb, Vector3 value, ForceMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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) rb.AddRelativeTorque(value * ForceScale(rb, mode), mode); } internal static void AddForceAtPosition(Rigidbody rb, Vector3 value, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddForceAtPosition(rb, value, point, (ForceMode)0); } internal static void AddForceAtPosition(Rigidbody rb, Vector3 value, Vector3 point, ForceMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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_000f: Unknown result type (might be due to invalid IL or missing references) rb.AddForceAtPosition(value * ForceScale(rb, mode), point, mode); } internal static void AddExplosionForce(Rigidbody rb, float force, Vector3 point, float radius) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddExplosionForce(rb, force, point, radius, 0f, (ForceMode)0); } internal static void AddExplosionForce(Rigidbody rb, float force, Vector3 point, float radius, float lift) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddExplosionForce(rb, force, point, radius, lift, (ForceMode)0); } internal static void AddExplosionForce(Rigidbody rb, float force, Vector3 point, float radius, float lift, ForceMode mode) { //IL_0003: 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_000f: Unknown result type (might be due to invalid IL or missing references) rb.AddExplosionForce(force * ForceScale(rb, mode), point, radius, lift, mode); } } [DefaultExecutionOrder(32000)] internal sealed class AdrenalinePhysicsStep : MonoBehaviour { private void FixedUpdate() { if (AdrenalineTime.Active) { AdrenalinePhysics.BeforeSimulation(); } } private void LateUpdate() { if ((Object)(object)AdrenalineTime.Instance != (Object)null) { AdrenalineTime.Instance.ApplyAnimations(); } } } [DefaultExecutionOrder(-32000)] internal sealed class AdrenalineTime : MonoBehaviourPunCallbacks { private sealed class Clock { public double Value; public double Scaled; public double Real; public bool Normal; } private sealed class LocalWait : CustomYieldInstruction { private float _remaining; private readonly Component _owner; public override bool keepWaiting { get { _remaining -= Delta(_owner); return _remaining > 0f; } } internal LocalWait(float seconds, Component owner) { _remaining = seconds; _owner = owner; } } private readonly AdrenalineWindow _window = new AdrenalineWindow(); private NetworkedEvent _snapshots; private NetworkedEvent _requests; private LevelGenerator _level; private string _token; private bool _ready; private bool _worldActive; private int _revision; private int _nonce; private float _nextRequest; private float _nextScan; private float _baseScale; private float _baseFixed; private float _appliedScale; private float _appliedFixed; private readonly Dictionary<Component, Clock> _clocks = new Dictionary<Component, Clock>(); private readonly Dictionary<Animator, float> _animation = new Dictionary<Animator, float>(); private Animator[] _animators = Array.Empty<Animator>(); private Rigidbody[] _bodies = Array.Empty<Rigidbody>(); internal static AdrenalineTime Instance { get; private set; } internal static bool Active { get { if ((Object)(object)Instance != (Object)null) { return Instance._worldActive; } return false; } } internal static float Compensation { get { if (!Active) { return 1f; } return 10f; } } private static double Now { get { if (!SemiFunc.IsMultiplayer()) { return Time.realtimeSinceStartupAsDouble; } return PhotonNetwork.Time; } } private static bool InLevel { get { if (SemiFunc.RunIsLevel() && (Object)(object)LevelGenerator.Instance != (Object)null) { return LevelGenerator.Instance.Generated; } return false; } } private static int PlayerId(PlayerAvatar player) { if (!SemiFunc.IsMultiplayer()) { return 1; } return player.photonView.ViewID; } internal static void Create(GameObject host) { host.AddComponent<AdrenalineTime>(); host.AddComponent<AdrenalinePhysicsStep>(); } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown Instance = this; _snapshots = new NetworkedEvent("BuckshotRoulette.Adrenaline.State", (Action<EventData>)OnSnapshot); _requests = new NetworkedEvent("BuckshotRoulette.Adrenaline.Request", (Action<EventData>)OnRequest); } private void Update() { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) RestoreAnimations(); foreach (KeyValuePair<Component, Clock> clock in _clocks) { AdvanceClock(clock.Key, clock.Value); } if ((Object)(object)_level != (Object)(object)LevelGenerator.Instance || !InLevel) { ResetEffect(); _level = LevelGenerator.Instance; if (!InLevel) { return; } } if (!_ready) { if (SemiFunc.IsMasterClientOrSingleplayer()) { _token = Guid.NewGuid().ToString("N"); _ready = true; Publish(); } else if (Time.unscaledTime >= _nextRequest) { _nextRequest = Time.unscaledTime + 1f; if (_nonce <= 0) { _nonce = 1; } _requests.RaiseEvent((object)_nonce, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } bool flag = _window.Expire(Now); if (SemiFunc.IsMasterClientOrSingleplayer()) { int[] players = _window.Players; foreach (int num in players) { PlayerAvatar val = ResolvePlayer(num); if ((Object)(object)val == (Object)null || val.deadSet || val.isDisabled) { flag |= _window.Remove(num); } } if (flag) { Publish(); } } ApplyWorld(_window.Count > 0); if (!_worldActive) { return; } if (Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + 0.2f; _bodies = Object.FindObjectsByType<Rigidbody>((FindObjectsSortMode)0); _animators = Object.FindObjectsByType<Animator>((FindObjectsSortMode)0); } Rigidbody[] bodies = _bodies; foreach (Rigidbody val2 in bodies) { if ((Object)(object)val2 != (Object)null && !val2.isKinematic) { AdrenalinePhysics.Factor(val2); } } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null && Beneficiary(instance)) { float num2 = (float)_window.Remaining(PlayerId(instance), Now); SemiFunc.UIItemInfoText((ItemAttributes)null, Texts.T($"Адреналин · {num2:F1} с", $"Adrenaline · {num2:F1}s")); } } private void FixedUpdate() { AdrenalinePhysics.RestoreStepParameters(); } internal void ApplyAnimations() { if (!_worldActive) { return; } Animator[] animators = _animators; foreach (Animator val in animators) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && NormalTime((Component)(object)val)) { float speed = val.speed; _animation[val] = speed; val.speed = speed * Compensation; } } } private void RestoreAnimations() { foreach (KeyValuePair<Animator, float> item in _animation) { if ((Object)(object)item.Key != (Object)null && Mathf.Approximately(item.Key.speed, item.Value * Compensation)) { item.Key.speed = item.Value; } } _animation.Clear(); } internal bool TryActivate(PlayerAvatar player) { if (!SemiFunc.IsMasterClientOrSingleplayer() || !_ready || !InLevel || (Object)(object)player == (Object)null || player.deadSet || player.isDisabled || !_window.TryStart(PlayerId(player), Now)) { return false; } Publish(); ApplyWorld(enabled: true); _nextScan = 0f; return true; } private static PlayerAvatar ResolvePlayer(int id) { if (!SemiFunc.IsMultiplayer()) { return PlayerAvatar.instance; } PhotonView obj = PhotonView.Find(id); if (obj == null) { return null; } return ((Component)obj).GetComponent<PlayerAvatar>(); } private bool Beneficiary(PlayerAvatar player) { if ((Object)(object)player != (Object)null) { return _window.Contains(PlayerId(player), Now); } return false; } internal static bool NormalTime(Component component) { if (!Active || (Object)(object)component == (Object)null) { return false; } PlayerController val = (PlayerController)(object)((component is PlayerController) ? component : null); if (val != null) { return Instance.Beneficiary(val.playerAvatarScript); } PhysGrabber val2 = (PhysGrabber)(object)((component is PhysGrabber) ? component : null); if (val2 != null) { return Instance.Beneficiary(val2.playerAvatar); } if (((object)component).GetType().Name.StartsWith("Camera", StringComparison.Ordinal)) { return Instance.Beneficiary(PlayerAvatar.instance); } PlayerAvatar componentInParent = component.GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent != (Object)null && Instance.Beneficiary(componentInParent)) { return true; } foreach (int playerId in Instance._window.PlayerIds) { PlayerAvatar val3 = ResolvePlayer(playerId); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.tumble != (Object)null && component.transform.IsChildOf(((Component)val3.tumble).transform)) { return true; } } PhysGrabObject componentInParent2 = component.GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent2 == (Object)null) { return false; } foreach (PhysGrabber item in componentInParent2.playerGrabbing) { if ((Object)(object)item != (Object)null && Instance.Beneficiary(item.playerAvatar)) { return true; } } return false; } internal static bool NormalBody(Rigidbody body) { if (!NormalTime((Component)(object)body)) { if ((Object)(object)PlayerController.instance != (Object)null && (Object)(object)PlayerController.instance.rb == (Object)(object)body) { return Instance.Beneficiary(PlayerAvatar.instance); } return false; } return true; } private void ApplyWorld(bool enabled) { if (enabled == _worldActive) { return; } foreach (KeyValuePair<Component, Clock> clock in _clocks) { AdvanceClock(clock.Key, clock.Value); } RestoreAnimations(); if (enabled) { _baseScale = Time.timeScale; _baseFixed = Time.fixedDeltaTime; _appliedScale = _baseScale * 0.1f; _appliedFixed = _baseFixed * 0.1f; Time.timeScale = _appliedScale; Time.fixedDeltaTime = _appliedFixed; _worldActive = true; } else { AdrenalinePhysics.RestoreAll(); if (Mathf.Approximately(Time.timeScale, _appliedScale)) { Time.timeScale = _baseScale; } if (Mathf.Approximately(Time.fixedDeltaTime, _appliedFixed)) { Time.fixedDeltaTime = _baseFixed; } _worldActive = false; } foreach (KeyValuePair<Component, Clock> clock2 in _clocks) { clock2.Value.Normal = NormalTime(clock2.Key); } } private void ResetEffect() { ApplyWorld(enabled: false); _window.Clear(); _ready = false; _token = null; _revision = 0; _nextRequest = 0f; _nonce = ((_nonce == int.MaxValue) ? 1 : (_nonce + 1)); _bodies = Array.Empty<Rigidbody>(); _animators = Array.Empty<Animator>(); Component[] array = _clocks.Keys.Where((Component owner) => (Object)(object)owner == (Object)null).ToArray(); foreach (Component key in array) { _clocks.Remove(key); } } private void Publish(int target = 0, int nonce = 0) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { if (target == 0) { _revision++; } _snapshots.RaiseEvent((object)new object[6] { _token, _revision, _window.Players, _window.Deadlines, target, nonce }, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } private void OnRequest(EventData data) { if (SemiFunc.IsMasterClientOrSingleplayer() && _ready && InLevel && data.CustomData is int num && num > 0 && PhotonNetwork.CurrentRoom.Players.ContainsKey(data.Sender)) { Publish(data.Sender, num); } } private void OnSnapshot(EventData data) { if (InLevel && !((Object)(object)_level != (Object)(object)LevelGenerator.Instance) && !SemiFunc.IsMasterClientOrSingleplayer() && PhotonNetwork.MasterClient != null && data.Sender == PhotonNetwork.MasterClient.ActorNumber && data.CustomData is object[] array && array.Length == 6 && array[0] is string text && !string.IsNullOrEmpty(text) && array[1] is int num && array[2] is int[] players && array[3] is double[] deadlines && array[4] is int num2 && array[5] is int num3 && (num2 == 0 || (num2 == PhotonNetwork.LocalPlayer.ActorNumber && num3 == _nonce)) && (_ready || nu