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 Drinkable v1.3.2
Drinkable.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using DigitalRuby.ThunderAndLightning; using Frailty; using Frailty.Manager; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Drinkable")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("Drinkable")] [assembly: AssemblyTitle("Drinkable")] [assembly: AssemblyVersion("1.3.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Drinkable { internal static class Assets { private static readonly Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>(); private static readonly Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>(); private static readonly Dictionary<string, Texture2D> cans = new Dictionary<string, Texture2D>(); internal static byte[] Read(string name) { using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("Drinkable." + name); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } internal static Sprite Icon(string name) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005e: 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 (sprites.TryGetValue(name, out var value)) { return value; } value = null; try { byte[] array = Read("Icons." + name + ".png"); if (array != null) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(val, array); ((Texture)val).wrapMode = (TextureWrapMode)1; value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)value).name = name; } else { Plugin.Log.LogWarning((object)("Missing icon " + name)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Icon " + name + ": " + ex.Message)); } sprites[name] = value; return value; } internal static Texture2D CanTexture(string key) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (cans.TryGetValue(key, out var value)) { return value; } value = null; try { byte[] array = Read("Cans." + key + ".png"); if (array != null) { value = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(value, array, false); ((Object)value).name = "Drinkable_" + key; ((Texture)value).wrapMode = (TextureWrapMode)1; ((Texture)value).filterMode = (FilterMode)1; ((Texture)value).anisoLevel = 4; value.Apply(true, true); } else { Plugin.Log.LogWarning((object)("Missing can texture " + key)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Can " + key + ": " + ex.Message)); } cans[key] = value; return value; } internal static Texture2D MachineTexture(string name) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string text = "Machine." + name; if (cans.TryGetValue(text, out var value)) { return value; } value = null; try { byte[] array = Read(text + ".png"); if (array != null) { value = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(value, array, false); ((Object)value).name = "Machine_" + name; ((Texture)value).wrapMode = (TextureWrapMode)1; ((Texture)value).anisoLevel = 4; value.Apply(true, true); } else { Plugin.Log.LogWarning((object)("Missing machine texture " + name)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Machine texture " + name + ": " + ex.Message)); } cans[text] = value; return value; } internal static Sprite CanIcon(string key) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) string text = key + "_icon"; if (sprites.TryGetValue(text, out var value)) { return value; } value = null; try { byte[] array = Read("Cans." + text + ".png"); if (array != null) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(val, array); ((Texture)val).wrapMode = (TextureWrapMode)1; value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)value).name = text; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Icon " + text + ": " + ex.Message)); } sprites[text] = value; return value; } internal static AudioClip Sound(string name) { if (clips.TryGetValue(name, out var value)) { return value; } value = null; try { byte[] array = Read("Sounds." + name + ".wav"); if (array != null) { value = LoadWav(name, array); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sound " + name + ": " + ex.Message)); } clips[name] = value; return value; } private static AudioClip LoadWav(string name, byte[] d) { int num = 1; int num2 = 44100; int num3 = 16; int num4 = -1; int num5 = 0; int num6; for (int i = 12; i + 8 <= d.Length; i += 8 + num6 + (num6 & 1)) { string text = Encoding.ASCII.GetString(d, i, 4); num6 = BitConverter.ToInt32(d, i + 4); if (text == "fmt ") { num = BitConverter.ToInt16(d, i + 10); num2 = BitConverter.ToInt32(d, i + 12); num3 = BitConverter.ToInt16(d, i + 22); } else if (text == "data") { num4 = i + 8; num5 = Math.Min(num6, d.Length - num4); break; } } if (num4 < 0 || num3 != 16) { throw new Exception("unsupported wav"); } int num7 = num5 / 2; float[] array = new float[num7]; for (int j = 0; j < num7; j++) { array[j] = (float)BitConverter.ToInt16(d, num4 + j * 2) / 32768f; } AudioClip obj = AudioClip.Create(name, num7 / num, num, num2, false); obj.SetData(array, 0); return obj; } } internal static class Batch2 { private static SodaConfig C => SodaConfig.Instance; internal static void Patch(Harmony h) { Type typeFromHandle = typeof(PlayerControllerB); Type typeFromHandle2 = typeof(HUDManager); NewDrinks.Try(h, typeFromHandle2, "MeetsScanNodeRequirements", typeof(LockedIn), "ScanRangePrefix", "ScanRangeFinalizer"); NewDrinks.Try(h, typeFromHandle2, "PingScan_performed", typeof(LockedIn), null, null, "PingPostfix"); NewDrinks.Try(h, typeof(Turret), "CheckForPlayersInLineOfSight", typeof(LockedIn), null, null, "TurretPostfix"); NewDrinks.Try(h, typeof(Landmine), "OnTriggerEnter", typeof(LockedIn), "MinePrefix", null); NewDrinks.Try(h, typeof(Landmine), "OnTriggerExit", typeof(LockedIn), "MinePrefix", null); NewDrinks.Try(h, typeof(SpikeRoofTrap), "Update", typeof(LockedIn), "SpikePrefix", null); NewDrinks.Try(h, typeFromHandle2, "HoldInteractionFill", typeof(LockedIn), "HoldPrefix", null); NewDrinks.Try(h, typeFromHandle, "BeginGrabObject", typeof(LockedIn), null, null, "GrabPostfix"); NewDrinks.Try(h, typeof(EnemyAI), "MeetsStandardPlayerCollisionConditions", typeof(HotStuff), null, null, "TouchPostfix", -1, 0); NewDrinks.Try(h, typeFromHandle, "DamagePlayer", typeof(HotStuff), "DamagePrefix", null, null, 600); NewDrinks.Try(h, typeof(SandSpiderWebTrap), "OnTriggerStay", typeof(HotStuff), "WebPrefix", null); NewDrinks.Try(h, typeof(BlobAI), "Update", typeof(Party), null, null, "BlobPostfix"); NewDrinks.Try(h, typeof(BlobAI), "OnCollideWithPlayer", typeof(Party), "BlobTouchPrefix", null); } internal static void Register(CustomMessagingManager cmm) { Party.Register(cmm); HotStuff.Register(cmm); } internal static void Tick(PlayerControllerB me) { DangerSense.Tick(me); HotStuff.Steam(me); Buddies.Tick(me); Party.Tick(me); } } internal static class Fx { private static readonly Dictionary<Color, Material> mats = new Dictionary<Color, Material>(); private static Mesh quad; private static Mesh sphere; private static readonly Color[] Confetti = (Color[])(object)new Color[7] { new Color(1f, 0.82f, 0.1f), new Color(0.25f, 0.88f, 1f), new Color(1f, 0.37f, 0.66f), new Color(0.49f, 1f, 0.35f), new Color(1f, 1f, 1f), new Color(1f, 0.54f, 0.16f), new Color(0.64f, 0.42f, 1f) }; internal static Material Mat(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (mats.TryGetValue(c, out var value) && (Object)(object)value != (Object)null) { return value; } Shader val = Shader.Find("HDRP/Unlit"); value = new Material(((Object)(object)val != (Object)null) ? val : Shader.Find("Standard")) { name = "Drinkable_Fx" }; value.SetColor("_UnlitColor", c); value.SetColor("_Color", c); if (value.HasProperty("_DoubleSidedEnable")) { value.SetFloat("_DoubleSidedEnable", 1f); } if (value.HasProperty("_CullMode")) { value.SetFloat("_CullMode", 0f); } if (value.HasProperty("_CullModeForward")) { value.SetFloat("_CullModeForward", 0f); } value.doubleSidedGI = true; mats[c] = value; return value; } private static Mesh MeshOf(PrimitiveType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(t); Mesh sharedMesh = obj.GetComponent<MeshFilter>().sharedMesh; Object.Destroy((Object)(object)obj); return sharedMesh; } internal static void Spawn(PrimitiveType type, Vector3 pos, Vector3 vel, Vector3 spin, Color color, float size, float life, float gravity, float grow) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) if ((int)type == 5) { if ((Object)(object)quad == (Object)null) { quad = MeshOf((PrimitiveType)5); } } else if ((Object)(object)sphere == (Object)null) { sphere = MeshOf((PrimitiveType)0); } GameObject val = new GameObject("Drinkable_Fx"); val.transform.position = pos; val.transform.rotation = Random.rotation; val.transform.localScale = Vector3.one * size; val.AddComponent<MeshFilter>().sharedMesh = (((int)type == 5) ? quad : sphere); MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = Mat(color); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; FxPiece fxPiece = val.AddComponent<FxPiece>(); fxPiece.vel = vel; fxPiece.spin = spin; fxPiece.life = life; fxPiece.gravity = gravity; fxPiece.size = size; fxPiece.grow = grow; } internal static void ConfettiBurst(Vector3 at, Vector3 up, int n = 70) { //IL_0007: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < n; i++) { Vector3 val = up * 1.6f + Random.insideUnitSphere; Vector3 normalized = ((Vector3)(ref val)).normalized; Spawn((PrimitiveType)5, at, normalized * Random.Range(2.5f, 5.5f), Random.insideUnitSphere * 720f, Confetti[i % Confetti.Length], Random.Range(0.05f, 0.09f), Random.Range(2f, 3.2f), 5f, 0f); } } internal static void SteamPuff(Vector3 at, Vector3 side) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) float num = Random.Range(0.82f, 0.95f); Spawn((PrimitiveType)0, at, side * 0.35f + Vector3.up * Random.Range(0.45f, 0.7f), Vector3.zero, new Color(num, num, num), 0.05f, 1.1f, -0.2f, 0.16f); } } internal class FxPiece : MonoBehaviour { public Vector3 vel; public Vector3 spin; public float life; public float gravity; public float size; public float grow; private float age; private void Update() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; age += deltaTime; if (age >= life) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } vel += Vector3.down * gravity * deltaTime; vel *= 1f - Mathf.Clamp01(1.6f * deltaTime); Transform transform = ((Component)this).transform; transform.position += vel * deltaTime; ((Component)this).transform.Rotate(spin * deltaTime, (Space)1); float num = age / life; float num2 = size + grow * Mathf.Sin(Mathf.Min(1f, num * 1.4f) * MathF.PI * 0.5f); if (num > 0.75f) { num2 *= 1f - (num - 0.75f) / 0.25f; } ((Component)this).transform.localScale = Vector3.one * Mathf.Max(0.001f, num2); } } internal static class LockedIn { private static SodaConfig C => SodaConfig.Instance; private static bool On { get { if (C != null) { return Buffs.Has(BuffKind.LockedIn); } return false; } } internal static float WaveScale { get { if (!On) { return 1f; } return 1f + Mathf.Max(0f, C.LockedScanWave.Value) / 100f; } } internal static void ScanRangePrefix(ScanNodeProperties node, out int __state) { __state = int.MinValue; if (On && !((Object)(object)node == (Object)null)) { __state = node.maxRange; node.maxRange = Mathf.RoundToInt((float)node.maxRange * (1f + Mathf.Max(0f, C.LockedScanRange.Value) / 100f)); } } internal static void ScanRangeFinalizer(ScanNodeProperties node, int __state) { if (__state != int.MinValue && (Object)(object)node != (Object)null) { node.maxRange = __state; } } internal static void PingPostfix(HUDManager __instance) { Animator scanEffectAnimator = __instance.scanEffectAnimator; if ((Object)(object)scanEffectAnimator != (Object)null && (Object)(object)((Component)scanEffectAnimator).GetComponent<ScanWaveStretch>() == (Object)null) { ((Component)scanEffectAnimator).gameObject.AddComponent<ScanWaveStretch>(); } } private static bool Unseen(PlayerControllerB p) { if ((Object)(object)p != (Object)null && C != null) { if (!NewDrinks.IsLocal(p)) { return Flags.Has(p, 32); } return Buffs.Has(BuffKind.LockedIn); } return false; } internal static void TurretPostfix(ref PlayerControllerB __result) { if (Unseen(__result)) { __result = null; } } internal static bool MinePrefix(Collider other) { if ((Object)(object)other == (Object)null || !On) { return true; } PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null) { return !NewDrinks.IsLocal(component); } return true; } internal static bool SpikePrefix(SpikeRoofTrap __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (!On || (Object)(object)__instance == (Object)null || (Object)(object)__instance.laserEye == (Object)null || !__instance.trapActive || __instance.slammingDown) { return true; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)val).transform.position - __instance.laserEye.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 64f)) { RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(__instance.laserEye.position, __instance.laserEye.forward, ref val3, 4.4f, StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers, (QueryTriggerInteraction)1) && (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponent<PlayerControllerB>() == (Object)(object)val) { return false; } return true; } } return true; } internal static void HoldPrefix(ref float speedMultiplier) { if (On) { speedMultiplier *= 1f + Mathf.Max(0f, C.LockedHands.Value) / 100f; } } internal static void GrabPostfix(PlayerControllerB __instance) { if (On && NewDrinks.IsLocal(__instance)) { __instance.grabObjectAnimationTime /= 1f + Mathf.Max(0f, C.LockedHands.Value) / 100f; } } } internal class ScanWaveStretch : MonoBehaviour { private Vector3 setScale = new Vector3(float.NaN, 0f, 0f); private Vector3 baseScale; private Animator anim; private void Start() { anim = ((Component)this).GetComponent<Animator>(); } private void LateUpdate() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) float waveScale = LockedIn.WaveScale; if ((Object)(object)anim != (Object)null) { anim.speed = 1f / waveScale; } Vector3 localScale = ((Component)this).transform.localScale; if (localScale != setScale) { baseScale = localScale; } setScale = baseScale * waveScale; ((Component)this).transform.localScale = setScale; } } internal class HotZap : MonoBehaviour { private static PatcherTool gun; private EnemyAI enemy; private PlayerControllerB from; private float end; private GameObject bolt; private Transform start; private Transform bend1; private Transform bend2; private Transform dest; private AudioSource loop; private float bend; private float bendSpeed; private AudioSource mixerFrom; private static PatcherTool Gun() { if ((Object)(object)gun == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.allItemsList != (Object)null) { foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { PatcherTool val = (((Object)(object)items != (Object)null && (Object)(object)items.spawnPrefab != (Object)null) ? items.spawnPrefab.GetComponent<PatcherTool>() : null); if ((Object)(object)val != (Object)null && (Object)(object)val.lightningObject != (Object)null) { gun = val; break; } } } return gun; } internal static void Play(EnemyAI enemy, PlayerControllerB from, float seconds) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) try { PatcherTool val = Gun(); if (!((Object)(object)val == (Object)null) && !((Object)(object)enemy == (Object)null) && !((Object)(object)from == (Object)null) && !(seconds <= 0f)) { new GameObject("Drinkable_HotZap").AddComponent<HotZap>().Init(val, enemy, from, seconds); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Hot Stuff zap effect: " + ex.Message)); } } private void Init(PatcherTool g, EnemyAI e, PlayerControllerB p, float seconds) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) enemy = e; from = p; end = Time.time + seconds; start = Point("Start"); bend1 = Point("Bend1"); bend2 = Point("Bend2"); dest = Point("Dest"); Place(); bolt = Object.Instantiate<GameObject>(g.lightningObject, ((Component)this).transform); LightningBoltPathScriptBase componentInChildren = bolt.GetComponentInChildren<LightningBoltPathScriptBase>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.LightningPath = new List<GameObject> { ((Component)start).gameObject, ((Component)bend1).gameObject, ((Component)bend2).gameObject, ((Component)dest).gameObject }; } bolt.SetActive(true); ((Component)this).transform.position = dest.position; mixerFrom = g.shockAudio; AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>(); Setup(val); if (g.beginShockClips != null && g.beginShockClips.Length != 0) { val.PlayOneShot(g.beginShockClips[Random.Range(0, g.beginShockClips.Length)]); } if ((Object)(object)g.shockAudio != (Object)null && (Object)(object)g.shockAudio.clip != (Object)null) { loop = ((Component)this).gameObject.AddComponent<AudioSource>(); Setup(loop); loop.clip = g.shockAudio.clip; loop.loop = true; loop.volume = 0.6f; loop.Play(); } static Transform Point(string n) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return new GameObject("Drinkable_HotZap_" + n).transform; } } private void OnDestroy() { Transform[] array = (Transform[])(object)new Transform[4] { start, bend1, bend2, dest }; foreach (Transform val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private void Setup(AudioSource a) { a.spatialBlend = 1f; a.rolloffMode = (AudioRolloffMode)1; a.minDistance = 2f; a.maxDistance = 30f; a.playOnAwake = false; if ((Object)(object)mixerFrom != (Object)null) { a.outputAudioMixerGroup = mixerFrom.outputAudioMixerGroup; } } private void Place() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //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_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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0094: 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_009e: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0104: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)enemy.eye != (Object)null) ? enemy.eye.position : (((Component)enemy).transform.position + Vector3.up)); Vector3 val2 = ((Component)from).transform.position + Vector3.up * 1.2f; dest.position = val + Random.insideUnitSphere * 0.3f; Vector3 val3 = val - val2; val3 = Vector3.Cross(((Vector3)(ref val3)).normalized, Vector3.up); Vector3 val4 = ((Vector3)(ref val3)).normalized * bend; start.position = val2; bend1.position = val2 + (val - val2) * 0.33f + val4; bend2.position = val2 + (val - val2) * 0.66f + val4; } private void LateUpdate() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy == (Object)null || (Object)(object)from == (Object)null || enemy.isEnemyDead || Time.time >= end) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } bendSpeed = Mathf.Clamp(bendSpeed + Random.Range(-1f, 1f) * 6f * Time.deltaTime, -1.2f, 1.2f); bend = Mathf.Clamp(bend + bendSpeed * Time.deltaTime * 4f, -1f, 1f); Place(); ((Component)this).transform.position = dest.position; if ((Object)(object)loop != (Object)null && end - Time.time < 0.3f) { loop.volume = Mathf.Max(0f, loop.volume - Time.deltaTime * 3f); } } } internal static class HotStuff { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnStun; } private const string Msg = "Miles.Drinkable.HotStun"; private static EnemyAI toucher; private static float touchedAt = -10f; private static readonly Dictionary<EnemyAI, float> stunnedAt = new Dictionary<EnemyAI, float>(); private static readonly Dictionary<ulong, float> nextPuff = new Dictionary<ulong, float>(); private static SodaConfig C => SodaConfig.Instance; internal static void Register(CustomMessagingManager cmm) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown stunnedAt.Clear(); object obj = <>O.<0>__OnStun; if (obj == null) { HandleNamedMessageDelegate val = OnStun; <>O.<0>__OnStun = val; obj = (object)val; } cmm.RegisterNamedMessageHandler("Miles.Drinkable.HotStun", (HandleNamedMessageDelegate)obj); } internal static void TouchPostfix(EnemyAI __instance, PlayerControllerB __result) { if ((Object)(object)__result != (Object)null && NewDrinks.IsLocal(__result)) { toucher = __instance; touchedAt = Time.time; } } internal static void DamagePrefix(PlayerControllerB __instance, ref int damageNumber, bool fallDamage, bool __runOriginal) { //IL_011b: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) try { if (!__runOriginal || C == null || damageNumber <= 0 || fallDamage || !NewDrinks.IsLocal(__instance) || __instance.isPlayerDead || !Buffs.Has(BuffKind.HotStuff) || (Object)(object)toucher == (Object)null || toucher.isEnemyDead || Time.time - touchedAt > 0.4f) { return; } EnemyAI val = toucher; toucher = null; damageNumber = Mathf.Max(1, Mathf.RoundToInt((float)damageNumber * (1f - Mathf.Clamp01(C.HotSkin.Value / 100f)))); if (!stunnedAt.TryGetValue(val, out var value) || !(Time.time - value < C.HotStunCooldown.Value)) { stunnedAt[val] = Time.time; Stun(val, __instance); Send(((NetworkBehaviour)val).NetworkObjectId, __instance.playerClientId); if (Random.value < Mathf.Clamp01(C.HotBurnBack.Value)) { Vector3 val2 = ((Component)val).transform.position - ((Component)__instance).transform.position; val.HitEnemyOnLocalClient(1, ((Vector3)(ref val2)).normalized, __instance, true, -1); } for (int i = 0; i < 4; i++) { Fx.SteamPuff(((Component)val).transform.position + Vector3.up * 1.2f + Random.insideUnitSphere * 0.4f, Random.onUnitSphere); } } } catch (Exception e) { BuffPatches.Once("hot stuff", e); } } private static void Stun(EnemyAI enemy, PlayerControllerB by) { if (!((Object)(object)enemy == (Object)null) && !enemy.isEnemyDead && !(C.HotStun.Value <= 0f)) { enemy.SetEnemyStunned(true, C.HotStun.Value, by); if ((Object)(object)enemy.enemyType != (Object)null && enemy.enemyType.canBeStunned) { HotZap.Play(enemy, by, C.HotStun.Value); } } } private unsafe static void Send(ulong enemy, ulong player) { //IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0062: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null || !singleton.IsListening) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref enemy, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref player, default(ForPrimitives)); if (singleton.IsServer) { singleton.CustomMessagingManager.SendNamedMessageToAll("Miles.Drinkable.HotStun", val, (NetworkDelivery)2); } else { singleton.CustomMessagingManager.SendNamedMessage("Miles.Drinkable.HotStun", 0uL, val, (NetworkDelivery)2); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnStun(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) try { ulong num = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); ulong num2 = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); NetworkManager singleton = NetworkManager.Singleton; if (singleton.IsServer && sender != singleton.LocalClientId) { Send(num, num2); } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (((Object)(object)val != (Object)null && val.playerClientId == num2) || !singleton.SpawnManager.SpawnedObjects.TryGetValue(num, out var value) || (Object)(object)value == (Object)null) { return; } StartOfRound instance = StartOfRound.Instance; PlayerControllerB val2 = (((Object)(object)instance != (Object)null && num2 < (ulong)instance.allPlayerScripts.Length) ? instance.allPlayerScripts[num2] : null); EnemyAI component = ((Component)value).GetComponent<EnemyAI>(); Stun(component, val2); if ((Object)(object)component != (Object)null) { for (int i = 0; i < 4; i++) { Fx.SteamPuff(((Component)component).transform.position + Vector3.up * 1.2f + Random.insideUnitSphere * 0.4f, Random.onUnitSphere); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Hot Stuff message: " + ex.Message)); } } internal static bool WebPrefix(SandSpiderWebTrap __instance, Collider other) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) try { if (C == null || !C.HotWebs.Value || !Buffs.Has(BuffKind.HotStuff) || (Object)(object)other == (Object)null) { return true; } PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>(); if (!NewDrinks.IsLocal(component) || component.isPlayerDead) { return true; } __instance.Hit(1, Vector3.zero, component, false, -1); return false; } catch (Exception e) { BuffPatches.Once("burn through", e); return true; } } internal static void Steam(PlayerControllerB me) { //IL_00eb: 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_00f9: 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_010f: 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) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)me) && val.isPlayerControlled && !val.isPlayerDead && Flags.Has(val, 16) && (!nextPuff.TryGetValue(val.playerClientId, out var value) || !(Time.time < value))) { nextPuff[val.playerClientId] = Time.time + Random.Range(2.2f, 3.6f); Transform val2 = (((Object)(object)val.playerGlobalHead != (Object)null) ? val.playerGlobalHead : ((Component)val.gameplayCamera).transform); float[] array = new float[2] { -1f, 1f }; foreach (float num in array) { Fx.SteamPuff(val2.position + val2.right * num * 0.16f, val2.right * num); } } } } } internal static class Party { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnParty; } private const string Msg = "Miles.Drinkable.Party"; private static readonly FieldRef<BlobAI, float> tamed = AccessTools.FieldRefAccess<BlobAI, float>("tamedTimer"); private static float nextCount; private static SodaConfig C => SodaConfig.Instance; internal static bool IsHost { get { Buff buff = Buffs.Get(BuffKind.Party); if (buff == null) { return false; } return buff.tier == 2; } } internal static int Crowd { get; private set; } internal static float SpeedPct { get { if (Crowd < 3) { if (Crowd != 2) { return C.PartySpeed.Value; } return C.PartySpeed2.Value; } return C.PartySpeed3.Value; } } internal static float RefillPct { get { if (Crowd < 3) { if (Crowd != 2) { return C.PartyRefill.Value; } return C.PartyRefill2.Value; } return C.PartyRefill3.Value; } } internal static void Register(CustomMessagingManager cmm) { //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_0021: Expected O, but got Unknown object obj = <>O.<0>__OnParty; if (obj == null) { HandleNamedMessageDelegate val = OnParty; <>O.<0>__OnParty = val; obj = (object)val; } cmm.RegisterNamedMessageHandler("Miles.Drinkable.Party", (HandleNamedMessageDelegate)obj); } internal static void Tick(PlayerControllerB me) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!Buffs.Has(BuffKind.Party) || Time.time < nextCount || C == null) { return; } nextCount = Time.time + 0.5f; float num = C.PartyRange.Value * C.PartyRange.Value; int num2 = 0; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)me && val.isPlayerControlled && !val.isPlayerDead) { Vector3 val2 = ((Component)val).transform.position - ((Component)me).transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= num) { num2++; } } } Crowd = num2; } internal static void Start(PlayerControllerB me) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) Buff buff = Buffs.Add(BuffKind.Party, C.PartyTime.Value); if (buff != null) { Buffs.SetLeft(buff, C.PartyTime.Value); buff.length = C.PartyTime.Value; buff.tier = 2; } Effect(me); Send(me.playerClientId, ((Component)me).transform.position); } private unsafe static void Send(ulong player, Vector3 at) { //IL_0031: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null || !singleton.IsListening) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(48, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref player, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref at); if (singleton.IsServer) { singleton.CustomMessagingManager.SendNamedMessageToAll("Miles.Drinkable.Party", val, (NetworkDelivery)2); } else { singleton.CustomMessagingManager.SendNamedMessage("Miles.Drinkable.Party", 0uL, val, (NetworkDelivery)2); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnParty(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) try { ulong num = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); Vector3 val = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref val); NetworkManager singleton = NetworkManager.Singleton; if (singleton.IsServer && sender != singleton.LocalClientId) { Send(num, val); } PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val2 == (Object)null || val2.playerClientId == num) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && num < (ulong)instance.allPlayerScripts.Length) { Effect(instance.allPlayerScripts[num]); } if (val2.isPlayerDead || !val2.isPlayerControlled || !(Vector3.Distance(((Component)val2).transform.position, val) <= C.PartyRange.Value)) { return; } Buff buff = Buffs.Add(BuffKind.Party, C.PartyTime.Value); if (buff != null && buff.tier != 2) { buff.tier = 1; } try { HUDManager.Instance.DisplayTip("Party!", "You joined the party.", false, false, "LC_Tip1"); } catch { } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Party message: " + ex.Message)); } } private static void Effect(PlayerControllerB p) { //IL_002d: 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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_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_0078: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)p == (Object)null)) { Transform val = (((Object)(object)p.gameplayCamera != (Object)null) ? ((Component)p.gameplayCamera).transform : ((Component)p).transform); Vector3 at = val.position + val.forward * 0.6f + Vector3.up * 0.1f; Vector3 val2 = Vector3.up + val.forward * 0.4f; Fx.ConfettiBurst(at, ((Vector3)(ref val2)).normalized); GameSounds.At(p, GameSounds.Horn, 1f, 1.15f); } } internal static void BlobPostfix(BlobAI __instance) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || ((EnemyAI)__instance).isEnemyDead) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead && (NewDrinks.IsLocal(val) ? IsHost : Flags.Has(val, 8)) && !(Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position) > 12f) && !Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.5f, ((Component)val).transform.position + Vector3.up * 0.5f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1)) { tamed.Invoke(__instance) = Mathf.Max(tamed.Invoke(__instance), 2f); } } } internal static bool BlobTouchPrefix(Collider other) { if (!IsHost || (Object)(object)other == (Object)null) { return true; } return !NewDrinks.IsLocal(((Component)other).GetComponent<PlayerControllerB>()); } } internal static class Buddies { private static float nextCheck; private static float nextHeal; internal const float ChillLinger = 3f; private static SodaConfig C => SodaConfig.Instance; internal static void Tick(PlayerControllerB me) { //IL_00b7: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) Buff buff = Buffs.Get(BuffKind.CrewSense); if (buff == null || me.isPlayerDead || C == null) { Buffs.Remove(BuffKind.Chill); Buffs.Remove(BuffKind.WellMakeIt); return; } if (Time.time >= nextCheck) { nextCheck = Time.time + 0.5f; float num = C.CrewRange.Value * C.CrewRange.Value; bool near = false; bool flag = false; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)me) { continue; } if (!val.isPlayerDead && val.isPlayerControlled) { Vector3 val2 = ((Component)val).transform.position - ((Component)me).transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= num) { near = true; } } if (val.isPlayerDead && (Object)(object)val.deadBody != (Object)null && !val.deadBody.deactivated && BodyNear(val.deadBody, ((Component)me).transform.position, num)) { flag = true; } } bool flag2 = me.currentlyHeldObjectServer is RagdollGrabbableObject; SetChill(near, buff); Set(BuffKind.WellMakeIt, flag || flag2, buff, (!flag2) ? 1 : 2); } if (Buffs.Has(BuffKind.Chill)) { me.insanityLevel = Mathf.Max(0f, me.insanityLevel - Mathf.Max(0f, C.ChillCalm.Value) * Time.deltaTime); if (Time.time >= nextHeal) { nextHeal = Time.time + Mathf.Max(0.5f, C.ChillHealEvery.Value); int num2 = Mathf.RoundToInt(C.ChillHealMax.Value) - me.health; int num3 = Mathf.Min(Mathf.RoundToInt(C.ChillHeal.Value), num2); if (num3 > 0 && (!FrailtyBridge.Installed || !FrailtyBridge.Bleeding())) { Buffs.GiveHealth(me, num3, evenWhileBleeding: false); } } } else { nextHeal = Time.time + Mathf.Max(0.5f, C.ChillHealEvery.Value); } } internal static Vector3 BodyPosition(DeadBodyInfo body) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (body.bodyParts != null && body.bodyParts.Length != 0) { Vector3 val = Vector3.zero; int num = 0; Rigidbody[] bodyParts = body.bodyParts; foreach (Rigidbody val2 in bodyParts) { if ((Object)(object)val2 != (Object)null) { val += val2.position; num++; } } if (num > 0) { return val / (float)num; } } return ((Component)body).transform.position; } private static bool BodyNear(DeadBodyInfo body, Vector3 me, float r2) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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) Vector3 val2; if (body.bodyParts != null) { Rigidbody[] bodyParts = body.bodyParts; foreach (Rigidbody val in bodyParts) { if ((Object)(object)val != (Object)null) { val2 = val.position - me; if (((Vector3)(ref val2)).sqrMagnitude <= r2) { return true; } } } } val2 = ((Component)body).transform.position - me; return ((Vector3)(ref val2)).sqrMagnitude <= r2; } private static void SetChill(bool near, Buff crew) { Buff buff = Buffs.Get(BuffKind.Chill); if (near) { buff = buff ?? Buffs.Add(BuffKind.Chill, crew.Left); if (buff != null) { Buffs.SetLeft(buff, crew.Left); buff.length = crew.length; buff.linger = false; } } else if (buff != null && !buff.linger) { buff.linger = true; buff.length = 3f; buff.end = Time.time + Mathf.Min(3f, crew.Left); } } private static void Set(BuffKind k, bool on, Buff crew, int tier) { if (!on) { Buffs.Remove(k); return; } Buff buff = Buffs.Add(k, crew.Left); if (buff != null) { Buffs.SetLeft(buff, crew.Left); buff.length = crew.length; buff.tier = tier; } } } internal static class DangerSense { private class Mark { public RectTransform root; public Image icon; public TextMeshProUGUI text; public CanvasGroup group; public Transform target; public string name; } private static readonly FieldRef<SteamValveHazard, bool> burst = AccessTools.FieldRefAccess<SteamValveHazard, bool>("valveHasBurst"); private static readonly FieldRef<SteamValveHazard, bool> repaired = AccessTools.FieldRefAccess<SteamValveHazard, bool>("valveHasBeenRepaired"); private const int MaxMarks = 16; private static readonly List<Mark> marks = new List<Mark>(); private static RectTransform layer; private static float nextPing; private static float shownAt = -100f; private static SodaConfig C => SodaConfig.Instance; internal static void PingSoon() { nextPing = Time.time + 0.6f; } internal static void Tick(PlayerControllerB me) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; if (!Buffs.Has(BuffKind.DangerSense) || me.isPlayerDead || !((Object)(object)instance != (Object)null) || !((Object)(object)instance.playerScreenRectTransform != (Object)null)) { if ((Object)(object)layer != (Object)null) { ((Component)layer).gameObject.SetActive(false); } } else { if ((Object)(object)layer == (Object)null && !Build(instance)) { return; } ((Component)layer).gameObject.SetActive(true); if (Time.time >= nextPing) { nextPing = Time.time + Mathf.Max(1f, C.DangerEvery.Value); Ping(me, instance); } float num = Mathf.Max(0.5f, C.DangerShow.Value); float num2 = Time.time - shownAt; float num3 = ((num2 < 0.15f) ? (num2 / 0.15f) : ((num2 > num) ? 0f : ((num2 > num - 0.6f) ? ((num - num2) / 0.6f) : 1f))); Camera gameplayCamera = me.gameplayCamera; instance.playerScreenRectTransform.GetWorldCorners(instance.playerScreenCorners); Vector3[] playerScreenCorners = instance.playerScreenCorners; bool flag = (Object)(object)IngamePlayerSettings.Instance != (Object)null && IngamePlayerSettings.Instance.flipCamera; foreach (Mark mark in marks) { if ((Object)(object)mark.target == (Object)null || num3 <= 0.01f) { ((Component)mark.root).gameObject.SetActive(false); continue; } Vector3 val = mark.target.position + Vector3.up * 1f; Vector3 val2 = gameplayCamera.WorldToViewportPoint(val); if (val2.z <= 0f || val2.x < 0f || val2.x > 1f || val2.y < 0f || val2.y > 1f) { ((Component)mark.root).gameObject.SetActive(false); continue; } ((Component)mark.root).gameObject.SetActive(true); ((Transform)mark.root).position = ((!flag) ? Vector3.Lerp(Vector3.Lerp(playerScreenCorners[0], playerScreenCorners[3], val2.x), Vector3.Lerp(playerScreenCorners[1], playerScreenCorners[2], val2.x), val2.y) : Vector3.Lerp(Vector3.Lerp(playerScreenCorners[3], playerScreenCorners[0], val2.x), Vector3.Lerp(playerScreenCorners[2], playerScreenCorners[1], val2.x), val2.y)); ((TMP_Text)mark.text).text = mark.name + "\n" + Mathf.RoundToInt(Vector3.Distance(((Component)me).transform.position, mark.target.position)) + "m"; mark.group.alpha = num3; } } } private static void Ping(PlayerControllerB me, HUDManager hud) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Vector3 p = ((Component)me).transform.position; float range = C.DangerRange.Value; List<KeyValuePair<Transform, string>> list = new List<KeyValuePair<Transform, string>>(); EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); foreach (EnemyAI val in array) { if ((Object)(object)val != (Object)null && !val.isEnemyDead && (Object)(object)val.enemyType != (Object)null && ((Component)val).gameObject.activeInHierarchy) { list.Add(new KeyValuePair<Transform, string>(((Component)val).transform, val.enemyType.enemyName)); } } Turret[] array2 = Object.FindObjectsOfType<Turret>(); foreach (Turret val2 in array2) { if ((Object)(object)val2 != (Object)null && val2.turretActive) { list.Add(new KeyValuePair<Transform, string>(((Component)val2).transform, "Turret")); } } Landmine[] array3 = Object.FindObjectsOfType<Landmine>(); foreach (Landmine val3 in array3) { if ((Object)(object)val3 != (Object)null && !val3.hasExploded) { list.Add(new KeyValuePair<Transform, string>(((Component)val3).transform, "Landmine")); } } SpikeRoofTrap[] array4 = Object.FindObjectsOfType<SpikeRoofTrap>(); foreach (SpikeRoofTrap val4 in array4) { if ((Object)(object)val4 != (Object)null && val4.trapActive) { list.Add(new KeyValuePair<Transform, string>(((Component)val4).transform, "Spike trap")); } } SteamValveHazard[] array5 = Object.FindObjectsOfType<SteamValveHazard>(); foreach (SteamValveHazard val5 in array5) { if ((Object)(object)val5 != (Object)null && burst.Invoke(val5) && !repaired.Invoke(val5)) { list.Add(new KeyValuePair<Transform, string>(((Component)val5).transform, "Steam leak")); } } List<KeyValuePair<Transform, string>> list2 = list.Where(delegate(KeyValuePair<Transform, string> f) { //IL_0007: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 val6 = f.Key.position - p; return ((Vector3)(ref val6)).sqrMagnitude <= range * range; }).OrderBy(delegate(KeyValuePair<Transform, string> f) { //IL_0007: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 val6 = f.Key.position - p; return ((Vector3)(ref val6)).sqrMagnitude; }).Take(16) .ToList(); for (int num = 0; num < marks.Count; num++) { marks[num].target = ((num < list2.Count) ? list2[num].Key : null); marks[num].name = ((num < list2.Count) ? list2[num].Value : ""); } shownAt = Time.time; if (list2.Count > 0 && (Object)(object)hud.UIAudio != (Object)null && (Object)(object)hud.scanSFX != (Object)null) { hud.UIAudio.PlayOneShot(hud.scanSFX, 0.25f); } } private static bool Build(HUDManager hud) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_02e0: 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_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) Transform val = ((hud.scanElements != null && hud.scanElements.Length != 0 && (Object)(object)hud.scanElements[0] != (Object)null) ? ((Transform)hud.scanElements[0]).parent : null); if ((Object)(object)val == (Object)null) { return false; } Rect rect = hud.scanElements[0].rect; float num = Mathf.Max(20f, ((Rect)(ref rect)).width); GameObject val2 = new GameObject("Drinkable Danger Sense", new Type[1] { typeof(RectTransform) }); val2.layer = ((Component)val).gameObject.layer; val2.transform.SetParent(val, false); layer = (RectTransform)val2.transform; TextMeshProUGUI val3 = ((hud.controlTipLines != null) ? ((IEnumerable<TextMeshProUGUI>)hud.controlTipLines).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => (Object)(object)t != (Object)null)) : null); marks.Clear(); for (int num2 = 0; num2 < 16; num2++) { Mark mark = new Mark(); GameObject val4 = new GameObject("Mark" + num2, new Type[1] { typeof(RectTransform) }); val4.layer = val2.layer; val4.transform.SetParent((Transform)(object)layer, false); mark.root = (RectTransform)val4.transform; mark.root.sizeDelta = new Vector2(num * 0.32f, num * 0.32f); mark.group = val4.AddComponent<CanvasGroup>(); mark.group.blocksRaycasts = false; GameObject val5 = new GameObject("Icon", new Type[1] { typeof(RectTransform) }); val5.layer = val2.layer; val5.transform.SetParent((Transform)(object)mark.root, false); mark.icon = val5.AddComponent<Image>(); mark.icon.sprite = Assets.Icon("DangerSense"); mark.icon.preserveAspect = true; ((Graphic)mark.icon).raycastTarget = false; ((RectTransform)val5.transform).sizeDelta = mark.root.sizeDelta; GameObject val6 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val6.layer = val2.layer; val6.transform.SetParent((Transform)(object)mark.root, false); mark.text = val6.AddComponent<TextMeshProUGUI>(); if ((Object)(object)val3 != (Object)null) { ((TMP_Text)mark.text).font = ((TMP_Text)val3).font; ((TMP_Text)mark.text).fontSharedMaterial = ((TMP_Text)val3).fontSharedMaterial; } ((TMP_Text)mark.text).fontSize = num * 0.11f; ((TMP_Text)mark.text).alignment = (TextAlignmentOptions)258; ((Graphic)mark.text).color = new Color(1f, 0.35f, 0.25f); ((Graphic)mark.text).raycastTarget = false; ((TMP_Text)mark.text).enableWordWrapping = false; RectTransform val7 = (RectTransform)val6.transform; val7.sizeDelta = new Vector2(num * 2f, num * 0.3f); val7.anchoredPosition = new Vector2(0f, (0f - num) * 0.32f); val4.SetActive(false); marks.Add(mark); } return true; } } internal static class BuffInfo { internal static readonly Color Gold = new Color(1f, 0.72f, 0.11f); internal static readonly Color Cyan = new Color(0f, 0.86f, 1f); internal static readonly Color Green = new Color(0.35f, 1f, 0.45f); internal static readonly Color Pink = new Color(1f, 0.55f, 0.75f); internal static readonly Color Purple = new Color(0.75f, 0.5f, 1f); internal static readonly Color Red = new Color(1f, 0f, 0.216f); internal static string Title(BuffKind k) { return k switch { BuffKind.SugarRush => "Sugar Rush", BuffKind.WebRush => "Sugar Rush+", BuffKind.SugarCrash => "Sugar Crash", BuffKind.Hydration => "Hydration", BuffKind.Dehydration => "Dehydration", BuffKind.SugarMend => "Sugar Mend", BuffKind.Brawn => "Brawn", BuffKind.Swift => "Swift", BuffKind.Spring => "Spring", BuffKind.SecondWind => "Second Wind", BuffKind.Endurance => "Endurance", BuffKind.Hyponatremia => "Hyponatremia", BuffKind.Equilibrium => "Equilibrium", BuffKind.Adrenaline => "Adrenaline", BuffKind.Equivalence => "Equivalence", BuffKind.SharpSight => "Sharp Sight", BuffKind.Exquisite => "Exquisite", BuffKind.CheeseSense => "Cheese Sense", BuffKind.Adapted => "Adapted", BuffKind.Silent => "Silent", BuffKind.ColdOne => "Cold One", BuffKind.Tipsy => "Tipsy", BuffKind.Drunk => "Drunk", BuffKind.Wobbly => "Wobbly", BuffKind.Staggering => "Staggering", BuffKind.BigBurp => "Big Burp", BuffKind.FizzJump => "Fizz Jump", BuffKind.Lucky => "Lucky", BuffKind.DangerSense => "Danger Sense", BuffKind.CrewSense => "Crew Sense", BuffKind.LockedIn => "Locked In", BuffKind.Party => "Party", BuffKind.HotStuff => "Hot Stuff", BuffKind.Chill => "Chill", BuffKind.WellMakeIt => "We'll Make It", _ => k.ToString(), }; } internal static string Title(Buff b) { if (b.kind != BuffKind.Adrenaline) { if (b.kind != BuffKind.BigBurp) { return Title(b.kind); } return Title(b.kind) + " (" + b.count + ")"; } return Title(b.kind) + " " + Roman(b.tier); } private static string Roman(int tier) { if (tier > 1) { return tier switch { 3 => "III", 2 => "II", _ => "IV", }; } return "I"; } internal static Sprite Icon(Buff b) { return Assets.Icon((b.kind == BuffKind.Adrenaline && b.tier > 1) ? ("Adrenaline_" + Mathf.Min(b.tier, 4)) : b.kind.ToString()); } internal static string Description(BuffKind k) { switch (k) { case BuffKind.SugarRush: return "The sugar hits: you move a bit faster and jump a bit higher. A Sugar Crash may follow."; case BuffKind.WebRush: return "A bigger sugar high: you move faster and jump higher for longer. A longer Sugar Crash may follow."; case BuffKind.SugarCrash: return "The sugar wears off: your stamina refills slower."; case BuffKind.SugarMend: return "Sweet and soothing: you slowly heal over time and your stamina refills faster."; case BuffKind.Hydration: return "Fresh and cool: while you drink, your stamina refills much faster."; case BuffKind.Dehydration: return "Way too salty: while you drink, your stamina drains."; case BuffKind.Brawn: return "You feel strong: carried weight slows you down and tires you less, and melee hits deal much more damage."; case BuffKind.SharpSight: return "Eyes wide open: you see wider, and dark places are easier to see in."; case BuffKind.Exquisite: return "Pure luxury: you move faster, jump higher, climb faster and your stamina refills faster."; case BuffKind.CheeseSense: return "You can smell it: inside the facility you can tell where the nearest scrap and the nearest exit are."; case BuffKind.Adapted: return "You adapt to the weather: you don't sink in quicksand and lightning doesn't hit you."; case BuffKind.Equilibrium: if (!FrailtyBridge.Installed) { return "Calm and steady: getting hit can give you Adrenaline, and getting infected can give you Equivalence."; } return "Calm and steady: getting hit can give you Adrenaline, and getting a debuff can give you Equivalence."; case BuffKind.Adrenaline: return "You were hit and adrenaline kicks in: you run faster and sprinting costs no stamina for a moment. The harder you're hit, the faster you go."; case BuffKind.Equivalence: return "Your body fights back: your debuffs last half as long (an infection grows half as fast), you take less damage and you slowly heal while they last."; case BuffKind.Swift: return "Light on your feet: you walk and run faster."; case BuffKind.Spring: return "A spring in your step: you jump higher."; case BuffKind.SecondWind: return "You catch your breath: your stamina refills faster."; case BuffKind.Endurance: return "You can keep going: sprinting drains less stamina."; case BuffKind.Hyponatremia: return "Too much Mystery Soda: you run slower, jump lower and sprinting costs more stamina."; case BuffKind.Silent: return "Hushed: your footsteps, landings and dropped items barely make a sound, so blind monsters only hear you up close."; case BuffKind.ColdOne: return "Ice cold: while you drink, your stamina refills very fast, and it's full when you finish."; case BuffKind.Tipsy: return "A little buzzed: a bit faster, higher jumps, carried weight slows you a little less, you take a bit less damage, paranoia creeps in slower, your voice carries further and Hoarding Bugs don't mind you."; case BuffKind.Drunk: return "Properly drunk: faster, higher jumps, carried weight slows you less, you take a bit less damage, paranoia stops creeping in, melee hits land harder, your voice carries much further and Hoarding Bugs don't mind you."; case BuffKind.Wobbly: return "Loose legs: you slip and slide a little when you move."; case BuffKind.Staggering: return "You can barely walk straight: you slip and slide a lot."; case BuffKind.BigBurp: return "Full of gas: press " + Burp.KeyName + " to burp. Hoarding Bugs back off, a Snare Flea lets go and Spore Lizards run."; case BuffKind.FizzJump: return "Bubbles in your boots: jump once more in mid-air."; case BuffKind.DangerSense: return "A bad feeling: every few seconds you sense the monsters and traps around you, even through walls."; case BuffKind.CrewSense: return "You know where your crew is: your compass shows your teammates and the bodies of the ones who didn't make it. Near a teammate you Chill; near a fallen one, We'll Make It."; case BuffKind.LockedIn: return "Locked in: your scanner reaches farther, your hands work faster - picking things up, opening doors and climbing ladders - and turrets, landmines and spike traps don't notice you."; case BuffKind.Chill: return "Your crew is close: you calm down, your stamina refills a little faster and you slowly heal up to half health (not while you bleed)."; case BuffKind.WellMakeIt: return "Not leaving them behind: near a fallen teammate's body you take less damage, and even less while you carry them."; case BuffKind.Party: return (Party.IsHost ? "You brought the party: you're faster and your stamina refills faster, the slime loves you and never hurts you." : "It's a party: you're faster and your stamina refills faster.") + " The more of your crew around you, the better."; case BuffKind.HotStuff: return "Too hot to handle: a monster that hits you is stunned for a moment and its hit hurts a bit less (it might even get burned). Spider webs burn away when you walk into them."; case BuffKind.Lucky: return "Fortune smiles on you: some hits miss you completely, and you may survive a blow that should kill you or slip out of a monster's grip (once)."; default: return ""; } } internal static string Value(Buff b) { SodaConfig instance = SodaConfig.Instance; switch (b.kind) { case BuffKind.Chill: if (!b.linger) { return ""; } return Visuals.FormatTime(b.Left); case BuffKind.WellMakeIt: return Mathf.RoundToInt((instance == null) ? 0f : ((b.tier >= 2) ? instance.CarryBodyReduction.Value : instance.BodyReduction.Value)) + "%"; default: return Visuals.FormatTime(b.Left); } } internal static bool Ending(Buff b) { if (b.kind == BuffKind.WellMakeIt || (b.kind == BuffKind.Chill && !b.linger)) { return false; } return b.Left <= 5f; } internal static Color Color(BuffKind k) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) switch (k) { case BuffKind.SugarCrash: case BuffKind.Dehydration: case BuffKind.Hyponatremia: return Red; case BuffKind.Wobbly: case BuffKind.Staggering: return Red; case BuffKind.BigBurp: case BuffKind.Lucky: return Green; case BuffKind.Silent: case BuffKind.DangerSense: return Gold; case BuffKind.Party: return Purple; case BuffKind.CrewSense: case BuffKind.Chill: return Green; case BuffKind.LockedIn: return Cyan; case BuffKind.HotStuff: return Pink; case BuffKind.WellMakeIt: return Gold; case BuffKind.Hydration: case BuffKind.Equilibrium: case BuffKind.Equivalence: case BuffKind.ColdOne: case BuffKind.FizzJump: return Cyan; case BuffKind.SugarMend: return Pink; case BuffKind.SharpSight: return Cyan; case BuffKind.Exquisite: case BuffKind.CheeseSense: return Purple; default: return Gold; } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class BuffPatches { private static bool applied; private static float savedSpeed; private static float newSpeed; private static float savedJump; private static float newJump; private static float savedClimb; private static float newClimb; private static float savedCarry; private static float newCarry; private static float staminaBefore = -1f; private static float lateCarrySaved; private static float lateCarryNew; private static bool lateCarry; private static float fovApplied; private static readonly HashSet<string> logged = new HashSet<string>(); [HarmonyPatch("Update")] [HarmonyPrefix] [HarmonyPriority(200)] private static void UpdatePrefix(PlayerControllerB __instance) { applied = false; if (!Local.Is(__instance) || SodaConfig.Instance == null) { return; } try { Buffs.Tick(__instance); NewDrinks.Tick(__instance); if (fovApplied != 0f && (Object)(object)__instance.gameplayCamera != (Object)null) { Camera gameplayCamera = __instance.gameplayCamera; gameplayCamera.fieldOfView -= fovApplied; } float num = Buffs.SpeedMul(); float num2 = Buffs.JumpMul(); float num3 = Buffs.ClimbMul(); float num4 = Buffs.CarryReduce(); if (num != 1f || num2 != 1f || num3 != 1f || num4 != 0f) { savedSpeed = __instance.movementSpeed; newSpeed = savedSpeed * num; __instance.movementSpeed = newSpeed; savedJump = __instance.jumpForce; newJump = savedJump * Mathf.Sqrt(Mathf.Max(0.01f, num2)); __instance.jumpForce = newJump; if (num2 < 1f && __instance.fallValueUncapped > newJump) { __instance.fallValueUncapped = newJump; } savedClimb = __instance.climbSpeed; newClimb = savedClimb * num3; __instance.climbSpeed = newClimb; savedCarry = __instance.carryWeight; newCarry = 1f + Mathf.Max(0f, savedCarry - 1f) * (1f - num4); __instance.carryWeight = newCarry; applied = true; } } catch (Exception e) { Once("update", e); } } [HarmonyPatch("Update")] [HarmonyFinalizer] private static void UpdateFinalizer(PlayerControllerB __instance) { if (!Local.Is(__instance)) { return; } if (applied) { applied = false; __instance.movementSpeed = Restore(__instance.movementSpeed, savedSpeed, newSpeed); __instance.jumpForce = Restore(__instance.jumpForce, savedJump, newJump); __instance.climbSpeed = Restore(__instance.climbSpeed, savedClimb, newClimb); __instance.carryWeight = Restore(__instance.carryWeight, savedCarry, newCarry); } try { float num = Buffs.FovAdd(); fovApplied = Mathf.MoveTowards(fovApplied, num, 30f * Time.deltaTime); if (fovApplied != 0f && (Object)(object)__instance.gameplayCamera != (Object)null) { Camera gameplayCamera = __instance.gameplayCamera; gameplayCamera.fieldOfView += fovApplied; } Visuals.Update(__instance); } catch (Exception e) { Once("visuals", e); } } private static float Restore(float now, float saved, float changed) { if (!Mathf.Approximately(now, changed)) { return now + (saved - changed); } return saved; } [HarmonyPatch("LateUpdate")] [HarmonyPrefix] [HarmonyPriority(200)] private static void LatePrefix(PlayerControllerB __instance) { staminaBefore = -1f; lateCarry = false; if (Local.Is(__instance) && SodaConfig.Instance != null && Buffs.All != null) { staminaBefore = __instance.sprintMeter; float num = Buffs.CarryReduce(); if (num > 0f) { lateCarrySaved = __instance.carryWeight; lateCarryNew = 1f + Mathf.Max(0f, lateCarrySaved - 1f) * (1f - num); __instance.carryWeight = lateCarryNew; lateCarry = true; } } } [HarmonyPatch("LateUpdate")] [HarmonyPostfix] [HarmonyPriority(600)] private static void LatePostfix(PlayerControllerB __instance) { if (lateCarry) { __instance.carryWeight = Restore(__instance.carryWeight, lateCarrySaved, lateCarryNew); lateCarry = false; } if (staminaBefore < 0f) { return; } try { float num = __instance.sprintMeter - staminaBefore; if (num > 0f) { __instance.sprintMeter = Mathf.Clamp01(staminaBefore + num * Buffs.RefillMul()); } else if (num < 0f) { __instance.sprintMeter = Mathf.Clamp01(staminaBefore + num * Buffs.DrainMul()); } if (Buffs.Has(BuffKind.Dehydration)) { __instance.sprintMeter = Mathf.Clamp01(__instance.sprintMeter - SodaConfig.Instance.DehydrationDrain.Value * Time.deltaTime); } } catch (Exception e) { Once("stamina", e); } staminaBefore = -1f; } [HarmonyPatch("DamagePlayer")] [HarmonyPrefix] [HarmonyPriority(600)] private static bool Damage(PlayerControllerB __instance, ref int damageNumber, bool fallDamage) { if (!Local.Is(__instance) || SodaConfig.Instance == null) { return true; } if (Lightning.Striking && Buffs.Has(BuffKind.Adapted)) { return false; } float num = Buffs.DamageMul(); if (num < 1f && damageNumber > 0) { damageNumber = Mathf.Max(1, Mathf.RoundToInt((float)damageNumber * num)); } if (!FrailtyBridge.Installed && damageNumber > 0 && !fallDamage && !__instance.isPlayerDead && __instance.AllowPlayerDeath()) { Kosher.Hit(damageNumber); } return true; } [HarmonyPatch("KillPlayer")] [HarmonyPrefix] [HarmonyPriority(600)] private static bool Kill(PlayerControllerB __instance) { if (Local.Is(__instance) && Lightning.Striking) { return !Buffs.Has(BuffKind.Adapted); } return true; } [HarmonyPatch("CheckConditionsForSinkingInQuicksand")] [HarmonyPostfix] private static void Quicksand(PlayerControllerB __instance, ref bool __result) { if (__result && Local.Is(__instance) && Buffs.Has(BuffKind.Adapted)) { __result = false; } } internal static void Once(string key, Exception e) { if (logged.Add(key)) { Plugin.Log.LogError((object)(key + ": " + e)); } } } [HarmonyPatch(typeof(StormyWeather), "LightningStrike")] internal static class Lightning { internal static bool Striking; [HarmonyPrefix] private static void Prefix() { Striking = true; } [HarmonyFinalizer] private static void Finalizer() { Striking = false; } } [HarmonyPatch] internal static class MeleePatches { private static readonly FieldRef<Shovel, PlayerControllerB> shovelHolder = AccessTools.FieldRefAccess<Shovel, PlayerControllerB>("previousPlayerHeldBy"); [HarmonyPatch(typeof(Shovel), "HitShovel")] [HarmonyPrefix] private static void ShovelPrefix(Shovel __instance, out int __state) { __state = int.MinValue; PlayerControllerB p = shovelHolder.Invoke(__instance) ?? ((GrabbableObject)__instance).playerHeldBy; float num = Buffs.MeleeMul(); if (num > 1f && Local.Is(p)) { __state = __instance.shovelHitForce; __instance.shovelHitForce = Mathf.Max(1, Mathf.RoundToInt((float)__state * num)); } } [HarmonyPatch(typeof(Shovel), "HitShovel")] [HarmonyFinalizer] private static void ShovelFinalizer(Shovel __instance, int __state) { if (__state != int.MinValue) { __instance.shovelHitForce = __state; } } [HarmonyPatch(typeof(KnifeItem), "HitKnife")] [HarmonyPrefix] private static void KnifePrefix(KnifeItem __instance, out int __state) { __state = int.MinValue; PlayerControllerB p = __instance.previousPlayerHeldBy ?? ((GrabbableObject)__instance).playerHeldBy; float num = Buffs.MeleeMul(); if (num > 1f && Local.Is(p)) { __state = __instance.knifeHitForce; __instance.knifeHitForce = Mathf.Max(1, Mathf.RoundToInt((float)__state * num)); } } [HarmonyPatch(typeof(KnifeItem), "HitKnife")] [HarmonyFinalizer] private static void KnifeFinalizer(KnifeItem __instance, int __state) { if (__state != int.MinValue) { __instance.knifeHitForce = __state; } } } public enum BuffKind { SugarRush, WebRush, SugarCrash, Hydration, Dehydration, SugarMend, Brawn, Swift, Spring, SecondWind, Endurance, Hyponatremia, Equilibrium, Adrenaline, Equivalence, SharpSight, Exquisite, CheeseSense, Adapted, Silent, ColdOne, Tipsy, Drunk, Wobbly, Staggering, BigBurp, FizzJump, Lucky, DangerSense, CrewSense, LockedIn, Party, HotStuff, Chill, WellMakeIt } public class Buff { public BuffKind kind; public float end; public float length; public float healLeft; public float healPending; public float crashAfter; public int tier = 1; public float damage; public int count; public bool linger; public float Left => Mathf.Max(0f, end - Time.time); } public static class Buffs { private static readonly Dictionary<BuffKind, Buff> active = new Dictionary<BuffKind, Buff>(); private static readonly List<Buff> expired = new List<Buff>(); private static int healedSinceSync; public static IEnumerable<Buff> All => active.Values; private static SodaConfig C => SodaConfig.Instance; public static bool Has(BuffKind k) { return active.ContainsKey(k); } public static Buff Get(BuffKind k) { if (!active.TryGetValue(k, out var value)) { return null; } return value; } public static Buff Add(BuffKind k, float seconds) { if (seconds <= 0f) { return null; } if (!active.TryGetValue(k, out var value)) { value = new Buff { kind = k, end = Time.time + seconds, length = seconds }; active[k] = value; } else if (value.Left < seconds) { value.end = Time.time + seconds; value.length = seconds; } return value; } public static void Remove(BuffKind k) { active.Remove(k); } public static void SetLeft(Buff b, float seconds) { b.end = Time.time + seconds; b.length = Mathf.Max(b.length, seconds); } public static void Clear() { active.Clear(); Kosher.Reset(); } public static bool IsDebuff(BuffKind k) { if (k != BuffKind.SugarCrash && k != BuffKind.Hyponatremia && k != BuffKind.Dehydration && k != BuffKind.Wobbly) { return k == BuffKind.Staggering; } return true; } public static void ClearDebuffs() { Remove(BuffKind.SugarCrash); Remove(BuffKind.Hyponatremia); Remove(BuffKind.Dehydration); Remove(BuffKind.Wobbly); Remove(BuffKind.Staggering); } internal static void Tick(PlayerControllerB player) { if (active.Count == 0) { return; } if (player.isPlayerDead) { Clear(); return; } float deltaTime = Time.deltaTime; Kosher.Tick(player); expired.Clear(); foreach (Buff value in active.Values) { if (value.healLeft > 0f || value.healPending > 0f) { Heal(player, value, deltaTime); } if (Time.time >= value.end) { expired.Add(value); } } foreach (Buff item in expired) { active.Remove(item.kind); if ((item.kind == BuffKind.SugarRush || item.kind == BuffKind.WebRush) && item.crashAfter > 0f && C.SugarCrash.Value && !Has(BuffKind.SugarRush) && !Has(BuffKind.WebRush)) { Add(BuffKind.SugarCrash, item.crashAfter); } } } private static void Heal(PlayerControllerB player, Buff b, float dt) { float num = b.healLeft / Mathf.Max(0.05f, b.Left); float num2 = Mathf.Min(b.healLeft, num * dt); if (Time.time + dt >= b.end || b.healLeft - num2 < 0.01f) { num2 = b.healLeft; } b.healLeft -= num2; b.healPending += num2; int num3; if (b.healLeft <= 0f) { b.healLeft = 0f; num3 = Mathf.RoundToInt(b.healPending); b.healPending = 0f; if (num3 <= 0) { return; } } else { num3 = Mathf.FloorToInt(b.healPending + 0.001f); if (num3 <= 0) { return; } b.healPending = Mathf.Max(0f, b.healPending - (float)num3); } GiveHealth(player, num3, evenWhileBleeding: false, b.healLeft < 1f); } internal static void GiveHealth(PlayerControllerB player, int n, bool evenWhileBleeding, bool last = false) { if (n <= 0 || player.health >= 100) { return; } player.health = Mathf.Min(100, player.health + n); if (evenWhileBleeding && FrailtyBridge.Installed) { FrailtyBridge.AcceptHealth(); } HUDManager.Instance.UpdateHealthUI(player.health, false); if (player.health >= 20 && player.criticallyInjured) { player.MakeCriticallyInjured(false); } healedSinceSync += n; if (healedSinceSync >= 5 || player.health >= 100 || last) { healedSinceSync = 0; if (FrailtyBridge.Installed) { FrailtyBridge.SyncHealth(player); } } } public static float SpeedMul() { float num = (Has(BuffKind.SugarRush) ? C.RushSpeed.Value : 0f); float num2 = (Has(BuffKind.WebRush) ? C.WebSpeed.Value : 0f); float num3 = (Has(BuffKind.Swift) ? C.GenericSpeed.Value : 0f); float num4 = (Has(BuffKind.Exquisite) ? C.ExqSpeed.Value : 0f); Buff buff = Get(BuffKind.Adrenaline); float num5 = ((buff != null) ? Kosher.AdrenalineSpeed(buff.tier) : 0f); float num6 = (Has(BuffKind.Party) ? Party.SpeedPct : 0f); float num7 = (Has(BuffKind.Drunk) ? C.DrunkSpeed.Value : (Has(BuffKind.Tipsy) ? (C.DrunkSpeed.Value / 2f) : 0f)); float num8 = 1f; if (C.SpeedBalance.Value) { float num9 = Mathf.Max(num, Mathf.Max(num2, Mathf.Max(num3, Mathf.Max(num4, Mathf.Max(num5, Mathf.Max(num6, num7)))))); num8 *= 1f + Mathf.Max(0f, num9) / 100f; } else { num8 *= (1f + num / 100f) * (1f + num2 / 100f) * (1f + num3 / 100f) * (1f + num4 / 100f) * (1f + num5 / 100f) * (1f + num6 / 100f) * (1f + num7 / 100f); } if (Has(BuffKind.Hyponatremia)) { num8 *= 1f - C.HypoSlow.Value / 100f; } return num8 * Beer.SlipSpeedFix; } public static float JumpMul() { float num = 1f; if (Has(BuffKind.SugarRush)) { num *= 1f + C.RushJump.Value / 100f; } if (Has(BuffKind.WebRush)) { num *= 1f + C.WebJump.Value / 100f; } if (Has(BuffKind.Spring)) { num *= 1f + C.GenericJump.Value / 100f; } if (Has(BuffKind.Exquisite)) { num *= 1f + C.ExqJump.Value / 100f; } if (Has(BuffKind.Drunk)) { num *= 1f + C.DrunkJump.Value / 100f; } else if (Has(BuffKind.Tipsy)) { num *= 1f + C.DrunkJump.Value / 200f; } if (Has(BuffKind.Hyponatremia)) { num *= 1f - C.HypoSlow.Value / 100f; } return num; } public static float ClimbMul() { return (Has(BuffKind.Exquisite) ? (1f + C.ExqClimb.Value / 100f) : 1f) * (Has(BuffKind.LockedIn) ? (1f + C.LockedClimb.Value / 100f) : 1f); } public static float RefillMul() { float num = 1f; if (Has(BuffKind.Hydration)) { num *= C.HydrationRefill.Value; } if (Has(BuffKind.ColdOne)) { num *= C.ColdOneRefill.Value; } if (Has(BuffKind.SugarMend)) { num *= 1f + C.MendRefill.Value / 100f; } if (Has(BuffKind.SecondWind)) { num *= 1f + C.GenericRefill.Value / 100f; } if (Has(BuffKind.Party)) { num *= 1f + Party.RefillPct / 100f; } if (Has(BuffKind.Chill)) { num *= 1f + C.ChillRefill.Value / 100f; } if (Has(BuffKind.Exquisite)) { num *= 1f + C.ExqRefill.Value / 100f; } if (Has(BuffKind.SugarCrash)) { num *= 1f - C.CrashRefill.Value / 100f; } return num; } public static float DrainMul() { if (Has(BuffKind.Adrenaline)) { return 0f; } float num = 1f; if (Has(BuffKind.Endurance)) { num *= 1f - C.GenericEndurance.Value / 100f; } if (Has(BuffKind.Hyponatremia)) { num *= 1f + C.HypoDrain.Value / 100f; } return num; } public static float CarryReduce() { float num = (Has(BuffKind.Brawn) ? C.BrawnCarry.Value : 0f); float num2 = (Has(BuffKind.Drunk) ? C.DrunkCarry.Value : (Has(BuffKind.Tipsy) ? (C.DrunkCarry.Value / 2f) : 0f)); return Mathf.Clamp01(Mathf.Max(num, num2) / 100f); } public static float DamageMul() { float num = 1f; if (Has(BuffKind.Equivalence)) { num *= 1f - Mathf.Clamp01(C.EquivalenceReduction.Value / 100f); } if (Has(BuffKind.Tipsy) || Has(BuffKind.Drunk)) { num *= 1f - Mathf.Clamp01(C.BeerReduction.Value / 100f); } Buff buff = Get(BuffKind.WellMakeIt); if (buff != null) { num *= 1f - Mathf.Clamp01(((buff.tier == 2) ? C.CarryBodyReduction.Value : C.BodyReduction.Value) / 100f); } return num; } public static float MeleeMul() { return Mathf.Max(Has(BuffKind.Brawn) ? C.BrawnMelee.Value : 1f, Has(BuffKind.Drunk) ? C.DrunkMelee.Value : 1f); } public static float FovA