using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("happyness.CruiserLoader")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1")] [assembly: AssemblyProduct("CruiserLoader")] [assembly: AssemblyTitle("happyness.CruiserLoader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CruiserLoader { [BepInPlugin("happyness.CruiserLoader", "CruiserLoader", "0.0.1")] public class CruiserLoader : BaseUnityPlugin { public static CruiserLoader Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static ConfigFile ItemZoneConfig { get; private set; } private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ItemZoneConfig = new ConfigFile(Paths.ConfigPath + "/CruiserLoader/Items.cfg", true); new Harmony("happyness.CruiserLoader").PatchAll(); Log.LogInfo((object)"happyness.CruiserLoader v0.0.1 loaded successfully!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "happyness.CruiserLoader"; public const string PLUGIN_NAME = "CruiserLoader"; public const string PLUGIN_VERSION = "0.0.1"; } } namespace CruiserLoader.Patches { [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] public static class CaptureCommand { [HarmonyPrefix] public static bool Prefix(string chatMessage) { if (string.IsNullOrEmpty(chatMessage)) { return true; } if (!chatMessage.Equals("/cload")) { return true; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return false; } if (!NetworkManager.Singleton.IsHost) { return false; } VehicleController val = Object.FindObjectOfType(); if ((Object)(object)val == (Object)null) { CruiserLoader.Log.LogInfo((object)"No cruiser found!"); return false; } CruiserZoneManager.MoveItemsToCruiser(val); return false; } } [HarmonyPatch(typeof(StartOfRound))] internal class CruiserLoadPatch { internal static Dictionary> ItemZoneConfig = new Dictionary>(); internal static Dictionary> ItemCountConfig = new Dictionary>(); [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyPrefix] internal static void PatchLogic() { CruiserPositions.PositionsDictionary.Clear(); CruiserPositions.ZoneAllocated.Clear(); CruiserPositions.Zones.Clear(); CruiserPositions.CreateZones(); PopulateItemConfig(); TranslateDictionaries(); } internal static void PopulateItemConfig() { List itemsList = StartOfRound.Instance.allItemsList.itemsList; foreach (Item item in itemsList) { if ((!item.isScrap || item.itemName.Equals("Kitchen knife") || item.itemName.Equals("Shotgun")) && !(item.itemName == "Binoculars") && !(item.itemName == "box") && !(item.itemName == "Mapper")) { ItemZoneConfig[item.itemName] = CruiserLoader.ItemZoneConfig.Bind("Items", item.itemName, "", "Set cruiser zone for " + item.itemName + ". Leave empty to not move. (e.g. A1, B2, C3)"); ItemCountConfig[item.itemName] = CruiserLoader.ItemZoneConfig.Bind("ItemCounts", item.itemName, 5, "How many " + item.itemName + " to move to cruiser."); } } } internal static void TranslateDictionaries() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair> item in ItemZoneConfig) { string value = item.Value.Value; if (string.IsNullOrEmpty(value) || !CruiserPositions.Zones.ContainsKey(value)) { continue; } if (CruiserPositions.PositionsDictionary.ContainsKey(item.Key)) { Vector3 oldPosition = CruiserPositions.PositionsDictionary[item.Key]; string key = CruiserPositions.Zones.First>((KeyValuePair kv) => kv.Value == oldPosition).Key; CruiserPositions.ZoneAllocated[key] = Math.Max(0, CruiserPositions.ZoneAllocated.GetValueOrDefault(key, 0) - 1); if (CruiserPositions.ZoneAllocated[key] == 0) { CruiserPositions.ZoneAllocated.Remove(key); } CruiserPositions.PositionsDictionary.Remove(item.Key); } CruiserPositions.PositionsDictionary[item.Key] = CruiserPositions.Zones[value]; CruiserPositions.ZoneAllocated[value] = CruiserPositions.ZoneAllocated.GetValueOrDefault(value, 0) + 1; } } } internal static class CruiserZoneManager { internal static void MoveItemsToCruiser(VehicleController cruiser) { //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: 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_0299: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return; } bool flag = (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsHost; CruiserPositions.ResetPlacedCounts(); Dictionary dictionary = new Dictionary(); GrabbableObject[] array = Object.FindObjectsOfType(); int num = 0; GrabbableObject[] array2 = array; foreach (GrabbableObject val2 in array2) { if ((val2.itemProperties.isScrap && !val2.itemProperties.itemName.Equals("Kitchen knife") && !val2.itemProperties.itemName.Equals("Shotgun")) || (Object)(object)((Component)val2).transform.parent == (Object)null || ((Object)((Component)val2).transform.parent).name != "HangarShip" || val2.isHeld || val2.isPocketed) { continue; } string itemName = val2.itemProperties.itemName; if (!CruiserPositions.PositionsDictionary.TryGetValue(itemName, out var _)) { continue; } int num2 = 1; if (CruiserLoadPatch.ItemCountConfig.TryGetValue(itemName, out ConfigEntry value2)) { num2 = value2.Value; } dictionary.TryGetValue(itemName, out var value3); if (value3 >= num2) { continue; } string value4 = CruiserLoadPatch.ItemZoneConfig[itemName].Value; Vector3 nextZonePosition = CruiserPositions.GetNextZonePosition(value4); NetworkObject component = ((Component)cruiser).GetComponent(); ((Component)val2).transform.SetParent(((Component)cruiser).transform, true); ((Component)val2).transform.localPosition = nextZonePosition; val2.fallTime = 1f; val2.reachedFloorTarget = true; val2.hasHitGround = true; val2.targetFloorPosition = nextZonePosition; val2.startFallingPosition = nextZonePosition; try { val.PlaceObjectServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val2).NetworkObject), NetworkObjectReference.op_Implicit(component), nextZonePosition, false); } catch (Exception ex) { CruiserLoader.Log.LogError((object)("Error calling RPC for " + itemName + ": " + ex.Message)); } if (flag) { Rigidbody component2 = ((Component)val2).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.position = ((Component)cruiser).transform.TransformPoint(nextZonePosition); component2.velocity = Vector3.zero; component2.angularVelocity = Vector3.zero; } Physics.SyncTransforms(); } dictionary[itemName] = value3 + 1; num++; } CruiserLoader.Log.LogInfo((object)$"Moved {num} items to cruiser."); } } internal static class CruiserPositions { internal static Dictionary Zones = new Dictionary(); internal static Dictionary PositionsDictionary = new Dictionary(); internal static Dictionary ZoneAllocated = new Dictionary(); internal static Dictionary ZonePlacedCount = new Dictionary(); private static readonly HashSet ZStackZones = new HashSet { "A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3", "E1", "E2", "E3", "F1", "F2", "F3", "G1", "G2", "G3" }; private static readonly HashSet XStackZonesPositive = new HashSet { "D1" }; private static readonly HashSet XStackZonesNegative = new HashSet { "D3" }; internal static void CreateZones() { //IL_0025: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: 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) Zones.Clear(); Zones["A1"] = new Vector3(-1.15f, -0.4f, -2.6f); Zones["A2"] = new Vector3(-1.15f, 0.46f, -2.6f); Zones["A3"] = new Vector3(-1.15f, 1.22f, -2.6f); Zones["B1"] = new Vector3(-1.15f, -0.4f, -1.7f); Zones["B2"] = new Vector3(-1.15f, 0.46f, -1.7f); Zones["B3"] = new Vector3(-1.15f, 1.22f, -1.7f); Zones["C1"] = new Vector3(-1.15f, -0.4f, -0.8f); Zones["C2"] = new Vector3(-1.15f, 0.46f, -0.8f); Zones["C3"] = new Vector3(-1.15f, 1.22f, -0.8f); Zones["D1"] = new Vector3(-0.91f, 0f, 0.3f); Zones["D2"] = new Vector3(0f, -0.5f, -0.55f); Zones["D3"] = new Vector3(0.82f, 0f, 0.3f); Zones["E1"] = new Vector3(1.15f, -0.4f, -2.6f); Zones["E2"] = new Vector3(1.15f, 0.46f, -2.6f); Zones["E3"] = new Vector3(1.15f, 1.22f, -2.6f); Zones["F1"] = new Vector3(1.15f, -0.4f, -1.7f); Zones["F2"] = new Vector3(1.15f, 0.46f, -1.7f); Zones["F3"] = new Vector3(1.15f, 1.22f, -1.7f); Zones["G1"] = new Vector3(1.15f, -0.4f, -0.8f); Zones["G2"] = new Vector3(1.15f, 0.46f, -0.8f); Zones["G3"] = new Vector3(1.15f, 1.22f, -0.8f); } internal static Vector3 GetNextZonePosition(string zoneName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0048: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Zones[zoneName]; int valueOrDefault = ZonePlacedCount.GetValueOrDefault(zoneName, 0); int num = valueOrDefault % 5; ZonePlacedCount[zoneName] = valueOrDefault + 1; if (ZStackZones.Contains(zoneName)) { return new Vector3(val.x, val.y, val.z + (float)num * 0.1f); } if (XStackZonesPositive.Contains(zoneName)) { return new Vector3(val.x + (float)num * 0.1f, val.y, val.z); } if (XStackZonesNegative.Contains(zoneName)) { return new Vector3(val.x - (float)num * 0.1f, val.y, val.z); } return val; } internal static void ResetPlacedCounts() { ZonePlacedCount.Clear(); } } }