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 AcidRain v0.1.0
LethalCompanyTemplate.dll
Decompiled a week agousing System; using System.Collections; 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MrovLib.Events; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using WeatherRegistry; using WeatherRegistry.Utils; [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("LethalCompanyTemplate")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalCompanyTemplate")] [assembly: AssemblyTitle("LethalCompanyTemplate")] [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 LethalCompanyTemplate { public static class PluginInfo { public const string PLUGIN_GUID = "LethalCompanyTemplate"; public const string PLUGIN_NAME = "LethalCompanyTemplate"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace AcidRainMod { public class AcidRainWeather : MonoBehaviour { private const float WarningDuration = 8f; private const float RainDuration = 60f; private const float SafetyDuration = 30f; private const float TickInterval = 1f; private const int PlayerDamagePerTick = 1; private const int ScrapCorrosionPerTick = 1; private static readonly HashSet<string> DamageableEnemies = new HashSet<string> { "MouthDogAI", "BaboonBirdAI", "DoublewingAI", "FlowerSnakeAI", "PumaAI" }; private static readonly HashSet<SelectableLevel> TriggeredLevelsToday = new HashSet<SelectableLevel>(); private const int ToolDestroyTickThreshold = 15; private Coroutine _cycleRoutine; private Coroutine _damageTickRoutine; private readonly Dictionary<int, int> _toolExposureTicks = new Dictionary<int, int>(); private readonly Dictionary<int, int> _bodyExposureTicks = new Dictionary<int, int>(); private ParticleSystem _rainVFX; public SelectableLevel BoundLevel; public static AudioClip DisintegrateSoundClip; public static AudioClip SizzleSoundClip; private static GameObject _warningUIRoot; private static Text _warningText; private static Image _warningTriangle; public static bool IsRaining { get; private set; } private void OnEnable() { ((MonoBehaviour)this).StartCoroutine(CreateRainVFXWhenReady()); _cycleRoutine = ((MonoBehaviour)this).StartCoroutine(RunCycle()); ((MonoBehaviour)this).StartCoroutine(VfxExposureLoop()); BuildWarningUI(); } private void BuildWarningUI() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00b1: 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_00e9: 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_011c: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_warningUIRoot != (Object)null)) { _warningUIRoot = new GameObject("AcidRainWarningUI"); Object.DontDestroyOnLoad((Object)(object)_warningUIRoot); Canvas val = _warningUIRoot.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 100; _warningUIRoot.AddComponent<CanvasScaler>(); _warningUIRoot.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("Triangle"); val2.transform.SetParent(_warningUIRoot.transform, false); _warningTriangle = val2.AddComponent<Image>(); _warningTriangle.sprite = Sprite.Create(CreateTriangleTexture(96), new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f)); ((Graphic)_warningTriangle).color = new Color(0.5f, 1f, 0.3f, 1f); RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(-770f, -155f); component.sizeDelta = new Vector2(80f, 80f); ((Transform)component).localEulerAngles = new Vector3(0f, 0f, 180f); GameObject val3 = new GameObject("CountdownText"); val3.transform.SetParent(val2.transform, false); _warningText = val3.AddComponent<Text>(); _warningText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); _warningText.alignment = (TextAnchor)4; ((Graphic)_warningText).color = new Color(0.5f, 1f, 0.3f, 1f); _warningText.fontSize = 28; _warningText.fontStyle = (FontStyle)1; RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = new Vector2(0f, 14f); component2.offsetMax = Vector2.zero; ((Transform)component2).localEulerAngles = new Vector3(0f, 0f, 180f); _warningUIRoot.SetActive(false); } } private Texture2D CreateTriangleTexture(int size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b3: 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_00b6: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_0104: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)5, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)size / 2f, 0f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, (float)(size - 1)); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor((float)(size - 1), (float)(size - 1)); float num = (float)size * 0.09f; Vector2 p = default(Vector2); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { ((Vector2)(ref p))..ctor((float)j, (float)i); if (!PointInTriangle(p, val2, val3, val4)) { val.SetPixel(j, i, new Color(0f, 0f, 0f, 0f)); continue; } float num2 = DistToSegment(p, val2, val3); float num3 = DistToSegment(p, val3, val4); float num4 = DistToSegment(p, val4, val2); float num5 = Mathf.Min(num2, Mathf.Min(num3, num4)); bool flag = num5 <= num; val.SetPixel(j, i, (Color)(flag ? Color.white : new Color(0f, 0f, 0f, 0f))); } } val.Apply(); return val; } private bool PointInTriangle(Vector2 p, Vector2 a, Vector2 b, Vector2 c) { //IL_0002: 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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = Sign(p, a, b); float num2 = Sign(p, b, c); float num3 = Sign(p, c, a); bool flag = num < 0f || num2 < 0f || num3 < 0f; bool flag2 = num > 0f || num2 > 0f || num3 > 0f; return !(flag && flag2); } private float Sign(Vector2 p1, Vector2 p2, Vector2 p3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002f: Unknown result type (might be due to invalid IL or missing references) return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y); } private float DistToSegment(Vector2 p, Vector2 a, Vector2 b) { //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) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0044: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; float num = ((sqrMagnitude > 0f) ? Mathf.Clamp01(Vector2.Dot(p - a, val) / sqrMagnitude) : 0f); Vector2 val2 = a + num * val; return Vector2.Distance(p, val2); } private void ShowWarningCountdown(int secondsLeft) { if (!((Object)(object)_warningUIRoot == (Object)null)) { _warningUIRoot.SetActive(true); _warningText.text = secondsLeft.ToString(); } } private void ShowRainActiveIcon() { if (!((Object)(object)_warningUIRoot == (Object)null)) { _warningUIRoot.SetActive(true); _warningText.text = "!"; } } private void HideWarningUI() { if (!((Object)(object)_warningUIRoot == (Object)null)) { _warningUIRoot.SetActive(false); } } private IEnumerator CreateRainVFXWhenReady() { float waited = 0f; Camera cam = null; for (; waited < 30f; waited += 0.5f) { PlayerControllerB localPlayer = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.gameplayCamera != (Object)null) { cam = localPlayer.gameplayCamera; break; } if ((Object)(object)Camera.main != (Object)null) { cam = Camera.main; break; } yield return (object)new WaitForSeconds(0.5f); } if ((Object)(object)cam == (Object)null) { Debug.LogWarning((object)"[AcidRain] No camera found after waiting 30s, giving up on VFX setup."); } else { BuildRainVFX(cam); } } private void BuildRainVFX(Camera localCam) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_01b8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("AcidRainVFX"); val.transform.SetParent(((Component)localCam).transform); val.transform.localPosition = new Vector3(0f, 10f, 0f); val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); _rainVFX = val.AddComponent<ParticleSystem>(); MainModule main = _rainVFX.main; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.6f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(25f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.03f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.6f, 1f, 0.4f, 0.55f)); ((MainModule)(ref main)).maxParticles = 3000; EmissionModule emission = _rainVFX.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(1500f); ShapeModule shape = _rainVFX.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(25f, 1f, 25f); ParticleSystemRenderer component = ((Component)_rainVFX).GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)1; component.lengthScale = 6f; component.velocityScale = 0.05f; Shader val2 = Shader.Find("Particles/Standard Unlit"); if ((Object)(object)val2 == (Object)null) { val2 = Shader.Find("Sprites/Default"); } Material val3 = (Material)((!((Object)(object)val2 != (Object)null)) ? ((object)((Renderer)component).material) : ((object)new Material(val2))); val3.color = new Color(0.6f, 1f, 0.4f, 0.55f); val3.mainTexture = (Texture)(object)CreateSoftDotTexture(16); ((Renderer)component).material = val3; _rainVFX.Stop(); } private Texture2D CreateSoftDotTexture(int size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)5, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)size / 2f, (float)size / 2f); float num = (float)size / 2f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val2); float num3 = Mathf.Clamp01(1f - num2 / num); val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(); return val; } private IEnumerator VfxExposureLoop() { while (true) { yield return (object)new WaitForSeconds(0.5f); if ((Object)(object)_rainVFX == (Object)null) { continue; } if (!IsRaining) { if (_rainVFX.isPlaying) { _rainVFX.Stop(); } continue; } PlayerControllerB localPlayer = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)localPlayer == (Object)null)) { bool exposed = IsExposed(((Component)localPlayer).transform.position, localPlayer.isInsideFactory); if (exposed && !_rainVFX.isPlaying) { _rainVFX.Play(); } if (!exposed && _rainVFX.isPlaying) { _rainVFX.Stop(); } } } } private void OnDisable() { if (_cycleRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_cycleRoutine); } if (_damageTickRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_damageTickRoutine); } IsRaining = false; } private void OnDestroy() { if ((Object)(object)_rainVFX != (Object)null) { Object.Destroy((Object)(object)((Component)_rainVFX).gameObject); } } public static void ResetForNewDay() { TriggeredLevelsToday.Clear(); IsRaining = false; } public static bool HasTriggeredForLevel(SelectableLevel level) { return TriggeredLevelsToday.Contains(level); } public static void MarkTriggeredForLevel(SelectableLevel level) { TriggeredLevelsToday.Add(level); } private IEnumerator RunCycle() { float initialDelay = Random.Range(30f, 120f); yield return (object)new WaitForSeconds(initialDelay); while (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)StartOfRound.Instance.currentLevel != (Object)(object)BoundLevel)) { yield return ((MonoBehaviour)this).StartCoroutine(WarningPhase()); yield return ((MonoBehaviour)this).StartCoroutine(RainPhase()); yield return ((MonoBehaviour)this).StartCoroutine(SafetyPhase()); } Debug.LogWarning((object)"[AcidRain] Left bound level before next phase -- shutting down cycle."); Object.Destroy((Object)(object)((Component)this).gameObject); } private IEnumerator WarningPhase() { Debug.Log((object)"[AcidRain] Warning triggered — rain incoming in 8s."); if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.AddChatMessage("Acid rain is approaching...", "", -1, true); } for (int secondsLeft = 8; secondsLeft > 0; secondsLeft--) { ShowWarningCountdown(secondsLeft); yield return (object)new WaitForSeconds(1f); } } private IEnumerator RainPhase() { IsRaining = true; Debug.Log((object)"[AcidRain] Rain started."); ShowRainActiveIcon(); _damageTickRoutine = ((MonoBehaviour)this).StartCoroutine(DamageTickLoop()); yield return (object)new WaitForSeconds(60f); if (_damageTickRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_damageTickRoutine); } IsRaining = false; HideWarningUI(); Debug.Log((object)"[AcidRain] Rain ended."); } private IEnumerator SafetyPhase() { yield return (object)new WaitForSeconds(30f); } private IEnumerator DamageTickLoop() { while (true) { yield return (object)new WaitForSeconds(1f); if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel != (Object)(object)BoundLevel) { break; } TryTick("Players", TickPlayers); TryTick("Enemies", TickEnemies); TryTick("Scrap", TickScrap); TryTick("Bodies", TickBodies); } Debug.LogWarning((object)"[AcidRain] Left bound level -- shutting down cycle."); Object.Destroy((Object)(object)((Component)this).gameObject); } private void TryTick(string label, Action tickMethod) { try { tickMethod(); } catch (Exception arg) { Debug.LogError((object)$"[AcidRain] Tick{label} threw an exception: {arg}"); } } private void TickPlayers() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && IsExposed(((Component)val).transform.position, val.isInsideFactory)) { val.DamagePlayer(1, true, true, (CauseOfDeath)0, 0, false, Vector3.zero); } } } private void TickEnemies() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); EnemyAI[] array2 = array; foreach (EnemyAI val in array2) { if (!((Object)(object)val == (Object)null) && !val.isEnemyDead && DamageableEnemies.Contains(((object)val).GetType().Name) && IsExposed(((Component)val).transform.position, isInsideFactory: false)) { val.HitEnemy(1, (PlayerControllerB)null, false, -1); } } } private void TickScrap() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { if ((Object)(object)val == (Object)null || (Object)(object)val.itemProperties == (Object)null || (val.itemProperties.itemName != null && val.itemProperties.itemName.IndexOf("hive", StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } bool isInsideFactory = (Object)(object)val.playerHeldBy != (Object)null && val.playerHeldBy.isInsideFactory; if (!IsExposed(((Component)val).transform.position, isInsideFactory)) { continue; } if (val.scrapValue > 0) { val.scrapValue--; if (val.scrapValue <= 0) { DisintegrateItem(val); continue; } PlaySizzleSound(((Component)val).transform.position); UpdateScanNodeValue(val); continue; } int instanceID = ((Object)val).GetInstanceID(); _toolExposureTicks.TryGetValue(instanceID, out var value); value++; if (value >= 15) { _toolExposureTicks.Remove(instanceID); DisintegrateItem(val); } else { _toolExposureTicks[instanceID] = value; PlaySizzleSound(((Component)val).transform.position); } } } private void TickBodies() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(); DeadBodyInfo[] array2 = array; foreach (DeadBodyInfo val in array2) { if (!((Object)(object)val == (Object)null) && IsExposed(((Component)val).transform.position, isInsideFactory: false)) { int instanceID = ((Object)val).GetInstanceID(); _bodyExposureTicks.TryGetValue(instanceID, out var value); value++; if (value >= 15) { _bodyExposureTicks.Remove(instanceID); Debug.Log((object)"[AcidRain] Corpse dissolved from acid exposure."); Object.Destroy((Object)(object)((Component)val).gameObject); } else { _bodyExposureTicks[instanceID] = value; } } } } private void DisintegrateItem(GrabbableObject item) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)("[AcidRain] " + item.itemProperties.itemName + " disintegrated from acid corrosion.")); PlayDisintegrateSound(((Component)item).transform.position); if ((Object)(object)item.playerHeldBy != (Object)null) { int num = Array.IndexOf(item.playerHeldBy.ItemSlots, item); if (num >= 0) { item.playerHeldBy.DestroyItemInSlotAndSync(num); } else { Object.Destroy((Object)(object)((Component)item).gameObject); } } else { Object.Destroy((Object)(object)((Component)item).gameObject); } } private void PlayDisintegrateSound(Vector3 position) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)DisintegrateSoundClip == (Object)null)) { AudioSource.PlayClipAtPoint(DisintegrateSoundClip, position, 1f); } } private void PlaySizzleSound(Vector3 position) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)SizzleSoundClip == (Object)null)) { AudioSource.PlayClipAtPoint(SizzleSoundClip, position, 0.3f); } } private void UpdateScanNodeValue(GrabbableObject item) { ScanNodeProperties componentInChildren = ((Component)item).GetComponentInChildren<ScanNodeProperties>(); if (!((Object)(object)componentInChildren == (Object)null)) { componentInChildren.subText = $"Value: ${item.scrapValue}"; } } private bool IsExposed(Vector3 position, bool isInsideFactory) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!IsRaining) { return false; } if (isInsideFactory) { return false; } int mask = LayerMask.GetMask(new string[2] { "Room", "Default" }); bool flag = Physics.Raycast(position, Vector3.up, 50f, mask); return !flag; } } [BepInPlugin("yourname.acidrainmod", "Acid Rain Weather", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class AcidRainPlugin : BaseUnityPlugin { public static AcidRainPlugin Instance; public static Weather AcidRainWeatherDef; private Harmony _harmony; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Instance = this; _harmony = new Harmony("yourname.acidrainmod"); _harmony.PatchAll(); RegisterWeather(); HookEvents(); ((MonoBehaviour)this).StartCoroutine(LoadAudioClip("disintegrate.wav", delegate(AudioClip clip) { AcidRainWeather.DisintegrateSoundClip = clip; })); ((MonoBehaviour)this).StartCoroutine(LoadAudioClip("sizzle.wav", delegate(AudioClip clip) { AcidRainWeather.SizzleSoundClip = clip; })); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Acid Rain Weather v0.1.0 loaded."); } private IEnumerator LoadAudioClip(string fileName, Action<AudioClip> onLoaded) { string dllFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string soundPath = Path.Combine(dllFolder, fileName); if (!File.Exists(soundPath)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[AcidRain] No " + fileName + " found next to the DLL -- that sound stays disabled until you add one.")); yield break; } string url = "file://" + soundPath; UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)20); try { yield return www.SendWebRequest(); if ((int)www.result != 1) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[AcidRain] Failed to load " + fileName + ": " + www.error)); yield break; } onLoaded(DownloadHandlerAudioClip.GetContent(www)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[AcidRain] " + fileName + " loaded successfully.")); } finally { ((IDisposable)www)?.Dispose(); } } private void RegisterWeather() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) ImprovedWeatherEffect val = ScriptableObject.CreateInstance<ImprovedWeatherEffect>(); val.EffectObject = null; val.WorldObject = null; AcidRainWeatherDef = new Weather("Acid Rain", val); AcidRainWeatherDef.Config.DefaultWeight = new IntegerConfigHandler(22, true); AcidRainWeatherDef.ColorGradient = ColorConverter.ToTMPColorGradient(new Color(0.2f, 1f, 0.2f)); WeatherManager.RegisterWeather(AcidRainWeatherDef); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Acid Rain weather registered with WeatherRegistry."); } private void ApplyRealRainEffect() { Weather weather = WeatherManager.GetWeather((LevelWeatherType)1); if (weather != null && (Object)(object)weather.Effect != (Object)null) { AcidRainWeatherDef.Effect = weather.Effect; AcidRainWeatherDef.Effect.SunAnimatorBool = "overcast"; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[AcidRain] Swapped in vanilla Rainy's real effect and forced overcast sky for actual cloud cover."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[AcidRain] Still could not find vanilla Rainy weather at SetupFinished -- atmosphere will not change, only the custom particle overlay will show."); } } private void RecolorVanillaWeathers() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) SetColor((LevelWeatherType)1, new Color(0f, 0f, 0.55f)); SetColor((LevelWeatherType)3, new Color(0.5f, 0.5f, 0.5f)); SetColor((LevelWeatherType)4, new Color(1f, 0.86f, 0f)); } private void SetColor(LevelWeatherType type, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Weather weather = WeatherManager.GetWeather(type); if (weather == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"[AcidRain] Could not find weather {type} to recolor."); } else { weather.ColorGradient = ColorConverter.ToTMPColorGradient(color); } } private void HookEvents() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown ((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.WeatherChanged).AddListener((ParameterEvent<(SelectableLevel, Weather)>)OnWeatherChanged); ((CustomEvent<int>)(object)EventManager.DayChanged).AddListener((ParameterEvent<int>)OnDayChanged); ((CustomEvent)EventManager.SetupFinished).AddListener(new Event(RecolorVanillaWeathers)); ((CustomEvent)EventManager.SetupFinished).AddListener(new Event(ApplyRealRainEffect)); } private void OnWeatherChanged((SelectableLevel level, Weather weather) data) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (data.weather == AcidRainWeatherDef) { if (AcidRainWeather.HasTriggeredForLevel(data.level)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Acid Rain already triggered for " + ((Object)data.level).name + " today, skipping duplicate.")); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Acid Rain selected for " + ((Object)data.level).name + ". Starting cycle.")); AcidRainWeather.MarkTriggeredForLevel(data.level); GameObject val = new GameObject("AcidRainCycleController"); (val.AddComponent<AcidRainWeather>().BoundLevel, _) = data; } } private void OnDayChanged(int day) { AcidRainWeather.ResetForNewDay(); } } internal static class PluginInfo { public const string GUID = "yourname.acidrainmod"; public const string NAME = "Acid Rain Weather"; public const string VERSION = "0.1.0"; } [HarmonyPatch(typeof(RedLocustBees), "IsHiveMissing")] public static class RedLocustBeesCrashGuard { public static Exception Finalizer(Exception __exception, ref bool __result) { if (__exception != null) { __result = true; } return null; } } }