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 RealCompany Atmosphere v1.0.0
RealisticBloomAndFlares.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RealisticBloomAndFlares")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RealisticBloomAndFlares")] [assembly: AssemblyTitle("RealisticBloomAndFlares")] [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 RealisticBloomAndFlares { [BepInPlugin("com.mavka.RealisticBloomAndFlares", "RealisticBloomAndFlares", "3.1.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("com.mavka.RealisticBloomAndFlares"); val.PatchAll(typeof(AtmosphereAndFX)); val.PatchAll(typeof(RagdollManager)); val.PatchAll(typeof(TerminalLiveScreen)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"RealisticBloomAndFlares (v3.1.0 Live Terminal Screen) загружен!"); } } public class AtmosphereAndFX { private static Volume vol; private static Exposure exp; private static IndirectLightingController indirect; private static GameObject sunHalo; private static Material sunHaloMat; private static GameObject sunStreak; private static Material sunStreakMat; private static GameObject spotStreak; private static Material spotStreakMat; private static Renderer skySun; private static Light mainDirLight; private static readonly List<Light> ShipSpotLights = new List<Light>(); private static float origDirIntensity = 1f; private static Color origDirColor = Color.white; private static bool sceneScanned; private static float nextScanTick; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] private static void OnSceneChanged() { skySun = null; mainDirLight = null; ShipSpotLights.Clear(); sceneScanned = false; nextScanTick = Time.time + 1f; } private static GameObject CreateBillboard(string name, int w, int h, bool horizontalStreak, Color hdrColor, int queue, out Material outMat) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = name; Object.DontDestroyOnLoad((Object)(object)val); Object.Destroy((Object)(object)val.GetComponent<Collider>()); Texture2D val2 = new Texture2D(w, h, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; float num = (float)(w - 1) * 0.5f; float num2 = (float)(h - 1) * 0.5f; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { float num3 = Mathf.Abs((float)j - num) / num; float num4 = Mathf.Abs((float)i - num2) / num2; float num5; if (horizontalStreak) { num5 = ((!(num3 >= 0.96f) && !(num4 >= 0.92f)) ? (Mathf.Pow(1f - num3, 3.2f) * Mathf.Pow(1f - num4, 4.5f) * 0.65f) : 0f); } else { float num6 = Mathf.Sqrt(num3 * num3 + num4 * num4); if (num6 >= 0.96f) { num5 = 0f; } else { float num7 = num6 / 0.96f; num5 = Mathf.Clamp01(Mathf.Pow(1f - num7, 4.5f) * 0.78f + Mathf.Clamp01((0.34f - num7) * 8f)); } } val2.SetPixel(j, i, (Color)((num5 <= 0.001f) ? Color.clear : new Color(num5, num5, num5, num5))); } } val2.Apply(); outMat = new Material(Shader.Find("HDRP/Unlit")); outMat.SetTexture("_UnlitColorMap", (Texture)(object)val2); outMat.SetColor("_UnlitColor", hdrColor); outMat.SetFloat("_SurfaceType", 1f); outMat.SetFloat("_BlendMode", 1f); HDMaterial.ValidateMaterial(outMat); outMat.renderQueue = queue; MeshRenderer component = val.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = outMat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; val.SetActive(false); return val; } private static void SetupOnce() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vol == (Object)null) { GameObject val = new GameObject("Mavka_PostFX"); Object.DontDestroyOnLoad((Object)(object)val); vol = val.AddComponent<Volume>(); vol.isGlobal = true; vol.priority = 999f; VolumeProfile val2 = ScriptableObject.CreateInstance<VolumeProfile>(); vol.sharedProfile = val2; Bloom val3 = val2.Add<Bloom>(true); ((VolumeParameter<float>)(object)val3.threshold).Override(1.28f); ((VolumeParameter<float>)(object)val3.intensity).Override(0.26f); ((VolumeParameter<float>)(object)val3.scatter).Override(0.62f); ((VolumeParameter<Color>)(object)val3.tint).Override(new Color(1f, 0.96f, 0.9f, 1f)); val3.highQualityFiltering = true; exp = val2.Add<Exposure>(true); ((VolumeParameter<ExposureMode>)(object)exp.mode).Override((ExposureMode)1); ((VolumeParameter<float>)(object)exp.limitMin).Override(0.35f); ((VolumeParameter<float>)(object)exp.limitMax).Override(2.15f); ((VolumeParameter<AdaptationMode>)(object)exp.adaptationMode).Override((AdaptationMode)1); ((VolumeParameter<float>)(object)exp.adaptationSpeedDarkToLight).Override(1.65f); ((VolumeParameter<float>)(object)exp.adaptationSpeedLightToDark).Override(0.65f); indirect = val2.Add<IndirectLightingController>(true); } if ((Object)(object)sunHalo == (Object)null) { sunHalo = CreateBillboard("Mavka_SunHalo", 128, 128, horizontalStreak: false, new Color(5.2f, 4.1f, 2f, 1f), 3100, out sunHaloMat); } if ((Object)(object)sunStreak == (Object)null) { sunStreak = CreateBillboard("Mavka_SunGlareStreak", 64, 16, horizontalStreak: true, new Color(2.4f, 1.9f, 1.1f, 1f), 3101, out sunStreakMat); } if ((Object)(object)spotStreak == (Object)null) { spotStreak = CreateBillboard("Mavka_SpotGlareStreak", 64, 16, horizontalStreak: true, new Color(2.2f, 2.3f, 2.6f, 1f), 3102, out spotStreakMat); } } [HarmonyPatch(typeof(FlashlightItem), "SwitchFlashlight")] [HarmonyPostfix] private static void OnFlashlightSwitch(FlashlightItem __instance) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null)) { Color color = default(Color); ((Color)(ref color))..ctor(1f, 0.94f, 0.84f, 1f); if ((Object)(object)__instance.flashlightBulb != (Object)null) { __instance.flashlightBulb.color = color; } if ((Object)(object)__instance.flashlightBulbGlow != (Object)null) { __instance.flashlightBulbGlow.color = color; } } } private static bool IsWetWeather() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 LevelWeatherType val = (LevelWeatherType)((!((Object)(object)TimeOfDay.Instance != (Object)null)) ? (-1) : ((int)TimeOfDay.Instance.currentLevelWeather)); if ((int)val == -1 && (Object)(object)StartOfRound.Instance?.currentLevel != (Object)null) { val = StartOfRound.Instance.currentLevel.currentWeather; } return (int)val == 1 || (int)val == 2 || (int)val == 4; } private static void ScanSceneOnce() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (sceneScanned) { return; } sceneScanned = true; float num = 0f; ShipSpotLights.Clear(); Light[] array = Object.FindObjectsOfType<Light>(); foreach (Light val in array) { if (!((Object)(object)val == (Object)null)) { if ((int)val.type == 1 && val.intensity > num) { num = val.intensity; mainDirLight = val; origDirIntensity = val.intensity; origDirColor = val.color; } else if ((int)val.type == 0 && val.range >= 18f && val.intensity >= 80f) { ShipSpotLights.Add(val); } } } bool flag = IsWetWeather(); HashSet<int> hashSet = (flag ? new HashSet<int>() : null); Renderer[] array2 = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val2 in array2) { if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)(object)sunHalo || (Object)(object)((Component)val2).gameObject == (Object)(object)sunStreak || (Object)(object)((Component)val2).gameObject == (Object)(object)spotStreak) { continue; } if ((Object)(object)skySun == (Object)null && ((Object)((Component)val2).gameObject).name.ToLower().Contains("sun")) { skySun = val2; } if (!flag || val2.sharedMaterials == null) { continue; } Material[] sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if (!((Object)(object)val3 == (Object)null) && hashSet.Add(((Object)val3).GetInstanceID()) && val3.HasProperty("_Smoothness") && !((Object)val3).name.ToLower().Contains("sky") && !((Object)val3).name.ToLower().Contains("fog")) { float num2 = val3.GetFloat("_Smoothness"); if (num2 < 0.72f) { val3.SetFloat("_Smoothness", Mathf.Clamp(num2 + 0.24f, 0.46f, 0.76f)); } } } } Volume[] array3 = Object.FindObjectsOfType<Volume>(); Fog val6 = default(Fog); foreach (Volume val4 in array3) { VolumeProfile val5 = (((Object)(object)val4 != (Object)null && (Object)(object)val4 != (Object)(object)vol) ? (val4.sharedProfile ?? val4.profile) : null); if ((Object)(object)val5 != (Object)null && val5.TryGet<Fog>(ref val6) && ((VolumeComponent)val6).active && ((VolumeParameter)val6.meanFreePath).overrideState) { ((VolumeParameter<float>)(object)val6.meanFreePath).value = Mathf.Max(((VolumeParameter<float>)(object)val6.meanFreePath).value * 1.32f, 18f); } } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void OnLateUpdate(PlayerControllerB __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Invalid comparison between Unknown and I4 //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Invalid comparison between Unknown and I4 //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_0766: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08bb: Unknown result type (might be due to invalid IL or missing references) //IL_08bd: Unknown result type (might be due to invalid IL or missing references) //IL_08c2: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08d5: Unknown result type (might be due to invalid IL or missing references) //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0815: Unknown result type (might be due to invalid IL or missing references) //IL_081c: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner) { return; } SetupOnce(); Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; bool flag = (Object)(object)StartOfRound.Instance != (Object)null && !name.Contains("Init") && !name.Contains("MainMenu"); vol.weight = (flag ? 1f : 0f); if (!flag) { sunHalo.SetActive(false); sunStreak.SetActive(false); spotStreak.SetActive(false); return; } if (!sceneScanned && Time.time >= nextScanTick) { ScanSceneOnce(); } float num = (((Object)(object)TimeOfDay.Instance != (Object)null) ? TimeOfDay.Instance.normalizedTimeOfDay : 0f); bool flag2 = !__instance.isInsideFactory && !__instance.isInHangarShipRoom && !StartOfRound.Instance.inShipPhase && !__instance.isPlayerDead; float num2 = ((flag2 && num > 0.58f) ? Mathf.Clamp01((num - 0.58f) / 0.25f) : 0f); float num3 = ((num > 0.58f) ? Mathf.Clamp01((num - 0.58f) / 0.25f) : 0f); float num4 = ((num > 0.56f) ? (1f - Mathf.Clamp01((num - 0.56f) / 0.16f)) : 1f); float num5 = ((flag2 && IsWetWeather()) ? 1.28f : 1f); float num6 = ((num > 0.43f && num < 0.65f) ? Mathf.Sin(Mathf.Clamp01((num - 0.43f) / 0.22f) * MathF.PI) : 0f); bool flag3 = ((Object)(object)TimeOfDay.Instance != (Object)null && (int)TimeOfDay.Instance.currentLevelWeather == 5) || ((Object)(object)StartOfRound.Instance.currentLevel != (Object)null && (int)StartOfRound.Instance.currentLevel.currentWeather == 5); ((VolumeParameter<float>)(object)exp.compensation).Override(flag2 ? Mathf.Lerp(0.12f, -2.02f, num2) : 0f); ((VolumeParameter<float>)(object)indirect.indirectDiffuseLightingMultiplier).Override(flag2 ? Mathf.Lerp(1.04f, 0.06f, num2) : 1f); ((VolumeParameter<float>)(object)indirect.reflectionLightingMultiplier).Override(flag2 ? Mathf.Lerp(1.04f * num5, 0.14f * num5, num2) : 1f); if ((Object)(object)mainDirLight != (Object)null) { mainDirLight.intensity = origDirIntensity * Mathf.Lerp(1.08f, 0.045f, num2); if (flag3) { mainDirLight.color = origDirColor; } else { Color val = origDirColor * new Color(1.04f, 0.99f, 0.92f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.72f, 0.42f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.62f, 0.78f, 1f, 1f); mainDirLight.color = Color.Lerp(Color.Lerp(val, val3, num3), val2, num6 * 0.9f); } } if ((Object)(object)sunHaloMat != (Object)null) { Color val4 = Color.Lerp(new Color(5.2f, 4.1f, 2f, 1f), new Color(6.4f, 3.5f, 1.2f, 1f), num6); Color val5 = Color.Lerp(new Color(2.4f, 1.9f, 1.1f, 1f), new Color(3.2f, 1.7f, 0.7f, 1f), num6); float num7 = num4 * num4; sunHaloMat.SetColor("_UnlitColor", val4 * num7); sunStreakMat.SetColor("_UnlitColor", val5 * num7); } bool flag4 = !flag3 && !__instance.isInsideFactory && num4 > 0.005f && (Object)(object)__instance.gameplayCamera != (Object)null && ((Object)(object)skySun != (Object)null || (Object)(object)mainDirLight != (Object)null); if ((Object)(object)skySun != (Object)null) { skySun.enabled = flag3; } sunHalo.SetActive(flag4); Vector3 val6; if (flag4) { Transform transform = ((Component)__instance.gameplayCamera).transform; Vector3 position = transform.position; Vector3 normalized; if (!((Object)(object)skySun != (Object)null)) { val6 = -((Component)mainDirLight).transform.forward; normalized = ((Vector3)(ref val6)).normalized; } else { val6 = ((Component)skySun).transform.position - position; normalized = ((Vector3)(ref val6)).normalized; } Vector3 val7 = normalized; float num8; if (!((Object)(object)skySun != (Object)null)) { num8 = 260f; } else { val6 = ((Component)skySun).transform.position - position; num8 = Mathf.Clamp(((Vector3)(ref val6)).magnitude - 3f, 120f, 380f); } float num9 = num8; Vector3 val8 = position + val7 * num9; sunHalo.transform.position = val8; sunHalo.transform.LookAt(position); sunHalo.transform.Rotate(0f, 180f, 0f); float num10 = 26f * (num9 / 280f); sunHalo.transform.localScale = new Vector3(num10, num10, 1f); float num11 = Vector3.Dot(transform.forward, val7); bool flag5 = num11 > 0.55f && !Physics.Raycast(position, val7, 140f, StartOfRound.Instance.collidersAndRoomMaskAndDefault); sunStreak.SetActive(flag5); if (flag5) { float num12 = Mathf.Clamp01((num11 - 0.55f) / 0.45f); sunStreak.transform.SetPositionAndRotation(val8 - val7 * 1.5f, sunHalo.transform.rotation); sunStreak.transform.localScale = new Vector3(num10 * 3.4f * num12, num10 * 0.42f * num12, 1f); } } else { sunStreak.SetActive(false); } bool flag6 = false; if ((Object)(object)__instance.gameplayCamera != (Object)null && !__instance.isInsideFactory && ShipSpotLights.Count > 0) { Transform transform2 = ((Component)__instance.gameplayCamera).transform; Vector3 position2 = transform2.position; Light val9 = null; float num13 = 0f; for (int i = 0; i < ShipSpotLights.Count; i++) { Light val10 = ShipSpotLights[i]; if ((Object)(object)val10 == (Object)null || !((Behaviour)val10).enabled || !((Component)val10).gameObject.activeInHierarchy) { continue; } Vector3 val11 = ((Component)val10).transform.position - position2; float sqrMagnitude = ((Vector3)(ref val11)).sqrMagnitude; if (sqrMagnitude > 1600f || sqrMagnitude < 2.25f) { continue; } float num14 = Mathf.Sqrt(sqrMagnitude); Vector3 val12 = val11 / num14; float num15 = Vector3.Dot(transform2.forward, val12); float num16 = Vector3.Dot(((Component)val10).transform.forward, -val12); if (num15 > 0.78f && num16 > 0.45f) { float num17 = num15 * num16 * (1f - num14 / 40f); if (num17 > num13 && !Physics.Linecast(position2, ((Component)val10).transform.position - val12 * 0.6f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) { num13 = num17; val9 = val10; } } } if ((Object)(object)val9 != (Object)null && num13 > 0.08f) { flag6 = true; spotStreak.SetActive(true); Transform transform3 = spotStreak.transform; Vector3 position3 = ((Component)val9).transform.position; val6 = ((Component)val9).transform.position - position2; transform3.position = position3 - ((Vector3)(ref val6)).normalized * 0.35f; spotStreak.transform.LookAt(position2); spotStreak.transform.Rotate(0f, 180f, 0f); float num18 = Mathf.Clamp(num13 * 4.2f, 0.6f, 2.8f); spotStreak.transform.localScale = new Vector3(num18, num18 * 0.16f, 1f); } } if (!flag6) { spotStreak.SetActive(false); } RagdollManager.Tick(__instance); TerminalLiveScreen.Tick(); } } public class RagdollManager { private class Body { public DeadBodyInfo info; public Rigidbody head; public List<Rigidbody> rbs = new List<Rigidbody>(); public List<Rigidbody> legs = new List<Rigidbody>(); public Vector3 dir; public float t0; public float twitchT; public bool twitch; } private static readonly List<Body> Bodies = new List<Body>(); private static readonly HashSet<int> DoneIds = new HashSet<int>(); private static readonly Dictionary<int, Vector3> Vels = new Dictionary<int, Vector3>(); [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] private static void Clear() { Bodies.Clear(); DoneIds.Clear(); Vels.Clear(); } [HarmonyPatch(typeof(DeadBodyInfo), "Start")] [HarmonyPostfix] private static void OnBodySpawn(DeadBodyInfo __instance) { //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0106: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Invalid comparison between Unknown and I4 //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || !DoneIds.Add(((Object)__instance).GetInstanceID())) { return; } Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { for (int j = i + 1; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[i] != (Object)null && (Object)(object)componentsInChildren[j] != (Object)null) { Physics.IgnoreCollision(componentsInChildren[i], componentsInChildren[j], true); } } } CharacterJoint[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<CharacterJoint>(true); foreach (CharacterJoint val in componentsInChildren2) { if (!((Object)(object)val == (Object)null)) { val.enableProjection = true; val.projectionDistance = 0.03f; val.projectionAngle = 14f; SoftJointLimit lowTwistLimit = val.lowTwistLimit; ((SoftJointLimit)(ref lowTwistLimit)).limit = -15f; val.lowTwistLimit = lowTwistLimit; SoftJointLimit highTwistLimit = val.highTwistLimit; ((SoftJointLimit)(ref highTwistLimit)).limit = 22f; val.highTwistLimit = highTwistLimit; SoftJointLimit swing1Limit = val.swing1Limit; ((SoftJointLimit)(ref swing1Limit)).limit = 34f; val.swing1Limit = swing1Limit; SoftJointLimit swing2Limit = val.swing2Limit; ((SoftJointLimit)(ref swing2Limit)).limit = 28f; val.swing2Limit = swing2Limit; } } Vector3 val2 = -((Component)__instance).transform.forward + ((Component)__instance).transform.right * ((Random.value > 0.5f) ? 0.45f : (-0.45f)); Vector3 normalized = ((Vector3)(ref val2)).normalized; Body body = new Body { info = __instance, dir = normalized, t0 = Time.time, twitch = ((int)__instance.causeOfDeath == 11), twitchT = Time.time + 0.25f }; Vector3 value; Vector3 val3 = (((Object)(object)__instance.playerScript != (Object)null && Vels.TryGetValue(((Object)__instance.playerScript).GetInstanceID(), out value)) ? Vector3.ClampMagnitude(value, 6f) : Vector3.zero); Rigidbody[] componentsInChildren3 = ((Component)__instance).GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val4 in componentsInChildren3) { if (!((Object)(object)val4 == (Object)null)) { string text = ((Object)((Component)val4).gameObject).name.ToLower(); val4.mass = ((text.Contains("pelvis") || text.Contains("spine") || text.Contains("torso") || text.Contains("chest")) ? 24f : ((text.Contains("thigh") || text.Contains("leg") || text.Contains("calf") || text.Contains("shin")) ? 6.8f : 3.4f)); if (text.Contains("head")) { body.head = val4; } else if (text.Contains("thigh") || text.Contains("leg") || text.Contains("foot") || text.Contains("calf") || text.Contains("shin")) { body.legs.Add(val4); } val4.drag = 1.35f; val4.angularDrag = 4.2f; val4.solverIterations = 12; val4.maxDepenetrationVelocity = 0.75f; val4.collisionDetectionMode = (CollisionDetectionMode)2; val4.interpolation = (RigidbodyInterpolation)1; Vector3 val5 = ((text.Contains("head") || text.Contains("chest") || text.Contains("spine")) ? (normalized * 2.2f) : ((text.Contains("foot") || text.Contains("shin") || text.Contains("calf")) ? (-normalized * 0.65f) : (normalized * 1.45f))); val4.velocity = (body.twitch ? (val3 * 0.4f) : val3) + val5; body.rbs.Add(val4); } } if (body.rbs.Count > 0) { Bodies.Add(body); } } [HarmonyPatch(typeof(DeadBodyInfo), "FixedUpdate")] [HarmonyPostfix] private static void OnBodyFixed(DeadBodyInfo __instance) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || ((Object)(object)__instance.grabBodyObject != (Object)null && __instance.grabBodyObject.isHeld)) { return; } for (int num = Bodies.Count - 1; num >= 0; num--) { Body body = Bodies[num]; if ((Object)(object)body.info == (Object)null) { Bodies.RemoveAt(num); } else if (!((Object)(object)body.info != (Object)(object)__instance)) { float num2 = Time.time - body.t0; if (num2 < 0.75f) { float num3 = (1f - num2 / 0.75f) * 18f; if ((Object)(object)body.head != (Object)null) { body.head.AddForce(body.dir * num3, (ForceMode)0); } foreach (Rigidbody leg in body.legs) { if ((Object)(object)leg != (Object)null) { leg.AddForce(-body.dir * (num3 * 0.85f), (ForceMode)0); } } } if (body.twitch && num2 > 0.35f && num2 < 1.65f && Time.time >= body.twitchT) { body.twitchT = Time.time + 0.22f; foreach (Rigidbody rb in body.rbs) { if ((Object)(object)rb != (Object)null && (((Object)((Component)rb).gameObject).name.ToLower().Contains("arm") || ((Object)((Component)rb).gameObject).name.ToLower().Contains("hand"))) { rb.AddTorque(Random.onUnitSphere * 5.5f, (ForceMode)1); } } } foreach (Rigidbody rb2 in body.rbs) { if ((Object)(object)rb2 != (Object)null && !rb2.isKinematic) { Vector3 velocity = rb2.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 64f) { velocity = rb2.velocity; rb2.velocity = ((Vector3)(ref velocity)).normalized * 8f; } } } } } } public static void Tick(PlayerControllerB p) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if (p.isPlayerControlled && !p.isPlayerDead && (Object)(object)p.thisController != (Object)null) { Vels[((Object)p).GetInstanceID()] = p.thisController.velocity; } if (!p.isPlayerControlled || p.isPlayerDead || Bodies.Count == 0 || (Object)(object)p.thisController == (Object)null) { return; } Vector3 velocity = p.thisController.velocity; velocity.y = 0f; if (((Vector3)(ref velocity)).magnitude < 0.9f) { return; } Vector3 val = ((Component)p).transform.position + Vector3.up * 0.35f; Vector3 val2 = ((Vector3)(ref velocity)).normalized * (((Vector3)(ref velocity)).magnitude * 1.4f) + Vector3.up * 0.6f; foreach (Body body in Bodies) { if (!((Object)(object)body.info != (Object)null) || (!((Object)(object)body.info.grabBodyObject == (Object)null) && body.info.grabBodyObject.isHeld)) { continue; } foreach (Rigidbody rb in body.rbs) { if ((Object)(object)rb != (Object)null && !rb.isKinematic && Mathf.Abs(rb.worldCenterOfMass.y - val.y) <= 0.6f) { Vector2 val3 = new Vector2(rb.worldCenterOfMass.x - val.x, rb.worldCenterOfMass.z - val.z); if (((Vector2)(ref val3)).sqrMagnitude < 0.6f) { rb.WakeUp(); rb.AddForce(val2 * (Time.deltaTime * 36f), (ForceMode)1); } } } } } } public class TerminalLiveScreen { private const string Tag = "<MT_SYNC>"; private static Terminal cachedTerminal; private static GameObject mirrorObj; private static TextMeshProUGUI worldText; private static string lastSent = ""; private static float nextSendTick; private static float hideAtTime; private static void EnsureWorldOverlay(Terminal term) { //IL_0076: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) if (!((Object)(object)worldText != (Object)null) && !((Object)(object)term?.screenText == (Object)null)) { mirrorObj = Object.Instantiate<GameObject>(((Component)term.screenText).gameObject, ((Component)term.screenText).transform.parent); ((Object)mirrorObj).name = "Mavka_TerminalWorldMirror"; mirrorObj.transform.localPosition = ((Component)term.screenText).transform.localPosition + new Vector3(0f, 0f, -0.002f); mirrorObj.transform.localRotation = ((Component)term.screenText).transform.localRotation; mirrorObj.transform.localScale = ((Component)term.screenText).transform.localScale; worldText = mirrorObj.GetComponent<TextMeshProUGUI>(); if ((Object)(object)worldText != (Object)null) { ((Graphic)worldText).color = new Color(0.18f, 1f, 0.35f, 0.95f); ((TMP_Text)worldText).enableWordWrapping = true; ((TMP_Text)worldText).overflowMode = (TextOverflowModes)3; } mirrorObj.SetActive(false); } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] [HarmonyPrefix] private static bool InterceptSyncPacket(string chatMessage) { if (string.IsNullOrEmpty(chatMessage) || !chatMessage.StartsWith("<MT_SYNC>")) { return true; } string text = chatMessage.Substring("<MT_SYNC>".Length); if ((Object)(object)cachedTerminal == (Object)null) { cachedTerminal = Object.FindObjectOfType<Terminal>(); } if ((Object)(object)cachedTerminal != (Object)null && !cachedTerminal.terminalInUse) { EnsureWorldOverlay(cachedTerminal); if ((Object)(object)mirrorObj != (Object)null && (Object)(object)worldText != (Object)null) { if (text == "OFF") { mirrorObj.SetActive(false); } else { mirrorObj.SetActive(true); ((TMP_Text)worldText).text = text; hideAtTime = Time.time + 12f; } } } return false; } [HarmonyPatch(typeof(Terminal), "QuitTerminal")] [HarmonyPostfix] private static void OnQuitTerminal(Terminal __instance) { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.AddTextToChatOnServer("<MT_SYNC>OFF", -1); } lastSent = ""; } public static void Tick() { if ((Object)(object)mirrorObj != (Object)null && mirrorObj.activeSelf && Time.time > hideAtTime) { mirrorObj.SetActive(false); } if (Time.time < nextSendTick) { return; } nextSendTick = Time.time + 0.22f; if ((Object)(object)cachedTerminal == (Object)null) { cachedTerminal = Object.FindObjectOfType<Terminal>(); } if (!((Object)(object)cachedTerminal == (Object)null) && cachedTerminal.terminalInUse && !((Object)(object)cachedTerminal.screenText == (Object)null)) { if ((Object)(object)mirrorObj != (Object)null && mirrorObj.activeSelf) { mirrorObj.SetActive(false); } string text = cachedTerminal.screenText.text ?? ""; if (text.Length > 850) { text = text.Substring(text.Length - 850); } if (text != lastSent && (Object)(object)HUDManager.Instance != (Object)null) { lastSent = text; HUDManager.Instance.AddTextToChatOnServer("<MT_SYNC>" + text, -1); } } } } }