Decompiled source of BetterCrime v0.10.1
plugins/BetterCrime.dll
Decompiled 5 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using ES3Internal; using Fusion; using Fusion.Photon.Realtime; using HarmonyLib; using I2.Loc; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BetterCrime")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BetterCrime")] [assembly: AssemblyTitle("BetterCrime")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CoolStuffMod { internal static class ArmorDispenser { private const string ContentId = "com.miner28.coolstuffmod.armor-dispenser"; internal const string NameTerm = "com.miner28.coolstuffmod.armor-dispenser.name"; internal const int Price = 10000; internal const int PurchaseLimit = 1; internal const long SaveId = 6697382455916195844L; internal const int FullArmor = 100; internal static HideoutFurniture Create(Transform templates) { return new HideoutFurniture(templates, "com.miner28.coolstuffmod.armor-dispenser", "Armor Dispenser", "Gives the whole crew full armor at the start of each mission while placed in the hideout.", 10000, 1, 6697382455916195844L, "873b17a4-001a-4341-a26f-de01a3b36e91", "CoolStuffMod.ArmorDispenser.png", BuildModel); } internal static void ApplyTo(FPP_Player player) { if (!player.hasArmor || player.armorHealth < 100f) { player.armorHealth = 100f; player.hasArmor = true; } } private static void BuildModel(GameObject model, GameObject shadow) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) FurnitureModel furnitureModel = new FurnitureModel(model, shadow); Material material = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)46, (byte)56, (byte)58, byte.MaxValue))); Material material2 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)103, (byte)122, (byte)114, byte.MaxValue))); Material material3 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)207, (byte)144, (byte)56, byte.MaxValue))); Material material4 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)22, (byte)38, (byte)39, byte.MaxValue))); Material material5 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)92, (byte)190, (byte)143, byte.MaxValue))); furnitureModel.SetPlacementBounds(new Vector3(0f, 0.81f, 0.01f), new Vector3(0.84f, 1.62f, 0.43f)); furnitureModel.AddPart("Cabinet", new Vector3(0f, 0.83f, 0f), new Vector3(0.79f, 1.47f, 0.36f), material); furnitureModel.AddPart("Plinth", new Vector3(0f, 0.048f, 0f), new Vector3(0.84f, 0.096f, 0.4f), material2); furnitureModel.AddPart("Header", new Vector3(0f, 1.49f, 0.186f), new Vector3(0.73f, 0.18f, 0.034f), material3, collides: false); furnitureModel.AddPart("Display", new Vector3(-0.12f, 1.29f, 0.184f), new Vector3(0.37f, 0.126f, 0.026f), material4, collides: false); furnitureModel.AddPart("Ready light", new Vector3(0.258f, 1.29f, 0.188f), new Vector3(0.05f, 0.05f, 0.028f), material5, collides: false); furnitureModel.AddPart("Armor compartment", new Vector3(0f, 0.84f, 0.184f), new Vector3(0.65f, 0.62f, 0.022f), material4, collides: false); furnitureModel.AddPart("Vest panel", new Vector3(0f, 0.79f, 0.2f), new Vector3(0.36f, 0.36f, 0.025f), material2, collides: false); furnitureModel.AddPart("Left vest strap", new Vector3(-0.12f, 1.005f, 0.2f), new Vector3(0.09f, 0.09f, 0.025f), material2, collides: false); furnitureModel.AddPart("Right vest strap", new Vector3(0.12f, 1.005f, 0.2f), new Vector3(0.09f, 0.09f, 0.025f), material2, collides: false); furnitureModel.AddPart("Tray", new Vector3(0f, 0.47f, 0.199f), new Vector3(0.61f, 0.075f, 0.05f), material3); furnitureModel.AddPart("Service panel", new Vector3(0f, 0.25f, 0.182f), new Vector3(0.63f, 0.23f, 0.022f), material2, collides: false); } } internal static class CircuitBreaker { private sealed class DeviceBudget { internal bool Spent { get; private set; } internal bool TrySpend(int before, int after, ref int other) { if (Spent || before != 2 || after != 1) { return false; } Spent = true; if (other > 1) { other--; } return true; } } [HarmonyPatch] internal static class SetAttemptsPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return typeof(Keypad).GetMethod("RPC_SetAttempts"); yield return typeof(ElectronicSafe).GetMethod("RPC_SetAttempts"); } private static void Prefix(NetworkBehaviour __instance, bool ___InvokeRpc, ref int __0, ref int __1) { if (!___InvokeRpc && !CarriesReserve(__0) && (__0 > 0 || __1 > 0) && !Budgets.TryGetValue(__instance, out var _) && RunCardBonus.CircuitBreaker.IsActive(((SimulationBehaviour)__instance).Runner) && __instance.HasStateAuthority) { __0 = 16777216 + Math.Max(0, AddReserve(__0)); __1 = AddReserve(__1); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo replacement = typeof(CircuitBreaker).GetMethod("SetCodeAttempts", BindingFlags.Static | BindingFlags.NonPublic); int replacements = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Stfld && instruction.operand is FieldInfo { Name: "attemptsLeft" } fieldInfo && (fieldInfo.DeclaringType == typeof(Keypad) || fieldInfo.DeclaringType == typeof(ElectronicSafe))) { instruction.opcode = OpCodes.Call; instruction.operand = replacement; replacements++; } yield return instruction; } if (replacements != 1) { throw new InvalidOperationException($"Expected one electronic lock counter store for Circuit Breaker, found {replacements}."); } } } [HarmonyPatch] internal static class FailedAttemptPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return typeof(Keypad).GetMethod("RPC_AttemptsLower"); yield return typeof(Keypad).GetMethod("RPC_AttemptsLowerFuse"); yield return typeof(ElectronicSafe).GetMethod("RPC_AttemptsLower"); yield return typeof(ElectronicSafe).GetMethod("RPC_AttemptsLowerFuse"); } private static void Prefix(NetworkBehaviour __instance, MethodBase __originalMethod, out int __state) { //IL_002d: 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) bool flag = __originalMethod.Name == "RPC_AttemptsLowerFuse"; Keypad val = (Keypad)(object)((__instance is Keypad) ? __instance : null); __state = ((val == null) ? (flag ? ((ElectronicSafe)__instance).attemptsLeftForFuse : ((ElectronicSafe)__instance).attemptsLeft) : (flag ? val.attemptsLeftForFuse : val.attemptsLeft)); } private static void Postfix(NetworkBehaviour __instance, MethodBase __originalMethod, int __state) { if (!Budgets.TryGetValue(__instance, out var value) || value.Spent) { return; } bool fuse = __originalMethod.Name == "RPC_AttemptsLowerFuse"; Keypad val = (Keypad)(object)((__instance is Keypad) ? __instance : null); if (val != null) { Spend(value, fuse, __state, ref val.attemptsLeft, ref val.attemptsLeftForFuse); return; } ElectronicSafe val2 = (ElectronicSafe)(object)((__instance is ElectronicSafe) ? __instance : null); if (val2 != null) { Spend(value, fuse, __state, ref val2.attemptsLeft, ref val2.attemptsLeftForFuse); } } private static void Spend(DeviceBudget budget, bool fuse, int before, ref int code, ref int fuseAttempts) { if (fuse) { budget.TrySpend(before, fuseAttempts, ref code); } else { budget.TrySpend(before, code, ref fuseAttempts); } } } [HarmonyPatch(typeof(FuseMinigame), "BeginMinigame")] internal static class FirstFusePatch { private static void Postfix(FuseMinigame __instance, FPP_Player __0, GameObject __1) { if (Object.op_Implicit((Object)(object)__0) && ((NetworkBehaviour)__0).HasStateAuthority && RunCardBonus.CircuitBreaker.IsActive(((SimulationBehaviour)__0).Runner) && (Object.op_Implicit((Object)(object)__1.GetComponent<Keypad>()) || Object.op_Implicit((Object)(object)__1.GetComponent<ElectronicSafe>())) && __instance.fuses != null && __instance.fuses.Count > 0 && Object.op_Implicit((Object)(object)__instance.fuses[0])) { ((Component)__instance).gameObject.AddComponent<CircuitBreakerFuseGuide>().Bind(__instance, __instance.fuses[0]); } } } internal const int ExtraAttempts = 1; private const int ReserveTag = 16777216; private static readonly ConditionalWeakTable<NetworkBehaviour, DeviceBudget> Budgets = new ConditionalWeakTable<NetworkBehaviour, DeviceBudget>(); private static readonly ConditionalWeakTable<WorldManager, object> CheckedWorlds = new ConditionalWeakTable<WorldManager, object>(); private static readonly FieldInfo PoliceCount = typeof(Keypad).GetField("copsAmount", BindingFlags.Instance | BindingFlags.NonPublic); internal static int AddReserve(int remaining) { if (remaining <= 0) { return remaining; } return remaining + 1; } internal static void BoostInitializedDevices(WorldManager world) { NetworkRunner runner = ((SimulationBehaviour)world).Runner; if (!RunCardBonus.CircuitBreaker.IsActive(runner) || CheckedWorlds.TryGetValue(world, out var _)) { return; } CheckedWorlds.Add(world, new object()); Keypad[] array = Object.FindObjectsOfType<Keypad>(); foreach (Keypad val in array) { if (CanUpdate((NetworkBehaviour)(object)val, runner) && val.codeGenerated && !val.isUnlocked) { val.RPC_SetAttempts(val.attemptsLeft, val.attemptsLeftForFuse, (int)PoliceCount.GetValue(val)); } } ElectronicSafe[] array2 = Object.FindObjectsOfType<ElectronicSafe>(); foreach (ElectronicSafe val2 in array2) { if (CanUpdate((NetworkBehaviour)(object)val2, runner) && val2.codeGenerated && (!val2.blockCodeMinigame || !val2.blockFuseMinigame)) { val2.RPC_SetAttempts(val2.attemptsLeft, val2.attemptsLeftForFuse); } } } private static bool CanUpdate(NetworkBehaviour device, NetworkRunner runner) { DeviceBudget value; if (Object.op_Implicit((Object)(object)((SimulationBehaviour)device).Object) && ((SimulationBehaviour)device).Object.IsValid && (Object)(object)((SimulationBehaviour)device).Runner == (Object)(object)runner && device.HasStateAuthority) { return !Budgets.TryGetValue(device, out value); } return false; } private static bool CarriesReserve(int transmitted) { if (transmitted >= 16777216) { return transmitted < 33554432; } return false; } private static void SetCodeAttempts(NetworkBehaviour device, int transmitted) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) int num = transmitted; if (CarriesReserve(transmitted) && ModSessions.AllowsContent(((SimulationBehaviour)device).Runner)) { num -= 16777216; Budgets.GetValue(device, (NetworkBehaviour _) => new DeviceBudget()); } Keypad val = (Keypad)(object)((device is Keypad) ? device : null); if (val != null) { val.attemptsLeft = num; } else { ((ElectronicSafe)device).attemptsLeft = num; } } } internal sealed class CircuitBreakerFuseGuide : MonoBehaviour { private FuseMinigame minigame; private Fuse first; private Canvas canvas; private RectTransform marker; internal void Bind(FuseMinigame minigame, Fuse first) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) this.minigame = minigame; this.first = first; GameObject val = new GameObject("Circuit Breaker fuse marker", new Type[2] { typeof(RectTransform), typeof(Canvas) }); canvas = val.GetComponent<Canvas>(); canvas.renderMode = (RenderMode)0; canvas.sortingOrder = 100; canvas.targetDisplay = minigame.mainCam.targetDisplay; GameObject val2 = new GameObject("First fuse", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Outline) }); marker = (RectTransform)val2.transform; ((Transform)marker).SetParent(val.transform, false); ((Transform)marker).localRotation = Quaternion.Euler(0f, 0f, 45f); Image component = val2.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; ((Graphic)component).color = Color32.op_Implicit(new Color32((byte)252, (byte)186, (byte)74, byte.MaxValue)); Outline component2 = val2.GetComponent<Outline>(); ((Shadow)component2).effectColor = Color32.op_Implicit(new Color32((byte)25, (byte)22, (byte)17, (byte)235)); ((Shadow)component2).effectDistance = new Vector2(1f, -1f); ((Behaviour)canvas).enabled = false; } private void LateUpdate() { //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) //IL_00a7: 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_00cd: 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_00f4: 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_00fd: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)canvas)) { return; } if (!Object.op_Implicit((Object)(object)minigame) || !Object.op_Implicit((Object)(object)minigame.player) || minigame.player.isDead || !Object.op_Implicit((Object)(object)minigame.mainCam) || !Object.op_Implicit((Object)(object)first) || first.isTakenOff || minigame.currentFuseIndex != 0) { ((Behaviour)canvas).enabled = false; return; } Camera mainCam = minigame.mainCam; Vector3 val = mainCam.WorldToScreenPoint(((Component)first).transform.position); float num = Mathf.Clamp((float)mainCam.pixelHeight * 0.011f, 8f, 22f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x, val.y + num * 1.5f); Canvas obj = canvas; int enabled; if (val.z > 0f) { Rect pixelRect = mainCam.pixelRect; enabled = (((Rect)(ref pixelRect)).Contains(val2) ? 1 : 0); } else { enabled = 0; } ((Behaviour)obj).enabled = (byte)enabled != 0; if (((Behaviour)canvas).enabled) { Vector2 anchoredPosition = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Component)canvas).transform, val2, (Camera)null, ref anchoredPosition); marker.anchoredPosition = anchoredPosition; marker.sizeDelta = new Vector2(num, num); } } private void OnDisable() { if (Object.op_Implicit((Object)(object)canvas)) { ((Behaviour)canvas).enabled = false; } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)canvas)) { Object.Destroy((Object)(object)((Component)canvas).gameObject); } } } [BepInPlugin("com.miner28.coolstuffmod", "BetterCrime", "0.10.1")] public sealed class FieldConditioningPlugin : BaseUnityPlugin { [HarmonyPatch] private static class GameStartupPatch { [HarmonyTargetMethods] internal static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[3] { "PlaySinglePlayer", "PlayOnline", "JoinSession" }; foreach (string text in array) { yield return (typeof(MainMenu).GetMethod(text)?.GetCustomAttribute<IteratorStateMachineAttribute>())?.StateMachineType.GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.NonPublic) ?? throw new InvalidOperationException("Could not locate the game startup coroutine " + text + "."); } } [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo original = typeof(NetworkRunner).GetMethod("StartGame", new Type[1] { typeof(StartGameArgs) }); MethodInfo method = typeof(GameStartupPatch).GetMethod("StartSession", BindingFlags.Static | BindingFlags.NonPublic); List<CodeInstruction> list = instructions.ToList(); CodeInstruction obj = list.Single((CodeInstruction instruction) => instruction.opcode == OpCodes.Callvirt && object.Equals(instruction.operand, original)); obj.opcode = OpCodes.Call; obj.operand = method; return list; } private static Task<StartGameResult> StartSession(NetworkRunner runner, StartGameArgs args) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) PrepareSession(runner, ref args, out var error); return error ?? runner.StartGame(args); } } [HarmonyPatch(typeof(NetworkRunner), "StartGame")] private static class FusionStartupPatch { private static bool Prefix(NetworkRunner __instance, ref StartGameArgs __0, ref Task<StartGameResult> __result) { PrepareSession(__instance, ref __0, out var error); if (error == null) { return true; } __result = error; return false; } } [HarmonyPatch(typeof(PlayerSkills), "LoadSkills")] private static class LoadSkillsPatch { private static void Prefix(PlayerSkills __instance) { FPP_Player player = __instance.player; if (!Object.op_Implicit((Object)(object)player) || !ModSessions.AllowsContent(((SimulationBehaviour)player).Runner) || !((NetworkBehaviour)player).HasStateAuthority) { return; } SkillLeaflet[] leaflets = instance.leaflets; foreach (SkillLeaflet skillLeaflet in leaflets) { try { skillLeaflet.RegisterSkill(__instance); } catch (Exception arg) { ((BaseUnityPlugin)instance).Logger.LogError((object)$"Could not register {skillLeaflet.DisplayName} for this save: {arg}"); } } } } [HarmonyPatch(typeof(PlayerSkills), "LearnSkill")] private static class LearnSkillPatch { private static void Prefix(PlayerSkills __instance, string __0, out float? __state) { __state = ((__0 == "com.miner28.coolstuffmod.field-conditioning") ? new float?(__instance.player.maxStamina) : ((float?)null)); } private static void Postfix(PlayerSkills __instance, string __0, float? __state) { if (__state.HasValue) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)$"Learned Field Conditioning. Maximum stamina: {__state.Value} -> {__instance.player.maxStamina}."); } if (__0 == "com.miner28.coolstuffmod.backpacker-ii") { ((BaseUnityPlugin)instance).Logger.LogInfo((object)$"Learned Backpacker II. Inventory slots: {__instance.inventory.itemSlots.Count}."); } } } [HarmonyPatch(typeof(ExtraItemSpawner), "SpawnItem")] private static class SkillMagazineLootPatch { private static void Prefix(ExtraItemSpawner __instance, out List<NetworkObject> __state) { __state = null; if ((!__instance.isSkillMagazine && !__instance.isGoldenCard) || !((NetworkBehaviour)__instance).HasStateAuthority || !ModSessions.AllowsContent(((SimulationBehaviour)__instance).Runner) || __instance.randomItems == null) { return; } if (__instance.isGoldenCard) { GoldenCard[] cards = FieldConditioningPlugin.instance.cards; foreach (GoldenCard goldenCard in cards) { NetworkObject registered = goldenCard.GetRegistered(((SimulationBehaviour)__instance).Runner); if (Object.op_Implicit((Object)(object)registered) && !goldenCard.Bonus.IsActive(((SimulationBehaviour)__instance).Runner) && !__instance.randomItems.Contains(registered)) { if (__state == null) { __state = __instance.randomItems; __instance.randomItems = new List<NetworkObject>(__state); } __instance.randomItems.Add(registered); } } return; } WorldManager instance = WorldManager.Instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.localPlayer) || !Object.op_Implicit((Object)(object)instance.localPlayer.skillManager)) { return; } PlayerSkills skillManager = instance.localPlayer.skillManager; bool flag = ((SimulationBehaviour)__instance).Runner.ActivePlayers.Any((PlayerRef player) => player != ((SimulationBehaviour)__instance).Runner.LocalPlayer); SkillLeaflet[] leaflets = FieldConditioningPlugin.instance.leaflets; foreach (SkillLeaflet skillLeaflet in leaflets) { if (!flag && skillManager.CheckIfSkillLearned(skillLeaflet.SkillId)) { continue; } NetworkObject registeredLeaflet = skillLeaflet.GetRegisteredLeaflet(((SimulationBehaviour)__instance).Runner); if (Object.op_Implicit((Object)(object)registeredLeaflet) && !__instance.randomItems.Contains(registeredLeaflet)) { if (__state == null) { __state = __instance.randomItems; __instance.randomItems = new List<NetworkObject>(__state); } __instance.randomItems.Add(registeredLeaflet); } } } private static void Finalizer(ExtraItemSpawner __instance, List<NetworkObject> __state) { if (__state != null) { __instance.randomItems = __state; } } } [HarmonyPatch(typeof(LocalizationManager), "GetTranslation")] private static class EnglishTextPatch { private static bool Prefix(string __0, ref string __result) { GoldenCard[] cards = instance.cards; foreach (GoldenCard goldenCard in cards) { if (__0 == goldenCard.Bonus.NameTerm) { __result = goldenCard.DisplayName; return false; } } HideoutFurniture[] furnishings = instance.furnishings; int i = 0; while (i < furnishings.Length) { HideoutFurniture hideoutFurniture = furnishings[i]; if (__0 == hideoutFurniture.NameTerm) { __result = hideoutFurniture.DisplayName; } else { if (!(__0 == hideoutFurniture.DescriptionTerm)) { i++; continue; } __result = hideoutFurniture.Description; } return false; } SkillLeaflet[] leaflets = instance.leaflets; i = 0; while (i < leaflets.Length) { SkillLeaflet skillLeaflet = leaflets[i]; if (__0 == skillLeaflet.SkillNameTerm) { __result = skillLeaflet.DisplayName; } else if (__0 == skillLeaflet.BonusTerm) { __result = skillLeaflet.BonusDescription; } else { if (!(__0 == skillLeaflet.LeafletNameTerm)) { i++; continue; } __result = skillLeaflet.DisplayName + " Leaflet"; } return false; } return true; } } [HarmonyPatch(typeof(WeaponManager), "SpawnHandLoot")] private static class HeldLeafletPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo original = typeof(Resources).GetMethods(BindingFlags.Static | BindingFlags.Public).Single((MethodInfo methodInfo) => methodInfo.Name == "Load" && methodInfo.IsGenericMethodDefinition && methodInfo.GetParameters().Length == 1).MakeGenericMethod(typeof(GameObject)); MethodInfo method = typeof(HeldLeafletPatch).GetMethod("LoadHandProp", BindingFlags.Static | BindingFlags.NonPublic); List<CodeInstruction> list = instructions.ToList(); list.Single((CodeInstruction instruction) => instruction.opcode == OpCodes.Call && object.Equals(instruction.operand, original)).operand = method; return list; } private static GameObject LoadHandProp(string path) { GoldenCard[] cards = instance.cards; foreach (GoldenCard goldenCard in cards) { if (path == goldenCard.HeldPrefabPath) { return goldenCard.HeldCard; } } SkillLeaflet[] leaflets = instance.leaflets; foreach (SkillLeaflet skillLeaflet in leaflets) { if (path == skillLeaflet.HeldPrefabPath) { return skillLeaflet.HeldLeaflet; } } return Resources.Load<GameObject>(path); } } private const string PluginId = "com.miner28.coolstuffmod"; internal const string PluginName = "BetterCrime"; private const string PluginVersion = "0.10.1"; internal const string FieldConditioningSkillId = "com.miner28.coolstuffmod.field-conditioning"; internal const string BackpackerSkillId = "com.miner28.coolstuffmod.backpacker-ii"; internal const string BackpackerPrerequisite = "backpackerSkill"; internal const int FieldConditioningStamina = 5; internal const int BackpackerSlotBonus = 1; private static FieldConditioningPlugin instance; private SkillLeaflet[] leaflets; private HideoutFurniture[] furnishings; private GoldenCard[] cards; private Harmony harmony; private FPP_Player lastObservedPlayer; private FPP_Player lastRefreshedGuest; private int lastFurnitureSlotBonus; private float nextStoreCheck; internal static IReadOnlyList<GoldenCard> Cards => instance.cards; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown try { GameObject val = new GameObject("BetterCrime runner") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = new GameObject("BetterCrime prefab templates"); val2.SetActive(false); val2.transform.SetParent(val.transform, false); SkillLeaflet skillLeaflet = new SkillLeaflet(val2.transform, ((BaseUnityPlugin)this).Logger, "com.miner28.coolstuffmod.field-conditioning", "Field Conditioning", $"+{5} maximum stamina", "CoolStuffMod.FieldConditioning.png", "CoolStuffMod_FieldConditioningLeaflet", 6697382455916195841L, "58a4ef02-94bb-4646-a700-642c3eeeca05", 5); SkillLeaflet skillLeaflet2 = new SkillLeaflet(val2.transform, ((BaseUnityPlugin)this).Logger, "com.miner28.coolstuffmod.backpacker-ii", "Backpacker II", $"+{1} inventory slot", "CoolStuffMod.BackpackerII.png", "CoolStuffMod_BackpackerIILeaflet", 6697382455916195842L, "ecfc94ab-95aa-4a86-8747-52ad620ed655", 0, 1, "backpackerSkill"); SkillLeaflet skillLeaflet3 = new SkillLeaflet(val2.transform, ((BaseUnityPlugin)this).Logger, "com.miner28.coolstuffmod.second-wind", "Second Wind", "Recover 0.5% of maximum health per second after 5 seconds without taking damage.", "CoolStuffMod.SecondWind.png", "CoolStuffMod_SecondWindLeaflet", 6697382455916195847L, "d1060fd0-408f-4804-9e42-523d7ba0c7e5"); SkillLeaflet skillLeaflet4 = new SkillLeaflet(val2.transform, ((BaseUnityPlugin)this).Logger, "com.miner28.coolstuffmod.steady-hands", "Steady Hands", "Shows a rough zone when picking locks and gives earlier audio and visual cues on mechanical safes.", "CoolStuffMod.SteadyHands.png", "CoolStuffMod_SteadyHandsLeaflet", 6697382455916195848L, "9cf32851-6f61-4e7a-a8bc-4f8e0c82dd97"); leaflets = new SkillLeaflet[4] { skillLeaflet, skillLeaflet2, skillLeaflet3, skillLeaflet4 }; furnishings = new HideoutFurniture[4] { FieldGearRack.Create(val2.transform), ArmorDispenser.Create(val2.transform), SupplyCabinet.Create(val2.transform), MaintenanceLocker.Create(val2.transform) }; cards = new GoldenCard[2] { new GoldenCard(val2.transform, RunCardBonus.ToolCare, "Tool Care Golden Card", "25% less tool durability loss", "CoolStuffMod.ToolCareCard.png", "CoolStuffMod_ToolCareCard", 6697382455916195845L, "6e6366b0-bc3e-4297-b07a-87a7c0ab49dc"), new GoldenCard(val2.transform, RunCardBonus.CircuitBreaker, "Circuit Breaker Golden Card", "+1 electronic lock attempt and a first-fuse hint", "CoolStuffMod.CircuitBreakerCard.png", "CoolStuffMod_CircuitBreakerCard", 6697382455916195849L, "d7461ee8-0b79-4e98-b294-de0dc3684575") }; instance = this; val.AddComponent<CoolStuffRunner>().Plugin = this; } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("Could not start {0}: {1}", "BetterCrime", arg)); ((Behaviour)this).enabled = false; } } internal bool InstallPatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { harmony = new Harmony("com.miner28.coolstuffmod"); Type[] array = new Type[31] { typeof(GameStartupPatch), typeof(FusionStartupPatch), typeof(LoadSkillsPatch), typeof(LearnSkillPatch), typeof(SkillMagazineLootPatch), typeof(EnglishTextPatch), typeof(HeldLeafletPatch), typeof(InventoryCapacity), typeof(HideoutFurniture.PurchaseCountPatch), typeof(HideoutFurniture.OrderPatch), typeof(MissionDeployment.MissionDeparturePatch), typeof(MissionDeployment.MissionLoadPatch), typeof(MissionDeployment.GrantBenefitsPatch), typeof(RunCardBonus.ActivatePatch), typeof(RunCardBonus.CheckActivePatch), typeof(RunCardBonus.RestorePatch), typeof(RunCardBonus.RunEndPatch), typeof(RunCardBonus.ResetPatch), typeof(ToolCareBonus), typeof(GoldenCardBonusesPanel.SpawnPatch), typeof(GoldenCardBonusesPanel.RefreshPatch), typeof(CircuitBreaker.SetAttemptsPatch), typeof(CircuitBreaker.FailedAttemptPatch), typeof(CircuitBreaker.FirstFusePatch), typeof(SecondWind.HealPatch), typeof(SecondWind.ArmorDamagePatch), typeof(SteadyHands.BasicLockPatch), typeof(SteadyHands.AdvancedLockPatch), typeof(SteadyHands.SafeStartPatch), typeof(SteadyHands.SafeVisualPatch), typeof(SteadyHands.SafeAudioPatch) }; foreach (Type type in array) { harmony.PatchAll(type); } foreach (MethodBase item in GameStartupPatch.TargetMethods()) { Patches patchInfo = Harmony.GetPatchInfo(item); if (patchInfo == null || !patchInfo.Owners.Contains("com.miner28.coolstuffmod")) { throw new InvalidOperationException("The session hook did not attach to " + item.DeclaringType?.Name + "."); } } MethodInfo? method = typeof(LocalizationManager).GetMethod("GetTranslation"); HideoutFurniture hideoutFurniture = furnishings[0]; if (object.Equals(method?.Invoke(null, new object[8] { hideoutFurniture.NameTerm, true, 0, true, false, null, null, true }), hideoutFurniture.DisplayName)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterCrime 0.10.1 verified its live text hook and attached the session hooks."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"BetterCrime 0.10.1 attached the session hooks, but the live text hook did not run."); } return true; } catch (Exception arg) { RemovePatches(); ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("Could not install {0} patches: {1}", "BetterCrime", arg)); return false; } } internal void Tick() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) WorldManager val = WorldManager.Instance; if (!Object.op_Implicit((Object)(object)val)) { return; } FPP_Player localPlayer = val.localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !localPlayer.initializedManagers || !localPlayer.spawnedAndReady || !((NetworkBehaviour)localPlayer).HasStateAuthority) { return; } bool flag = ModSessions.AllowsContent(((SimulationBehaviour)localPlayer).Runner); if ((Object)(object)lastObservedPlayer != (Object)(object)localPlayer) { lastObservedPlayer = localPlayer; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Local {((SimulationBehaviour)localPlayer).Runner.GameMode} player is ready. Mod prefabs registered: {flag}."); } if (!flag) { return; } RunCardBonus.RefreshRoom(((SimulationBehaviour)localPlayer).Runner); if (!((SimulationBehaviour)localPlayer).Runner.IsSinglePlayer && !((SimulationBehaviour)localPlayer).Runner.IsSharedModeMasterClient) { RefreshGuestSlots(localPlayer, val.furnitureManager); return; } CircuitBreaker.BoostInitializedDevices(val); if (!localPlayer.isDead) { RefreshStore(((SimulationBehaviour)localPlayer).Runner); } } internal void RemovePatches() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } private void RefreshStore(NetworkRunner runner) { if (Time.unscaledTime < nextStoreCheck) { return; } nextStoreCheck = Time.unscaledTime + 1f; FurnitureWebsite val = Object.FindObjectOfType<FurnitureWebsite>(); if (!Object.op_Implicit((Object)(object)val)) { return; } HideoutFurniture[] array = furnishings; foreach (HideoutFurniture hideoutFurniture in array) { try { if (hideoutFurniture.AddStoreEntry(val, runner)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Added the " + hideoutFurniture.DisplayName + " to the furniture store.")); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Could not add the {hideoutFurniture.DisplayName} store entry: {arg}"); } } } private void RefreshGuestSlots(FPP_Player player, FurnitureManager manager) { if (!Object.op_Implicit((Object)(object)manager) || !Object.op_Implicit((Object)(object)((SimulationBehaviour)manager).Object) || !((SimulationBehaviour)manager).Object.IsValid || !manager.loadedBonuses) { return; } int extraItemSlots = manager.extraItemSlots; if (!((Object)(object)lastRefreshedGuest == (Object)(object)player) || lastFurnitureSlotBonus != extraItemSlots) { if (InventoryCapacity.CurrentCapacity(player.inventory, extraItemSlots) > player.inventory.itemSlots.Count) { player.inventory.CheckSlots(false); } lastRefreshedGuest = player; lastFurnitureSlotBonus = extraItemSlots; } } private static void PrepareSession(NetworkRunner runner, ref StartGameArgs args, out Task<StartGameResult> error) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) error = null; if (((int)args.GameMode != 1 && (int)args.GameMode != 2) || ModSessions.IsPrepared(runner)) { return; } ((BaseUnityPlugin)instance).Logger.LogInfo((object)string.Format("Preparing {0} content before Fusion starts {1}.", "BetterCrime", args.GameMode)); try { string text = ModSessions.Prepare(runner, ref args, instance.leaflets, instance.furnishings, instance.cards); ((BaseUnityPlugin)instance).Logger.LogInfo((object)((text == null) ? "Registered all BetterCrime prefabs for Solo." : ("Registered all BetterCrime prefabs for a private co-op room. Compatibility ID: " + text + "."))); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)string.Format("Could not prepare {0}'s prefabs before connecting: {1}", "BetterCrime", ex)); ConstructorInfo constructor = typeof(StartGameResult).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[3] { typeof(ShutdownReason), typeof(string), typeof(string) }, null); error = Task.FromResult<StartGameResult>((StartGameResult)constructor.Invoke(new object[3] { (object)(ShutdownReason)2, ex.Message, null })); } } } internal sealed class CoolStuffRunner : MonoBehaviour { internal FieldConditioningPlugin Plugin { get; set; } private void Start() { ((Behaviour)this).enabled = Plugin.InstallPatches(); } private void Update() { Plugin.Tick(); } private void OnDestroy() { Plugin?.RemovePatches(); } } internal static class FieldGearRack { internal const int SlotBonus = 1; internal const int PurchaseLimit = 1; internal static HideoutFurniture Create(Transform templates) { return new HideoutFurniture(templates, "com.miner28.coolstuffmod.field-gear-rack", "Field Gear Rack", "+1 inventory slot while this rack is in your hideout. Applies when furniture bonuses are loaded.", 1500, 1, 6697382455916195843L, "8a680657-3a62-4bc6-8cec-1dde9fe1046a", "CoolStuffMod.FieldGearRack.png", GearRackModel.Apply, 1); } } internal sealed class FurnitureModel { private readonly GameObject model; private readonly GameObject shadow; private readonly Material originalMaterial; private readonly Material previewMaterial; private readonly Mesh cube; internal FurnitureModel(GameObject model, GameObject shadow) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown this.model = model; this.shadow = shadow; MeshRenderer[] componentsInChildren = model.GetComponentsInChildren<MeshRenderer>(true); MeshRenderer? obj = Array.Find(componentsInChildren, (MeshRenderer renderer) => Object.op_Implicit((Object)(object)((Renderer)renderer).sharedMaterial)); originalMaterial = ((obj != null) ? ((Renderer)obj).sharedMaterial : null); FurnitureShadow component = shadow.GetComponent<FurnitureShadow>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.shadowMat) || !Object.op_Implicit((Object)(object)originalMaterial)) { throw new InvalidOperationException(((Object)model).name + " has no compatible model or preview material."); } Collider[] componentsInChildren2 = model.GetComponentsInChildren<Collider>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { componentsInChildren2[num].enabled = false; } MeshRenderer[] array = componentsInChildren; for (int num = 0; num < array.Length; num++) { ((Renderer)array[num]).forceRenderingOff = true; } Renderer[] componentsInChildren3 = shadow.GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren3.Length; num++) { componentsInChildren3[num].forceRenderingOff = true; } previewMaterial = new Material(component.shadowMat); component.shadowMat = previewMaterial; GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); val.SetActive(false); cube = val.GetComponent<MeshFilter>().sharedMesh; Object.Destroy((Object)(object)val); } internal void SetPlacementBounds(Vector3 center, Vector3 size) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) BoxCollider component = shadow.GetComponent<BoxCollider>(); if (!Object.op_Implicit((Object)(object)component)) { throw new InvalidOperationException(((Object)shadow).name + " has no placement bounds."); } component.center = center; component.size = size; } internal void AddPart(string name, Vector3 center, Vector3 size, Material material, bool collides = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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) AddVisual(model.transform, name, center, size, material); AddVisual(shadow.transform, name, center, size, previewMaterial); if (collides) { BoxCollider obj = model.AddComponent<BoxCollider>(); obj.center = center; obj.size = size; } } internal Material Solid(Color color) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0041: 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) Shader val = Shader.Find("Standard"); Material val2 = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(originalMaterial)); val2.mainTexture = null; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", color); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", color); } return val2; } private void AddVisual(Transform parent, string name, Vector3 center, Vector3 size, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = center; val.transform.localScale = size; val.AddComponent<MeshFilter>().sharedMesh = cube; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; } } internal static class GearRackModel { internal static void Apply(GameObject model, GameObject shadow) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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_020f: Unknown result type (might be due to invalid IL or missing references) FurnitureModel furnitureModel = new FurnitureModel(model, shadow); Material material = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)31, (byte)55, (byte)62, byte.MaxValue))); Material material2 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)57, (byte)89, (byte)94, byte.MaxValue))); Material material3 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)216, (byte)153, (byte)56, byte.MaxValue))); Material material4 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)35, (byte)45, (byte)47, byte.MaxValue))); float[] array = new float[2] { -0.465f, 0.465f }; foreach (float num in array) { float[] array2 = new float[2] { -0.111f, 0.111f }; foreach (float num2 in array2) { furnitureModel.AddPart("Upright", new Vector3(num, 0.99f, num2), new Vector3(0.055f, 1.98f, 0.055f), material); } } array = new float[5] { 0.07f, 0.5f, 0.94f, 1.38f, 1.82f }; foreach (float num3 in array) { furnitureModel.AddPart("Shelf", new Vector3(0f, num3, 0f), new Vector3(0.98f, 0.058f, 0.275f), material2); } array = new float[4] { 0.235f, 0.665f, 1.105f, 1.545f }; foreach (float num4 in array) { float[] array2 = new float[2] { -0.218f, 0.218f }; foreach (float num5 in array2) { furnitureModel.AddPart("Gear bin", new Vector3(num5, num4, 0.003f), new Vector3(0.391f, 0.272f, 0.234f), material3); furnitureModel.AddPart("Recessed pull", new Vector3(num5, num4 + 0.052f, 0.123f), new Vector3(0.138f, 0.035f, 0.012f), material4, collides: false); } } } } internal sealed class GoldenCard { private readonly Transform templates; private readonly RegisteredPrefab registration; private readonly string artwork; private readonly string heldPrefabName; internal RunCardBonus Bonus { get; } internal string DisplayName { get; } internal string BonusDescription { get; } internal string HeldPrefabPath => "LootHandPrefabs/" + heldPrefabName; internal GameObject HeldCard { get; private set; } internal Sprite Icon { get; private set; } internal GoldenCard(Transform templates, RunCardBonus bonus, string displayName, string bonusDescription, string artwork, string heldPrefabName, long saveId, string prefabGuid) { this.templates = templates; this.artwork = artwork; this.heldPrefabName = heldPrefabName; Bonus = bonus; DisplayName = displayName; BonusDescription = bonusDescription; registration = new RegisteredPrefab(saveId, prefabGuid); } internal void Register(NetworkPrefabTable table, ES3PrefabDatabase database) { if (!Object.op_Implicit((Object)(object)registration.Template)) { Build(database); } registration.Register(table, database); } internal NetworkObject GetRegistered(NetworkRunner runner) { return registration.GetRegistered(runner); } private void Build(ES3PrefabDatabase database) { //IL_0163: 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_016d: Unknown result type (might be due to invalid IL or missing references) Pickupable? obj = (from prefab in database.prefabs where Object.op_Implicit((Object)(object)prefab) && ((Component)prefab).gameObject.activeSelf select ((Component)prefab).GetComponent<Pickupable>()).FirstOrDefault((Func<Pickupable, bool>)((Pickupable pickup) => Object.op_Implicit((Object)(object)pickup) && Object.op_Implicit((Object)(object)((Component)pickup).GetComponent<NetworkObject>()) && Object.op_Implicit((Object)(object)pickup.assignedItem) && pickup.assignedItem.isGoldenCard && !pickup.assignedItem.hasToBeCarried && Object.op_Implicit((Object)(object)pickup.assignedItem.itemHoldingPrefab) && Object.op_Implicit((Object)(object)pickup.assignedItem.itemHoldingPrefab.GetComponent<CarriedLoot>()) && Object.op_Implicit((Object)(object)LeafletArt.FindRenderer(((Component)pickup).gameObject, pickup.renderer)) && Object.op_Implicit((Object)(object)LeafletArt.FindRenderer(pickup.assignedItem.itemHoldingPrefab)))); if (!Object.op_Implicit((Object)(object)obj)) { throw new InvalidOperationException("No compatible Golden Card prefab was found in the game's save database."); } LeafletArt leafletArt = new LeafletArt(artwork); GameObject val = Object.Instantiate<GameObject>(((Component)obj).gameObject, templates); GameObject val2 = Object.Instantiate<GameObject>(obj.assignedItem.itemHoldingPrefab, templates); Item val3 = Object.Instantiate<Item>(obj.assignedItem); try { ((Object)val).name = DisplayName; ((Object)val2).name = heldPrefabName; val2.SetActive(true); Pickupable component = val.GetComponent<Pickupable>(); ApplyArtwork(LeafletArt.FindRenderer(val, component.renderer), leafletArt.Icon.texture); ApplyArtwork(LeafletArt.FindRenderer(val2), leafletArt.Icon.texture); ((Object)val3).name = heldPrefabName; val3.itemName = Bonus.NameTerm; val3.itemNameExtra = ""; val3.itemDropPrefab = val; val3.itemHoldingPrefab = val2; val3.itemSlotIcon = leafletArt.Icon; val3.iconColor = Color32.op_Implicit(Color.white); val3.flipIconX = false; val3.canStack = false; val3.requiredPlayerPrefToSpawn = ""; component.assignedItem = val3; component.pickupSavePref = ""; component.blockGeneratingPref = true; registration.SetTemplate(val); HeldCard = val2; Icon = leafletArt.Icon; } catch { Object.Destroy((Object)(object)val); Object.Destroy((Object)(object)val2); Object.Destroy((Object)(object)val3); throw; } } private static void ApplyArtwork(MeshRenderer renderer, Texture2D texture) { //IL_0006: 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_0013: Expected O, but got Unknown //IL_003f: 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) Material val = new Material(((Renderer)renderer).sharedMaterial) { mainTexture = (Texture)(object)texture }; if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)texture); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } ((Renderer)renderer).sharedMaterial = val; } } internal static class GoldenCardBonusesPanel { private sealed class PanelState { internal int ActiveMask; } [HarmonyPatch(typeof(PlayerStats), "SpawnBonuses")] internal static class SpawnPatch { private static void Postfix(PlayerStats __instance, FPP_Player ___player) { //IL_0078: 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_00a3: Unknown result type (might be due to invalid IL or missing references) BonusUI bonus = __instance.bonus; if (!CanDisplay(___player) || !Object.op_Implicit((Object)(object)bonus) || !Object.op_Implicit((Object)(object)__instance.bonusesCountTxt)) { return; } IReadOnlyList<GoldenCard> cards = FieldConditioningPlugin.Cards; int num = ActiveMask(cards, ((SimulationBehaviour)___player).Runner); for (int i = 0; i < cards.Count; i++) { if ((num & (1 << i)) != 0) { GoldenCard goldenCard = cards[i]; BonusUI val = Object.Instantiate<BonusUI>(bonus, ((Component)bonus).transform.parent); ((Component)val).transform.localScale = ((Component)bonus).transform.localScale; ((TMP_Text)val.bonusNameTxt).text = goldenCard.DisplayName; ((Graphic)val.bonusNameTxt).color = Color32.op_Implicit(val.goodCol); ((TMP_Text)val.bonusDescTxt).text = "<sprite=0> " + goldenCard.BonusDescription; val.bonusImage.sprite = goldenCard.Icon; val.bonusImage.preserveAspect = true; ((Behaviour)val.clockImage).enabled = false; ((Component)val).gameObject.SetActive(true); __instance.bonusSpawns.Add(((Component)val).gameObject); } } int num2 = ___player.WM.bonusManager.allBonuses.Count + cards.Count; ((TMP_Text)__instance.bonusesCountTxt).text = $"({__instance.bonusSpawns.Count}/{num2})"; Panels.GetValue(__instance, (PlayerStats _) => new PanelState()).ActiveMask = num; } } [HarmonyPatch(typeof(PlayerStats), "Update")] internal static class RefreshPatch { private static void Postfix(PlayerStats __instance, FPP_Player ___player) { if (!Panels.TryGetValue(__instance, out var value) || !CanDisplay(___player) || value.ActiveMask == ActiveMask(FieldConditioningPlugin.Cards, ((SimulationBehaviour)___player).Runner)) { return; } __instance.SpawnBonuses(); foreach (RefreshLayoutUI layout in __instance.layouts) { if (Object.op_Implicit((Object)(object)layout)) { layout.Refresh(); } } } } private static readonly ConditionalWeakTable<PlayerStats, PanelState> Panels = new ConditionalWeakTable<PlayerStats, PanelState>(); private static bool CanDisplay(FPP_Player player) { if (Object.op_Implicit((Object)(object)player) && ModSessions.AllowsContent(((SimulationBehaviour)player).Runner) && Object.op_Implicit((Object)(object)player.WM) && Object.op_Implicit((Object)(object)player.WM.bonusManager) && Object.op_Implicit((Object)(object)((SimulationBehaviour)player.WM.bonusManager).Object)) { return ((SimulationBehaviour)player.WM.bonusManager).Object.IsValid; } return false; } private static int ActiveMask(IReadOnlyList<GoldenCard> cards, NetworkRunner runner) { int num = 0; for (int i = 0; i < cards.Count; i++) { if (cards[i].Bonus.IsActive(runner)) { num |= 1 << i; } } return num; } } internal sealed class HideoutFurniture { [HarmonyPatch(typeof(FurnitureManager), "AmountOfFurniture")] internal static class PurchaseCountPatch { private static void Postfix(FurnitureManager __instance, Furniture __0, ref int __result) { NetworkRunner runner = ((SimulationBehaviour)__instance).Runner; if (__result == 0 && CountsPendingDelivery(__0) && ModSessions.AllowsContent(runner)) { GameObject prefab = ((Component)__0.prefab).gameObject; WorldManager instance = WorldManager.Instance; WeaponManager val = ((Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.localPlayer)) ? instance.localPlayer.weaponManager : null); if ((Object.op_Implicit((Object)(object)instance) && (Object)(object)((SimulationBehaviour)instance).Runner == (Object)(object)runner && IsPlacedIn(instance, __0.furnitureName)) || (Object.op_Implicit((Object)(object)val) && val.furnitureMode && (Object)(object)val.assignedFurniture == (Object)(object)__0) || Object.FindObjectsOfType<DeliveryDrone>().Any((DeliveryDrone drone) => (Object)(object)((SimulationBehaviour)drone).Runner == (Object)(object)runner && (drone.toSpawnOnDrop?.Contains(prefab) ?? false)) || Object.FindObjectsOfType<DropBox>().Any((DropBox box) => (Object)(object)((SimulationBehaviour)box).Runner == (Object)(object)runner && (box.spawnOnBreak?.Contains(prefab) ?? false))) { __result = 1; } } } } [HarmonyPatch(typeof(FurnitureWebsite), "OrderFurniture")] internal static class OrderPatch { private static bool Prefix(FurnitureWebsite __instance, Furniture ___selectedFurniture) { if (!CountsPendingDelivery(___selectedFurniture)) { return true; } WorldManager instance = WorldManager.Instance; if (!Object.op_Implicit((Object)(object)instance) || !ModSessions.AllowsContent(((SimulationBehaviour)instance).Runner) || (!((SimulationBehaviour)instance).Runner.IsSinglePlayer && !((SimulationBehaviour)instance).Runner.IsSharedModeMasterClient)) { return false; } if (instance.furnitureManager.AmountOfFurniture(___selectedFurniture) < ___selectedFurniture.maxLimit && instance.sharedMoney >= ___selectedFurniture.cost) { return true; } __instance.CheckIfCanBuy(); return false; } } private readonly Transform templates; private readonly RegisteredPrefab registration; private readonly int price; private readonly int limit; private readonly int itemSlots; private readonly string artwork; private readonly Action<GameObject, GameObject> buildModel; private Furniture furniture; internal string DisplayName { get; } internal string NameTerm { get; } internal string DescriptionTerm { get; } internal string Description { get; } internal HideoutFurniture(Transform templates, string contentId, string displayName, string description, int price, int limit, long saveId, string networkGuid, string artwork, Action<GameObject, GameObject> buildModel, int itemSlots = 0) { this.templates = templates; DisplayName = displayName; NameTerm = contentId + ".name"; DescriptionTerm = contentId + ".description"; Description = description; this.price = price; this.limit = limit; this.itemSlots = itemSlots; this.artwork = artwork; this.buildModel = buildModel; registration = new RegisteredPrefab(saveId, networkGuid); } internal static bool IsPlacedIn(WorldManager world, string nameTerm) { FurnitureObject val = default(FurnitureObject); return ((SimulationBehaviour)world).Runner.GetAllNetworkObjects().Any((NetworkObject networkObject) => Object.op_Implicit((Object)(object)networkObject) && ((Component)networkObject).TryGetComponent<FurnitureObject>(ref val) && Object.op_Implicit((Object)(object)val.assignedFurniture) && val.assignedFurniture.furnitureName == nameTerm); } internal void Register(NetworkPrefabTable table, ES3PrefabDatabase database) { if (!Object.op_Implicit((Object)(object)registration.Template)) { Build(database); } registration.Register(table, database); } internal bool AddStoreEntry(FurnitureWebsite website, NetworkRunner runner) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)registration.GetRegistered(runner)) || !Object.op_Implicit((Object)(object)website.listPage)) { return false; } FurnitureButton[] componentsInChildren = website.listPage.GetComponentsInChildren<FurnitureButton>(true); if (componentsInChildren.Any((FurnitureButton button) => (Object)(object)button.furniture == (Object)(object)furniture)) { return false; } FurnitureButton val = (from button in componentsInChildren where Object.op_Implicit((Object)(object)button.furniture) && Object.op_Implicit((Object)(object)((Component)button).GetComponent<Button>()) orderby string.Equals(button.furniture.furnitureName, "geometric shelf", StringComparison.OrdinalIgnoreCase) descending select button).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)val)) { return false; } FurnitureButton val2 = Object.Instantiate<FurnitureButton>(val, templates); ((Object)val2).name = "CoolStuffMod " + DisplayName + " Store Entry"; val2.website = website; val2.furniture = furniture; val2.reqStolenItems = false; val2.reqVIPStolenItems = false; val2.reqJobsCompleted = false; val2.reqChallengesCompleted = false; val2.reqItemListsCompleted = false; val2.reqInspectedJewelry = false; val2.reqSmeltedGoldBars = false; val2.reqGameWon = false; val2.reqTotalCreditsMade = false; val2.reqLevel = false; val2.reqHideoutExpansion = false; val2.reqAmountOfFurniture = false; val2.reqDLC = false; Button component = ((Component)val2).GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(new UnityAction(val2.Select)); ((Component)val2).transform.SetParent(((Component)val).transform.parent, false); ((Component)val2).transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); ((Component)val2).gameObject.SetActive(true); return true; } private void Build(ES3PrefabDatabase database) { FurnitureObject val = (from prefab in database.prefabs where Object.op_Implicit((Object)(object)prefab) select ((Component)prefab).GetComponent<FurnitureObject>()).FirstOrDefault((Func<FurnitureObject, bool>)((FurnitureObject candidate) => Object.op_Implicit((Object)(object)candidate) && Object.op_Implicit((Object)(object)candidate.assignedFurniture) && string.Equals(candidate.assignedFurniture.furnitureName, "geometric shelf", StringComparison.OrdinalIgnoreCase))); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.assignedFurniture.shadow)) { throw new InvalidOperationException("The floor shelf and its placement preview are required to build " + DisplayName + "."); } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, templates); GameObject val3 = Object.Instantiate<GameObject>(val.assignedFurniture.shadow, templates); Furniture val4 = ScriptableObject.CreateInstance<Furniture>(); try { ((Object)val2).name = DisplayName; ((Object)val3).name = DisplayName + " Placement Preview"; buildModel(val2, val3); ((Object)val4).name = DisplayName; val4.furnitureName = NameTerm; val4.storeDesc = DescriptionTerm; val4.storeImage = new LeafletArt(artwork).Icon; val4.cost = price; val4.maxLimit = limit; val4.bonusItemSlots = itemSlots; val4.achievementOnPurchase = ""; val4.activateBonus = ""; val4.prefab = val2.GetComponent<NetworkObject>(); val4.shadow = val3; val2.GetComponent<FurnitureObject>().assignedFurniture = val4; registration.SetTemplate(val2); furniture = val4; } catch { Object.Destroy((Object)(object)val2); Object.Destroy((Object)(object)val3); Object.Destroy((Object)(object)val4); throw; } } private static bool CountsPendingDelivery(Furniture furniture) { if (Object.op_Implicit((Object)(object)furniture)) { if (!(furniture.furnitureName == "com.miner28.coolstuffmod.armor-dispenser.name") && !(furniture.furnitureName == "com.miner28.coolstuffmod.supply-cabinet.name")) { return furniture.furnitureName == "com.miner28.coolstuffmod.maintenance-locker.name"; } return true; } return false; } } [HarmonyPatch(typeof(PlayerInventory), "CheckSlots")] internal static class InventoryCapacity { private const int NativeBaseSlots = 5; private const int NativeSlotCap = 10; private const int ExpandedSlotCount = 11; private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown FieldInfo field = typeof(PlayerInventory).GetField("availableSlots", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo spawn = typeof(PlayerInventory).GetMethod("SpawnItemSlots"); MethodInfo method = typeof(InventoryCapacity).GetMethod("ExpandSlots", BindingFlags.Static | BindingFlags.NonPublic); List<CodeInstruction> list = instructions.ToList(); CodeInstruction item = list.Single((CodeInstruction instruction) => object.Equals(instruction.operand, spawn)); int num = list.IndexOf(item); if (num == 0 || list[num - 1].opcode != OpCodes.Ldarg_0) { throw new InvalidOperationException("The game's inventory slot creation order has changed."); } list.InsertRange(num, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldflda, (object)field), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Call, (object)method), new CodeInstruction(OpCodes.Ldarg_0, (object)null) }); return list; } private static void ExpandSlots(ref int originalSlots, PlayerInventory inventory, bool load) { if (ModSessions.AllowsContent(((SimulationBehaviour)inventory.player).Runner)) { int extraItemSlots = inventory.player.WM.furnitureManager.extraItemSlots; originalSlots = Math.Max(originalSlots, CurrentCapacity(inventory, extraItemSlots)); if (load) { originalSlots = Math.Max(originalSlots, SavedSlotCount(originalSlots)); } } } internal static int CurrentCapacity(PlayerInventory inventory, int furnitureSlots) { int num = 5 + inventory.skills.extraItemSlots + furnitureSlots; bool hasBackpacker = inventory.skills.CheckIfSkillLearned("com.miner28.coolstuffmod.backpacker-ii"); return ExpandedCapacity(Math.Min(num, 10), num, hasBackpacker); } internal static int ExpandedCapacity(int nativeSlots, int requestedSlots, bool hasBackpacker) { if (hasBackpacker && requestedSlots >= 11) { return Math.Max(nativeSlots, 11); } return nativeSlots; } private static int SavedSlotCount(int availableSlots) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown if (availableSlots >= 11) { return availableSlots; } ES3Settings val = new ES3Settings(new Enum[1] { (Enum)(object)(Location)4 }); for (int num = 10; num >= availableSlots; num--) { string text = "ItemSlot" + num; try { if (ES3.KeyExists(text, val)) { SaveItemSlot val2 = new SaveItemSlot(); ES3.LoadInto<SaveItemSlot>(text, val2, val); if (val2.amount > 0) { return num + 1; } } } catch (Exception ex) { Debug.LogWarning((object)("BetterCrime could not read " + text + ": " + ex.Message)); } } return availableSlots; } } internal sealed class LeafletArt { private static readonly Vector3[] Axes = (Vector3[])(object)new Vector3[3] { Vector3.right, Vector3.up, Vector3.forward }; private readonly Texture2D cover; internal Sprite Icon { get; } internal LeafletArt(string artworkResource) { //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) using Stream stream = typeof(LeafletArt).Assembly.GetManifestResourceStream(artworkResource) ?? throw new InvalidOperationException("Missing embedded artwork " + artworkResource + "."); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); cover = new Texture2D(2, 2, (TextureFormat)4, true) { name = artworkResource, wrapMode = (TextureWrapMode)1 }; if (!ImageConversion.LoadImage(cover, memoryStream.ToArray(), true)) { throw new InvalidOperationException("Could not decode " + artworkResource + "."); } Icon = Sprite.Create(cover, new Rect(0f, 0f, (float)((Texture)cover).width, (float)((Texture)cover).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)Icon).name = artworkResource; } internal static MeshRenderer FindRenderer(GameObject model, MeshRenderer preferred = null) { if (Object.op_Implicit((Object)(object)preferred) && Object.op_Implicit((Object)(object)GetMesh(preferred))) { return preferred; } return (from renderer in model.GetComponentsInChildren<MeshRenderer>(true) where ((Renderer)renderer).enabled && Object.op_Implicit((Object)(object)GetMesh(renderer)) select renderer).OrderByDescending(delegate(MeshRenderer renderer) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = GetMesh(renderer).bounds; Vector3 size = ((Bounds)(ref bounds)).size; return ((Vector3)(ref size)).sqrMagnitude; }).FirstOrDefault(); } internal void Apply(GameObject model, MeshRenderer preferred = null) { //IL_003a: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) MeshRenderer val = FindRenderer(model, preferred); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("No display mesh found on " + ((Object)model).name + "."); } MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); component.sharedMesh = MakeBooklet(component.sharedMesh.bounds); Shader val2 = Shader.Find("Standard"); Material val3 = (Object.op_Implicit((Object)(object)val2) ? new Material(val2) : new Material(((Renderer)val).sharedMaterial)); ((Object)val3).name = "Skill leaflet print"; val3.mainTexture = (Texture)(object)cover; val3.mainTextureScale = Vector2.one; val3.mainTextureOffset = Vector2.zero; if (val3.HasProperty("_Color")) { val3.SetColor("_Color", Color.white); } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", Color.white); } if (val3.HasProperty("_Metallic")) { val3.SetFloat("_Metallic", 0f); } if (val3.HasProperty("_Glossiness")) { val3.SetFloat("_Glossiness", 0.2f); } ((Renderer)val).sharedMaterials = (Material[])(object)new Material[1] { val3 }; ((Renderer)val).enabled = true; Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)(object)val) { val4.forceRenderingOff = true; } } } private Mesh MakeBooklet(Bounds bounds) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0122: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_015f: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown int[] array = Enumerable.Range(0, 3).OrderBy(delegate(int axis) { //IL_0006: 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) Vector3 size = ((Bounds)(ref bounds)).size; return ((Vector3)(ref size))[axis]; }).ToArray(); Vector3 extents = ((Bounds)(ref bounds)).extents; float num = ((Vector3)(ref extents))[array[2]]; extents = ((Bounds)(ref bounds)).extents; float num2 = ((Vector3)(ref extents))[array[1]]; float num3 = (float)((Texture)cover).width / (float)((Texture)cover).height; num = Mathf.Min(num, num2 / num3); num2 = num * num3; Vector3 val = Axes[array[1]] * num2; Vector3 val2 = Axes[array[2]] * num; Vector3 val3 = Vector3.Cross(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized); extents = ((Bounds)(ref bounds)).extents; Vector3 val4 = val3 * Mathf.Max(((Vector3)(ref extents))[array[0]], num / 40f); Vector3 center = ((Bounds)(ref bounds)).center; List<Vector3> vertices = new List<Vector3>(24); List<int> triangles = new List<int>(36); List<Vector2> uv = new List<Vector2>(24); AddFace(center + val4, val, val2, printCover: true); AddFace(center - val4, -val, val2, printCover: true); AddFace(center + val, -val4, val2, printCover: false); AddFace(center - val, val4, val2, printCover: false); AddFace(center + val2, val, -val4, printCover: false); AddFace(center - val2, val, val4, printCover: false); Mesh val5 = new Mesh { name = "Skill leaflet booklet" }; val5.SetVertices(vertices); val5.SetTriangles(triangles, 0); val5.SetUVs(0, uv); val5.RecalculateNormals(); val5.RecalculateBounds(); return val5; void AddFace(Vector3 faceCenter, Vector3 horizontal, Vector3 vertical, bool printCover) { //IL_0012: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00af: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(faceCenter - horizontal - vertical); vertices.Add(faceCenter + horizontal - vertical); vertices.Add(faceCenter + horizontal + vertical); vertices.Add(faceCenter - horizontal + vertical); triangles.AddRange(new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); if (printCover) { uv.AddRange((IEnumerable<Vector2>)(object)new Vector2[4] { Vector2.right, Vector2.zero, Vector2.up, Vector2.one }); } else { uv.AddRange(Enumerable.Repeat<Vector2>(new Vector2(0.02f, 0.5f), 4)); } } } private static Mesh GetMesh(MeshRenderer renderer) { MeshFilter val = default(MeshFilter); if (!((Component)renderer).TryGetComponent<MeshFilter>(ref val)) { return null; } return val.sharedMesh; } } internal static class MaintenanceLocker { private const string ContentId = "com.miner28.coolstuffmod.maintenance-locker"; internal const string NameTerm = "com.miner28.coolstuffmod.maintenance-locker.name"; internal const int Price = 5000; internal const int PurchaseLimit = 1; internal const int RepairAmount = 15; internal static HideoutFurniture Create(Transform templates) { return new HideoutFurniture(templates, "com.miner28.coolstuffmod.maintenance-locker", "Maintenance Locker", "Restores 15 durability to each crew member's most worn repairable tool at the start of each mission while placed in the hideout.", 5000, 1, 6697382455916195850L, "8de71777-dc88-47da-9857-eb32932fa365", "CoolStuffMod.MaintenanceLocker.png", BuildModel); } internal static void ApplyTo(FPP_Player player) { PlayerInventory inventory = player.inventory; if (Object.op_Implicit((Object)(object)inventory) && inventory.itemSlots != null) { RepairMostWorn(from slot in inventory.itemSlots where Object.op_Implicit((Object)(object)slot) && IsRepairableTool(slot.assignedItem) select (damagesPerItem: slot.damagesPerItem, amount: slot.amount)); } } private static bool IsRepairableTool(Item item) { if (Object.op_Implicit((Object)(object)item) && item.canBeRepaired && item.isWeapon && !item.isLoot && !item.isAmmo && !item.isFirstAid && !item.isArmorVest) { return !item.isCarFuel; } return false; } internal static void RepairMostWorn(IEnumerable<(List<float> Damage, int Amount)> stacks) { List<float> list = null; int index = 0; float num = 0f; foreach (var stack in stacks) { if (stack.Damage == null) { continue; } int num2 = Math.Min(stack.Amount, stack.Damage.Count); for (int i = 0; i < num2; i++) { float num3 = stack.Damage[i]; if (float.IsFinite(num3) && !(num3 <= num)) { list = stack.Damage; index = i; num = num3; } } } if (list != null) { list[index] = Math.Max(0f, num - 15f); } } private static void BuildModel(GameObject model, GameObject shadow) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) FurnitureModel furnitureModel = new FurnitureModel(model, shadow); Material material = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)63, (byte)79, (byte)85, byte.MaxValue))); Material material2 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)104, (byte)123, (byte)124, byte.MaxValue))); Material material3 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)30, (byte)42, (byte)44, byte.MaxValue))); Material material4 = furnitureModel.Solid(Color32.op_Implicit(new Color32((byte)194, (byte)146, (byte)58, byte.MaxValue))); furnitureModel.SetPlacementBounds(new Vector3(0f, 0.79f, 0f), new Vector3(0.98f, 1.58f, 0.47f)); furnitureModel.AddPart("Cabinet", new Vector3(0f, 0.8f, 0f), new Vector3(0.93f, 1.48f, 0.4f), material); furnitureModel.AddPart("Base", new Vector3(0f, 0.04f, 0f), new Vector3(0.98f, 0.08f, 0.44f), material3); furnitureModel.AddPart("Top", new Vector3(0f, 1.54f, 0f), new Vector3(0.98f, 0.072f, 0.44f), material); furnitureModel.AddPart("Left door", new Vector3(-0.226f, 0.82f, 0.208f), new Vector3(0.427f, 1.31f, 0.024f), material2, collides: false); furnitureModel.AddPart("Right door", new Vector3(0.226f, 0.82f, 0.208f), new Vector3(0.427f, 1.31f, 0.024f), material2, collides: false); furnitureModel.AddPart("Left handle", new Vector3(-0.075f, 0.78f, 0.226f), new Vector3(0.037f, 0.16f, 0.048f), material3, collides: false); furnitureModel.AddPart("Right handle", new Vector3(0.075f, 0.78f, 0.226f), new Vector3(0.037f, 0.16f, 0.048f), material3, collides: false); furnitureModel.AddPart("Service plate", new Vector3(0.226f, 1.11f, 0.225f), new Vector3(0.2f, 0.095f, 0.016f), material4, collides: false); for (int i = 0; i < 3; i++) { float num = 1.335f - (float)i * 0.05f; furnitureModel.AddPart("Left vent", new Vector3(-0.226f, num, 0.223f), new Vector3(0.23f, 0.018f, 0.008f), material3, collides: false); furnitureModel.AddPart("Right vent", new Vector3(0.226f, num, 0.223f), new Vector3(0.23f, 0.018f, 0.008f), material3, collides: false); } } } internal static class MissionDeployment { [Flags] private enum Benefits { None = 0, Armor = 1, Supplies = 2, Maintenance = 4 } private sealed class PendingDeployment { private readonly string destination; private readonly int departureHandle; internal Benefits Grants { get; } internal PendingDeployment(Benefits grants, string destination, int departureHandle) { Grants = grants; this.destination = destination; this.departureHandle = departureHandle; } internal bool Matches(string scene, int handle) { if (scene == destination) { return handle != departureHandle; } return false; } } [HarmonyPatch(typeof(FPP_Player), "InitManagers")] internal static class GrantBenefitsPatch { private static void Postfix(FPP_Player __instance) { //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) if (!((NetworkBehaviour)__instance).HasStateAuthority || !ModSessions.AllowsContent(((SimulationBehaviour)__instance).Runner) || !Deployments.TryGetValue(((SimulationBehaviour)__instance).Runner, out var value)) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (!value.Matches(((Scene)(ref activeScene)).name, ((Scene)(ref activeScene)).handle) || !Deployments.Remove(((SimulationBehaviour)__instance).Runner)) { return; } if ((value.Grants & Benefits.Armor) != Benefits.None) { ArmorDispenser.ApplyTo(__instance); } if ((value.Grants & Benefits.Maintenance) != Benefits.None) { MaintenanceLocker.ApplyTo(__instance); } if ((value.Grants & Benefits.Supplies) == 0 || !IsHost(((SimulationBehaviour)__instance).Runner)) { return; } try { SupplyCabinet.Dispatch(__instance.WM); } catch (Exception arg) { Debug.LogError((object)string.Format("{0} could not dispatch the Supply Cabinet order: {1}", "BetterCrime", arg)); } } } [HarmonyPatch(typeof(Pinboard), "Update")] internal static class MissionDeparturePatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceCall(instructions, typeof(WorldManager).GetMethod("RPC_TriggerLoad"), "StartMission"); } } [HarmonyPatch(typeof(WorldManager), "RPC_TriggerLoad")] internal static class MissionLoadPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return ReplaceCall(instructions, typeof(LoadManager).GetMethod("TriggerLoad"), "BeginLoad"); } } private const string Hideout = "PlayerHideout"; private const string MissionScenePrefix = "csm-mission:"; private static readonly ConditionalWeakTable<NetworkRunner, PendingDeployment> Deployments = new ConditionalWeakTable<NetworkRunner, PendingDeployment>(); private static bool IsHost(NetworkRunner runner) { if (!runner.IsSinglePlayer) { return runner.IsSharedModeMasterClient; } return true; } private static void StartMission(WorldManager world, string scene, bool savePlayer) { NetworkRunner runner = ((SimulationBehaviour)world).Runner; Benefits benefits = Benefits.None; if (ModSessions.AllowsContent(runner) && IsHost(runner) && world.loadedMapName == "PlayerHideout") { if (HideoutFurniture.IsPlacedIn(world, "com.miner28.coolstuffmod.armor-dispenser.name")) { benefits |= Benefits.Armor; } if (HideoutFurniture.IsPlacedIn(world, "com.miner28.coolstuffmod.supply-cabinet.name")) { benefits |= Benefits.Supplies; } if (HideoutFurniture.IsPlacedIn(world, "com.miner28.coolstuffmod.maintenance-locker.name")) { benefits |= Benefits.Maintenance; } } world.RPC_TriggerLoad(EncodeScene(scene, benefits), savePlayer); } private static void BeginLoad(LoadManager loader, string scene, bool soloLoad) { //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) string destination; Benefits benefits = DecodeScene(scene, out destination); WorldManager instance = WorldManager.Instance; if (Object.op_Implicit((Object)(object)instance) && ModSessions.AllowsContent(((SimulationBehaviour)instance).Runner)) { NetworkRunner runner = ((SimulationBehaviour)instance).Runner; Deployments.Remove(runner); if (!IsHost(runner)) { benefits &= ~Benefits.Supplies; } if (benefits != Benefits.None && instance.loadedMapName == "PlayerHideout") { ConditionalWeakTable<NetworkRunner, PendingDeployment> deployments = Deployments; Benefits grants = benefits; string destination2 = destination; Scene activeScene = SceneManager.GetActiveScene(); deployments.Add(runner, new PendingDeployment(grants, destination2, ((Scene)(ref activeScene)).handle)); } } loader.TriggerLoad(destination, soloLoad); } private static string EncodeScene(string scene, Benefits benefits) { if (benefits != Benefits.None) { return "csm-mission:" + (char)(48 + benefits) + ":" + scene; } return scene; } private static Benefits DecodeScene(string scene, out string destination) { destination = scene; int length = "csm-mission:".Length; if (scene == null || scene.Length <= length + 2 || scene[length + 1] != ':' || !scene.StartsWith("csm-mission:", StringComparison.Ordinal)) { return Benefits.None; } Benefits benefits = (Benefits)(scene[length] - 48); if (benefits == Benefits.None || (benefits & ~(Benefits.Armor | Benefits.Supplies | Benefits.Maintenance)) != Benefits.None) { return Benefits.None; } destination = scene.Substring(length + 2); return benefits; } private static IEnumerable<CodeInstruction> ReplaceCall(IEnumerable<CodeInstruction> instructions, MethodInfo original, string replacementName) { MethodInfo replacement = typeof(MissionDeployment).GetMethod(replacementName, BindingFlags.Static | BindingFlags.NonPublic); int replacements = 0; foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && object.Equals(instruction.operand, original)) { instruction.opcode = OpCodes.Call; instruction.operand = replacement; replacements++; } yield return instruction; } if (replacements != 1) { throw new InvalidOperationException($"Expected one call to {original?.Name} for mission-start furniture, found {replacements}."); } } } internal static class ModSessions { private static readonly ConditionalWeakTable<NetworkRunner, object> PreparedRunners = new ConditionalWeakTable<NetworkRunner, object>(); internal static bool AllowsContent(NetworkRunner runner) { if (Object.op_Implicit((Object)(object)runner) && runner.IsRunning) { return IsPrepared(runner); } return false; } internal static bool IsPrepared(NetworkRunner runner) { object value; return PreparedRunners.TryGetValue(runner, out value); } internal static string Prepare(NetworkRunner runner, ref StartGameArgs args, IEnumerable<SkillLeaflet> leaflets, IEnumerable<HideoutFurniture> furnishings, IEnumerable<GoldenCard> cards) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 if ((int)args.GameMode == 2 && runner.IsCloudReady) { throw new InvalidOperationException("BetterCrime needs a new Fusion runner before connecting to an online room."); } ES3PrefabDatabase instance = ES3PrefabDatabase.Instance; if (!Object.op_Implicit((Object)(object)instance)) { throw new InvalidOperationException("The game's save prefab database could not be loaded."); } NetworkProjectConfig val = args.Config ?? NetworkProjectConfig.Global; NetworkProjectConfig val2 = (NetworkProjectConfig)(typeof(NetworkProjectConfig).GetMethod("Copy", BindingFlags.Instance | BindingFlags.Non