Decompiled source of JosyImplantsMod v0.0.2
JosyImplantsAndMoreA.0.dll
Decompiled 5 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using ScavLib.item; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ImplantsMod { public class Afterimage : MonoBehaviour { private SpriteRenderer renderer2; private Color baseColor; private float life; private float age; public static void Spawn(Body body, float life, Color color) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer[] componentsInChildren = ((Component)body).GetComponentsInChildren<SpriteRenderer>(false); foreach (SpriteRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && ((Renderer)val).enabled && !((Object)(object)val.sprite == (Object)null)) { GameObject val2 = new GameObject("implant_afterimage"); val2.transform.position = ((Component)val).transform.position; val2.transform.rotation = ((Component)val).transform.rotation; val2.transform.localScale = ((Component)val).transform.lossyScale; SpriteRenderer val3 = val2.AddComponent<SpriteRenderer>(); val3.sprite = val.sprite; val3.flipX = val.flipX; val3.flipY = val.flipY; ((Renderer)val3).sortingLayerID = ((Renderer)val).sortingLayerID; ((Renderer)val3).sortingOrder = ((Renderer)val).sortingOrder - 1; val3.color = color; Afterimage afterimage = val2.AddComponent<Afterimage>(); afterimage.renderer2 = val3; afterimage.baseColor = color; afterimage.life = life; } } } private void Update() { //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_005b: Unknown result type (might be due to invalid IL or missing references) age += Time.deltaTime; float num = 1f - age / life; if (num <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Color color = baseColor; color.a = baseColor.a * num; renderer2.color = color; } } public static class Assets { private static readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>(); private static readonly Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>(); private static AudioSource source; private static AudioSource dragSource; private static readonly Dictionary<string, Sprite> moodleSprites = new Dictionary<string, Sprite>(); public static void Init(GameObject host) { source = host.AddComponent<AudioSource>(); source.playOnAwake = false; source.spatialBlend = 0f; dragSource = host.AddComponent<AudioSource>(); dragSource.playOnAwake = false; dragSource.spatialBlend = 0f; } public static Texture2D Texture(string file) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (textures.TryGetValue(file, out var value)) { return value; } value = null; try { byte[] array = ReadBytes(file); if (array != null) { value = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(value, array)) { Object.Destroy((Object)(object)value); value = null; } else { ((Texture)value).filterMode = (FilterMode)0; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Texture " + file + ": " + ex.Message)); value = null; } textures[file] = value; return value; } public static Sprite MoodleSprite(string file) { //IL_0045: 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) if (moodleSprites.TryGetValue(file, out var value) && (Object)(object)value != (Object)null) { return value; } Texture2D val = Texture(file); if ((Object)(object)val == (Object)null) { return null; } value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); moodleSprites[file] = value; return value; } public static Sprite ItemSprite(string file, Sprite template) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Texture(file); if ((Object)(object)val == (Object)null) { return null; } float num = 32f; if ((Object)(object)template != (Object)null) { Rect rect = template.rect; if (((Rect)(ref rect)).width > 0f) { float num2 = (float)((Texture)val).width * template.pixelsPerUnit; rect = template.rect; num = num2 / ((Rect)(ref rect)).width; } } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), num); } public static void PlayDrag() { if (!((Object)(object)dragSource == (Object)null) && !dragSource.isPlaying) { AudioClip val = Clip("drag"); if (!((Object)(object)val == (Object)null)) { float value = Plugin.SoundVariation.Value; dragSource.clip = val; dragSource.pitch = 1f + Random.Range(0f - value, value); dragSource.volume = Mathf.Clamp01(Plugin.SoundVolume.Value); dragSource.Play(); } } } public static void StopDrag() { if ((Object)(object)dragSource != (Object)null && dragSource.isPlaying) { dragSource.Stop(); } } public static bool Has(string name) { return (Object)(object)Clip(name) != (Object)null; } public static void PlayFirst(string name, string fallback) { Play(Has(name) ? name : fallback); } public static void Play(string name) { if (!((Object)(object)source == (Object)null)) { AudioClip val = Clip(name); if (!((Object)(object)val == (Object)null)) { float value = Plugin.SoundVariation.Value; source.pitch = 1f + Random.Range(0f - value, value); source.PlayOneShot(val, Plugin.SoundVolume.Value * (1f + Random.Range(0f - value, value))); } } } public static Sprite EntitySprite(string file, float ppu) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Texture(file); if ((Object)(object)val == (Object)null) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), ppu); } public static AudioClip Clip(string name) { if (clips.TryGetValue(name, out var value)) { return value; } value = null; try { byte[] array = ReadBytes(name + ".wav"); if (array != null) { value = LoadWav(array, name); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sound " + name + ": " + ex.Message)); value = null; } clips[name] = value; return value; } private static byte[] ReadBytes(string file) { using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream(file); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } return array; } private static AudioClip LoadWav(byte[] b, string name) { if (b.Length < 44 || Encoding.ASCII.GetString(b, 0, 4) != "RIFF") { return null; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = -1; int num6 = 0; int num7 = 12; while (num7 + 8 <= b.Length) { string text = Encoding.ASCII.GetString(b, num7, 4); int num8 = BitConverter.ToInt32(b, num7 + 4); int num9 = num7 + 8; if (text == "fmt ") { num = BitConverter.ToInt16(b, num9); num2 = BitConverter.ToInt16(b, num9 + 2); num3 = BitConverter.ToInt32(b, num9 + 4); num4 = BitConverter.ToInt16(b, num9 + 14); } else if (text == "data") { num5 = num9; num6 = Math.Min(num8, b.Length - num9); break; } num7 = num9 + num8 + (num8 & 1); } if (num5 < 0 || num2 < 1 || num3 <= 0 || num4 < 8) { return null; } if (num != 1 && num != 3 && num != -2) { return null; } int num10 = num4 / 8; int num11 = num6 / num10 / num2; if (num11 <= 0) { return null; } float[] array = new float[num11 * num2]; float num13; for (int i = 0; i < array.Length; array[i] = num13, i++) { int num12 = num5 + i * num10; switch (num4) { case 8: num13 = (float)(b[num12] - 128) / 128f; continue; case 16: num13 = (float)BitConverter.ToInt16(b, num12) / 32768f; continue; case 24: num13 = (float)((b[num12] | (b[num12 + 1] << 8) | (b[num12 + 2] << 16)) << 8 >> 8) / 8388608f; continue; case 32: if (num == 3) { num13 = BitConverter.ToSingle(b, num12); continue; } break; } if (num4 == 32) { num13 = (float)BitConverter.ToInt32(b, num12) / 2.1474836E+09f; continue; } return null; } AudioClip obj = AudioClip.Create(name, num11, num2, num3, false); obj.SetData(array, 0); return obj; } } public class Burst : MonoBehaviour { private struct Particle { public Transform t; public SpriteRenderer r; public Vector2 vel; public float life; public float startScale; } private static Sprite dot; private static Sprite ring; private Particle[] particles; private Transform ringT; private SpriteRenderer ringR; private float age; private float ringLife = 0.3f; private Color color; public static void Spawn(Vector3 pos, int layerId, int order, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) EnsureSprites(); GameObject val = new GameObject("implant_burst"); val.transform.position = pos; Burst burst = val.AddComponent<Burst>(); burst.color = color; GameObject val2 = new GameObject("ring"); val2.transform.SetParent(val.transform, false); burst.ringT = val2.transform; burst.ringT.localScale = Vector3.one * 0.3f; burst.ringR = val2.AddComponent<SpriteRenderer>(); burst.ringR.sprite = ring; ((Renderer)burst.ringR).sortingLayerID = layerId; ((Renderer)burst.ringR).sortingOrder = order; burst.ringR.color = color; int num = 16; burst.particles = new Particle[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / (float)num * (float)Math.PI * 2f + Random.Range(-0.2f, 0.2f); float num3 = Random.Range(4f, 9f); GameObject val3 = new GameObject("p"); val3.transform.SetParent(val.transform, false); SpriteRenderer val4 = val3.AddComponent<SpriteRenderer>(); val4.sprite = dot; ((Renderer)val4).sortingLayerID = layerId; ((Renderer)val4).sortingOrder = order; val4.color = color; float num4 = Random.Range(0.12f, 0.3f); val3.transform.localScale = Vector3.one * num4; burst.particles[i] = new Particle { t = val3.transform, r = val4, vel = new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * num3, life = Random.Range(0.3f, 0.55f), startScale = num4 }; } } public static Sprite RingSprite() { EnsureSprites(); return ring; } private static void EnsureSprites() { if ((Object)(object)dot == (Object)null) { dot = MakeSprite(32, 0f, 1f); } if ((Object)(object)ring == (Object)null) { ring = MakeSprite(64, 0.82f, 1f); } } private static Sprite MakeSprite(int size, float inner, float outer) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_00cc: 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_0097: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; float num = (float)(size - 1) * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num; float num3 = 0f; if (num2 <= outer && num2 >= inner) { num3 = Mathf.Clamp01(Mathf.Min((outer - num2) / 0.12f, (inner > 0f) ? ((num2 - inner) / 0.08f) : 1f)); } val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), (float)size); } private void Update() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007e: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) age += Time.deltaTime; bool flag = false; for (int i = 0; i < particles.Length; i++) { Particle particle = particles[i]; if (age >= particle.life) { ((Renderer)particle.r).enabled = false; continue; } flag = true; float num = 1f - age / particle.life; Transform t = particle.t; t.position += Vector2.op_Implicit(particle.vel * Time.deltaTime); particles[i].vel = particle.vel * (1f - 4f * Time.deltaTime); particle.t.localScale = Vector3.one * particle.startScale * num; Color val = color; val.a = color.a * num; particle.r.color = val; } if (age < ringLife) { flag = true; float num2 = age / ringLife; ringT.localScale = Vector3.one * Mathf.Lerp(0.3f, 3f, 1f - (1f - num2) * (1f - num2)); Color val2 = color; val2.a = color.a * (1f - num2); ringR.color = val2; } else { ((Renderer)ringR).enabled = false; } if (!flag) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class ChipState { public ImplantType Type; public Limb Limb; public Item Item; public RectTransform Chip; public RectTransform Target; public Image TargetImage; public bool Held; public bool Done; public Vector2 Offset; public Vector2 Home; public float Age; } public static class ChipGame { private const string ScreenId = "Special/ShrapnelMinigame"; private static readonly ConditionalWeakTable<ShrapnelMinigame, ChipState> states = new ConditionalWeakTable<ShrapnelMinigame, ChipState>(); public static void Begin(ImplantType type, Limb limb, Item item) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown MinigameBase main = MinigameBase.main; if (!((Object)(object)main == (Object)null)) { ShrapnelMinigame val = new ShrapnelMinigame(limb, false); ChipState value = new ChipState { Type = type, Limb = limb, Item = item }; states.Add(val, value); main.StartMinigame((Minigame)(object)val, item); } } public static bool Owns(ShrapnelMinigame mg, out ChipState s) { return states.TryGetValue(mg, out s); } private static Vector2 TargetFor(Limb limb) { //IL_005b: 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) Vector2 val = default(Vector2); if (((Object)limb).name == "UpTorso") { ((Vector2)(ref val))..ctor(-114f, 142f); } else if (((Object)limb).name == "DownTorso") { ((Vector2)(ref val))..ctor(-114f, -29f); } else { ((Vector2)(ref val))..ctor(-188f, -193f); } return val + new Vector2(Plugin.ChipTargetX.Value, Plugin.ChipTargetY.Value); } public static void Start(ChipState s) { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) MinigameBase main = MinigameBase.main; main.CreateScreen("Special/ShrapnelMinigame"); Transform transform = ((Component)main.spawnedMiniGame).transform; if (Plugin.DumpMinigame.Value) { for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null); Plugin.Log.LogInfo((object)("Minigame child " + i + " " + ((Object)child).name + " active=" + ((Component)child).gameObject.activeSelf + (((Object)(object)val != (Object)null) ? (" pos=" + ((object)val.anchoredPosition/*cast due to .constrained prefix*/).ToString() + " size=" + ((object)val.sizeDelta/*cast due to .constrained prefix*/).ToString()) : ""))); } } for (int j = 0; j < 5 && j < transform.childCount; j++) { ((Component)transform.GetChild(j)).gameObject.SetActive(false); } GameObject val2 = new GameObject("implant_target", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(transform, false); s.Target = val2.GetComponent<RectTransform>(); s.Target.anchoredPosition = TargetFor(s.Limb); s.TargetImage = val2.GetComponent<Image>(); Sprite val3 = Assets.MoodleSprite("target.png"); Rect rect; if ((Object)(object)val3 != (Object)null) { s.TargetImage.sprite = val3; RectTransform target = s.Target; rect = val3.rect; float width = ((Rect)(ref rect)).width; rect = val3.rect; target.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height) * Plugin.TargetScale.Value; ((Graphic)s.TargetImage).color = Color.white; } else { s.TargetImage.sprite = Burst.RingSprite(); s.Target.sizeDelta = new Vector2(120f, 120f); ((Graphic)s.TargetImage).color = new Color(0.3f, 0.65f, 1f, 0.9f); } ((Graphic)s.TargetImage).raycastTarget = false; GameObject val4 = new GameObject("implant_chip", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(transform, false); s.Chip = val4.GetComponent<RectTransform>(); Image component = val4.GetComponent<Image>(); Sprite val5 = (component.sprite = Assets.MoodleSprite("chip.png")); ((Graphic)component).raycastTarget = true; float value = Plugin.ChipScale.Value; RectTransform chip = s.Chip; Vector2 sizeDelta; if (!((Object)(object)val5 != (Object)null)) { sizeDelta = new Vector2(120f, 140f); } else { rect = val5.rect; float num = ((Rect)(ref rect)).width * value; rect = val5.rect; sizeDelta = new Vector2(num, ((Rect)(ref rect)).height * value); } chip.sizeDelta = sizeDelta; s.Home = new Vector2(300f, -230f); s.Chip.anchoredPosition = s.Home; } public static void Tick(ChipState s, List<RaycastResult> uiCasts) { //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_00ac: 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) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (s.Done || (Object)(object)s.Chip == (Object)null) { return; } MinigameBase main = MinigameBase.main; s.Age += Time.unscaledDeltaTime; if (!s.Held) { if (!main.handStartedClicking || uiCasts == null) { return; } for (int i = 0; i < uiCasts.Count; i++) { RaycastResult val = uiCasts[i]; if ((Object)(object)((RaycastResult)(ref val)).gameObject == (Object)(object)((Component)s.Chip).gameObject) { s.Held = true; s.Offset = s.Chip.anchoredPosition - main.handPos; break; } } return; } s.Chip.anchoredPosition = main.handPos + s.Offset; if (((Vector2)(ref main.handVelocity)).magnitude > 0.5f) { Assets.PlayDrag(); } else { Assets.StopDrag(); } if (((Vector2)(ref main.handVelocity)).magnitude > Plugin.ChipMaxSpeed.Value) { Slip(s, main); } else if (main.handStoppedClicking) { s.Held = false; Assets.StopDrag(); Vector2 val2 = s.Chip.anchoredPosition - s.Target.anchoredPosition; if (((Vector2)(ref val2)).magnitude <= Plugin.ChipTargetRadius.Value) { s.Done = true; Plugin.FinishInstall(s.Type, s.Limb, s.Item); main.EndMinigame(); } else { s.Chip.anchoredPosition = s.Home; } } } private static void Slip(ChipState s, MinigameBase game) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) s.Held = false; Assets.StopDrag(); game.ForceUngrab(); s.Chip.anchoredPosition = s.Home; Limb limb = s.Limb; limb.skinHealth = Mathf.Max(0f, limb.skinHealth - Random.Range(4f, 6f)); limb.bleedAmount += Random.Range(0.4f, 1f); limb.pain += Random.Range(9f, 16f); if ((Object)(object)limb.body != (Object)null) { limb.body.DoGoreSound(); } } } [HarmonyPatch(typeof(ShrapnelMinigame), "Start")] internal static class ChipStartPatch { private static bool Prefix(ShrapnelMinigame __instance) { if (!ChipGame.Owns(__instance, out var s)) { return true; } ChipGame.Start(s); return false; } } [HarmonyPatch(typeof(ShrapnelMinigame), "Update")] internal static class ChipUpdatePatch { private static bool Prefix(ShrapnelMinigame __instance, List<RaycastResult> uiCasts) { if (!ChipGame.Owns(__instance, out var s)) { return true; } ChipGame.Tick(s, uiCasts); return false; } } [HarmonyPatch(typeof(ShrapnelMinigame), "GuideLocaleString")] internal static class ChipGuidePatch { private static void Postfix(ShrapnelMinigame __instance, ref string __result) { if (ChipGame.Owns(__instance, out var _)) { __result = "Carefully carry the chip to the marked spot and release it. Fast movement tears the wound."; } } } [HarmonyPatch(typeof(MinigameBase), "EndMinigame")] internal static class ChipEndPatch { private static void Postfix() { Assets.StopDrag(); } } public static class ConfigClean { public static void Run(ConfigFile c) { try { c.Save(); string configFilePath = c.ConfigFilePath; List<string> list = new List<string>(); string[] array = File.ReadAllLines(configFilePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (!text.StartsWith("#") && (text.Length != 0 || (list.Count != 0 && list[list.Count - 1].Length != 0))) { list.Add(text); } } File.WriteAllLines(configFilePath, list.ToArray()); } catch (Exception) { } } } public static class CrateLoot { private static readonly HashSet<int> rolled = new HashSet<int>(); public static void OnDestroyed(BuildingEntity building) { //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (rolled.Count > 4096) { rolled.Clear(); } if (!rolled.Add(((Object)building).GetInstanceID())) { return; } string text = (building.id ?? string.Empty).ToLowerInvariant(); if (Plugin.LogBuildings.Value) { Plugin.Log.LogInfo((object)("Building destroyed: " + text)); } if (Matches(text) && !(Random.value > Plugin.DropChance.Value)) { List<string> list = new List<string>(); if (Plugin.AllowDuplicateDrops.Value || !ImplantState.Impulse) { list.Add("implants_impulse"); } if (Plugin.AllowDuplicateDrops.Value || !ImplantState.Spatial) { list.Add("implants_spatial"); } if (Plugin.AllowDuplicateDrops.Value || !ImplantState.Medical) { list.Add("implants_medical"); } if (Plugin.AllowDuplicateDrops.Value || !ImplantState.Quantum) { list.Add("implants_quantum"); } int num = Mathf.RoundToInt(TumorBotConfig.DropWeight.Value); for (int i = 0; i < num; i++) { list.Add("implants_tumorbot"); } if (list.Count != 0) { Vector3 position = ((Component)building).transform.position; Spawn(list[Random.Range(0, list.Count)], new Vector2(position.x, position.y)); } } } public static void Spawn(string itemId, Vector2 position) { //IL_0001: 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) GameObject val = Utils.Create(itemId, position, 0f); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Could not create item " + itemId)); return; } Rigidbody2D component = val.GetComponent<Rigidbody2D>(); if ((Object)(object)component != (Object)null) { component.velocity = new Vector2(Random.Range(-2f, 2f), Random.Range(1f, 4f)); } } private static bool Matches(string id) { string[] array = Plugin.CrateKeywords.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().ToLowerInvariant(); if (text.Length > 0 && id.Contains(text)) { return true; } } return false; } } public static class GramophoneConfig { public static ConfigEntry<float> SpawnChance; public static ConfigEntry<float> Scale; public static ConfigEntry<float> TriggerRadius; public static ConfigEntry<float> MusicRange; public static ConfigEntry<float> MusicVolume; public static ConfigEntry<int> Beeps; public static ConfigEntry<float> BeepInterval; public static ConfigEntry<float> BeepVolume; public static ConfigEntry<bool> CancelOnLeave; public static ConfigEntry<float> MinWalkDistance; public static ConfigEntry<float> MaxWalkDistance; public static ConfigEntry<KeyCode> DebugKey; public static void Bind(ConfigFile c) { SpawnChance = c.Bind<float>("gram", "chance", 0.5f, ""); Scale = c.Bind<float>("gram", "scale", 3f, ""); TriggerRadius = c.Bind<float>("gram", "radius", 9f, ""); MusicRange = c.Bind<float>("gram", "mus_range", 55f, ""); MusicVolume = c.Bind<float>("gram", "mus_vol", 1f, ""); Beeps = c.Bind<int>("gram", "beeps", 4, ""); BeepInterval = c.Bind<float>("gram", "beep_int", 1f, ""); BeepVolume = c.Bind<float>("gram", "beep_vol", 0.9f, ""); CancelOnLeave = c.Bind<bool>("gram", "cancel", true, ""); MinWalkDistance = c.Bind<float>("gram", "min_dist", 70f, ""); MaxWalkDistance = c.Bind<float>("gram", "max_dist", 220f, ""); DebugKey = c.Bind<KeyCode>("dbg", "key_gram", (KeyCode)291, ""); } } public class GramophoneEntity : MonoBehaviour { public static readonly List<GramophoneEntity> All = new List<GramophoneEntity>(); private AudioSource music; private AudioSource beeper; private SpriteRenderer rend; private bool triggered; private bool finished; private int beepsDone; private float timer; public static GramophoneEntity Create(Vector2 pos, Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0043: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ImplantsGramophone"); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, true); } float num = Mathf.Max(0.5f, GramophoneConfig.Scale.Value); val.transform.localScale = new Vector3(num, num, 1f); val.transform.position = new Vector3(pos.x, pos.y + (num - 1f) * 0.5f, 0f); return val.AddComponent<GramophoneEntity>(); } private void Awake() { All.Add(this); rend = ((Component)this).gameObject.AddComponent<SpriteRenderer>(); rend.sprite = Assets.EntitySprite("gramophone.png", 32f); GramophoneLook.Apply(rend); music = ((Component)this).gameObject.AddComponent<AudioSource>(); music.playOnAwake = false; music.spatialBlend = 0f; music.loop = true; music.volume = 0f; music.clip = Assets.Clip("gramophone_music"); beeper = ((Component)this).gameObject.AddComponent<AudioSource>(); beeper.playOnAwake = false; beeper.spatialBlend = 0f; if ((Object)(object)music.clip != (Object)null) { music.time = Random.value * music.clip.length * 0.9f; music.Play(); } } private void OnDestroy() { All.Remove(this); } private void Update() { //IL_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) PlayerCamera main = PlayerCamera.main; Body val = (((Object)(object)main != (Object)null) ? main.body : null); if ((Object)(object)val == (Object)null || (Object)(object)rend == (Object)null) { SetMusic(0f, 0f); return; } Vector3 position = ((Component)val).transform.position; Vector3 position2 = ((Component)this).transform.position; float num = position2.x - position.x; float num2 = position2.y - position.y; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Max(5f, GramophoneConfig.MusicRange.Value); float num5 = Mathf.Clamp01(1f - num3 / num4); num5 = Mathf.Sqrt(num5) * GramophoneConfig.MusicVolume.Value; float pan = Mathf.Clamp(num / 18f, -1f, 1f) * 0.85f; if (!val.alive) { num5 *= 0.3f; } SetMusic(num5, pan); if (finished || !val.alive) { return; } float num6 = Mathf.Max(1f, GramophoneConfig.TriggerRadius.Value); if (!triggered) { if (num3 <= num6) { triggered = true; beepsDone = 0; timer = 0f; } return; } if (GramophoneConfig.CancelOnLeave.Value && num3 > num6) { triggered = false; beepsDone = 0; if ((Object)(object)beeper != (Object)null) { beeper.Stop(); } return; } timer -= Time.deltaTime; if (timer > 0f) { return; } int num7 = Mathf.Max(1, GramophoneConfig.Beeps.Value); if (beepsDone < num7) { DoBeep(main, beepsDone, num7); beepsDone++; timer = Mathf.Max(0.2f, GramophoneConfig.BeepInterval.Value); if (beepsDone >= num7) { timer *= 0.8f; } return; } finished = true; GramophoneWorld.Consumed(this); try { main.StartSelfDestruct(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gramophone self-destruct failed: " + ex.Message)); } } private void SetMusic(float volume, float pan) { if (!((Object)(object)music == (Object)null) && !((Object)(object)music.clip == (Object)null)) { music.volume = volume; music.panStereo = pan; bool flag = Time.timeScale <= 0.001f; if (flag && music.isPlaying) { music.Pause(); } else if (!flag && !music.isPlaying) { music.UnPause(); } } } private void DoBeep(PlayerCamera cam, int index, int total) { AudioClip val = GramophoneSounds.Beep(); if ((Object)(object)val != (Object)null && (Object)(object)beeper != (Object)null) { float num = ((total <= 1) ? 1f : ((float)index / (float)(total - 1))); beeper.pitch = Mathf.Lerp(0.9f, 1.45f, num); beeper.PlayOneShot(val, Mathf.Clamp01(GramophoneConfig.BeepVolume.Value * Plugin.SoundVolume.Value)); } if ((Object)(object)cam != (Object)null && cam.shaker != null) { cam.shaker.Shake(18f + (float)index * 14f); } } } public static class GramophoneSounds { private static AudioClip beep; public static AudioClip Beep() { if ((Object)(object)beep != (Object)null) { return beep; } int num = 44100; int num2 = (int)((float)num * 0.22f); float[] array = new float[num2]; for (int i = 0; i < num2; i++) { float num3 = (float)i / (float)num; float num4 = Mathf.Min(1f, (float)i / 120f) * Mathf.Clamp01(1f - (float)i / (float)num2); float num5 = Mathf.Sin((float)Math.PI * 2900f * num3) * 0.8f + Mathf.Sin((float)Math.PI * 5800f * num3) * 0.2f; array[i] = num5 * num4 * 0.7f; } beep = AudioClip.Create("gramophone_beep", num2, 1, num, false); beep.SetData(array, 0); return beep; } } public static class GramophoneLook { private static bool searched; private static Material mat; private static int layerId; private static int order = 5; public static void Apply(SpriteRenderer target) { if (!searched) { searched = true; try { SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>(); foreach (SpriteRenderer val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Renderer)val).sharedMaterial == (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<BuildingEntity>() == (Object)null)) { mat = ((Renderer)val).sharedMaterial; layerId = ((Renderer)val).sortingLayerID; order = ((Renderer)val).sortingOrder; break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gramophone look: " + ex.Message)); } } if ((Object)(object)mat != (Object)null) { ((Renderer)target).sharedMaterial = mat; } ((Renderer)target).sortingLayerID = layerId; ((Renderer)target).sortingOrder = order; } public static void Reset() { searched = false; mat = null; } } public static class GramophoneWorld { private static bool need; private static bool restore; private static bool wasGenerating; private static float readyDelay; private static string FilePath => Path.Combine(Application.persistentDataPath, "implants_gramophone.txt"); public static void OnNewBody() { need = true; restore = SaveSystem.loadedRun; readyDelay = 0f; GramophoneLook.Reset(); if (!restore) { DeleteFile(); } } public static void Tick(Body body) { WorldGeneration world = WorldGeneration.world; if ((Object)(object)world == (Object)null) { return; } bool generatingWorld = world.generatingWorld; if (wasGenerating && !generatingWorld && !need) { need = true; restore = false; readyDelay = 0f; DeleteFile(); } wasGenerating = generatingWorld; TickDebug(body); if (!need || generatingWorld || !world.worldExists || !body.alive) { return; } readyDelay += Time.deltaTime; if (readyDelay < 1.5f) { return; } need = false; try { if (restore) { Restore(world); } else { Roll(world, body); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gramophone placement failed: " + ex)); } } private static Transform GridParent(WorldGeneration wg) { if ((Object)(object)wg == (Object)null || (Object)(object)wg.worldGrid == (Object)null) { return null; } return ((Component)wg.worldGrid).transform; } private static void Roll(WorldGeneration wg, Body body) { //IL_0046: 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) float value = GramophoneConfig.SpawnChance.Value; if (value <= 0f || Random.value > value) { Plugin.Log.LogInfo((object)"Gramophone: not placed on this layer"); return; } if (!FindSpot(wg, body, out var result)) { Plugin.Log.LogInfo((object)"Gramophone: no suitable spot found"); return; } GramophoneEntity.Create(result, GridParent(wg)); SaveFile(result); Plugin.Log.LogInfo((object)("Gramophone placed at " + result.x.ToString("F1") + ", " + result.y.ToString("F1"))); } private static void Restore(WorldGeneration wg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) try { if (File.Exists(FilePath)) { string[] array = File.ReadAllText(FilePath).Trim().Split(new char[1] { ' ' }); if (array.Length == 2) { float num = float.Parse(array[0], CultureInfo.InvariantCulture); float num2 = float.Parse(array[1], CultureInfo.InvariantCulture); GramophoneEntity.Create(new Vector2(num, num2), GridParent(wg)); Plugin.Log.LogInfo((object)("Gramophone restored at " + num.ToString("F1") + ", " + num2.ToString("F1"))); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gramophone restore failed: " + ex.Message)); } } public static void Consumed(GramophoneEntity g) { DeleteFile(); } private static void SaveFile(Vector2 pos) { try { File.WriteAllText(FilePath, pos.x.ToString("F2", CultureInfo.InvariantCulture) + " " + pos.y.ToString("F2", CultureInfo.InvariantCulture)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save gramophone: " + ex.Message)); } } private static void DeleteFile() { try { if (File.Exists(FilePath)) { File.Delete(FilePath); } } catch (Exception) { } } private static void TickDebug(Body body) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0045: 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_005e: 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_006a: Unknown result type (might be due to invalid IL or missing references) KeyCode value = GramophoneConfig.DebugKey.Value; if ((int)value != 0 && Input.GetKeyDown(value)) { Camera main = Camera.main; Vector3 val = (((Object)(object)main != (Object)null) ? main.ScreenToWorldPoint(Input.mousePosition) : (((Component)body).transform.position + new Vector3(8f, 0f, 0f))); WorldGeneration world = WorldGeneration.world; GramophoneEntity.Create(new Vector2(val.x, val.y), GridParent(world)); Plugin.Log.LogInfo((object)"Debug: gramophone placed at cursor"); } } private static bool FindSpot(WorldGeneration wg, Body body, out Vector2 result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //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_0059: 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_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) result = Vector2.zero; int width = (int)wg.width; int height = (int)wg.height; int num = Mathf.Max(40, (int)GramophoneConfig.MaxWalkDistance.Value); int num2 = Mathf.Clamp((int)GramophoneConfig.MinWalkDistance.Value, 10, num - 10); Vector2Int val = wg.WorldToBlockPos(Vector2.op_Implicit(((Component)body).transform.position)); Plugin.Log.LogInfo((object)("Gramophone search: world " + width + "x" + height + ", start " + ((Vector2Int)(ref val)).x + "," + ((Vector2Int)(ref val)).y)); int num3 = Mathf.Max(1, ((Vector2Int)(ref val)).x - num); int num4 = Mathf.Min(width - 2, ((Vector2Int)(ref val)).x + num); int num5 = Mathf.Max(1, ((Vector2Int)(ref val)).y - num); int num6 = Mathf.Min(height - 2, ((Vector2Int)(ref val)).y + num); int num7 = num4 - num3 + 1; int num8 = num6 - num5 + 1; if (num7 < 10 || num8 < 10) { return false; } bool[] array = new bool[num7 * num8]; for (int i = 0; i < num8; i++) { for (int j = 0; j < num7; j++) { array[i * num7 + j] = wg.GetBlock(new Vector2Int(num3 + j, num5 + i)) == 0; } } int num9 = ((Vector2Int)(ref val)).x - num3; int num10 = ((Vector2Int)(ref val)).y - num5; if (num9 < 0 || num10 < 0 || num9 >= num7 || num10 >= num8) { return false; } if (!array[num10 * num7 + num9]) { bool flag = false; for (int k = 1; k < 6; k++) { if (flag) { break; } for (int l = -k; l <= k; l++) { if (flag) { break; } for (int m = -k; m <= k; m++) { if (flag) { break; } int num11 = num9 + m; int num12 = num10 + l; if (num11 >= 0 && num12 >= 0 && num11 < num7 && num12 < num8 && array[num12 * num7 + num11]) { num9 = num11; num10 = num12; flag = true; } } } } if (!flag) { return false; } } int[] array2 = new int[num7 * num8]; for (int n = 0; n < array2.Length; n++) { array2[n] = int.MaxValue; } List<int>[] array3 = new List<int>[num + 8 + 2]; for (int num13 = 0; num13 < array3.Length; num13++) { array3[num13] = new List<int>(); } array2[num10 * num7 + num9] = 0; array3[0].Add(num10 * num7 + num9); int num14 = 0; for (int num15 = 0; num15 <= num; num15++) { List<int> list = array3[num15]; for (int num16 = 0; num16 < list.Count; num16++) { int num17 = list[num16]; if (array2[num17] != num15) { continue; } num14++; int num18 = num17 % num7; int num19 = num17 / num7; for (int num20 = 0; num20 < 4; num20++) { int num21 = num18 + num20 switch { 1 => -1, 0 => 1, _ => 0, }; int num22 = num19 + num20 switch { 3 => -1, 2 => 1, _ => 0, }; if (num21 >= 0 && num22 >= 0 && num21 < num7 && num22 < num8) { int num23 = num22 * num7 + num21; int num24 = num15 + (array[num23] ? 1 : 8); if (num24 <= num && num24 < array2[num23]) { array2[num23] = num24; array3[num24].Add(num23); } } } } list.Clear(); } int num25 = 0; int num26 = 0; for (int num27 = 0; num27 < array.Length; num27++) { if (array[num27]) { num25++; } } float num28 = float.MinValue; int num29 = -1; int num30 = -1; for (int num31 = 2; num31 < num8 - 2; num31++) { for (int num32 = 2; num32 < num7 - 2; num32++) { int num33 = num31 * num7 + num32; int num34 = array2[num33]; if (num34 != int.MaxValue && num34 >= num2 && num34 <= num && array[num33] && !array[(num31 - 1) * num7 + num32]) { num26++; int num35; for (num35 = 0; num35 < 8 && num31 + 1 + num35 < num8 && array[(num31 + 1 + num35) * num7 + num32]; num35++) { } int num36; for (num36 = 0; num36 < 8 && num32 - 1 - num36 >= 0 && array[num31 * num7 + num32 - 1 - num36]; num36++) { } int num37; for (num37 = 0; num37 < 8 && num32 + 1 + num37 < num7 && array[num31 * num7 + num32 + 1 + num37]; num37++) { } int num38 = num36 + num37 + 1; float num39 = (float)(8 - num35) * 1.2f + (float)(16 - Mathf.Min(num38, 16)) * 0.35f; if (num35 < 4) { num39 -= 20f; } num39 += Random.value * 2.5f; if (num39 > num28) { num28 = num39; num29 = num32; num30 = num31; } } } } Plugin.Log.LogInfo((object)("Gramophone search: box " + num7 + "x" + num8 + ", air " + num25 + ", reached " + num14 + ", candidates " + num26)); if (num29 < 0) { return false; } result = wg.BlockToWorldPos(new Vector2Int(num3 + num29, num5 + num30)); return true; } } public static class Text { public static string Name(ImplantType t) { return t switch { ImplantType.Impulse => "Impulse Implant", ImplantType.Spatial => "Spatial Implant", ImplantType.Medical => "Medical Implant", _ => "Quantum Implant", }; } public static string Description(ImplantType t) { return t switch { ImplantType.Impulse => "Install into the legs. Grants a double jump and reduces fall damage." + Requirements.Suffix(Requirements.Impulse.Value), ImplantType.Spatial => "Install into the pelvis. Grants a dash." + Requirements.Suffix(Requirements.Spatial.Value), ImplantType.Medical => "Install into the torso. Regenerates small wounds." + Requirements.Suffix(Requirements.Medical.Value), _ => "Install into the head. Grants a short-range teleport toward the cursor." + Requirements.Suffix(Requirements.Quantum.Value), }; } public static string Installed(ImplantType t) { return "Installed: " + Name(t); } public static string AlreadyInstalled(ImplantType t) { return "Already installed: " + Name(t); } public static string WrongPart(ImplantType t) { return t switch { ImplantType.Impulse => "This implant goes into the legs", ImplantType.Spatial => "This implant goes into the pelvis", ImplantType.Medical => "This implant goes into the torso", _ => "This implant goes into the head", }; } public static string TumorBotName() { return "Tumor Bot"; } public static string TumorBotDescription() { return "Apply to an infected body part. Take a painkiller first. You will fall asleep while it works. The infection will be gone, but a wound will remain." + Requirements.Suffix(Requirements.TumorBot.Value); } public static string TumorBotHint() { return "Apply it to an infected body part in the health panel"; } public static string TumorBotNoInfection() { return "No infection here"; } public static string TumorBotBusy() { return "The bot is already working"; } public static string TumorBotStarted() { return "The bot is working"; } public static string TumorBotDone() { return "The infection is gone"; } public static string UseHint() { return "Apply it to a body part in the health panel"; } } public static class Hud { private static string toast; private static float toastTime; private static GUIStyle toastStyle; private static GUIStyle labelStyle; public static void Toast(string message) { toast = message; toastTime = 3f; } public static void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (toastStyle == null) { toastStyle = new GUIStyle(GUI.skin.label); toastStyle.alignment = (TextAnchor)4; toastStyle.fontSize = 18; toastStyle.normal.textColor = new Color(0.6f, 0.85f, 1f, 1f); labelStyle = new GUIStyle(GUI.skin.label); labelStyle.alignment = (TextAnchor)4; labelStyle.fontSize = 12; labelStyle.normal.textColor = Color.white; } if (toastTime > 0f) { toastTime -= Time.unscaledDeltaTime; GUI.Label(new Rect(0f, 60f, (float)Screen.width, 40f), toast, toastStyle); } TumorBot.Draw(); } } public enum ImplantType { Impulse, Spatial, Medical, Quantum } public static class ImplantState { public static bool Impulse; public static bool Spatial; public static bool Medical; public static bool Quantum; private static string FilePath => Path.Combine(Application.persistentDataPath, "implants_state.txt"); public static bool Has(ImplantType type) { return type switch { ImplantType.Impulse => Impulse, ImplantType.Spatial => Spatial, ImplantType.Medical => Medical, _ => Quantum, }; } public static void Set(ImplantType type, bool value) { switch (type) { case ImplantType.Impulse: Impulse = value; break; case ImplantType.Spatial: Spatial = value; break; case ImplantType.Medical: Medical = value; break; default: Quantum = value; break; } } public static void Reset() { Impulse = false; Spatial = false; Medical = false; Quantum = false; } public static void Save() { try { File.WriteAllText(FilePath, "impulse=" + (Impulse ? 1 : 0) + "\nspatial=" + (Spatial ? 1 : 0) + "\nmedical=" + (Medical ? 1 : 0) + "\nquantum=" + (Quantum ? 1 : 0) + "\n"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save implant state: " + ex.Message)); } } public static void Load() { Reset(); try { if (!File.Exists(FilePath)) { return; } string[] array = File.ReadAllLines(FilePath); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }); if (array2.Length == 2) { bool flag = array2[1].Trim() == "1"; switch (array2[0].Trim()) { case "impulse": Impulse = flag; break; case "spatial": Spatial = flag; break; case "medical": Medical = flag; break; case "quantum": Quantum = flag; break; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load implant state: " + ex.Message)); Reset(); } } public static void DeleteFile() { try { if (File.Exists(FilePath)) { File.Delete(FilePath); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not delete implant state: " + ex.Message)); } } } internal static class PlayerCheck { public static bool IsPlayer(Body body) { PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null && (Object)(object)main.body != (Object)null) { return (Object)(object)main.body == (Object)(object)body; } return false; } } [HarmonyPatch(typeof(Body), "Jump")] internal static class JumpPatch { private static readonly MethodInfo wallLeft = AccessTools.PropertyGetter(typeof(Body), "canWalljumpLeft"); private static readonly MethodInfo wallRight = AccessTools.PropertyGetter(typeof(Body), "canWalljumpRight"); private static bool Prefix(Body __instance, ref float ___jumpCooldown, bool ___movingAllowed, float ___timeSinceGrounded) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!ImplantState.Impulse) { return true; } if (!PlayerCheck.IsPlayer(__instance)) { return true; } if (ImplantRuntime.AirJumpsLeft <= 0) { return true; } if (!Input.GetKeyDown(KeyBinds.GetBind("jump"))) { return true; } if (!__instance.standing || ___jumpCooldown > 0f || __instance.forceWalk || !___movingAllowed) { return true; } if (__instance.grounded || (Object)(object)__instance.currentClimbable != (Object)null || ___timeSinceGrounded <= 0.11f) { return true; } if ((Object)(object)__instance.bodyAffect != (Object)null && __instance.bodyAffect.wasWater) { return true; } if (wallLeft != null && (bool)wallLeft.Invoke(__instance, null)) { return true; } if (wallRight != null && (bool)wallRight.Invoke(__instance, null)) { return true; } ImplantRuntime.AirJump(__instance, ref ___jumpCooldown); return false; } } [HarmonyPatch(typeof(Limb), "ImpactDamage")] internal static class ImpactPatch { private static void Prefix(Limb __instance, ref float force) { if (PlayerCheck.IsPlayer(__instance.body)) { if (ImplantState.Impulse) { force *= Plugin.FallDamageMultiplier.Value; } if (ImplantState.Spatial && ImplantRuntime.DashActive) { force *= 0.15f; } } } } [HarmonyPatch(typeof(BuildingEntity), "CheckDamage")] internal static class CratePatch { private static void Prefix(BuildingEntity __instance) { if (!__instance.indestructible && !(__instance.health >= 0.5f)) { CrateLoot.OnDestroyed(__instance); } } } [HarmonyPatch(typeof(SaveSystem), "SaveGame")] internal static class SavePatch { private static void Postfix() { ImplantState.Save(); } } [HarmonyPatch(typeof(MoodleManager), "AddAllMoodles")] internal static class MoodlePatch { private static void Prefix(MoodleManager __instance, Body ___body) { if (!((Object)(object)___body == (Object)null) && ___body.alive && (ImplantState.Impulse || ImplantState.Spatial || ImplantState.Medical || ImplantState.Quantum)) { Add(__instance, ImplantType.Impulse, ImplantState.Impulse, "effect_impulse"); Add(__instance, ImplantType.Spatial, ImplantState.Spatial, "effect_spatial"); Add(__instance, ImplantType.Medical, ImplantState.Medical, "effect_medical"); Add(__instance, ImplantType.Quantum, ImplantState.Quantum, "effect_quantum"); } } private static void Add(MoodleManager m, ImplantType type, bool active, string key) { if (active && m.icons is Dictionary<string, Sprite> dictionary) { Sprite val = Assets.MoodleSprite(key + ".png"); if (!((Object)(object)val == (Object)null)) { dictionary[key] = val; m.AddMoodle(0, key, Text.Name(type), Text.Description(type), false, false); } } } } [BepInPlugin("com.implantsmod.scavprototype", "Implants", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Use <>9__58_0; public static Action<GameObject> <>9__58_1; internal void <RegisterTumorBot>b__58_0(Body body, Item item) { Hud.Toast(Text.TumorBotHint()); } internal void <RegisterTumorBot>b__58_1(GameObject go) { ApplyIcon(go, "tumorbot.png"); } } public const string Guid = "com.implantsmod.scavprototype"; public const string ImpulseId = "implants_impulse"; public const string SpatialId = "implants_spatial"; public const string MedicalId = "implants_medical"; public const string QuantumId = "implants_quantum"; public const string TumorBotId = "implants_tumorbot"; public static Plugin Instance; public static ManualLogSource Log; public static ConfigEntry<float> SoundVolume; public static ConfigEntry<KeyCode> DebugGiveKey; public static ConfigEntry<KeyCode> DebugInfectKey; public static ConfigEntry<KeyCode> DebugEffectsKey; public static ConfigEntry<bool> LogBuildings; public static ConfigEntry<float> DropChance; public static ConfigEntry<bool> AllowDuplicateDrops; public static ConfigEntry<string> CrateKeywords; public static ConfigEntry<int> AirJumps; public static ConfigEntry<float> AirJumpPower; public static ConfigEntry<float> AirJumpStaminaCost; public static ConfigEntry<float> FallDamageMultiplier; public static ConfigEntry<KeyCode> DashKey; public static ConfigEntry<float> DashSpeed; public static ConfigEntry<float> DashAngle; public static ConfigEntry<float> SoundVariation; public static ConfigEntry<bool> ChipMinigame; public static ConfigEntry<bool> DumpMinigame; public static ConfigEntry<float> ChipMaxSpeed; public static ConfigEntry<float> ChipTargetRadius; public static ConfigEntry<float> ChipScale; public static ConfigEntry<float> TargetScale; public static ConfigEntry<float> ChipTargetX; public static ConfigEntry<float> ChipTargetY; public static ConfigEntry<KeyCode> QuantumKey; public static ConfigEntry<float> QuantumRange; public static ConfigEntry<float> QuantumCooldown; public static ConfigEntry<float> QuantumHeat; public static ConfigEntry<float> QuantumPain; public static ConfigEntry<float> QuantumVomitChance; public static ConfigEntry<float> QuantumZoom; public static ConfigEntry<float> ImplantBleed; public static ConfigEntry<float> ImplantSkinDamage; public static ConfigEntry<float> ImplantPain; public static ConfigEntry<float> DashDuration; public static ConfigEntry<float> DashCooldown; public static ConfigEntry<float> DashBloodCost; public static ConfigEntry<float> DashMinBlood; public static ConfigEntry<float> RegenSkin; public static ConfigEntry<float> RegenBleed; public static ConfigEntry<float> RegenPain; public static ConfigEntry<float> SmallWoundSkinMin; public static ConfigEntry<float> SmallBleedMax; private Body lastBody; private float nextBeat; private int beats; private bool firstUpdate; private float nextItemCheck; private void Awake() { //IL_003e: 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_005b: 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_0088: Unknown result type (might be due to invalid IL or missing references) Instance = this; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Log = ((BaseUnityPlugin)this).Logger; BindConfig(); Log.LogInfo((object)("Implants loaded. GiveImplantsKey=" + ((object)DebugGiveKey.Value/*cast due to .constrained prefix*/).ToString() + " DashKey=" + ((object)DashKey.Value/*cast due to .constrained prefix*/).ToString())); Assets.Init(((Component)this).gameObject); new Harmony("com.implantsmod.scavprototype").PatchAll(); RegisterItem(ImplantType.Impulse, "implants_impulse", "implant.png"); RegisterItem(ImplantType.Spatial, "implants_spatial", "implant.png"); RegisterItem(ImplantType.Medical, "implants_medical", "implant.png"); RegisterItem(ImplantType.Quantum, "implants_quantum", "implant.png"); RegisterTumorBot(); } private void BindConfig() { SoundVariation = ((BaseUnityPlugin)this).Config.Bind<float>("gen", "snd_var", 0.08f, ""); ChipMinigame = ((BaseUnityPlugin)this).Config.Bind<bool>("mini", "on", true, ""); DumpMinigame = ((BaseUnityPlugin)this).Config.Bind<bool>("mini", "log", true, ""); ChipMaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "max_spd", 3.5f, ""); ChipTargetRadius = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "tgt_rad", 70f, ""); ChipScale = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "chip_sc", 3f, ""); TargetScale = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "tgt_sc", 2f, ""); ChipTargetX = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "tgt_x", 0f, ""); ChipTargetY = ((BaseUnityPlugin)this).Config.Bind<float>("mini", "tgt_y", 0f, ""); QuantumKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("qnt", "key", (KeyCode)303, ""); QuantumRange = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "range", 5f, ""); QuantumCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "cd", 3f, ""); QuantumHeat = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "heat", 0.7f, ""); QuantumPain = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "pain", 12f, ""); QuantumVomitChance = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "vomit", 0.25f, ""); QuantumZoom = ((BaseUnityPlugin)this).Config.Bind<float>("qnt", "zoom", 0.15f, ""); ImplantBleed = ((BaseUnityPlugin)this).Config.Bind<float>("gen", "ins_bld", 6f, ""); ImplantSkinDamage = ((BaseUnityPlugin)this).Config.Bind<float>("gen", "ins_skin", 15f, ""); ImplantPain = ((BaseUnityPlugin)this).Config.Bind<float>("gen", "ins_pain", 10f, ""); SoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("gen", "snd_vol", 0.8f, ""); DebugGiveKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("dbg", "key_give", (KeyCode)290, ""); DebugInfectKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("dbg", "key_inf", (KeyCode)289, ""); DebugEffectsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("dbg", "key_fx", (KeyCode)288, ""); Requirements.Bind(((BaseUnityPlugin)this).Config); GramophoneConfig.Bind(((BaseUnityPlugin)this).Config); TumorBotConfig.Bind(((BaseUnityPlugin)this).Config); LogBuildings = ((BaseUnityPlugin)this).Config.Bind<bool>("dbg", "log_bld", false, ""); DropChance = ((BaseUnityPlugin)this).Config.Bind<float>("drop", "chance", 0.06f, ""); AllowDuplicateDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("drop", "dupes", true, ""); CrateKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("drop", "crates", "crate,box,chest", ""); AirJumps = ((BaseUnityPlugin)this).Config.Bind<int>("imp", "jumps", 1, ""); AirJumpPower = ((BaseUnityPlugin)this).Config.Bind<float>("imp", "power", 0.9f, ""); AirJumpStaminaCost = ((BaseUnityPlugin)this).Config.Bind<float>("imp", "stam", 1f, ""); FallDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("imp", "fall", 0.5f, ""); DashKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("spt", "key", (KeyCode)325, ""); DashSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "speed", 34f, ""); DashAngle = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "angle", 14f, ""); DashDuration = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "dur", 0.2f, ""); DashCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "cd", 1.5f, ""); DashBloodCost = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "blood", 2f, ""); DashMinBlood = ((BaseUnityPlugin)this).Config.Bind<float>("spt", "min_blood", 60f, ""); RegenSkin = ((BaseUnityPlugin)this).Config.Bind<float>("med", "skin_ps", 1.2f, ""); RegenBleed = ((BaseUnityPlugin)this).Config.Bind<float>("med", "bleed_ps", 0.8f, ""); RegenPain = ((BaseUnityPlugin)this).Config.Bind<float>("med", "pain_ps", 0.5f, ""); SmallWoundSkinMin = ((BaseUnityPlugin)this).Config.Bind<float>("med", "skin_min", 50f, ""); SmallBleedMax = ((BaseUnityPlugin)this).Config.Bind<float>("med", "bleed_max", 15f, ""); ConfigClean.Run(((BaseUnityPlugin)this).Config); } private void RegisterItem(ImplantType type, string id, string iconFile) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown Dictionary<string, string> dictionary = new Dictionary<string, string> { { "EN", Text.Name(type) }, { "RU", Text.Name(type) } }; Dictionary<string, string> dictionary2 = new Dictionary<string, string> { { "EN", Text.Description(type) }, { "RU", Text.Description(type) } }; string text = default(string); CustomItemBuilder.Create(id, "ImplantsMod", (ItemTemplate)0).Category("implant").Tags(new string[1] { "implant" }) .Weight(0.1f) .Value(300) .RotSpeed(0f) .UsableWithLMB(false) .DisplayName((IDictionary<string, string>)dictionary) .Description((IDictionary<string, string>)dictionary2) .Usable((Use)delegate(Body body, Item item) { UseImplant(type, item); }, true) .OnSpawn((Action<GameObject>)delegate(GameObject go) { ApplyIcon(go, iconFile); }) .Register(ref text); if (!string.IsNullOrEmpty(text)) { Log.LogError((object)("Item " + id + ": " + text)); } } private void RegisterTumorBot() { //IL_00bd: 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_00c8: Expected O, but got Unknown Dictionary<string, string> dictionary = new Dictionary<string, string> { { "EN", Text.TumorBotName() }, { "RU", Text.TumorBotName() } }; Dictionary<string, string> dictionary2 = new Dictionary<string, string> { { "EN", Text.TumorBotDescription() }, { "RU", Text.TumorBotDescription() } }; CustomItemBuilder obj = CustomItemBuilder.Create("implants_tumorbot", "ImplantsMod", (ItemTemplate)0).Category("implant").Tags(new string[1] { "implant" }) .Weight(0.1f) .Value(250) .RotSpeed(0f) .UsableWithLMB(false) .DisplayName((IDictionary<string, string>)dictionary) .Description((IDictionary<string, string>)dictionary2); object obj2 = <>c.<>9__58_0; if (obj2 == null) { Use val = delegate { Hud.Toast(Text.TumorBotHint()); }; <>c.<>9__58_0 = val; obj2 = (object)val; } string text = default(string); obj.Usable((Use)obj2, true).OnSpawn((Action<GameObject>)delegate(GameObject go) { ApplyIcon(go, "tumorbot.png"); }).Register(ref text); if (!string.IsNullOrEmpty(text)) { Log.LogError((object)("Item implants_tumorbot: " + text)); } } private static void ApplyIcon(GameObject go, string iconFile) { SpriteRenderer component = go.GetComponent<SpriteRenderer>(); if (!((Object)(object)component == (Object)null)) { Sprite val = Assets.ItemSprite(iconFile, component.sprite); if ((Object)(object)val != (Object)null) { component.sprite = val; } } } private static void UseImplant(ImplantType type, Item item) { Hud.Toast(Text.UseHint()); } private static void InstallOnLimb(ImplantType type, Limb limb, Item item) { if ((Object)(object)limb == (Object)null || (Object)(object)item == (Object)null) { return; } if (!LimbMatches(type, limb)) { Hud.Toast(Text.WrongPart(type)); } else if (ImplantState.Has(type)) { Hud.Toast(Text.AlreadyInstalled(type)); } else if (Requirements.Check(limb.body, Requirements.For(type))) { if ((Object)(object)MinigameBase.main == (Object)null || !ChipMinigame.Value) { FinishInstall(type, limb, item); } else { ChipGame.Begin(type, limb, item); } } } public static void FinishInstall(ImplantType type, Limb limb, Item item) { if (!ImplantState.Has(type)) { ImplantState.Set(type, value: true); Assets.Play("implant_use"); Hud.Toast(Text.Installed(type)); limb.bleedAmount += ImplantBleed.Value; limb.skinHealth = Mathf.Max(0f, limb.skinHealth - ImplantSkinDamage.Value); limb.pain += ImplantPain.Value; PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null && main.shaker != null) { main.shaker.Shake(40f); } if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); } } } private static bool LimbMatches(ImplantType type, Limb limb) { return type switch { ImplantType.Impulse => limb.isLegLimb, ImplantType.Spatial => ((Object)limb).name == "DownTorso", ImplantType.Medical => ((Object)limb).name == "UpTorso", _ => limb.isHead, }; } private static void LimbImpulse(Limb limb, Item item) { InstallOnLimb(ImplantType.Impulse, limb, item); } private static void LimbSpatial(Limb limb, Item item) { InstallOnLimb(ImplantType.Spatial, limb, item); } private static void LimbMedical(Limb limb, Item item) { InstallOnLimb(ImplantType.Medical, limb, item); } private static void LimbQuantum(Limb limb, Item item) { InstallOnLimb(ImplantType.Quantum, limb, item); } private static void LimbTumorBot(Limb limb, Item item) { TumorBot.Apply(limb, item); } private void EnsureLimbUse() { if (Time.unscaledTime < nextItemCheck) { return; } nextItemCheck = Time.unscaledTime + 1f; if (Item.GlobalItems != null) { FieldInfo field = typeof(ItemInfo).GetField("useLimbAction"); if (!(field == null)) { PatchInfo("implants_impulse", "LimbImpulse", field); PatchInfo("implants_spatial", "LimbSpatial", field); PatchInfo("implants_medical", "LimbMedical", field); PatchInfo("implants_quantum", "LimbQuantum", field); PatchInfo("implants_tumorbot", "LimbTumorBot", field); } } } private static void PatchInfo(string id, string method, FieldInfo field) { if (Item.GlobalItems.TryGetValue(id, out var value) && value != null && (!value.usableOnLimb || field.GetValue(value) == null || value.usableWithLMB)) { MethodInfo method2 = typeof(Plugin).GetMethod(method, BindingFlags.Static | BindingFlags.NonPublic); Delegate value2 = Delegate.CreateDelegate(field.FieldType, method2); field.SetValue(value, value2); value.usableOnLimb = true; value.usableWithLMB = false; } } private void Update() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!firstUpdate) { firstUpdate = true; Log.LogInfo((object)"Update is running"); } PlayerCamera main = PlayerCamera.main; Body val = (((Object)(object)main != (Object)null) ? main.body : null); if (beats < 6 && Time.realtimeSinceStartup > nextBeat) { nextBeat = Time.realtimeSinceStartup + 10f; beats++; ManualLogSource log = Log; string[] obj = new string[6] { "State: camera=", ((Object)(object)main != (Object)null).ToString(), " body=", ((Object)(object)val != (Object)null).ToString(), " scene=", null }; Scene activeScene = SceneManager.GetActiveScene(); obj[5] = ((Scene)(ref activeScene)).name; log.LogInfo((object)string.Concat(obj)); } if ((Object)(object)val != (Object)(object)lastBody) { lastBody = val; if ((Object)(object)val != (Object)null) { OnNewBody(); } } EnsureLimbUse(); if (!((Object)(object)val == (Object)null)) { ImplantRuntime.Tick(val, Time.deltaTime); GramophoneWorld.Tick(val); TumorBot.Tick(val, Time.unscaledDeltaTime); } } private void LateUpdate() { ImplantRuntime.ApplyZoom(); } private void FixedUpdate() { if (!((Object)(object)lastBody == (Object)null)) { ImplantRuntime.FixedTick(lastBody); } } private void OnNewBody() { Log.LogInfo((object)("New player body detected. loadedRun=" + SaveSystem.loadedRun)); ImplantRuntime.Reset(); TumorBot.Reset(); GramophoneWorld.OnNewBody(); if (SaveSystem.loadedRun) { ImplantState.Load(); return; } ImplantState.Reset(); ImplantState.DeleteFile(); } private void OnGUI() { Hud.Draw(); } } public static class Requirements { public static ConfigEntry<int> Impulse; public static ConfigEntry<int> Spatial; public static ConfigEntry<int> Medical; public static ConfigEntry<int> Quantum; public static ConfigEntry<int> TumorBot; public static void Bind(ConfigFile c) { Medical = c.Bind<int>("req", "med", 7, ""); Impulse = c.Bind<int>("req", "imp", 9, ""); Spatial = c.Bind<int>("req", "spt", 11, ""); Quantum = c.Bind<int>("req", "qnt", 14, ""); TumorBot = c.Bind<int>("req", "bot", 10, ""); } public static int For(ImplantType t) { return t switch { ImplantType.Impulse => Impulse.Value, ImplantType.Spatial => Spatial.Value, ImplantType.Medical => Medical.Value, _ => Quantum.Value, }; } public static string Suffix(int required) { if (required <= 0) { return string.Empty; } return " Requires intelligence " + required + "."; } public static bool Check(Body body, int required) { if (required <= 0) { return true; } int num = (((Object)(object)body != (Object)null && body.skills != null) ? body.skills.INT : 0); if (num >= required) { return true; } Hud.Toast("Not enough intelligence: " + required + " needed, you have " + num); return false; } } public static class ImplantRuntime { public static int AirJumpsLeft; private static float dashTime; private static float dashTail; private static float dashCooldown; private static float ghostTimer; private static float jumpGlow; private static int dashDir = 1; private static float regenSoundTimer; private static float quantumCooldown; private static float zoomTimer; private static float zoomBase; private static bool zoomActive; private const float ZoomDuration = 0.35f; public static bool DashActive { get { if (!(dashTime > 0f)) { return dashTail > 0f; } return true; } } public static float DashCooldownFraction { get { float value = Plugin.DashCooldown.Value; if (value <= 0f || dashCooldown <= 0f) { return 0f; } return Mathf.Clamp01(dashCooldown / value); } } public static void Reset() { AirJumpsLeft = 0; dashTime = 0f; dashTail = 0f; dashCooldown = 0f; ghostTimer = 0f; jumpGlow = 0f; regenSoundTimer = 0f; quantumCooldown = 0f; } public static void Tick(Body body, float dt) { if (!body.alive) { dashTime = 0f; dashTail = 0f; return; } if (ImplantState.Impulse && (body.grounded || (Object)(object)body.currentClimbable != (Object)null || ((Object)(object)body.bodyAffect != (Object)null && body.bodyAffect.wasWater))) { AirJumpsLeft = Plugin.AirJumps.Value; } if (ImplantState.Spatial) { TickDash(body, dt); } if (ImplantState.Medical) { TickRegen(body, dt); } if (ImplantState.Quantum) { TickQuantum(body, dt); } TickDebug(body); } public static void FixedTick(Body body) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (dashTime <= 0f || !body.alive) { return; } float num = Plugin.DashAngle.Value * ((float)Math.PI / 180f); Vector2 velocity = default(Vector2); ((Vector2)(ref velocity))..ctor((float)dashDir * Plugin.DashSpeed.Value * Mathf.Cos(num), Plugin.DashSpeed.Value * Mathf.Sin(num)); PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null && main.bonusAbber < 0.3f) { main.bonusAbber = 0.3f; } body.rb.velocity = velocity; Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if ((Object)(object)val != (Object)null && (Object)(object)val.rb != (Object)null) { val.rb.velocity = velocity; } } } public static void AirJump(Body body, ref float jumpCooldown) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) AirJumpsLeft--; Vector2 velocity = body.rb.velocity; body.rb.velocity = new Vector2(velocity.x, body.actualJumpSpeed * Plugin.AirJumpPower.Value); body.stamina -= Plugin.AirJumpStaminaCost.Value * (1f + body.overEncumberance); jumpCooldown = 0.25f; jumpGlow = 0.3f; Assets.Play("double_jump"); Vector3 position = ((Component)body).transform.position; body.CreateCloudSmall(new Vector2(position.x, position.y), (Vector2?)null); int layerId = 0; int order = 10; SpriteRenderer componentInChildren = ((Component)body).GetComponentInChildren<SpriteRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { layerId = ((Renderer)componentInChildren).sortingLayerID; order = ((Renderer)componentInChildren).sortingOrder + 5; } Burst.Spawn(position, layerId, order, new Color(0.3f, 0.65f, 1f, 0.9f)); PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null && main.shaker != null) { main.shaker.Shake(25f); } } private static void TickDash(Body body, float dt) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) if (dashCooldown > 0f) { dashCooldown -= dt; } if (dashTime > 0f) { dashTime -= dt; if (dashTime <= 0f) { dashTail = 0.2f; } } else if (dashTail > 0f) { dashTail -= dt; } if (jumpGlow > 0f) { jumpGlow -= dt; } if (dashTime > 0f || dashTail > 0.1f || jumpGlow > 0f) { ghostTimer -= dt; if (ghostTimer <= 0f) { ghostTimer = 0.035f; Afterimage.Spawn(body, 0.35f, new Color(0.25f, 0.55f, 1f, 0.6f)); } } if (!(dashCooldown > 0f) && !(dashTime > 0f) && Input.GetKeyDown(Plugin.DashKey.Value) && body.standing && body.conscious && !body.sleeping && !(body.bloodVolume < Plugin.DashMinBlood.Value + Plugin.DashBloodCost.Value)) { float x = body.moveDir.x; if (Mathf.Abs(x) > 0.1f) { dashDir = ((x > 0f) ? 1 : (-1)); } else { dashDir = (body.isRight ? 1 : (-1)); } body.bloodVolume -= Plugin.DashBloodCost.Value; dashTime = Plugin.DashDuration.Value; dashTail = 0f; dashCooldown = Plugin.DashCooldown.Value; ghostTimer = 0f; Assets.Play("dash"); PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null && main.shaker != null) { main.shaker.Shake(70f); } } } private static void BurstAt(Body body, Vector3 pos, Color color) { //IL_0025: 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) int layerId = 0; int order = 10; SpriteRenderer componentInChildren = ((Component)body).GetComponentInChildren<SpriteRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { layerId = ((Renderer)componentInChildren).sortingLayerID; order = ((Renderer)componentInChildren).sortingOrder + 5; } Burst.Spawn(pos, layerId, order, color); } private static void TickQuantum(Body body, float dt) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) if (quantumCooldown > 0f) { quantumCooldown -= dt; } if (quantumCooldown > 0f || !Input.GetKeyDown(Plugin.QuantumKey.Value) || !body.conscious || body.sleeping) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Vector3 mousePosition = Input.mousePosition; mousePosition.z = Mathf.Abs(((Component)main).transform.position.z); Vector2 val = Vector2.op_Implicit(main.ScreenToWorldPoint(mousePosition)); Vector2 val2 = Vector2.op_Implicit(((Component)body).transform.position); Vector2 val3 = val - val2; float value = Plugin.QuantumRange.Value; if (((Vector2)(ref val3)).magnitude > value) { val3 = ((Vector2)(ref val3)).normalized * value; } if (((Vector2)(ref val3)).magnitude < 0.5f) { return; } int mask = LayerMask.GetMask(new string[1] { "Ground" }); bool flag = false; for (int num = 10; num >= 2; num--) { Vector2 val4 = val2 + val3 * ((float)num / 10f); if ((Object)(object)Physics2D.OverlapPoint(val4, mask) == (Object)null) { val3 = val4 - val2; flag = true; break; } } if (!flag) { return; } Color color = default(Color); ((Color)(ref color))..ctor(0.55f, 0.35f, 1f, 0.9f); Afterimage.Spawn(body, 0.5f, new Color(0.55f, 0.35f, 1f, 0.6f)); BurstAt(body, ((Component)body).transform.position, color); Vector3 val5 = Vector2.op_Implicit(val3); Transform transform = ((Component)body).transform; transform.position += val5; Limb[] limbs = body.limbs; foreach (Limb val6 in limbs) { if (!((Object)(object)val6 == (Object)null)) { if (!((Component)val6).transform.IsChildOf(((Component)body).transform)) { Transform transform2 = ((Component)val6).transform; transform2.position += val5; } if ((Object)(object)val6.rb != (Object)null) { val6.rb.velocity = Vector2.zero; } } } if ((Object)(object)body.rb != (Object)null) { body.rb.velocity = Vector2.zero; } BurstAt(body, ((Component)body).transform.position, color); quantumCooldown = Plugin.QuantumCooldown.Value; body.temperature += Plugin.QuantumHeat.Value; for (int j = 0; j < limbs.Length; j++) { if ((Object)(object)limbs[j] != (Object)null && limbs[j].isHead) { Limb obj = limbs[j]; obj.pain += Plugin.QuantumPain.Value; } } if (Random.value < Plugin.QuantumVomitChance.Value && (Object)(object)body.vomiter != (Object)null) { body.vomiter.Vomit(); } Assets.PlayFirst("teleport", "dash"); PlayerCamera main2 = PlayerCamera.main; if ((Object)(object)main2 != (Object)null) { if (main2.shaker != null) { main2.shaker.Shake(110f); } if (main2.bonusAbber < 0.8f) { main2.bonusAbber = 0.8f; } } zoomTimer = 0.35f; } public static void ApplyZoom() { Camera main = Camera.main; if (zoomTimer <= 0f) { if (zoomActive && (Object)(object)main != (Object)null) { main.orthographicSize = zoomBase; } zoomActive = false; } else if (!((Object)(object)main == (Object)null)) { if (!zoomActive) { zoomBase = main.orthographicSize; zoomActive = true; } zoomTimer -= Time.unscaledDeltaTime; float num = Mathf.Clamp01(zoomTimer / 0.35f); float num2 = Mathf.Sin((1f - num) * (float)Math.PI); main.orthographicSize = zoomBase * (1f - Plugin.QuantumZoom.Value * num2); if (zoomTimer <= 0f) { main.orthographicSize = zoomBase; zoomActive = false; } } } private static void TickRegen(Body body, float dt) { bool flag = false; Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if ((Object)(object)val == (Object)null || val.dismembered) { continue; } bool flag2 = val.skinHealth < 100f && val.skinHealth >= Plugin.SmallWoundSkinMin.Value; bool flag3 = val.bleedAmount > 0f && val.bleedAmount <= Plugin.SmallBleedMax.Value; if (flag2 || flag3) { if (flag2) { val.skinHealth = Mathf.Min(100f, val.skinHealth + Plugin.RegenSkin.Value * dt); } if (flag3) { val.bleedAmount = Mathf.Max(0f, val.bleedAmount - Plugin.RegenBleed.Value * dt); } if (val.pain > 0f) { val.pain = Mathf.Max(0f, val.pain - Plugin.RegenPain.Value * dt); } flag = true; } } regenSoundTimer -= dt; if (flag && regenSoundTimer <= 0f) { regenSoundTimer = 6f; Assets.Play("regen"); } } private static void TickDebug(Body body) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) KeyCode value = Plugin.DebugInfectKey.Value; if ((int)value != 0 && Input.GetKeyDown(value)) { Limb[] limbs = body.limbs; Limb val = limbs[Random.Range(0, limbs.Length)]; val.infected = true; val.infectionAmount = Mathf.Max(val.infectionAmount, 30f); Hud.Toast("Infected: " + ((Object)val).name); } KeyCode value2 = Plugin.DebugEffectsKey.Value; if ((int)value2 != 0 && Input.GetKeyDown(value2)) { bool flag = !ImplantState.Impulse || !ImplantState.Spatial || !ImplantState.Medical || !ImplantState.Quantum; ImplantState.Set(ImplantType.Impulse, flag); ImplantState.Set(ImplantType.Spatial, flag); ImplantState.Set(ImplantType.Medical, flag); ImplantState.Set(ImplantType.Quantum, flag); Hud.Toast(flag ? "All implant effects on" : "All implant effects off"); } KeyCode value3 = Plugin.DebugGiveKey.Value; if ((int)value3 != 0 && Input.GetKeyDown(value3)) { Plugin.Log.LogInfo((object)"Debug key pressed, spawning implants"); Vector3 position = ((Component)body).transform.position; CrateLoot.Spawn("implants_impulse", new Vector2(position.x - 0.6f, position.y + 1f)); CrateLoot.Spawn("implants_spatial", new Vector2(position.x, position.y + 1f)); CrateLoot.Spawn("implants_medical", new Vector2(position.x + 0.6f, position.y + 1f)); CrateLoot.Spawn("implants_quantum", new Vector2(position.x + 1.2f, position.y + 1f)); CrateLoot.Spawn("implants_tumorbot", new Vector2(position.x + 1.8f, position.y + 1f)); } } } public static class TumorBotConfig { public static ConfigEntry<float> SleepSeconds; public static ConfigEntry<float> UnnumbedSleepFactor; public static ConfigEntry<float> NumbThreshold; public static ConfigEntry<float> WoundSkinDamage; public static ConfigEntry<float> WoundBleeding; public static ConfigEntry<float> PainNumbed; public static ConfigEntry<float> PainUnnumbed; public static ConfigEntry<float> AnimScale; public static ConfigEntry<float> FrameTime; public static ConfigEntry<float> DropWeight; public static void Bind(ConfigFile c) { SleepSeconds = c.Bind<float>("bot", "sleep", 10f, ""); UnnumbedSleepFactor = c.Bind<float>("bot", "raw_factor", 0.5f, ""); NumbThreshold = c.Bind<float>("bot", "numb", 10f, ""); WoundSkinDamage = c.Bind<float>("bot", "w_skin", 35f, ""); WoundBleeding = c.Bind<float>("bot", "w_bleed", 5f, ""); PainNumbed = c.Bind<float>("bot", "pain_ok", 6f, ""); PainUnnumbed = c.Bind<float>("bot", "pain_raw", 45f, ""); AnimScale = c.Bind<float>("bot", "anim_size", 3f, ""); FrameTime = c.Bind<float>("bot", "frame", 0.5f, ""); DropWeight = c.Bind<float>("bot", "drop", 1f, ""); } } public static class TumorBot { public const string Id = "implants_tumorbot"; private static bool active; private static bool allowWake; private static float elapsed; private static float duration; private static bool numbed; private static Limb target; private static Body targetBody; public static bool Active => active; public static bool AllowWake => allowWake; public static void Apply(Limb limb, Item item) { if ((Object)(object)limb == (Object)null || (Object)(object)item == (Object)null) { return; } if (ac