Stacklands now has official mod support. Thunderstore is no longer recommended for this game, and most mods can now be found on the Steam Workshop.
Decompiled source of BetterCrane v0.3.0
plugins/BetterCrane.dll
Decompiled 2 years 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("BetterCrane")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Improves cranes. Allows them to buy and sell, take out cards from boosters and coin chests, move any player-draggable cards exept buildings, and prohibits them for moving cards that in a process of something.")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1")] [assembly: AssemblyProduct("BetterCrane")] [assembly: AssemblyTitle("BetterCrane")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 BetterCraneNS { [BepInPlugin("BetterCrane", "BetterCrane", "0.1.1")] public class BetterCranePlugin : BaseUnityPlugin { private enum WhatCardsCranable { SameAsBaseGame, DraggableButBuildings, Draggable, All } public static ManualLogSource L; public static Harmony HarmonyInstance; private static ConfigEntry<bool> canMoveOccupiedCards; private static ConfigEntry<bool> canTargetSellBuy; private static ConfigEntry<bool> canUnloadBoosters; private static ConfigEntry<WhatCardsCranable> canMoveWhat; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown L = ((BaseUnityPlugin)this).Logger; try { HarmonyInstance = new Harmony("BetterCranePlugin"); HarmonyInstance.PatchAll(typeof(BetterCranePlugin)); } catch (Exception ex) { Log("Patching failed: " + ex.Message); } string text = ""; text = "Anable cranes to move cards that are in a process of doing something."; canMoveOccupiedCards = ((BaseUnityPlugin)this).Config.Bind<bool>("Allow cranes to", "Move occupied cards", false, text); text = "Anable cranes to target sell and buy boxes."; canTargetSellBuy = ((BaseUnityPlugin)this).Config.Bind<bool>("Allow cranes to", "Target sell and buy boxes", true, text); text = "Anable cranes pull cards out of booster packs."; canUnloadBoosters = ((BaseUnityPlugin)this).Config.Bind<bool>("Allow cranes to", "Unload booster packs", true, text); text = "What card types are cranable"; canMoveWhat = ((BaseUnityPlugin)this).Config.Bind<WhatCardsCranable>("Allow cranes to", "move which cards", WhatCardsCranable.DraggableButBuildings, text); CreateConfigWatcher(); } private void CreateConfigWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)); fileSystemWatcher.Changed += delegate { ((BaseUnityPlugin)this).Config.Reload(); }; fileSystemWatcher.Created += delegate { ((BaseUnityPlugin)this).Config.Reload(); }; fileSystemWatcher.Renamed += delegate { ((BaseUnityPlugin)this).Config.Reload(); }; fileSystemWatcher.EnableRaisingEvents = true; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; } public static void Log(string s) { L.LogInfo((object)(DateTime.Now.ToString("HH:MM:ss") + ": " + s)); } public static Vector3 getDirectionVector(Conveyor conveyor) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_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) //IL_0060: 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) if (conveyor.Direction == 0) { return Vector3.back; } if (conveyor.Direction == 1) { return Vector3.left; } if (conveyor.Direction == 2) { return Vector3.forward; } if (conveyor.Direction == 3) { return Vector3.right; } return Vector3.back; } [HarmonyPatch(typeof(Conveyor), "UpdateCard")] [HarmonyPrefix] private static bool Conveyor_UpdateCard_Prefix(ref Conveyor __instance) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_019a: 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_01c1: 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_00ba: 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_00f5: Expected O, but got Unknown //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) if (((CardData)__instance).MyGameCard.IsDemoCard) { return false; } bool flag = true; if (((Draggable)((CardData)__instance).MyGameCard).Velocity.HasValue) { flag = false; } Draggable val = null; if (flag) { val = GetInputDraggable(__instance, getDirectionVector(__instance), allowDraggingCards: true); } Draggable output = null; GameCard val2 = (GameCard)(object)((val is GameCard) ? val : null); if (val2 != null) { CardData cardData = val2.GetLeafCard().CardData; if ((Object)(object)cardData != (Object)null && InputCardHasConveyableCard(cardData)) { CardData inputCardConveyablePrefab = GetInputCardConveyablePrefab(cardData); string text = SokLoc.Translate("card_conveyor_status", (LocParam[])(object)new LocParam[1] { LocParam.Create("resource", inputCardConveyablePrefab.Name) }); ((CardData)__instance).MyGameCard.StartTimer(__instance.TotalTime, new TimerAction(__instance.LoadCard), text, ((CardData)__instance).GetActionId("LoadCard"), true); output = GetTarget(__instance, inputCardConveyablePrefab, -getDirectionVector(__instance), allowDraggedCards: true); } else { val = null; ((CardData)__instance).MyGameCard.CancelAnyTimer(); } } else { Boosterpack val3 = (Boosterpack)(object)((val is Boosterpack) ? val : null); if (val3 != null) { string text2 = SokLoc.Translate("card_conveyor_status", (LocParam[])(object)new LocParam[1] { LocParam.Create("resource", val3.Name) }); ((CardData)__instance).MyGameCard.StartTimer(__instance.TotalTime, new TimerAction(__instance.LoadCard), text2, ((CardData)__instance).GetActionId("LoadCard"), true); output = GetTarget(__instance, (Draggable)null, -getDirectionVector(__instance), allowDraggedCards: true); } else { ((CardData)__instance).MyGameCard.CancelAnyTimer(); } } DrawArrows(__instance, getDirectionVector(__instance), val, output); return false; } public static Draggable GetInputDraggable(Conveyor conveyor, Vector3 directionVector, bool allowDraggingCards) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) return GetBestInDirection(conveyor, directionVector, allowDraggingCards, (Draggable draggable) => CanBeInputDraggable(conveyor, draggable)); } public static Draggable GetBestInDirection(Conveyor conveyor, Vector3 direction, bool allowDraggedCards, Func<Draggable, bool> pred) { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006e: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) Vector3 position = ((Component)((CardData)conveyor).MyGameCard).transform.position; float num = float.MinValue; Draggable result = null; float num2 = float.MaxValue; foreach (Draggable allDraggable in WorldManager.instance.AllDraggables) { if (!allowDraggedCards && allDraggable.BeingDragged) { continue; } Vector3 val = ((Component)allDraggable).transform.position - position; float num3 = Vector3.Dot(direction, val); if (num3 <= 0f) { continue; } float num4 = num3 / ((Vector3)(ref val)).sqrMagnitude; if (num4 > 0.5f && num4 > num && pred(allDraggable)) { num = num4; Vector3 val2 = ((Component)allDraggable).transform.position - position; val2.y = 0f; if (((Vector3)(ref val2)).magnitude <= 2f && ((Vector3)(ref val2)).magnitude <= num2) { result = allDraggable; num2 = ((Vector3)(ref val2)).magnitude; } } } return result; } public static bool CanBeInputDraggable(Conveyor conveyor, Draggable drag) { GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); if (val != null) { if (Object.op_Implicit((Object)(object)val.HasCardInStack((Predicate<CardData>)((CardData cd) => (Object)(object)cd == (Object)(object)conveyor)))) { return false; } CardData cardData = val.GetLeafCard().CardData; if (((Draggable)cardData.MyGameCard).Velocity.HasValue || (Object)(object)cardData.MyGameCard.BounceTarget != (Object)null) { return false; } if (((CardData)conveyor).MyGameCard.IsParentOf(cardData.MyGameCard)) { return false; } ResourceChest val2 = (ResourceChest)(object)((cardData is ResourceChest) ? cardData : null); if (val2 != null) { if (string.IsNullOrEmpty(val2.HeldCardId)) { return false; } return CanBeConveyed(val2.HeldCardId); } ResourceMagnet val3 = (ResourceMagnet)(object)((cardData is ResourceMagnet) ? cardData : null); if (val3 != null) { if (string.IsNullOrEmpty(val3.PullCardId)) { return false; } return CanBeConveyed(val3.PullCardId); } Chest val4 = (Chest)(object)((cardData is Chest) ? cardData : null); if (val4 != null) { if (string.IsNullOrEmpty(val4.HeldCardId)) { return false; } return CanBeConveyed(val4.HeldCardId); } if (CanBeConveyed(cardData)) { return true; } } else if (drag is Boosterpack) { return canUnloadBoosters.Value; } return false; } public static bool CanBeConveyed(string cardId) { CardData cardPrefab = WorldManager.instance.GetCardPrefab(cardId, true); return CanBeConveyed(cardPrefab); } public static bool CanBeConveyed(CardData otherCard) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 if ((Object)(object)otherCard == (Object)null) { return false; } switch (canMoveWhat.Value) { case WhatCardsCranable.Draggable: if (!otherCard.CanBeDragged) { return false; } break; case WhatCardsCranable.DraggableButBuildings: if (!otherCard.CanBeDragged || otherCard.IsBuilding) { return false; } break; case WhatCardsCranable.SameAsBaseGame: if ((int)otherCard.MyCardType != 2 && (int)otherCard.MyCardType != 4 && (int)otherCard.MyCardType != 1) { Mob val = (Mob)(object)((otherCard is Mob) ? otherCard : null); if (val == null || val.IsAggressive) { return false; } } break; } if ((Object)(object)otherCard.MyGameCard == (Object)null) { return true; } GameCard cardWithStatusInStack = otherCard.MyGameCard.GetCardWithStatusInStack(); if ((Object)(object)cardWithStatusInStack != (Object)null && !canMoveOccupiedCards.Value) { if (!(cardWithStatusInStack.TimerBlueprintId != "")) { return false; } Blueprint blueprintWithId = WorldManager.instance.GetBlueprintWithId(cardWithStatusInStack.TimerBlueprintId); Subprint val2 = blueprintWithId.Subprints[cardWithStatusInStack.TimerSubprintIndex]; List<string> allCardsToRemove = val2.GetAllCardsToRemove(); List<GameCard> allCardsInStack = cardWithStatusInStack.GetAllCardsInStack(); allCardsInStack.Remove(otherCard.MyGameCard); bool flag = true; for (int i = 0; i < allCardsToRemove.Count; i++) { string[] possibleRemovables = allCardsToRemove[i].Split(new char[1] { '|' }); GameCard val3 = ((IEnumerable<GameCard>)allCardsInStack).FirstOrDefault((Func<GameCard, bool>)((GameCard x) => possibleRemovables.Contains(x.CardData.Id))); if ((Object)(object)val3 != (Object)null) { allCardsInStack.Remove(val3); continue; } flag = false; break; } if (!flag) { return false; } } return true; } public static bool InputCardHasConveyableCard(CardData card) { ResourceChest val = (ResourceChest)(object)((card is ResourceChest) ? card : null); if (val != null) { return val.ResourceCount > 0; } ResourceMagnet val2 = (ResourceMagnet)(object)((card is ResourceMagnet) ? card : null); if (val2 != null && ((CardData)val2).MyGameCard.HasChild) { return true; } Chest val3 = (Chest)(object)((card is Chest) ? card : null); if (val3 != null && (val3.CoinCount > 0 || Object.op_Implicit((Object)(object)((CardData)val3).MyGameCard.HasCardInStack((Predicate<CardData>)delegate(CardData cd) { Chest val4 = (Chest)(object)((cd is Chest) ? cd : null); return val4 != null && val4.CoinCount > 0; })))) { return true; } if (CanBeConveyed(card) || CanBeConveyed((card != null) ? card.MyGameCard.GetLeafCard().CardData : null)) { return true; } return false; } public static CardData GetInputCardConveyablePrefab(CardData card) { ResourceChest val = (ResourceChest)(object)((card is ResourceChest) ? card : null); if (val != null) { return WorldManager.instance.GetCardPrefab(val.HeldCardId, true); } ResourceMagnet val2 = (ResourceMagnet)(object)((card is ResourceMagnet) ? card : null); if (val2 != null) { return WorldManager.instance.GetCardPrefab(val2.PullCardId, true); } Chest val3 = (Chest)(object)((card is Chest) ? card : null); if (val3 != null) { return WorldManager.instance.GetCardPrefab(val3.HeldCardId, true); } if (CanBeConveyed(card)) { return card; } return null; } public static Draggable GetTarget(Conveyor conveyor, Draggable inputDrag, Vector3 direction, bool allowDraggedCards) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return GetBestInDirection(conveyor, direction, allowDraggedCards, delegate(Draggable drag) { if ((Object)(object)drag == (Object)(object)inputDrag) { return false; } GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); return (val == null || !Object.op_Implicit((Object)(object)val.HasCardInStack((Predicate<CardData>)((CardData cd) => (Object)(object)cd == (Object)(object)conveyor)))) && OutputDraggableAllowed(drag, inputDrag); }); } public static Draggable GetTarget(Conveyor conveyor, CardData inputPrefub, Vector3 direction, bool allowDraggedCards) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return GetBestInDirection(conveyor, direction, allowDraggedCards, delegate(Draggable drag) { GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); return (val == null || (!((Object)(object)val.CardData == (Object)(object)inputPrefub) && !Object.op_Implicit((Object)(object)val.HasCardInStack((Predicate<CardData>)((CardData cd) => (Object)(object)cd == (Object)(object)conveyor))))) && OutputDraggableAllowed(drag, inputPrefub); }); } public static bool OutputDraggableAllowed(Draggable drag, CardData inputPrefub) { GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); if (val != null) { if (Object.op_Implicit((Object)(object)val.HasCardInStack((Predicate<CardData>)((CardData cd) => (Object)(object)cd == (Object)(object)inputPrefub)))) { return false; } GameCard leafCard = val.GetLeafCard(); try { if ((Object)(object)inputPrefub != (Object)null && !leafCard.CardData.CanHaveCardOnTop(inputPrefub, true)) { CardData obj = inputPrefub; Chest val2 = (Chest)(object)((obj is Chest) ? obj : null); if (val2 == null || !(leafCard.CardData.Id == val2.HeldCardId)) { return false; } } } catch (Exception ex) { if (Application.isEditor) { Debug.LogError((object)ex); } return false; } return true; } CardTarget val3 = (CardTarget)(object)((drag is CardTarget) ? drag : null); if (val3 != null) { if (!canTargetSellBuy.Value) { return false; } return (Object)(object)inputPrefub?.MyGameCard == (Object)null || val3.CanHaveCard(inputPrefub.MyGameCard); } Boosterpack val4 = (Boosterpack)(object)((drag is Boosterpack) ? drag : null); if (val4 != null) { return false; } return false; } public static bool OutputDraggableAllowed(Draggable drag, Draggable inputDrag) { GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); if (val != null) { if (!((Component)val).gameObject.activeInHierarchy) { return false; } if ((Object)(object)((Draggable)val).MyBoard == (Object)null) { Debug.Log((object)(((object)val)?.ToString() + " does not have a board")); return false; } if (!((Draggable)val).MyBoard.IsCurrent) { return false; } try { GameCard val2 = (GameCard)(object)((inputDrag is GameCard) ? inputDrag : null); if (val2 != null && (Object)(object)val2?.CardData != (Object)null) { return OutputDraggableAllowed(drag, val2.GetLeafCard().CardData); } Boosterpack val3 = (Boosterpack)(object)((inputDrag is Boosterpack) ? inputDrag : null); if (val3 != null && canUnloadBoosters.Value) { return false; } } catch (Exception ex) { if (Application.isEditor) { Debug.LogError((object)ex); } return false; } return true; } CardTarget val4 = (CardTarget)(object)((drag is CardTarget) ? drag : null); if (val4 != null) { if (!canTargetSellBuy.Value) { return false; } GameCard val5 = (GameCard)(object)((inputDrag is GameCard) ? inputDrag : null); if (val5 != null) { return val4.CanHaveCard(val5.GetLeafCard()); } return false; } Boosterpack val6 = (Boosterpack)(object)((drag is Boosterpack) ? drag : null); if (val6 != null) { CanBoosterHave(val6, inputDrag); } return false; } public static bool CanBoosterHave(Boosterpack bp, Draggable drag) { return false; } public static void DrawArrows(Conveyor conveyor, Vector3 directionVector, Draggable input, Draggable output) { //IL_0002: 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) DrawInputArrow(conveyor, directionVector, input); DrawOutputArrow(conveyor, directionVector, output); } public static float DynamicClamp(float clampThis, float betweenThis, float andThis) { if (betweenThis == andThis) { return betweenThis; } return (betweenThis < andThis) ? Mathf.Clamp(clampThis, betweenThis, andThis) : Mathf.Clamp(clampThis, andThis, betweenThis); } public static Vector3 GetClosestCenter(Draggable drag, Conveyor conveyor) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003c: 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_005b: 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_0078: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00b8: 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) GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); if (val != null) { GameCard rootCard = val.GetRootCard(); GameCard leafCard = val.GetLeafCard(); Vector3 position = ((Component)conveyor).transform.position; return new Vector3(DynamicClamp(position.x, ((Component)rootCard).transform.position.x, ((Component)leafCard).transform.position.x), DynamicClamp(position.y, ((Component)rootCard).transform.position.y, ((Component)leafCard).transform.position.y), DynamicClamp(position.z, ((Component)rootCard).transform.position.z, ((Component)leafCard).transform.position.z)); } return ((Component)drag).transform.position; } public static void DrawInputArrow(Conveyor conveyor, Vector3 directionVector, Draggable input) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_002a: 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_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_0060: 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_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_0076: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)((CardData)conveyor).MyGameCard).transform.position; Vector3 start = (((Object)(object)input == (Object)null) ? (((Component)((CardData)conveyor).MyGameCard).transform.position + directionVector * 0.5f) : TransformToEdge(conveyor, GetClosestCenter(input, conveyor), position, input, -1f)); position = TransformToEdge(conveyor, start, position, (Draggable)(object)((CardData)conveyor).MyGameCard, 1f); DrawManager.instance.DrawShape((IShape)(object)new ConveyorArrow { Start = start, End = position }); } public static void DrawOutputArrow(Conveyor conveyor, Vector3 directionVector, Draggable output) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_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_0060: 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_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_0076: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)((CardData)conveyor).MyGameCard).transform.position; Vector3 end = (((Object)(object)output == (Object)null) ? (((Component)((CardData)conveyor).MyGameCard).transform.position - directionVector * 0.5f) : TransformToEdge(conveyor, position, GetClosestCenter(output, conveyor), output, 1f)); position = TransformToEdge(conveyor, position, end, (Draggable)(object)((CardData)conveyor).MyGameCard, -1f); DrawManager.instance.DrawShape((IShape)(object)new ConveyorArrow { Start = position, End = end }); } public static Vector3 TransformToEdge(Conveyor conveyor, Vector3 start, Vector3 end, Draggable drag, float dir) { //IL_0003: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002a: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0062: 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_006c: 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) Vector2 start2 = default(Vector2); ((Vector2)(ref start2))..ctor(start.x, start.z); Vector2 end2 = default(Vector2); ((Vector2)(ref end2))..ctor(end.x, end.z); Vector2 pointOnDraggableEdge = GetPointOnDraggableEdge(start2, end2, drag); Vector3 val = new Vector3(pointOnDraggableEdge.x, 0f, pointOnDraggableEdge.y); Vector3 val2 = start - end; return val + ((Vector3)(ref val2)).normalized * conveyor.ExtraSideDistance * dir; } public static Vector2 GetPointOnDraggableEdge(Vector2 start, Vector2 end, Draggable drag) { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_018f: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01ef: 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_0205: 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) //IL_003e: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) //IL_009f: 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_00b9: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f5: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) Vector2[] array = (Vector2[])(object)new Vector2[4]; GameCard val = (GameCard)(object)((drag is GameCard) ? drag : null); Quaternion val4 = default(Quaternion); if (val != null) { GameCard rootCard = val.GetRootCard(); GameCard leafCard = val.GetLeafCard(); Vector3 val2 = default(Vector3); Vector3 val3 = default(Vector3); PhysicsExtensions.ToWorldSpaceBox(((Draggable)rootCard).boxCollider, ref val2, ref val3, ref val4); Bounds val5 = default(Bounds); ((Bounds)(ref val5))..ctor(val2, new Vector3(val3.x * 2f, 0.01f, val3.y * 2f)); Vector3 val6 = default(Vector3); Vector3 val7 = default(Vector3); PhysicsExtensions.ToWorldSpaceBox(((Draggable)leafCard).boxCollider, ref val6, ref val7, ref val4); Bounds val8 = default(Bounds); ((Bounds)(ref val8))..ctor(val6, new Vector3(val7.x * 2f, 0.01f, val7.y * 2f)); array[0] = new Vector2(((Bounds)(ref val8)).min.x, ((Bounds)(ref val8)).min.z); array[1] = new Vector2(((Bounds)(ref val8)).max.x, ((Bounds)(ref val8)).min.z); array[2] = new Vector2(((Bounds)(ref val5)).max.x, ((Bounds)(ref val5)).max.z); array[3] = new Vector2(((Bounds)(ref val5)).min.x, ((Bounds)(ref val5)).max.z); } else { Vector3 val9 = default(Vector3); Vector3 val10 = default(Vector3); PhysicsExtensions.ToWorldSpaceBox(drag.boxCollider, ref val9, ref val10, ref val4); Bounds val11 = default(Bounds); ((Bounds)(ref val11))..ctor(val9, new Vector3(val10.x * 2f, 0.01f, val10.y * 2f)); array[0] = new Vector2(((Bounds)(ref val11)).min.x, ((Bounds)(ref val11)).min.z); array[1] = new Vector2(((Bounds)(ref val11)).max.x, ((Bounds)(ref val11)).min.z); array[2] = new Vector2(((Bounds)(ref val11)).max.x, ((Bounds)(ref val11)).max.z); array[3] = new Vector2(((Bounds)(ref val11)).min.x, ((Bounds)(ref val11)).max.z); } Vector2 result = default(Vector2); float num = default(float); for (int i = 0; i < 4; i++) { Vector2 val12 = array[i]; Vector2 val13 = array[(i + 1) % 4]; if (MathHelper.LineSegmentsIntersection(start, end, val12, val13, ref result, ref num)) { return result; } } return start; } [HarmonyPatch(typeof(Conveyor), "LoadCard")] [HarmonyPrefix] private static bool Conveyor_LoadCard_Prefix(ref Conveyor __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //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_0096: 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_00a2: Unknown result type (might be due to invalid IL or missing references) Draggable inputDraggable = GetInputDraggable(__instance, getDirectionVector(__instance), allowDraggingCards: false); if ((Object)(object)inputDraggable == (Object)null) { return false; } Draggable conveyableFromInput = GetConveyableFromInput(inputDraggable); if ((Object)(object)conveyableFromInput != (Object)null) { Draggable target = GetTarget(__instance, conveyableFromInput, -getDirectionVector(__instance), allowDraggedCards: false); GameCard val = (GameCard)(object)((conveyableFromInput is GameCard) ? conveyableFromInput : null); if (val != null) { val.RemoveFromStack(); } if ((Object)(object)target != (Object)null) { SendToTarget(conveyableFromInput, target); } else { conveyableFromInput.SendToPosition(((Component)((CardData)__instance).MyGameCard).transform.position - getDirectionVector(__instance)); } } return false; } public static Draggable GetConveyableFromInput(Draggable drag) { //IL_010a: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) Draggable obj = drag; GameCard val = (GameCard)(object)((obj is GameCard) ? obj : null); if (val != null) { CardData cardData = val.GetLeafCard().CardData; ResourceChest val2 = (ResourceChest)(object)((cardData is ResourceChest) ? cardData : null); if (val2 != null && val2.ResourceCount > 0) { return (Draggable)(object)val2.RemoveResources(1); } ResourceMagnet val3 = (ResourceMagnet)(object)((cardData is ResourceMagnet) ? cardData : null); if (val3 != null && ((CardData)val3).MyGameCard.HasChild) { return (Draggable)(object)((CardData)val3).MyGameCard.GetLeafCard(); } Chest val4 = (Chest)(object)((cardData is Chest) ? cardData : null); if (val4 != null) { Chest val5 = val4; while (val5.CoinCount == 0) { CardData obj2 = ((CardData)val5).MyGameCard.Parent?.CardData; Chest val6 = (Chest)(object)((obj2 is Chest) ? obj2 : null); if (val6 == null) { break; } val5 = val6; } Chest obj3 = val5; obj3.CoinCount--; return (Draggable)(object)WorldManager.instance.CreateCardStack(((Component)val5).transform.position + Vector3.up * 0.2f, 1, val5.HeldCardId, false); } if (CanBeConveyed(cardData)) { return (Draggable)(object)val.GetLeafCard(); } return null; } Draggable obj4 = drag; Boosterpack val7 = (Boosterpack)(object)((obj4 is Boosterpack) ? obj4 : null); if (val7 != null) { ((Draggable)val7).Clicked(); return WorldManager.instance.AllDraggables.FindLast((Draggable newDrag) => (Object)(object)newDrag != (Object)(object)drag && Vector3.Distance(((Component)newDrag).transform.position, ((Component)drag).transform.position) < 0.01f); } return null; } public static void SendToTarget(Draggable drag, Draggable target) { //IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_00c3: Unknown result type (might be due to invalid IL or missing references) Draggable val = target; GameCard val2 = (GameCard)(object)((target is GameCard) ? target : null); if (val2 != null) { val = (Draggable)(object)val2.GetLeafCard(); } Vector3 val3 = ((Component)val).transform.position - ((Component)drag).transform.position; val3.y = 0f; Vector3 value = default(Vector3); ((Vector3)(ref value))..ctor(val3.x * 4f, 7f, val3.z * 4f); GameCard val4 = (GameCard)(object)((drag is GameCard) ? drag : null); if (val4 != null) { GameCard val5 = (GameCard)(object)((val is GameCard) ? val : null); if (val5 != null) { val4.BounceTarget = val5.GetRootCard(); } else { CardTarget val6 = (CardTarget)(object)((val is CardTarget) ? val : null); if (val6 != null) { val6.CardDropped(val4); } } } drag.Velocity = value; } [HarmonyPatch(typeof(DrawManager), "GetShapeDrawerForShape")] [HarmonyPrefix] private static void GetShapeDrawerForShape(IShape shape, ref DrawManager __instance, ref List<ShapeDrawer> ___shapeObjectPool, List<ShapeDrawerPrefab> ___Prefabs) { if ((Object)(object)((IEnumerable<ShapeDrawer>)___shapeObjectPool).FirstOrDefault((Func<ShapeDrawer, bool>)((ShapeDrawer o) => o.DrawingType == ((object)shape).GetType())) == (Object)null) { ShapeDrawer val = ((IEnumerable<ShapeDrawerPrefab>)___Prefabs).FirstOrDefault((Func<ShapeDrawerPrefab, bool>)((ShapeDrawerPrefab o) => o.Prefab.DrawingType == ((object)shape).GetType()))?.Prefab; if ((Object)(object)val != (Object)null) { ShapeDrawer val2 = Object.Instantiate<ShapeDrawer>(val); Extensions.SetParentClean(((Component)val2).transform, ((Component)__instance).transform); ((Component)val2).gameObject.SetActive(false); ___shapeObjectPool.Add(val2); } } } } }