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 Predator Abilities v1.0.0
BepInEx/plugins/Sector208-PredatorAbilities.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 Sector208.PredatorAbilities { [BepInPlugin("Sector208.PredatorAbilities", "Predator Abilities", "0.1.0")] public class Plugin : BaseUnityPlugin { private enum RState { None, Ghost, White } private class PitchEntry { public float orig; public float set; } private ConfigEntry<Key> keyCamo; private ConfigEntry<Key> keyThermal; private ConfigEntry<float> sfxVolume; private ConfigEntry<float> blueTintAlpha; private ConfigEntry<float> thermalFarClip; private ConfigEntry<float> valuableRadius; private ConfigEntry<float> itemRadius; private ConfigEntry<float> loopEarlySeconds; private ConfigEntry<bool> ambientFx; private ConfigEntry<float> ambientFxStrength; private ConfigEntry<float> enemyVoicePitch; private ConfigEntry<bool> outlineOn; private ConfigEntry<float> outlineScale; private static readonly FieldInfo SteamIdField = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo NoVisionField = typeof(EnemyDirector).GetField("debugNoVision", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private bool camoOn; private bool thermalOn; private AudioSource sfxSource; private AudioSource loopSource; private AudioSource enableSource; private AudioClip camoOnClip; private AudioClip camoOffClip; private AudioClip thermalEnableClip; private AudioClip thermalLoopClip; private AudioClip thermalDisableClip; private Shader flatShader; private Material hotMat; private Material tintMat; private Material greenMat; private Material yellowMat; private Material cyanMat; private Material orangeMat; private const byte EventCamo = 150; private readonly Dictionary<int, bool> remoteCamo = new Dictionary<int, bool>(); private float nextBroadcast; private Material remoteGhostMat; private Material whiteMat; private float remotePulse; private float remoteTick; private readonly Dictionary<Renderer, Material[]> remoteOrig = new Dictionary<Renderer, Material[]>(); private readonly Dictionary<Renderer, RState> remoteState = new Dictionary<Renderer, RState>(); private const float CloakAnimTime = 0.7f; private Material ghostMat; private float cloakAnim; private readonly Dictionary<Renderer, Material[]> flashOriginals = new Dictionary<Renderer, Material[]>(); private readonly Dictionary<AudioSource, PitchEntry> pitches = new Dictionary<AudioSource, PitchEntry>(); private readonly Dictionary<Renderer, EnemyParent> outlineOwner = new Dictionary<Renderer, EnemyParent>(); private readonly Dictionary<Renderer, Mesh> outlineBake = new Dictionary<Renderer, Mesh>(); private readonly Dictionary<Renderer, Material[]> cartOriginals = new Dictionary<Renderer, Material[]>(); private readonly Dictionary<Renderer, Material[]> itemOriginals = new Dictionary<Renderer, Material[]>(); private readonly Dictionary<Renderer, Material[]> valuableOriginals = new Dictionary<Renderer, Material[]>(); private GameObject tintQuad; private readonly Dictionary<Renderer, Material[]> originals = new Dictionary<Renderer, Material[]>(); private float scanTimer; private Mesh glowDisc; private AudioLowPassFilter fxLow; private AudioChorusFilter fxChorus; private AudioEchoFilter fxEcho; private AudioDistortionFilter fxDist; private void Awake() { ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; keyCamo = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "Camouflage", (Key)40, "Клавиша маскировки"); keyThermal = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "Thermal", (Key)38, "Клавиша тепловизора"); sfxVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "Volume", 0.8f, "Громкость звуков 0..1"); blueTintAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Thermal", "TintPower", 0.75f, "Сила синего оттенка 0..1 (больше = синее)"); thermalFarClip = ((BaseUnityPlugin)this).Config.Bind<float>("Thermal", "EnemyViewDistance", 200f, "Дальность видимости мобов в тепловизоре (метры)"); valuableRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Thermal", "ValuableRadius", 12f, "Радиус подсветки ценных предметов зелёным (метры)"); loopEarlySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "LoopStartsEarlierBySeconds", 1f, "На сколько секунд раньше конца звука включения стартует loop"); ambientFx = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "AmbientDistortionEnabled", false, "Искажение звуков окружающей среды в тепловизоре (как у Хищника)"); ambientFxStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "AmbientFxPower", 0.9f, "Сила искажения звуков окружения 0..1"); enemyVoicePitch = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "EnemyVoicePitch", 0.55f, "Высота голоса мобов в тепловизоре (эффект гексафторида серы; меньше = ниже, 1 = без изменений)"); outlineOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Thermal", "EnemyGlow", true, "Мягкое оранжевое свечение вокруг мобов"); outlineScale = ((BaseUnityPlugin)this).Config.Bind<float>("Thermal", "EnemyGlowSize", 1.8f, "Размер свечения вокруг моба (1 = по размеру моба, 2.5 = большое облако)"); itemRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Thermal", "ItemRadius", 15f, "Радиус подсветки купленных вещей (мины, аптечки...) голубым (метры)"); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); camoOnClip = WavLoader.Load(Path.Combine(directoryName, "camouflage_on.wav"), ((BaseUnityPlugin)this).Logger); camoOffClip = WavLoader.Load(Path.Combine(directoryName, "camouflage_off.wav"), ((BaseUnityPlugin)this).Logger); thermalEnableClip = WavLoader.Load(Path.Combine(directoryName, "thermalVis_enable.wav"), ((BaseUnityPlugin)this).Logger); thermalLoopClip = WavLoader.Load(Path.Combine(directoryName, "thermalVis_loop.wav"), ((BaseUnityPlugin)this).Logger); thermalDisableClip = WavLoader.Load(Path.Combine(directoryName, "thermalVis_disable.wav"), ((BaseUnityPlugin)this).Logger); sfxSource = ((Component)this).gameObject.AddComponent<AudioSource>(); sfxSource.spatialBlend = 0f; sfxSource.playOnAwake = false; sfxSource.bypassListenerEffects = true; enableSource = ((Component)this).gameObject.AddComponent<AudioSource>(); enableSource.spatialBlend = 0f; enableSource.playOnAwake = false; enableSource.bypassListenerEffects = true; loopSource = ((Component)this).gameObject.AddComponent<AudioSource>(); loopSource.spatialBlend = 0f; loopSource.playOnAwake = false; loopSource.loop = true; loopSource.bypassListenerEffects = true; loopSource.clip = thermalLoopClip; try { PhotonNetwork.NetworkingClient.EventReceived += OnPhotonEvent; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Не удалось подписаться на сетевые события: " + ex.Message)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Predator Abilities загружен. Z = маскировка, X = тепловизор."); } private static bool InLevel() { try { return (Object)(object)RunManager.instance != (Object)null && SemiFunc.RunIsLevel() && (Object)(object)PlayerAvatar.instance != (Object)null; } catch { return false; } } private void Update() { //IL_004f: 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) Keyboard current = Keyboard.current; if (current == null) { return; } UpdateCloakVisual(); UpdateRemotePlayers(); if (!InLevel()) { if (camoOn) { SetCamouflage(on: false, silent: true); } if (thermalOn) { SetThermal(on: false, silent: true); } return; } if (SemiFunc.NoTextInputsActive()) { if (((ButtonControl)current[keyCamo.Value]).wasPressedThisFrame) { SetCamouflage(!camoOn, silent: false); } if (((ButtonControl)current[keyThermal.Value]).wasPressedThisFrame) { SetThermal(!thermalOn, silent: false); } } if (SemiFunc.IsMultiplayer()) { HostApplyRemoteCamo(); if (Time.unscaledTime >= nextBroadcast) { nextBroadcast = Time.unscaledTime + 2f; BroadcastCamo(announce: false); } } if (camoOn) { ApplyCamouflage(on: true); } if (!thermalOn) { return; } scanTimer -= Time.unscaledDeltaTime; if (scanTimer <= 0f) { scanTimer = 0.25f; ScanEnemies(); if (ambientFx.Value) { SetAmbientFx(on: true); } ScanValuables(); ScanCartsAndItems(); } UpdateTintQuad(); } private void SetCamouflage(bool on, bool silent) { if (camoOn != on) { camoOn = on; ApplyCamouflage(on); if (!silent) { PlaySfx(on ? camoOnClip : camoOffClip); cloakAnim = 0.7f; } if (silent) { cloakAnim = 0f; } BroadcastCamo(!silent); } } private void ApplyCamouflage(bool on) { if ((Object)(object)EnemyDirector.instance == (Object)null || (Object)(object)PlayerAvatar.instance == (Object)null || NoVisionField == null || SteamIdField == null || !(NoVisionField.GetValue(EnemyDirector.instance) is List<string> list)) { return; } string item = SteamIdField.GetValue(PlayerAvatar.instance) as string; if (on) { if (!list.Contains(item)) { list.Add(item); } } else { list.Remove(item); } } private void UpdateCloakVisual() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) FlashlightController instance = FlashlightController.Instance; bool num = (camoOn || cloakAnim > 0f) && (Object)(object)instance != (Object)null && InLevel(); if (cloakAnim > 0f) { cloakAnim = Mathf.Max(0f, cloakAnim - Time.unscaledDeltaTime); } if (!num) { RestoreFlashlight(); return; } if ((Object)(object)ghostMat == (Object)null) { if ((Object)(object)flatShader == (Object)null) { flatShader = Shader.Find("Hidden/Internal-Colored"); } ghostMat = MakeFlatMaterial(new Color(0.55f, 0.85f, 1f, 0.12f), 3000); ghostMat.SetInt("_ZTest", 4); } List<Renderer> list = new List<Renderer>(); foreach (KeyValuePair<Renderer, Material[]> flashOriginal in flashOriginals) { if ((Object)(object)flashOriginal.Key == (Object)null) { list.Add(flashOriginal.Key); } } foreach (Renderer item in list) { flashOriginals.Remove(item); } Renderer[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Renderer>(false); foreach (Renderer val in componentsInChildren) { if (!flashOriginals.ContainsKey(val) && !Skippable(val)) { Material[] sharedMaterials = val.sharedMaterials; flashOriginals[val] = sharedMaterials; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < array.Length; j++) { array[j] = ghostMat; } val.sharedMaterials = array; } } Color val2 = default(Color); ((Color)(ref val2))..ctor(0.1f, 0.95f, 1f, 0.95f); float num2 = 0.1f + 0.04f * Mathf.Sin(Time.unscaledTime * 5f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.55f, 0.85f, 1f, num2); if (cloakAnim > 0f) { float num3 = 1f - cloakAnim / 0.7f; ghostMat.color = (camoOn ? Color.Lerp(val2, val3, num3) : Color.Lerp(val3, val2, Mathf.Clamp01(num3 * 3f))); } else { ghostMat.color = val3; } } private void RestoreFlashlight() { if (flashOriginals.Count == 0) { return; } foreach (KeyValuePair<Renderer, Material[]> flashOriginal in flashOriginals) { if ((Object)(object)flashOriginal.Key != (Object)null) { flashOriginal.Key.sharedMaterials = flashOriginal.Value; } } flashOriginals.Clear(); } private void BroadcastCamo(bool announce) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001d: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) try { if (PhotonNetwork.InRoom && SemiFunc.IsMultiplayer()) { RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; PhotonNetwork.RaiseEvent((byte)150, (object)new object[2] { camoOn, announce }, val, SendOptions.SendReliable); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("BroadcastCamo: " + ex.Message)); } } private void OnPhotonEvent(EventData e) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) try { if (e.Code != 150 || !(e.CustomData is object[] array) || array.Length < 2) { return; } bool flag = (bool)array[0]; bool num = (bool)array[1]; int sender = e.Sender; remoteCamo.TryGetValue(sender, out var value); remoteCamo[sender] = flag; if (num && flag != value) { remotePulse = 0.7f; PlayerAvatar val = FindAvatar(sender); AudioClip val2 = (flag ? camoOnClip : camoOffClip); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { AudioSource.PlayClipAtPoint(val2, ((Component)val).transform.position, sfxVolume.Value); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("OnPhotonEvent: " + ex.Message)); } } private static PlayerAvatar FindAvatar(int actor) { if ((Object)(object)GameDirector.instance == (Object)null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && (Object)(object)player.photonView != (Object)null && player.photonView.OwnerActorNr == actor) { return player; } } return null; } private void HostApplyRemoteCamo() { if (!PhotonNetwork.IsMasterClient || (Object)(object)EnemyDirector.instance == (Object)null || NoVisionField == null || SteamIdField == null || !(NoVisionField.GetValue(EnemyDirector.instance) is List<string> list)) { return; } foreach (KeyValuePair<int, bool> item2 in remoteCamo) { PlayerAvatar val = FindAvatar(item2.Key); if ((Object)(object)val == (Object)null) { continue; } string item = SteamIdField.GetValue(val) as string; if (item2.Value) { if (!list.Contains(item)) { list.Add(item); } } else { list.Remove(item); } } } private void UpdateRemotePlayers() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) if (!InLevel() || !SemiFunc.IsMultiplayer() || !((Object)(object)GameDirector.instance != (Object)null)) { RestoreRemote(); return; } if (remotePulse > 0f) { remotePulse = Mathf.Max(0f, remotePulse - Time.unscaledDeltaTime); } if ((Object)(object)remoteGhostMat != (Object)null) { Color val = default(Color); ((Color)(ref val))..ctor(0.1f, 0.95f, 1f, 0.95f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.55f, 0.85f, 1f, 0.1f + 0.04f * Mathf.Sin(Time.unscaledTime * 5f)); remoteGhostMat.color = ((remotePulse > 0f) ? Color.Lerp(val2, val, remotePulse / 0.7f) : val2); } remoteTick -= Time.unscaledDeltaTime; if (remoteTick > 0f) { return; } remoteTick = 0.2f; if ((Object)(object)flatShader == (Object)null) { flatShader = Shader.Find("Hidden/Internal-Colored"); } if ((Object)(object)remoteGhostMat == (Object)null) { remoteGhostMat = MakeFlatMaterial(new Color(0.55f, 0.85f, 1f, 0.12f), 3000); remoteGhostMat.SetInt("_ZTest", 4); } if ((Object)(object)whiteMat == (Object)null) { whiteMat = MakeFlatMaterial(new Color(1f, 1f, 1f, 1f), 4000); } List<Renderer> list = new List<Renderer>(); foreach (KeyValuePair<Renderer, Material[]> item in remoteOrig) { if ((Object)(object)item.Key == (Object)null) { list.Add(item.Key); } } foreach (Renderer item2 in list) { remoteOrig.Remove(item2); remoteState.Remove(item2); } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null || (Object)(object)player == (Object)(object)PlayerAvatar.instance) { continue; } bool value = false; if ((Object)(object)player.photonView != (Object)null) { remoteCamo.TryGetValue(player.photonView.OwnerActorNr, out value); } RState want = (thermalOn ? RState.White : (value ? RState.Ghost : RState.None)); if ((Object)(object)player.playerAvatarVisuals != (Object)null) { Renderer[] componentsInChildren = ((Component)player.playerAvatarVisuals).GetComponentsInChildren<Renderer>(false); foreach (Renderer r in componentsInChildren) { ApplyRemote(r, want); } } if ((Object)(object)player.flashlightController != (Object)null) { Renderer[] componentsInChildren = ((Component)player.flashlightController).GetComponentsInChildren<Renderer>(false); foreach (Renderer r2 in componentsInChildren) { ApplyRemote(r2, want); } } } } private void ApplyRemote(Renderer r, RState want) { remoteState.TryGetValue(r, out var value); if (value == want) { return; } if (want == RState.None) { if (remoteOrig.TryGetValue(r, out var value2)) { r.sharedMaterials = value2; remoteOrig.Remove(r); } remoteState.Remove(r); } else if (!Skippable(r)) { if (!remoteOrig.ContainsKey(r)) { remoteOrig[r] = r.sharedMaterials; } Material val = ((want == RState.White) ? whiteMat : remoteGhostMat); Material[] array = (Material[])(object)new Material[remoteOrig[r].Length]; for (int i = 0; i < array.Length; i++) { array[i] = val; } r.sharedMaterials = array; remoteState[r] = want; } } private void RestoreRemote() { if (remoteOrig.Count == 0 && remoteState.Count == 0) { return; } foreach (KeyValuePair<Renderer, Material[]> item in remoteOrig) { if ((Object)(object)item.Key != (Object)null) { item.Key.sharedMaterials = item.Value; } } remoteOrig.Clear(); remoteState.Clear(); } private void SetThermal(bool on, bool silent) { if (thermalOn == on) { return; } thermalOn = on; if (on) { EnsureMaterials(); SetAmbientFx(on: true); scanTimer = 0f; double num = AudioSettings.dspTime + 0.1; double num2 = num; if (!silent && (Object)(object)thermalEnableClip != (Object)null) { enableSource.clip = thermalEnableClip; enableSource.volume = sfxVolume.Value; enableSource.PlayScheduled(num); num2 = num + (double)thermalEnableClip.samples / (double)thermalEnableClip.frequency - (double)loopEarlySeconds.Value; if (num2 < num) { num2 = num; } } if ((Object)(object)thermalLoopClip != (Object)null) { loopSource.volume = sfxVolume.Value; loopSource.PlayScheduled(num2); } } else { loopSource.Stop(); enableSource.Stop(); SetAmbientFx(on: false); RestoreEnemies(); if ((Object)(object)tintQuad != (Object)null) { tintQuad.SetActive(false); } if (!silent) { PlaySfx(thermalDisableClip); } } } private void EnsureMaterials() { //IL_0063: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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) if (!((Object)(object)hotMat != (Object)null)) { flatShader = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)flatShader == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Hidden/Internal-Colored не найден, пробую Sprites/Default (сквозь стены может не работать)"); flatShader = Shader.Find("Sprites/Default"); } hotMat = MakeFlatMaterial(new Color(1f, 0.12f, 0.05f, 1f), 4000); greenMat = MakeFlatMaterial(new Color(0.1f, 1f, 0.2f, 1f), 4000); yellowMat = MakeFlatMaterial(new Color(1f, 0.85f, 0.05f, 1f), 4000); orangeMat = MakeFlatMaterial(new Color(1f, 0.5f, 0.05f, 0.09f), 3995); cyanMat = MakeFlatMaterial(new Color(0.35f, 0.9f, 1f, 1f), 4000); tintMat = MakeFlatMaterial(new Color(0.02f, 0.12f, 1f, blueTintAlpha.Value), 3990); } } private Material MakeFlatMaterial(Color c, int queue) { //IL_0006: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown Material val = new Material(flatShader) { hideFlags = (HideFlags)61, color = c }; val.SetInt("_SrcBlend", 5); val.SetInt("_DstBlend", 10); val.SetInt("_Cull", 0); val.SetInt("_ZWrite", 0); val.SetInt("_ZTest", 8); val.renderQueue = queue; return val; } private void ScanEnemies() { List<Renderer> list = new List<Renderer>(); foreach (KeyValuePair<Renderer, Material[]> original in originals) { if ((Object)(object)original.Key == (Object)null) { list.Add(original.Key); } } foreach (Renderer item in list) { originals.Remove(item); outlineOwner.Remove(item); outlineBake.Remove(item); } List<AudioSource> list2 = new List<AudioSource>(); foreach (KeyValuePair<AudioSource, PitchEntry> pitch in pitches) { if ((Object)(object)pitch.Key == (Object)null) { list2.Add(pitch.Key); } } foreach (AudioSource item2 in list2) { pitches.Remove(item2); } if ((Object)(object)EnemyDirector.instance == (Object)null) { return; } foreach (EnemyParent item3 in EnemyDirector.instance.enemiesSpawned) { if ((Object)(object)item3 == (Object)null) { continue; } AudioSource[] componentsInChildren = ((Component)item3).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !pitches.ContainsKey(val)) { pitches[val] = new PitchEntry { orig = val.pitch, set = val.pitch }; } } Renderer[] componentsInChildren2 = ((Component)item3).GetComponentsInChildren<Renderer>(false); foreach (Renderer val2 in componentsInChildren2) { if ((val2 is MeshRenderer || val2 is SkinnedMeshRenderer) && !originals.ContainsKey(val2)) { Material[] sharedMaterials = val2.sharedMaterials; originals[val2] = sharedMaterials; outlineOwner[val2] = item3; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < array.Length; j++) { array[j] = hotMat; } val2.sharedMaterials = array; val2.shadowCastingMode = (ShadowCastingMode)0; } } } } private void RestoreEnemies() { foreach (KeyValuePair<Renderer, Material[]> original in originals) { if ((Object)(object)original.Key != (Object)null) { original.Key.sharedMaterials = original.Value; } } originals.Clear(); outlineOwner.Clear(); foreach (KeyValuePair<Renderer, Mesh> item in outlineBake) { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } outlineBake.Clear(); foreach (KeyValuePair<AudioSource, PitchEntry> pitch in pitches) { if ((Object)(object)pitch.Key != (Object)null && Mathf.Approximately(pitch.Key.pitch, pitch.Value.set)) { pitch.Key.pitch = pitch.Value.orig; } } pitches.Clear(); foreach (KeyValuePair<Renderer, Material[]> valuableOriginal in valuableOriginals) { if ((Object)(object)valuableOriginal.Key != (Object)null) { valuableOriginal.Key.sharedMaterials = valuableOriginal.Value; } } valuableOriginals.Clear(); foreach (KeyValuePair<Renderer, Material[]> cartOriginal in cartOriginals) { if ((Object)(object)cartOriginal.Key != (Object)null) { cartOriginal.Key.sharedMaterials = cartOriginal.Value; } } cartOriginals.Clear(); foreach (KeyValuePair<Renderer, Material[]> itemOriginal in itemOriginals) { if ((Object)(object)itemOriginal.Key != (Object)null) { itemOriginal.Key.sharedMaterials = itemOriginal.Value; } } itemOriginals.Clear(); } private static bool Skippable(Renderer r) { if (!(r is MeshRenderer) && !(r is SkinnedMeshRenderer)) { return true; } Material[] sharedMaterials = r.sharedMaterials; foreach (Material val in sharedMaterials) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null)) { string name = ((Object)val.shader).name; if (name.Contains("TextMeshPro") || name.Contains("Particle") || name.StartsWith("UI/") || name.Contains("Sprites")) { return true; } } } return false; } private static void Paint(GameObject go, Material mat, Dictionary<Renderer, Material[]> store) { Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(false); foreach (Renderer val in componentsInChildren) { if (!store.ContainsKey(val) && !Skippable(val)) { Material[] array = (store[val] = val.sharedMaterials); Material[] array2 = (Material[])(object)new Material[array.Length]; for (int j = 0; j < array2.Length; j++) { array2[j] = mat; } val.sharedMaterials = array2; } } } private void ScanCartsAndItems() { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = new List<Renderer>(); foreach (KeyValuePair<Renderer, Material[]> cartOriginal in cartOriginals) { if ((Object)(object)cartOriginal.Key == (Object)null) { list.Add(cartOriginal.Key); } } foreach (KeyValuePair<Renderer, Material[]> itemOriginal in itemOriginals) { if ((Object)(object)itemOriginal.Key == (Object)null) { list.Add(itemOriginal.Key); } } foreach (Renderer item in list) { cartOriginals.Remove(item); itemOriginals.Remove(item); } PhysGrabCart[] array = Object.FindObjectsByType<PhysGrabCart>((FindObjectsSortMode)0); foreach (PhysGrabCart val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { Paint(((Component)val).gameObject, yellowMat, cartOriginals); } } if ((Object)(object)PlayerAvatar.instance == (Object)null) { return; } Vector3 position = ((Component)PlayerAvatar.instance).transform.position; float value = itemRadius.Value; float num = value * 1.15f; List<Renderer> list2 = new List<Renderer>(); Vector3 val2; foreach (KeyValuePair<Renderer, Material[]> itemOriginal2 in itemOriginals) { val2 = ((Component)itemOriginal2.Key).transform.position - position; if (((Vector3)(ref val2)).magnitude > num) { list2.Add(itemOriginal2.Key); } } foreach (Renderer item2 in list2) { item2.sharedMaterials = itemOriginals[item2]; itemOriginals.Remove(item2); } ItemAttributes[] array2 = Object.FindObjectsByType<ItemAttributes>((FindObjectsSortMode)0); foreach (ItemAttributes val3 in array2) { if (!((Object)(object)val3 == (Object)null) && ((Component)val3).gameObject.activeInHierarchy && !((Object)(object)((Component)val3).GetComponentInParent<PhysGrabCart>() != (Object)null)) { val2 = ((Component)val3).transform.position - position; if (!(((Vector3)(ref val2)).magnitude > value)) { Paint(((Component)val3).gameObject, cyanMat, itemOriginals); } } } } private void ScanValuables() { //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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = new List<Renderer>(); foreach (KeyValuePair<Renderer, Material[]> valuableOriginal in valuableOriginals) { if ((Object)(object)valuableOriginal.Key == (Object)null) { list.Add(valuableOriginal.Key); } } foreach (Renderer item in list) { valuableOriginals.Remove(item); } if ((Object)(object)PlayerAvatar.instance == (Object)null) { return; } Vector3 position = ((Component)PlayerAvatar.instance).transform.position; float value = valuableRadius.Value; float num = value * 1.15f; List<Renderer> list2 = new List<Renderer>(); Vector3 val; foreach (KeyValuePair<Renderer, Material[]> valuableOriginal2 in valuableOriginals) { val = ((Component)valuableOriginal2.Key).transform.position - position; if (((Vector3)(ref val)).magnitude > num) { list2.Add(valuableOriginal2.Key); } } foreach (Renderer item2 in list2) { item2.sharedMaterials = valuableOriginals[item2]; valuableOriginals.Remove(item2); } ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); foreach (ValuableObject val2 in array) { if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy) { continue; } val = ((Component)val2).transform.position - position; if (((Vector3)(ref val)).magnitude > value) { continue; } Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(false); foreach (Renderer val3 in componentsInChildren) { if ((val3 is MeshRenderer || val3 is SkinnedMeshRenderer) && !valuableOriginals.ContainsKey(val3)) { Material[] sharedMaterials = val3.sharedMaterials; valuableOriginals[val3] = sharedMaterials; Material[] array2 = (Material[])(object)new Material[sharedMaterials.Length]; for (int k = 0; k < array2.Length; k++) { array2[k] = greenMat; } val3.sharedMaterials = array2; } } } } private void LateUpdate() { if (!thermalOn) { return; } Camera val = (((Object)(object)CameraUtils.Instance != (Object)null) ? CameraUtils.Instance.MainCamera : Camera.main); if ((Object)(object)val != (Object)null && val.farClipPlane < thermalFarClip.Value) { val.farClipPlane = thermalFarClip.Value; } float num = Mathf.Clamp(enemyVoicePitch.Value, 0.2f, 1f); foreach (KeyValuePair<AudioSource, PitchEntry> pitch in pitches) { AudioSource key = pitch.Key; if (!((Object)(object)key == (Object)null)) { PitchEntry value = pitch.Value; if (!Mathf.Approximately(key.pitch, value.set)) { value.orig = key.pitch; } value.set = value.orig * num; key.pitch = value.set; } } } private Mesh GetGlowDisc() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if ((Object)(object)glowDisc != (Object)null) { return glowDisc; } Vector3[] array = (Vector3[])(object)new Vector3[33]; int[] array2 = new int[96]; array[0] = Vector3.zero; for (int i = 0; i < 32; i++) { float num = (float)i / 32f * MathF.PI * 2f; array[i + 1] = new Vector3(Mathf.Cos(num), Mathf.Sin(num), 0f); array2[i * 3] = 0; array2[i * 3 + 1] = i + 1; array2[i * 3 + 2] = (i + 1) % 32 + 1; } glowDisc = new Mesh(); ((Object)glowDisc).hideFlags = (HideFlags)61; glowDisc.vertices = array; glowDisc.triangles = array2; return glowDisc; } private void DrawOutlines(Camera cam) { //IL_00d0: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { return; } Dictionary<EnemyParent, Bounds> dictionary = new Dictionary<EnemyParent, Bounds>(); foreach (KeyValuePair<Renderer, EnemyParent> item in outlineOwner) { Renderer key = item.Key; if (!((Object)(object)key == (Object)null) && !((Object)(object)item.Value == (Object)null) && key.enabled && ((Component)key).gameObject.activeInHierarchy) { if (dictionary.TryGetValue(item.Value, out var value)) { ((Bounds)(ref value)).Encapsulate(key.bounds); dictionary[item.Value] = value; } else { dictionary[item.Value] = key.bounds; } } } Mesh val = GetGlowDisc(); Quaternion rotation = ((Component)cam).transform.rotation; foreach (KeyValuePair<EnemyParent, Bounds> item2 in dictionary) { Bounds value2 = item2.Value; Vector3 val2 = ((Bounds)(ref value2)).center - ((Component)cam).transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 22500f)) { float num = Mathf.Max(new float[3] { ((Bounds)(ref value2)).extents.x, ((Bounds)(ref value2)).extents.y, ((Bounds)(ref value2)).extents.z }) * Mathf.Max(0.5f, outlineScale.Value); for (int i = 0; i < 14; i++) { float num2 = (float)(i + 1) / 14f; float num3 = num * (1.05f - num2 * 0.95f); Matrix4x4 val3 = Matrix4x4.TRS(((Bounds)(ref value2)).center, rotation, new Vector3(num3, num3, 1f)); Graphics.DrawMesh(val, val3, orangeMat, 0, (Camera)null, 0, (MaterialPropertyBlock)null, false, false); } } } } private void UpdateTintQuad() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) Camera val = (((Object)(object)CameraUtils.Instance != (Object)null) ? CameraUtils.Instance.MainCamera : Camera.main); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)tintQuad == (Object)null) { tintQuad = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)tintQuad).name = "PredatorThermalTint"; Collider component = tintQuad.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } ((Object)tintQuad).hideFlags = (HideFlags)61; tintQuad.GetComponent<Renderer>().sharedMaterial = tintMat; tintQuad.GetComponent<Renderer>().shadowCastingMode = (ShadowCastingMode)0; } tintQuad.SetActive(true); tintMat.color = new Color(0.02f, 0.12f, 1f, Mathf.Clamp01(blueTintAlpha.Value)); float num = val.nearClipPlane + 0.05f; float num2 = 2f * num * Mathf.Tan(val.fieldOfView * 0.5f * (MathF.PI / 180f)); float num3 = num2 * val.aspect; Transform transform = tintQuad.transform; transform.SetParent(((Component)val).transform, false); transform.localPosition = new Vector3(0f, 0f, num); transform.localRotation = Quaternion.identity; transform.localScale = new Vector3(num3 * 1.3f, num2 * 1.3f, 1f); } private void SetAmbientFx(bool on) { on = on && ambientFx.Value; if (on && (Object)(object)fxLow == (Object)null) { AudioListener val = Object.FindFirstObjectByType<AudioListener>(); if ((Object)(object)val == (Object)null) { return; } GameObject gameObject = ((Component)val).gameObject; fxLow = gameObject.AddComponent<AudioLowPassFilter>(); fxChorus = gameObject.AddComponent<AudioChorusFilter>(); fxEcho = gameObject.AddComponent<AudioEchoFilter>(); fxDist = gameObject.AddComponent<AudioDistortionFilter>(); } if (!((Object)(object)fxLow == (Object)null)) { float num = Mathf.Clamp01(ambientFxStrength.Value); fxLow.cutoffFrequency = Mathf.Lerp(22000f, 1100f, num); fxLow.lowpassResonanceQ = 1f + 3.5f * num; fxChorus.dryMix = 0.6f; fxChorus.wetMix1 = 0.8f * num; fxChorus.wetMix2 = 0.6f * num; fxChorus.wetMix3 = 0f; fxChorus.delay = 25f; fxChorus.rate = 0.8f; fxChorus.depth = 0.9f * num; fxEcho.delay = 70f; fxEcho.decayRatio = 0.55f * num; fxEcho.wetMix = 0.55f * num; fxEcho.dryMix = 1f; fxDist.distortionLevel = 0.6f * num; ((Behaviour)fxLow).enabled = on; ((Behaviour)fxChorus).enabled = on; ((Behaviour)fxEcho).enabled = on; ((Behaviour)fxDist).enabled = on; } } private void PlaySfx(AudioClip clip) { if (!((Object)(object)clip == (Object)null)) { sfxSource.PlayOneShot(clip, sfxVolume.Value); } } private void OnDestroy() { RestoreFlashlight(); RestoreRemote(); try { PhotonNetwork.NetworkingClient.EventReceived -= OnPhotonEvent; } catch { } RestoreEnemies(); if ((Object)(object)tintQuad != (Object)null) { Object.Destroy((Object)(object)tintQuad); } } } internal static class WavLoader { public static AudioClip Load(string path, ManualLogSource log) { try { if (!File.Exists(path)) { log.LogWarning((object)("Нет файла звука: " + path)); return null; } byte[] array = File.ReadAllBytes(path); if (array.Length < 44 || array[0] != 82 || array[1] != 73 || array[2] != 70 || array[3] != 70) { log.LogWarning((object)("Не WAV: " + path)); return null; } int num = 12; int num2 = 1; int num3 = 1; int num4 = 44100; int num5 = 16; int num6 = -1; int num7 = 0; while (num + 8 <= array.Length) { char c = (char)array[num]; string text = c.ToString(); c = (char)array[num + 1]; string text2 = c.ToString(); c = (char)array[num + 2]; string text3 = c.ToString(); c = (char)array[num + 3]; string text4 = text + text2 + text3 + c; int num8 = BitConverter.ToInt32(array, num + 4); int num9 = num + 8; if (text4 == "fmt ") { num2 = BitConverter.ToUInt16(array, num9); num3 = BitConverter.ToUInt16(array, num9 + 2); num4 = BitConverter.ToInt32(array, num9 + 4); num5 = BitConverter.ToUInt16(array, num9 + 14); if (num2 == 65534 && num8 >= 26) { num2 = BitConverter.ToUInt16(array, num9 + 24); } } else if (text4 == "data") { num6 = num9; num7 = Math.Min(num8, array.Length - num9); break; } num = num9 + num8 + (num8 & 1); } if (num6 < 0) { log.LogWarning((object)("Нет data в " + path)); return null; } int num10 = num5 / 8; int num11 = num7 / num10; float[] array2 = new float[num11]; for (int i = 0; i < num11; i++) { int num12 = num6 + i * num10; if (num2 == 3 && num5 == 32) { array2[i] = BitConverter.ToSingle(array, num12); continue; } switch (num5) { case 8: array2[i] = (float)(array[num12] - 128) / 128f; break; case 16: array2[i] = (float)BitConverter.ToInt16(array, num12) / 32768f; break; case 24: array2[i] = (float)(((array[num12 + 2] << 24) | (array[num12 + 1] << 16) | (array[num12] << 8)) >> 8) / 8388608f; break; case 32: array2[i] = (float)BitConverter.ToInt32(array, num12) / 2.1474836E+09f; break; } } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num11 / num3, num3, num4, false); obj.SetData(array2, 0); return obj; } catch (Exception ex) { log.LogError((object)("Ошибка чтения " + path + ": " + ex.Message)); return null; } } } }