Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoCheque v1.0.0
BepInEx\plugins\RepoCheque\RepoCheque.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")] [assembly: IgnoresAccessChecksTo("Unity.Localization")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.ResourceManager")] [assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("RepoCheque")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4dc31dc4d014babf6c29b277fbc5203dd16cb115")] [assembly: AssemblyProduct("RepoCheque")] [assembly: AssemblyTitle("RepoCheque")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoCheque { internal class ChequeAmount : MonoBehaviour { private ValuableObject? _valuable; private TextMeshPro[] _texts = Array.Empty<TextMeshPro>(); private float _lastDrawn = float.NaN; private float _retryTimer; private static TMP_FontAsset? _gameFont; private static bool _fontSearched; internal static void Attach(GameObject root, ChequeMarker marker) { if (ChequeConfig.ShowPrintedAmount.Value && !((Object)(object)marker.Card == (Object)null) && !((Object)(object)root.GetComponent<ChequeAmount>() != (Object)null)) { root.AddComponent<ChequeAmount>().Build(marker); } } private void Build(ChequeMarker marker) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) _valuable = ((Component)this).GetComponent<ValuableObject>(); Vector3 cardLocalSize = marker.CardLocalSize; string text = ChequeConfig.TextSide.Value.Trim().ToLowerInvariant(); bool flag = ((text == "front" || text == "both") ? true : false); bool flag2 = flag; flag = ((text == "back" || text == "both") ? true : false); bool flag3 = flag; if (!flag2 && !flag3) { flag2 = true; } List<TextMeshPro> list = new List<TextMeshPro>(2); if (flag2) { list.Add(MakeText(marker, cardLocalSize, onFront: true)); } if (flag3) { list.Add(MakeText(marker, cardLocalSize, onFront: false)); } _texts = list.Where((TextMeshPro t) => (Object)(object)t != (Object)null).ToArray(); Refresh(); } private TextMeshPro MakeText(ChequeMarker marker, Vector3 size, bool onFront) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0062: 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_006c: 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_0075: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(onFront ? "RepoCheque_Amount_Front" : "RepoCheque_Amount_Back"); val.transform.SetParent(marker.Card, false); val.layer = ((Component)marker.Card).gameObject.layer; TextMeshPro val2 = val.AddComponent<TextMeshPro>(); RectTransform rectTransform = ((TMP_Text)val2).rectTransform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); rectTransform.pivot = val3; Vector2 anchorMin = (rectTransform.anchorMax = val3); rectTransform.anchorMin = anchorMin; rectTransform.sizeDelta = new Vector2(size.x * ChequeConfig.TextBoxWidth.Value, size.y * ChequeConfig.TextBoxHeight.Value); float value = ChequeConfig.TextOffsetU.Value; float num = (0.5f - value) * size.x; float num2 = (ChequeConfig.TextOffsetV.Value - 0.5f) * size.y; float num3 = size.z * 0.5f + ChequeConfig.TextDepthOffset.Value; if (onFront) { ((Transform)rectTransform).localPosition = new Vector3(num, num2, num3); ((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 180f, 0f); } else { ((Transform)rectTransform).localPosition = new Vector3(0f - num, num2, 0f - num3); ((Transform)rectTransform).localRotation = Quaternion.identity; } ((Transform)rectTransform).localScale = Vector3.one; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).enableWordWrapping = false; ((Graphic)val2).color = ChequeConfig.GetTextColor(); ((TMP_Text)val2).text = string.Empty; TMP_FontAsset gameFont = GetGameFont(); if ((Object)(object)gameFont != (Object)null) { ((TMP_Text)val2).font = gameFont; } if (ChequeConfig.TextAutoFit.Value) { ((TMP_Text)val2).enableAutoSizing = true; ((TMP_Text)val2).fontSizeMin = 0.01f; ((TMP_Text)val2).fontSizeMax = ChequeConfig.TextSize.Value; } else { ((TMP_Text)val2).enableAutoSizing = false; ((TMP_Text)val2).fontSize = ChequeConfig.TextSize.Value; } Log(string.Format("Amount text ({0}) at local {1}, ", onFront ? "front" : "back", ((Transform)rectTransform).localPosition) + string.Format("box {0}, font '{1}'.", rectTransform.sizeDelta, ((Object)(object)gameFont != (Object)null) ? ((Object)gameFont).name : "TMP default")); return val2; } private static TMP_FontAsset? GetGameFont() { if (_fontSearched) { return _gameFont; } _fontSearched = true; try { TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); _gameFont = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null && ((Object)f).name.IndexOf("teko", StringComparison.OrdinalIgnoreCase) >= 0)) ?? TMP_Settings.defaultFontAsset ?? ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null)); if ((Object)(object)_gameFont != (Object)null) { RepoCheque.Logger.LogInfo((object)("Using game font '" + ((Object)_gameFont).name + "' for the printed amount.")); } else { RepoCheque.Logger.LogWarning((object)"No TextMeshPro font asset found - falling back to the built-in font."); } } catch (Exception ex) { RepoCheque.Logger.LogWarning((object)("Font lookup failed (" + ex.Message + ") - using the built-in font.")); } return _gameFont; } private void Update() { if (_texts.Length != 0 && !((Object)(object)_valuable == (Object)null)) { _retryTimer -= Time.deltaTime; if (!(_retryTimer > 0f)) { _retryTimer = 0.25f; Refresh(); } } } private void Refresh() { if (_texts.Length == 0 || (Object)(object)_valuable == (Object)null) { return; } if (!_valuable.dollarValueSet) { TextMeshPro[] texts = _texts; foreach (TextMeshPro val in texts) { ((TMP_Text)val).text = string.Empty; } return; } float dollarValueCurrent = _valuable.dollarValueCurrent; if (!Mathf.Approximately(dollarValueCurrent, _lastDrawn)) { _lastDrawn = dollarValueCurrent; string text = "$" + SemiFunc.DollarGetString(Mathf.RoundToInt(dollarValueCurrent)); TextMeshPro[] texts2 = _texts; foreach (TextMeshPro val2 in texts2) { ((TMP_Text)val2).text = text; } Log("Cheque amount drawn: " + text); } } private static void Log(string msg) { if (ChequeConfig.DebugLogging.Value) { RepoCheque.Logger.LogInfo((object)msg); } } } internal class ChequeCartProbe : MonoBehaviour { private PhysGrabObjectImpactDetector? _impact; private MeshRenderer? _renderer; private float _timer; private bool _wasInCart; internal static void Attach(GameObject root, ChequeMarker marker) { if (ChequeConfig.CartProbeLogging.Value && !((Object)(object)root.GetComponent<ChequeCartProbe>() != (Object)null)) { ChequeCartProbe chequeCartProbe = root.AddComponent<ChequeCartProbe>(); chequeCartProbe._impact = root.GetComponentInChildren<PhysGrabObjectImpactDetector>(); chequeCartProbe._renderer = (((Object)(object)marker.Card != (Object)null) ? ((Component)marker.Card).GetComponent<MeshRenderer>() : null); } } private void Update() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_impact == (Object)null || (Object)(object)_renderer == (Object)null) { return; } bool inCart = _impact.inCart; if (inCart != _wasInCart) { _wasInCart = inCart; RepoCheque.Logger.LogInfo((object)$"[cart probe] inCart = {inCart}"); _timer = 0f; } if (!inCart) { return; } _timer -= Time.deltaTime; if (_timer > 0f) { return; } _timer = 1f; Bounds bounds = ((Renderer)_renderer).bounds; Transform transform = ((Component)this).transform; Transform transform2 = ((Component)_renderer).transform; float num = Mathf.Abs(Vector3.Dot(transform2.forward, Vector3.up)); string arg = "no cart found"; PhysGrabCart val = FindNearestCart(transform.position); if ((Object)(object)val != (Object)null && (Object)(object)val.inCart != (Object)null) { BoxCollider component = ((Component)val.inCart).GetComponent<BoxCollider>(); float num2; if (!((Object)(object)component != (Object)null)) { num2 = val.inCart.position.y - val.inCart.lossyScale.y * 0.5f; } else { Bounds bounds2 = ((Collider)component).bounds; num2 = ((Bounds)(ref bounds2)).min.y; } float num3 = num2; arg = $"cartFloorY={num3:0.000} chequeMinY={((Bounds)(ref bounds)).min.y:0.000} " + $"deltaAboveFloor={((Bounds)(ref bounds)).min.y - num3:0.000} cartPos={((Component)val).transform.position}"; } RepoCheque.Logger.LogInfo((object)($"[cart probe] rendererEnabled={((Renderer)_renderer).enabled} isVisible={((Renderer)_renderer).isVisible} " + $"cardWorldPos={transform2.position} boundsSize={((Bounds)(ref bounds)).size} " + $"flatness={num:0.00} (1=lying flat, 0=edge-on) | {arg}")); } private static PhysGrabCart? FindNearestCart(Vector3 from) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) PhysGrabCart result = null; float num = float.MaxValue; PhysGrabCart[] array = Object.FindObjectsOfType<PhysGrabCart>(); foreach (PhysGrabCart val in array) { if (!((Object)(object)val == (Object)null)) { float num2 = Vector3.Distance(from, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } } internal static class ChequeConfig { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> DebugLogging; internal static ConfigEntry<bool> CartProbeLogging; internal static ConfigEntry<float> ScaleMultiplier; internal static ConfigEntry<float> Thickness; internal static ConfigEntry<float> ColliderThickness; internal static ConfigEntry<float> AspectRatioOverride; internal static ConfigEntry<float> Mass; internal static ConfigEntry<bool> FitToCart; internal static ConfigEntry<bool> ShowPrintedAmount; internal static ConfigEntry<float> TextSize; internal static ConfigEntry<bool> TextAutoFit; internal static ConfigEntry<float> TextBoxWidth; internal static ConfigEntry<float> TextBoxHeight; internal static ConfigEntry<string> TextSide; internal static ConfigEntry<float> TextDepthOffset; internal static ConfigEntry<string> TextColor; internal static ConfigEntry<float> TextOffsetU; internal static ConfigEntry<float> TextOffsetV; internal static ConfigEntry<bool> SpawnInCart; internal static ConfigEntry<float> CartSearchRadius; internal static ConfigEntry<bool> Indestructible; internal static void Init(ConfigFile cfg) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Expected O, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Expected O, but got Unknown Enabled = cfg.Bind<bool>("1. General", "Enabled", true, "Master switch. If false the mod does nothing at all and the vanilla money bag comes back."); DebugLogging = cfg.Bind<bool>("1. General", "DebugLogging", false, "Write extra detail to BepInEx\\LogOutput.log. Turn this on if something looks wrong."); CartProbeLogging = cfg.Bind<bool>("1. General", "CartProbeLogging", false, "Very chatty diagnostic that logs the cheque's position every second while it is inside a cart. Only switch this on if asked to - it floods the log."); ScaleMultiplier = cfg.Bind<float>("2. Appearance", "ScaleMultiplier", 1f, new ConfigDescription("Overall size of the cheque. 1.0 is the measured default (about twice the largest dimension of an upgrade pack). Raise for a bigger cheque, lower for smaller.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 4f), Array.Empty<object>())); Thickness = cfg.Bind<float>("2. Appearance", "Thickness", 0.06f, new ConfigDescription("How thick the paper LOOKS, as a fraction of the cheque's height.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.005f, 0.3f), Array.Empty<object>())); ColliderThickness = cfg.Bind<float>("2. Appearance", "ColliderThickness", 0.075f, new ConfigDescription("How thick the INVISIBLE physics box is, in metres. This is deliberately thicker than the paper looks: it stops the cheque resting exactly level with the floor (which causes flickering) or sinking into a cart. Raise it if you still see flickering, lower it if the cheque looks like it is hovering.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.005f, 0.4f), Array.Empty<object>())); AspectRatioOverride = cfg.Bind<float>("2. Appearance", "AspectRatioOverride", 0f, new ConfigDescription("Width-to-height ratio of the cheque. Leave at 0 to match your cheque.png automatically (recommended - then whatever you paint fits with no stretching). A real cheque is 2.2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); FitToCart = cfg.Bind<bool>("2. Appearance", "FitToCart", true, "Shrink the cheque if it is too big to lie flat inside a cart. A cheque wider than the cart interior gets squeezed against the walls and pushed out through the cart, which makes it look like it vanished."); Mass = cfg.Bind<float>("2. Appearance", "Mass", 0.6f, new ConfigDescription("How heavy the cheque is. Paper should be light. This is applied to every cheque regardless of the surplus amount, so a $100k cheque weighs the same as a $5k one. Set to 0 to keep the original money bag's weight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); ShowPrintedAmount = cfg.Bind<bool>("3. Printed Amount", "ShowPrintedAmount", true, "Draw the money value on the cheque."); TextAutoFit = cfg.Bind<bool>("3. Printed Amount", "TextAutoFit", true, "Scale the amount automatically so it always fills the box below without spilling out. Turn off to use TextSize as a fixed size instead."); TextSize = cfg.Bind<float>("3. Printed Amount", "TextSize", 4f, new ConfigDescription("Font size. Used as the maximum when TextAutoFit is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 40f), Array.Empty<object>())); TextBoxWidth = cfg.Bind<float>("3. Printed Amount", "TextBoxWidth", 0.56f, new ConfigDescription("Width of the blank amount box in your artwork, as a fraction of the whole image.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>())); TextBoxHeight = cfg.Bind<float>("3. Printed Amount", "TextBoxHeight", 0.34f, new ConfigDescription("Height of the blank amount box in your artwork, as a fraction of the whole image.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 1f), Array.Empty<object>())); TextColor = cfg.Bind<string>("3. Printed Amount", "TextColor", "#1A1A2E", "Colour of the printed amount, as a hex code like #1A1A2E."); TextOffsetU = cfg.Bind<float>("3. Printed Amount", "TextOffsetU", 0.35f, new ConfigDescription("Left-to-right position of the amount on the cheque face. 0 = far left edge, 1 = far right edge. Default sits over the blank amount box in the artwork.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); TextOffsetV = cfg.Bind<float>("3. Printed Amount", "TextOffsetV", 0.33f, new ConfigDescription("Bottom-to-top position of the amount. 0 = bottom edge, 1 = top edge.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); TextSide = cfg.Bind<string>("3. Printed Amount", "TextSide", "Front", new ConfigDescription("Which face the amount is printed on. If it shows up on the blank reverse instead of inside your amount box, change this to Back.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Front", "Back", "Both" }), Array.Empty<object>())); TextDepthOffset = cfg.Bind<float>("3. Printed Amount", "TextDepthOffset", 0.004f, new ConfigDescription("How far the text floats above the paper, in metres. Raise it if the number flickers against the artwork, lower it if it looks detached.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.0005f, 0.05f), Array.Empty<object>())); SpawnInCart = cfg.Bind<bool>("4. Cart Spawning", "SpawnInCart", true, "Spawn the cheque gently inside a nearby cart instead of dropping it from above. Turn off if a future game update breaks this."); CartSearchRadius = cfg.Bind<float>("4. Cart Spawning", "CartSearchRadius", 25f, new ConfigDescription("How far from the extraction point to look for a cart, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>())); Indestructible = cfg.Bind<bool>("5. Durability", "Indestructible", true, "The cheque never loses value from impacts, drops, explosions or monsters."); } internal static Color GetTextColor() { //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (ColorUtility.TryParseHtmlString(TextColor.Value, ref result)) { return result; } RepoCheque.Logger.LogWarning((object)("TextColor '" + TextColor.Value + "' is not a valid hex colour (expected something like #1A1A2E). Using dark blue.")); return Color32.op_Implicit(new Color32((byte)26, (byte)26, (byte)46, byte.MaxValue)); } } internal class ChequeMarker : MonoBehaviour { internal bool VisualsReady; internal Vector3 CardSize = Vector3.one; internal Transform? Card; internal Vector3 CardLocalSize = Vector3.one; private PhysGrabObjectImpactDetector? _impact; private void Awake() { _impact = ((Component)this).GetComponentInChildren<PhysGrabObjectImpactDetector>(); } private void Update() { if (!((Object)(object)_impact == (Object)null) && ChequeConfig.Indestructible.Value) { _impact.isIndestructible = true; _impact.destroyDisable = true; _impact.indestructibleBreakEffects = true; } } internal static ChequeMarker? Find(Component? c) { if ((Object)(object)c == (Object)null) { return null; } return c.GetComponentInParent<ChequeMarker>() ?? c.GetComponentInChildren<ChequeMarker>(); } internal static bool Is(Component? c) { return (Object)(object)Find(c) != (Object)null; } } internal class ChequeSettle : MonoBehaviour { private Rigidbody? _rb; private PhysGrabObject? _grab; private float _timer; internal static void Attach(GameObject root, float seconds = 0.4f) { //IL_005b: 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_009d: 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) if (!((Object)(object)root.GetComponent<ChequeSettle>() != (Object)null)) { ChequeSettle chequeSettle = root.AddComponent<ChequeSettle>(); chequeSettle._rb = root.GetComponent<Rigidbody>(); chequeSettle._grab = root.GetComponent<PhysGrabObject>(); chequeSettle._timer = seconds; root.transform.rotation = Quaternion.Euler(-90f, Random.Range(-8f, 8f), 0f); if ((Object)(object)chequeSettle._grab != (Object)null) { chequeSettle._grab.spawnTorque = Vector3.zero; } if ((Object)(object)chequeSettle._rb != (Object)null) { chequeSettle._rb.velocity = Vector3.zero; chequeSettle._rb.angularVelocity = Vector3.zero; } } } private void FixedUpdate() { //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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (_timer <= 0f) { Object.Destroy((Object)(object)this); return; } _timer -= Time.fixedDeltaTime; if ((Object)(object)_grab != (Object)null) { _grab.spawnTorque = Vector3.zero; } if (!((Object)(object)_rb == (Object)null)) { _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; } } } internal static class ChequeTextures { internal const int PlaceholderWidth = 1024; internal const int PlaceholderHeight = 466; private static Texture2D? _front; private static Texture2D? _back; private static bool _loaded; internal static Texture2D Front { get { EnsureLoaded(); return _front; } } internal static Texture2D? Back { get { EnsureLoaded(); return _back; } } private static void EnsureLoaded() { if (!_loaded) { Load(); } } internal static void Load() { _loaded = true; string text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "."; _back = TryLoad(text, new string[2] { "cheque_back.png", "cheque-back.png" }, "back"); _front = TryLoad(text, new string[2] { "cheque.png", "cheque_front.png" }, "front", _back); if ((Object)(object)_front == (Object)null) { RepoCheque.Logger.LogWarning((object)("No usable cheque front image found - using the built-in placeholder texture instead. Drop a PNG named 'cheque.png' (or anything with 'front' in the name) into: " + text)); _front = BuildPlaceholder(); } if ((Object)(object)_back == (Object)null) { RepoCheque.Logger.LogInfo((object)"No back image supplied - the reverse side will mirror the front."); } } private static Texture2D? TryLoad(string dir, string[] exactNames, string keyword, Texture2D? exclude = null) { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown List<string> list = new List<string>(); foreach (string text in exactNames) { list.Add(Path.Combine(dir, text)); list.Add(Path.Combine(dir, "RepoCheque", text)); } string[] array = new string[2] { dir, Path.Combine(dir, "RepoCheque") }; foreach (string path in array) { if (!Directory.Exists(path)) { continue; } string[] files = Directory.GetFiles(path, "*.png"); foreach (string text2 in files) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if (fileNameWithoutExtension.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(text2); } } } foreach (string item in list) { if (!File.Exists(item) || ((Object)(object)exclude != (Object)null && ((Object)exclude).name == Path.GetFileName(item))) { continue; } try { byte[] array2 = File.ReadAllBytes(item); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val, array2)) { RepoCheque.Logger.LogWarning((object)("'" + item + "' exists but is not a readable PNG/JPG. Ignoring it.")); Object.Destroy((Object)(object)val); continue; } string text3 = (((Object)val).name = Path.GetFileName(item)); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).anisoLevel = 4; val.Apply(true, false); RepoCheque.Logger.LogInfo((object)$"Loaded {text3} ({((Texture)val).width}x{((Texture)val).height}) from {item}"); WarnIfOddAspect(text3, val); return val; } catch (Exception ex) { RepoCheque.Logger.LogWarning((object)("Failed to read '" + item + "': " + ex.Message)); } } return null; } internal static bool HasTransparency(Texture2D? tex) { //IL_0035: 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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tex == (Object)null) { return false; } try { Color32[] pixels = tex.GetPixels32(Mathf.Max(((Texture)tex).mipmapCount - 4, 0)); Color32[] array = pixels; foreach (Color32 val in array) { if (val.a < 250) { return true; } } } catch (Exception ex) { RepoCheque.Logger.LogWarning((object)("Could not inspect '" + ((Object)tex).name + "' for transparency: " + ex.Message)); } return false; } private static void WarnIfOddAspect(string fileName, Texture2D tex) { float num = (float)((Texture)tex).width / (float)((Texture)tex).height; if (Mathf.Abs(num - 2.2f) > 0.35f) { RepoCheque.Logger.LogWarning((object)($"{fileName} is {((Texture)tex).width}x{((Texture)tex).height} (ratio {num:0.00}:1). The cheque mesh is " + $"2.2:1, so your image will look stretched. Ideal size is {1024}x{466}.")); } } private static Texture2D BuildPlaceholder() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) Color32 val = default(Color32); ((Color32)(ref val))..ctor((byte)242, (byte)238, (byte)222, byte.MaxValue); Color32 c = default(Color32); ((Color32)(ref c))..ctor((byte)43, (byte)58, (byte)85, byte.MaxValue); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)201, (byte)210, (byte)224, byte.MaxValue); Color32 c2 = default(Color32); ((Color32)(ref c2))..ctor((byte)126, (byte)154, (byte)184, byte.MaxValue); Color32[] array = (Color32[])(object)new Color32[477184]; for (int i = 0; i < array.Length; i++) { array[i] = val; } for (int j = 0; j < 466; j++) { if (j % 14 == 0) { for (int k = 0; k < 1024; k++) { float num = Mathf.Sin((float)k / 1024f * MathF.PI * 6f) * 0.5f + 0.5f; array[j * 1024 + k] = Color32.Lerp(val, val2, num * 0.35f); } } } Rect(array, 1024, 466, 0.02f, 0.04f, 0.98f, 0.96f, c2, 3); Rect(array, 1024, 466, 0.04f, 0.78f, 0.42f, 0.9f, c, 0); Rect(array, 1024, 466, 0.62f, 0.8f, 0.96f, 0.9f, val2, 2); Line(array, 1024, 466, 0.04f, 0.455f, 0.58f, c); Line(array, 1024, 466, 0.04f, 0.3f, 0.58f, val2); Line(array, 1024, 466, 0.6f, 0.13f, 0.94f, c); Line(array, 1024, 466, 0.04f, 0.13f, 0.4f, val2); Rect(array, 1024, 466, 0.62f, 0.54f, 0.96f, 0.7f, c, 3); Texture2D val3 = new Texture2D(1024, 466, (TextureFormat)4, true) { name = "cheque_placeholder" }; val3.SetPixels32(array); ((Texture)val3).wrapMode = (TextureWrapMode)1; ((Texture)val3).filterMode = (FilterMode)1; ((Texture)val3).anisoLevel = 4; val3.Apply(true); return val3; } private static void Rect(Color32[] px, int w, int h, float u0, float v0, float u1, float v1, Color32 c, int thickness) { //IL_0086: 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) int num = Mathf.Clamp((int)(u0 * (float)w), 0, w - 1); int num2 = Mathf.Clamp((int)(u1 * (float)w), 0, w - 1); int num3 = Mathf.Clamp((int)(v0 * (float)h), 0, h - 1); int num4 = Mathf.Clamp((int)(v1 * (float)h), 0, h - 1); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { bool flag = j - num < thickness || num2 - j < thickness || i - num3 < thickness || num4 - i < thickness; if (thickness == 0 || flag) { px[i * w + j] = c; } } } } private static void Line(Color32[] px, int w, int h, float u0, float v, float u1, Color32 c) { //IL_004f: 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) int num = Mathf.Clamp((int)(u0 * (float)w), 0, w - 1); int num2 = Mathf.Clamp((int)(u1 * (float)w), 0, w - 1); int num3 = Mathf.Clamp((int)(v * (float)h), 0, h - 1); for (int i = num; i <= num2; i++) { for (int j = 0; j < 3; j++) { if (num3 + j < h) { px[(num3 + j) * w + i] = c; } } } } } internal static class ChequeVisuals { internal const float DefaultAspectRatio = 2.2f; private static float _cachedUpgradePackSize = -1f; private const string CardObjectName = "RepoCheque_Card"; internal static bool Apply(GameObject root) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return false; } if ((Object)(object)root.GetComponent<ChequeMarker>() != (Object)null) { return true; } ChequeMarker chequeMarker = root.AddComponent<ChequeMarker>(); DumpHierarchy(root); float num = ResolveAspectRatio(); float upgradePackSize = GetUpgradePackSize(); float num2 = upgradePackSize * 2f * ChequeConfig.ScaleMultiplier.Value; if (ChequeConfig.FitToCart.Value) { num2 = ClampToCart(num2, num); } float num3 = num2 / num; float num4 = Mathf.Max(num3 * ChequeConfig.Thickness.Value, 0.004f); float num5 = Mathf.Max(ChequeConfig.ColliderThickness.Value, num4); Vector3 cardSize = default(Vector3); ((Vector3)(ref cardSize))..ctor(num2, num3, num4); chequeMarker.CardSize = cardSize; Log($"Cheque {num2:0.000} x {num3:0.000}, paper {num4:0.000} thick, " + $"physics box {num5:0.000} thick (aspect {num:0.00}, pack ref {upgradePackSize:0.000})"); int layer = FindVisualLayer(root); Material donor = HideOriginalRenderers(root); BoxCollider main = ReshapeColliders(root, new Vector3(num2, num3, num5)); try { BuildCardObject(root, main, cardSize, donor, layer); } catch (Exception arg) { RepoCheque.Logger.LogError((object)$"Failed to build the cheque mesh: {arg}"); return false; } RefreshGrabGeometry(root); TuneRigidbody(root, main); ValuableObject component = root.GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null) { component.volumeType = (Type)4; } ChequeAmount.Attach(root, chequeMarker); ChequeCartProbe.Attach(root, chequeMarker); chequeMarker.VisualsReady = true; return true; } private static float ResolveAspectRatio() { float value = ChequeConfig.AspectRatioOverride.Value; if (value > 0.01f) { return value; } Texture2D front = ChequeTextures.Front; if ((Object)(object)front != (Object)null && ((Texture)front).height > 0) { float num = (float)((Texture)front).width / (float)((Texture)front).height; if (num >= 1f && num <= 5f) { return num; } } return 2.2f; } private static float ClampToCart(float width, float aspect) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) PhysGrabCart[] array = Object.FindObjectsOfType<PhysGrabCart>(); if (array == null || array.Length == 0) { Log("No cart in the level to size against - leaving the cheque at its natural size."); return width; } float num = float.MaxValue; float num2 = float.MaxValue; PhysGrabCart[] array2 = array; foreach (PhysGrabCart val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.inCart == (Object)null)) { Vector3 lossyScale = val.inCart.lossyScale; RepoCheque.Logger.LogInfo((object)$"Cart '{((Object)val).name}' interior = {lossyScale} (small cart: {val.isSmallCart})."); num = Mathf.Min(num, Mathf.Abs(lossyScale.x)); num2 = Mathf.Min(num2, Mathf.Abs(lossyScale.z)); } } if (num == float.MaxValue) { return width; } float num3 = num * 0.85f; float num4 = num2 * 0.85f * aspect; float num5 = Mathf.Min(num3, num4); if (width <= num5) { return width; } RepoCheque.Logger.LogInfo((object)$"Cheque narrowed from {width:0.000} to {num5:0.000} so it lies flat inside the cart."); return num5; } private static float GetUpgradePackSize() { if (_cachedUpgradePackSize > 0f) { return _cachedUpgradePackSize; } float num = MeasureFromItemRegistry(); if (num > 0f) { return _cachedUpgradePackSize = num; } num = MeasureFromResources(); if (num > 0f) { return _cachedUpgradePackSize = num; } RepoCheque.Logger.LogWarning((object)($"Could not measure an upgrade pack - using fallback {0.35f}. " + "The cheque size is still fine; tune ScaleMultiplier in the config if you want it different.")); return _cachedUpgradePackSize = 0.35f; } private static float MeasureFromItemRegistry() { try { StatsManager instance = StatsManager.instance; if (instance?.itemDictionary == null || instance.itemDictionary.Count == 0) { return -1f; } if (ChequeConfig.DebugLogging.Value) { Log($"itemDictionary has {instance.itemDictionary.Count} entries, e.g. " + string.Join(", ", instance.itemDictionary.Keys.Take(6))); } foreach (KeyValuePair<string, Item> item in instance.itemDictionary) { if (item.Key.IndexOf("upgrade", StringComparison.OrdinalIgnoreCase) < 0) { continue; } GameObject val = ((PrefabRef<GameObject>)(object)item.Value?.prefab)?.Prefab; if (!((Object)(object)val == (Object)null)) { float num = LargestDimension(val); if (!(num <= 0f)) { RepoCheque.Logger.LogInfo((object)$"Measured upgrade pack '{item.Key}': largest dimension {num:0.000} units."); return num; } } } } catch (Exception ex) { Log("Item-registry measurement failed: " + ex.Message); } return -1f; } private static float MeasureFromResources() { string[] array = new string[3] { "Items/Item Upgrade Player Health", "Items/Item Upgrade Player Energy", "Item Upgrade Player Health" }; string[] array2 = array; foreach (string text in array2) { try { GameObject val = Resources.Load<GameObject>(text); if (!((Object)(object)val == (Object)null)) { float num = LargestDimension(val); if (!(num <= 0f)) { RepoCheque.Logger.LogInfo((object)$"Measured upgrade pack via Resources '{text}': {num:0.000} units."); return num; } } } catch { } } return -1f; } private static float LargestDimension(GameObject prefab) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Bounds? val = null; Collider[] componentsInChildren = prefab.GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren) { if (!val2.isTrigger) { MeshCollider val3 = (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null); if (val3 == null || val3.convex) { val = (val.HasValue ? Grow(val.Value, val2.bounds) : val2.bounds); } } } if (!val.HasValue) { MeshRenderer[] componentsInChildren2 = prefab.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val4 in componentsInChildren2) { val = (val.HasValue ? Grow(val.Value, ((Renderer)val4).bounds) : ((Renderer)val4).bounds); } } if (!val.HasValue) { return -1f; } Bounds value = val.Value; Vector3 size = ((Bounds)(ref value)).size; return Mathf.Max(size.x, Mathf.Max(size.y, size.z)); } private static Bounds Grow(Bounds a, Bounds b) { //IL_0003: 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) ((Bounds)(ref a)).Encapsulate(b); return a; } private static Material? HideOriginalRenderers(GameObject root) { Material val = null; int num = 0; MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if (!(((Object)((Component)val2).gameObject).name == "RepoCheque_Card")) { if (val == null) { val = ((Renderer)val2).sharedMaterial; } ((Renderer)val2).enabled = false; num++; } } SkinnedMeshRenderer[] componentsInChildren2 = root.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val3 in componentsInChildren2) { if (val == null) { val = ((Renderer)val3).sharedMaterial; } ((Renderer)val3).enabled = false; num++; } Log(string.Format("Hid {0} original renderer(s); donor shader = {1}", num, ((Object)(object)val != (Object)null) ? ((Object)val.shader).name : "none")); return val; } private static void BuildCardObject(GameObject root, BoxCollider? main, Vector3 cardSize, Material? donor, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0053: 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_0065: 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_0090: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.TransformPoint(main.center) : root.transform.position); GameObject val2 = new GameObject("RepoCheque_Card"); val2.transform.SetParent(root.transform, false); val2.transform.localPosition = root.transform.InverseTransformPoint(val); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; val2.layer = layer; Vector3 lossyScale = root.transform.lossyScale; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(cardSize.x / Mathf.Max(Mathf.Abs(lossyScale.x), 0.0001f), cardSize.y / Mathf.Max(Mathf.Abs(lossyScale.y), 0.0001f), cardSize.z / Mathf.Max(Mathf.Abs(lossyScale.z), 0.0001f)); bool flag = ChequeTextures.HasTransparency(ChequeTextures.Front); val2.AddComponent<MeshFilter>().sharedMesh = BuildChequeMesh(val3.x, val3.y, val3.z, !flag); MeshRenderer val4 = val2.AddComponent<MeshRenderer>(); Material val5 = MakeMaterial(donor, ChequeTextures.Front); Material val6 = (Material)(((Object)(object)ChequeTextures.Back != (Object)null) ? ((object)MakeMaterial(donor, ChequeTextures.Back)) : ((object)val5)); ((Renderer)val4).sharedMaterials = (Material[])(object)new Material[2] { val5, val6 }; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val4).receiveShadows = true; ChequeMarker component = root.GetComponent<ChequeMarker>(); if ((Object)(object)component != (Object)null) { component.Card = val2.transform; component.CardLocalSize = val3; } Log($"Card parented to root at local {val2.transform.localPosition}, " + $"layer {layer}, mesh size {val3}."); } private static int FindVisualLayer(GameObject root) { MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (((Renderer)val).enabled && ((Object)((Component)val).gameObject).name != "RepoCheque_Card") { return ((Component)val).gameObject.layer; } } return 0; } private static Vector3 ScaleFactor(Transform root, Transform child) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_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_00b6: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = root.lossyScale; Vector3 lossyScale2 = child.lossyScale; return new Vector3(Mathf.Approximately(lossyScale.x, 0f) ? 1f : Mathf.Max(Mathf.Abs(lossyScale2.x / lossyScale.x), 0.0001f), Mathf.Approximately(lossyScale.y, 0f) ? 1f : Mathf.Max(Mathf.Abs(lossyScale2.y / lossyScale.y), 0.0001f), Mathf.Approximately(lossyScale.z, 0f) ? 1f : Mathf.Max(Mathf.Abs(lossyScale2.z / lossyScale.z), 0.0001f)); } internal static Mesh BuildChequeMesh(float width, float height, float thickness, bool includeEdges = true) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d3: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) float num = width * 0.5f; float num2 = height * 0.5f; float num3 = thickness * 0.5f; List<Vector3> verts = new List<Vector3>(24); List<Vector3> norms = new List<Vector3>(24); List<Vector2> uvs = new List<Vector2>(24); List<int> list = new List<int>(30); List<int> list2 = new List<int>(6); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); Vector2 uvBl = default(Vector2); ((Vector2)(ref uvBl))..ctor(1f, 0f); Vector2 uvBr = default(Vector2); ((Vector2)(ref uvBr))..ctor(0f, 0f); Vector2 uvTr = default(Vector2); ((Vector2)(ref uvTr))..ctor(0f, 1f); Vector2 uvTl = default(Vector2); ((Vector2)(ref uvTl))..ctor(1f, 1f); Quad(new Vector3(0f - num, 0f - num2, num3), new Vector3(num, 0f - num2, num3), new Vector3(num, num2, num3), new Vector3(0f - num, num2, num3), Vector3.forward, uvBl, uvBr, uvTr, uvTl, list); Quad(new Vector3(num, 0f - num2, 0f - num3), new Vector3(0f - num, 0f - num2, 0f - num3), new Vector3(0f - num, num2, 0f - num3), new Vector3(num, num2, 0f - num3), Vector3.back, uvBl, uvBr, uvTr, uvTl, list2); if (includeEdges) { Quad(new Vector3(num, 0f - num2, num3), new Vector3(num, 0f - num2, 0f - num3), new Vector3(num, num2, 0f - num3), new Vector3(num, num2, num3), Vector3.right, val, val, val, val, list); Quad(new Vector3(0f - num, 0f - num2, 0f - num3), new Vector3(0f - num, 0f - num2, num3), new Vector3(0f - num, num2, num3), new Vector3(0f - num, num2, 0f - num3), Vector3.left, val, val, val, val, list); Quad(new Vector3(num, num2, 0f - num3), new Vector3(0f - num, num2, 0f - num3), new Vector3(0f - num, num2, num3), new Vector3(num, num2, num3), Vector3.up, val, val, val, val, list); Quad(new Vector3(0f - num, 0f - num2, 0f - num3), new Vector3(num, 0f - num2, 0f - num3), new Vector3(num, 0f - num2, num3), new Vector3(0f - num, 0f - num2, num3), Vector3.down, val, val, val, val, list); } Mesh val2 = new Mesh { name = "RepoChequeCard" }; val2.SetVertices(verts); val2.SetNormals(norms); val2.SetUVs(0, uvs); val2.subMeshCount = 2; val2.SetTriangles(list, 0); val2.SetTriangles(list2, 1); val2.RecalculateTangents(); val2.RecalculateBounds(); return val2; void Quad(Vector3 bl, Vector3 br, Vector3 tr, Vector3 tl, Vector3 n, Vector2 item, Vector2 item2, Vector2 item3, Vector2 item4, List<int> tris) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) int count = verts.Count; verts.Add(bl); verts.Add(br); verts.Add(tr); verts.Add(tl); for (int i = 0; i < 4; i++) { norms.Add(n); } uvs.Add(item); uvs.Add(item2); uvs.Add(item3); uvs.Add(item4); tris.Add(count); tris.Add(count + 1); tris.Add(count + 2); tris.Add(count); tris.Add(count + 2); tris.Add(count + 3); } } private static Material MakeMaterial(Material? donor, Texture2D tex) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)donor != (Object)null) ? new Material(donor) : new Material(Shader.Find("Standard") ?? Shader.Find("Diffuse"))); ((Object)val).name = "RepoChequeMaterial"; string[] array = new string[4] { "_AlbedoTexture", "_MainTex", "_BaseMap", "_BaseColorMap" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)tex); } } string[] array2 = new string[3] { "_AlbedoColor", "_Color", "_BaseColor" }; foreach (string text2 in array2) { if (val.HasProperty(text2)) { val.SetColor(text2, Color.white); } } if (val.HasProperty("_ColorOverlayAmount")) { val.SetFloat("_ColorOverlayAmount", 0f); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } if (val.HasProperty("_METALLIC_ON")) { val.SetFloat("_METALLIC_ON", 0f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.1f); } if (ChequeTextures.HasTransparency(tex)) { val.SetOverrideTag("RenderType", "TransparentCutout"); if (val.HasProperty("_Mode")) { val.SetFloat("_Mode", 1f); } if (val.HasProperty("_Cutoff")) { val.SetFloat("_Cutoff", 0.5f); } val.EnableKeyword("_ALPHATEST_ON"); val.DisableKeyword("_ALPHABLEND_ON"); val.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val.renderQueue = 2450; RepoCheque.Logger.LogInfo((object)("'" + ((Object)tex).name + "' has transparency - using alpha cutout so the torn edges show.")); } return val; } private static BoxCollider? ReshapeColliders(GameObject root, Vector3 cardSize) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) //IL_0106: 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_019a: Unknown result type (might be due to invalid IL or missing references) List<Collider> list = new List<Collider>(); PhysGrabObjectCollider[] componentsInChildren = root.GetComponentsInChildren<PhysGrabObjectCollider>(true); foreach (PhysGrabObjectCollider val in componentsInChildren) { list.AddRange(((Component)val).GetComponents<Collider>()); } List<BoxCollider> list2 = (from b in list.OfType<BoxCollider>() where !((Collider)b).isTrigger select b).ToList(); if (list2.Count == 0) { RepoCheque.Logger.LogWarning((object)"No grabbable BoxCollider found on the surplus valuable - leaving its physics alone. The cheque will look right but keep the bag's original shape."); return null; } BoxCollider val2 = list2.OrderByDescending((BoxCollider b) => b.size.x * b.size.y * b.size.z).First(); ((Component)val2).transform.rotation = root.transform.rotation; Vector3 val3 = ScaleFactor(root.transform, ((Component)val2).transform); val2.size = new Vector3(cardSize.x / val3.x, cardSize.y / val3.y, cardSize.z / val3.z); ((Collider)val2).contactOffset = 0.01f; int num = 0; foreach (Collider item in list) { if (!((Object)(object)item == (Object)(object)val2) && !item.isTrigger && item.enabled) { item.enabled = false; num++; } } Log($"Reshaped grab collider '{((Object)val2).name}' to {val2.size} (contactOffset {((Collider)val2).contactOffset:0.0000}); " + $"disabled {num} other grab collider(s) out of {list.Count}."); return val2; } private static void RefreshGrabGeometry(GameObject root) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c8: 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_00d1: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject component = root.GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { return; } Bounds? val = null; Collider[] componentsInChildren = root.GetComponentsInChildren<Collider>(false); foreach (Collider val2 in componentsInChildren) { if (!val2.isTrigger && val2.enabled) { val = (val.HasValue ? Grow(val.Value, val2.bounds) : val2.bounds); } } if (val.HasValue) { Transform transform = root.transform; Bounds value = val.Value; component.midPointOffset = transform.InverseTransformPoint(((Bounds)(ref value)).center); value = val.Value; component.centerPoint = ((Bounds)(ref value)).center; Log($"Grab midpoint moved to local {component.midPointOffset}."); } } private static void TuneRigidbody(GameObject root, BoxCollider? main) { Rigidbody component = root.GetComponent<Rigidbody>(); if ((Object)(object)component == (Object)null) { return; } float value = ChequeConfig.Mass.Value; if (value > 0f) { PhysGrabObject component2 = root.GetComponent<PhysGrabObject>(); Log($"Mass {component.mass:0.00} -> {value:0.00} (the bag's weight scaled with the surplus; paper shouldn't)."); component.mass = value; if ((Object)(object)component2 != (Object)null) { component2.massOriginal = value; } } component.angularDrag = Mathf.Max(component.angularDrag, 2.5f); component.maxAngularVelocity = Mathf.Min(component.maxAngularVelocity, 12f); component.collisionDetectionMode = (CollisionDetectionMode)2; } private static void DumpHierarchy(GameObject root) { StringBuilder sb; if (ChequeConfig.DebugLogging.Value) { sb = new StringBuilder(); sb.AppendLine("--- surplus valuable '" + ((Object)root).name + "' hierarchy ---"); Walk(root.transform, 0); RepoCheque.Logger.LogInfo((object)sb.ToString()); } void Walk(Transform t, int depth) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) string text = new string(' ', depth * 2); List<string> list = new List<string>(); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val != (Object)null && !(val is Transform)) { list.Add(((object)val).GetType().Name); } } Collider component = ((Component)t).GetComponent<Collider>(); if (1 == 0) { } BoxCollider val2 = (BoxCollider)(object)((component is BoxCollider) ? component : null); string text2 = ((val2 != null) ? $" box size={val2.size} center={val2.center}" : ((component != null) ? (" " + ((object)component).GetType().Name) : "")); if (1 == 0) { } string arg = text2; StringBuilder stringBuilder = sb; string text3 = $"{text}{((Object)t).name} [layer {((Component)t).gameObject.layer}] local={t.localPosition} "; Quaternion localRotation = t.localRotation; stringBuilder.AppendLine(text3 + $"rot={((Quaternion)(ref localRotation)).eulerAngles} lossyScale={t.lossyScale}{arg}"); sb.AppendLine(text + " " + string.Join(", ", list)); for (int j = 0; j < t.childCount; j++) { Walk(t.GetChild(j), depth + 1); } } } private static void Log(string msg) { if (ChequeConfig.DebugLogging.Value) { RepoCheque.Logger.LogInfo((object)msg); } } } [BepInPlugin("RepoCheque", "RepoCheque", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class RepoCheque : BaseUnityPlugin { internal static RepoCheque Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } internal static bool Healthy { get; private set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ChequeConfig.Init(((BaseUnityPlugin)this).Config); if (!ChequeConfig.Enabled.Value) { Logger.LogWarning((object)"RepoCheque is disabled in the config - the vanilla money bag will be used."); return; } try { ChequeTextures.Load(); } catch (Exception arg) { Logger.LogError((object)$"Loading the cheque artwork failed; continuing with the placeholder.\n{arg}"); } Patch(); if (Healthy) { Logger.LogInfo((object)($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded! " + "Built against game build 23363152.")); } else { Logger.LogWarning((object)($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded but is INACTIVE " + "- see the error above. The vanilla money bag will be used.")); } } internal void Patch() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0027: Expected O, but got Unknown try { if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); Healthy = true; } catch (Exception ex) { Healthy = false; Logger.LogError((object)("RepoCheque could not apply its patches and has disabled itself. Your game is unaffected and the vanilla money bag will be used. This usually means R.E.P.O. was updated and a class or method was renamed.\n" + ex)); Unpatch(); } } internal void Unpatch() { try { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception ex) { Logger.LogWarning((object)("Unpatch failed: " + ex.Message)); } } } } namespace RepoCheque.Patches { [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal static class IndestructiblePatch { [HarmonyPrefix] [HarmonyPatch("Break")] private static void Break_Prefix(PhysGrabObjectImpactDetector __instance, ref float valueLost, ref bool _forceBreak) { if (ChequeConfig.Indestructible.Value && ChequeMarker.Is((Component?)(object)__instance)) { valueLost = 0f; _forceBreak = false; __instance.isIndestructible = true; __instance.destroyDisable = true; } } [HarmonyPrefix] [HarmonyPatch("DestroyObject")] private static bool DestroyObject_Prefix(PhysGrabObjectImpactDetector __instance) { if (!ChequeConfig.Indestructible.Value) { return true; } if (!ChequeMarker.Is((Component?)(object)__instance)) { return true; } return false; } } [HarmonyPatch(typeof(EnemyValuableThrower))] internal static class RugratPatch { [HarmonyPostfix] [HarmonyPatch("StateGetValuable")] private static void StateGetValuable_Postfix(EnemyValuableThrower __instance) { if (!ChequeConfig.Enabled.Value) { return; } PhysGrabObject valuableTarget = __instance.valuableTarget; if (!((Object)(object)valuableTarget == (Object)null) && ChequeMarker.Is((Component?)(object)valuableTarget)) { PhysGrabObject val = FindNextValuable(__instance); if ((Object)(object)val != (Object)null) { __instance.valuableTarget = val; Log("Rugrat retargeted from the cheque to '" + ((Object)val).name + "'."); } else { __instance.valuableTarget = null; __instance.UpdateState((State)10); Log("Rugrat found only a cheque worth taking - leaving empty-handed."); } } } [HarmonyPostfix] [HarmonyPatch("StateGoToTarget")] private static void StateGoToTarget_Postfix(EnemyValuableThrower __instance) { DropCheque(__instance); } [HarmonyPostfix] [HarmonyPatch("StatePickUpTarget")] private static void StatePickUpTarget_Postfix(EnemyValuableThrower __instance) { DropCheque(__instance); } private static void DropCheque(EnemyValuableThrower instance) { if (ChequeConfig.Enabled.Value) { PhysGrabObject valuableTarget = instance.valuableTarget; if (!((Object)(object)valuableTarget == (Object)null) && ChequeMarker.Is((Component?)(object)valuableTarget)) { instance.valuableTarget = null; instance.UpdateState((State)10); Log("Rugrat was holding onto a cheque - released it and moved on."); } } } private static PhysGrabObject? FindNextValuable(EnemyValuableThrower instance) { //IL_0034: 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: Invalid comparison between Unknown and I4 //IL_00cf: 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_00ee: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar playerTarget = instance.playerTarget; if ((Object)(object)playerTarget == (Object)null) { return null; } PhysGrabObject val = null; PhysGrabObject val2 = null; float num = float.MaxValue; float num2 = float.MaxValue; Collider[] array = Physics.OverlapSphere(((Component)playerTarget).transform.position, 10f, LayerMask.GetMask(new string[1] { "PhysGrabObject" })); Collider[] array2 = array; NavMeshHit val4 = default(NavMeshHit); foreach (Collider val3 in array2) { ValuableObject componentInParent = ((Component)val3).GetComponentInParent<ValuableObject>(); if ((Object)(object)componentInParent == (Object)null || (int)componentInParent.volumeType > 3 || ChequeMarker.Is((Component?)(object)componentInParent)) { continue; } PhysGrabObject physGrabObject = componentInParent.physGrabObject; if ((Object)(object)physGrabObject == (Object)null) { continue; } float num3 = Vector3.Distance(((Component)playerTarget).transform.position, ((Component)componentInParent).transform.position); if (NavMesh.SamplePosition(((Component)componentInParent).transform.position, ref val4, 1f, -1)) { if (num3 < num) { num = num3; val = physGrabObject; } } else if (num3 < num2) { num2 = num3; val2 = physGrabObject; } } return val ?? val2; } private static void Log(string msg) { if (ChequeConfig.DebugLogging.Value) { RepoCheque.Logger.LogInfo((object)msg); } } } [HarmonyPatch(typeof(ExtractionPoint))] internal static class SurplusSpawnPatch { private static Vector3? _savedPosition; private const float DropClearance = 0.3f; [HarmonyPrefix] [HarmonyPatch("SpawnTaxReturn")] private static void SpawnTaxReturn_Prefix(ExtractionPoint __instance) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) _savedPosition = null; try { if (!ChequeConfig.Enabled.Value || !ChequeConfig.SpawnInCart.Value || !SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)RoundDirector.instance == (Object)null || RoundDirector.instance.extractionPointSurplus <= 0) { return; } Transform surplusSpawnTransform = __instance.surplusSpawnTransform; if (!((Object)(object)surplusSpawnTransform == (Object)null)) { Vector3? val = FindCartPoint(surplusSpawnTransform.position) ?? FindGroundPoint(surplusSpawnTransform.position); if (!val.HasValue) { Log("No cart and no ground found - keeping the vanilla spawn position."); return; } _savedPosition = surplusSpawnTransform.position; surplusSpawnTransform.position = val.Value; ChequeSpawnFlag.Arm(); } } catch (Exception arg) { RepoCheque.Logger.LogError((object)$"Cart spawn redirect failed, falling back to vanilla:\n{arg}"); _savedPosition = null; } } [HarmonyPostfix] [HarmonyPatch("SpawnTaxReturn")] private static void SpawnTaxReturn_Postfix(ExtractionPoint __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (_savedPosition.HasValue && (Object)(object)__instance.surplusSpawnTransform != (Object)null) { __instance.surplusSpawnTransform.position = _savedPosition.Value; } _savedPosition = null; } private static Vector3? FindCartPoint(Vector3 near) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) PhysGrabCart val = null; float num = ChequeConfig.CartSearchRadius.Value; PhysGrabCart[] array = Object.FindObjectsOfType<PhysGrabCart>(); foreach (PhysGrabCart val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.inCart == (Object)null)) { float num2 = Vector3.Distance(near, ((Component)val2).transform.position); if (!(num2 > num)) { num = num2; val = val2; } } } if ((Object)(object)val == (Object)null) { return null; } BoxCollider component = ((Component)val.inCart).GetComponent<BoxCollider>(); Bounds val3 = (Bounds)(((Object)(object)component != (Object)null) ? ((Collider)component).bounds : new Bounds(val.inCart.position, val.inCart.lossyScale)); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Bounds)(ref val3)).center.x, ((Bounds)(ref val3)).min.y + 0.3f, ((Bounds)(ref val3)).center.z); RepoCheque.Logger.LogInfo((object)($"Spawning the cheque inside cart '{((Object)val).name}' at {val4} " + $"(interior {((Bounds)(ref val3)).size}, {num:0.0}m from the extraction point).")); return val4; } private static Vector3? FindGroundPoint(Vector3 from) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(from + Vector3.up * 0.5f, Vector3.down, ref val, 12f, -1, (QueryTriggerInteraction)1)) { return null; } Vector3 val2 = ((RaycastHit)(ref val)).point + Vector3.up * 0.3f; RepoCheque.Logger.LogInfo((object)($"No cart within {ChequeConfig.CartSearchRadius.Value}m - " + $"spawning the cheque low at the extraction point instead ({val2}).")); return val2; } private static void Log(string msg) { if (ChequeConfig.DebugLogging.Value) { RepoCheque.Logger.LogInfo((object)msg); } } } internal static class ChequeSpawnFlag { private static float _armedUntil = -1f; internal static void Arm() { _armedUntil = Time.time + 3f; } internal static bool ConsumeIfArmed() { if (Time.time > _armedUntil) { return false; } _armedUntil = -1f; return true; } } [HarmonyPatch(typeof(SurplusValuable))] internal static class SurplusValuablePatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(SurplusValuable __instance) { if (!ChequeConfig.Enabled.Value) { return; } try { if (ChequeVisuals.Apply(((Component)__instance).gameObject)) { RepoCheque.Logger.LogInfo((object)("Surplus valuable re-skinned as a cheque (" + ((Object)((Component)__instance).gameObject).name + ").")); } else { RepoCheque.Logger.LogWarning((object)"Cheque re-skin did not complete; the vanilla bag may still be visible."); } if (SemiFunc.IsMasterClientOrSingleplayer() && ChequeSpawnFlag.ConsumeIfArmed()) { ChequeSettle.Attach(((Component)__instance).gameObject); } } catch (Exception arg) { RepoCheque.Logger.LogError((object)$"Cheque re-skin threw an exception, leaving the vanilla bag alone:\n{arg}"); } } } }