using System; using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; 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 Dawn; using GameNetcodeStuff; using HatLib.Tools; using MetalItemVariants.NetcodePatcher; using MetalItemVariants.Utils; 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("MetalItemVariants")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1")] [assembly: AssemblyProduct("MetalItemVariants")] [assembly: AssemblyTitle("MetalItemVariants")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MetalItemVariants { internal class ConfigManager { internal const string DawnModGUID = "MrHat.MetalItemVariants"; private static readonly DuskConfigInjector Configs = new DuskConfigInjector("MrHat.MetalItemVariants"); internal static ConfigEntry? DebugLogging { get; private set; } internal ConfigManager() { DebugLogging = Configs.Bind("_Mod Internal Settings", "Debug Logs", false, "Enables debug logging"); } } [BepInPlugin("MrHat.MetalItemVariants.Internals", "MetalItemVariants", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { internal const string modGUID = "MrHat.MetalItemVariants.Internals"; internal const string modName = "MetalItemVariants"; internal const string modVersion = "0.1.1"; internal const string HatLibGUID = "MrHat.Lib"; private const string DawnLibGUID = "com.github.teamxiaolan.dawnlib"; private const string DuskGUID = "com.github.teamxiaolan.dawnlib.dusk"; internal static ManualLogSource mls; internal static Plugin instance; internal const string DawnNamespace = "metalitemvariants"; internal static ConfigManager Configs { get; private set; } private void Awake() { instance = this; mls = Logger.CreateLogSource("MrHat.MetalItemVariants.Internals"); Configs = new ConfigManager(); DawnFindResource.OnFreeze((Registry)(object)LethalContent.Items, (Action)Utility.CacheLoadedResources); } internal static void LogDebug(object message) { ConfigEntry? debugLogging = ConfigManager.DebugLogging; if (debugLogging != null && debugLogging.Value) { mls.LogDebug(message); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MetalItemVariants"; public const string PLUGIN_NAME = "MetalItemVariants"; public const string PLUGIN_VERSION = "0.1.1"; } } namespace MetalItemVariants.Utils { internal static class Utility { internal static AudioClip OpenGiftAudio; internal static void CacheLoadedResources() { NamespacedKey val = NamespacedKey.Vanilla("gift"); NamespacedKey val2 = NamespacedKey.Vanilla("big_bolt"); NamespacedKey val3 = NamespacedKey.Vanilla("cash_register"); NamespacedKey val4 = NamespacedKey.Vanilla("cookie_pan"); NamespacedKey val5 = NamespacedKey.Vanilla("egg_beater"); NamespacedKey dropSourceKey = NamespacedKey.Vanilla("garbage_lid"); NamespacedKey val6 = NamespacedKey.Vanilla("gold_bar"); NamespacedKey dropSourceKey2 = NamespacedKey.Vanilla("golden_cup"); NamespacedKey val7 = NamespacedKey.Vanilla("large_axle"); NamespacedKey val8 = NamespacedKey.Vanilla("magnifying_glass"); NamespacedKey dropSourceKey3 = NamespacedKey.Vanilla("metal_sheet"); NamespacedKey val9 = NamespacedKey.Vanilla("proflashlight"); NamespacedKey dropSourceKey4 = NamespacedKey.Vanilla("stop_sign"); NamespacedKey val10 = NamespacedKey.Vanilla("vtype_engine"); AudioClip val11 = default(AudioClip); if (DawnFindResource.Resolve((Registry)(object)LethalContent.Items, val, (Func)delegate(DawnItemInfo info) { GameObject spawnPrefab = info.Item.spawnPrefab; return (spawnPrefab == null) ? null : spawnPrefab.GetComponent()?.openGiftAudio; }, "gift open audio", ref val11)) { OpenGiftAudio = val11; AudioTools.Load(val11); Plugin.LogDebug("Found gift open audio " + ((Object)OpenGiftAudio).name); } else { Plugin.mls.LogError((object)"Gift open audio source missing"); } AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_bolt"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_bolt"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_bolt"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_cash_register"), val3, val3, null, val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_cash_register"), val3, val3, null, val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_cash_register"), val3, val3, null, val3); AssignNoisemakerAudio(NamespacedKey.From("metalitemvariants", "bronze_cash_register"), val3); AssignNoisemakerAudio(NamespacedKey.From("metalitemvariants", "silver_cash_register"), val3); AssignNoisemakerAudio(NamespacedKey.From("metalitemvariants", "gold_cash_register"), val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_cookie_mold"), val4, val4, null, val4); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_cookie_mold"), val4, val4, null, val4); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_cookie_mold"), val4, val4, null, val4); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_egg_beater"), val5, val5, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_egg_beater"), val5, val5, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_egg_beater"), val5, val5, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_cup"), null, dropSourceKey2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_cup"), null, dropSourceKey2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "true_gold_cup"), null, dropSourceKey2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "lordly_garbage_lid"), null, dropSourceKey, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_gift"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_gift"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_gift"), val2, val2, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_bar"), val6, val6, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_bar"), val6, val6, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "radiant_golden_jar_of_pickles"), val2, dropSourceKey4, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_large_axle"), val7, val7, null, val7); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_large_axle"), val7, val7, null, val7); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_large_axle"), val7, val7, null, val7); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_magnifying_glass"), val8, val8, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_magnifying_glass"), val8, val8, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_magnifying_glass"), val8, val8, null, null); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_metal_sheet"), null, dropSourceKey3, null, val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_metal_sheet"), null, dropSourceKey3, null, val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_metal_sheet"), null, dropSourceKey3, null, val3); AssignItemAudio(NamespacedKey.From("metalitemvariants", "golden_flashlight"), val9, val2, val9, null); AssignFlashlightAudio(NamespacedKey.From("metalitemvariants", "golden_flashlight"), val9); AssignItemAudio(NamespacedKey.From("metalitemvariants", "bronze_vtype_engine"), val10, val10, null, val10); AssignItemAudio(NamespacedKey.From("metalitemvariants", "silver_vtype_engine"), val10, val10, null, val10); AssignItemAudio(NamespacedKey.From("metalitemvariants", "gold_vtype_engine"), val10, val10, null, val10); } private static void AssignItemAudio(NamespacedKey targetKey, NamespacedKey? grabSourceKey, NamespacedKey? dropSourceKey, NamespacedKey? pocketSourceKey, NamespacedKey? clinkSourceKey) { DawnItemInfo val = default(DawnItemInfo); if (!DawnFindResource.Resolve((Registry)(object)LethalContent.Items, targetKey, ref val)) { Plugin.mls.LogError((object)$"Audio target item missing: {targetKey}"); return; } AudioClip grabSFX = default(AudioClip); if (grabSourceKey != null && DawnFindResource.Resolve((Registry)(object)LethalContent.Items, grabSourceKey, (Func)((DawnItemInfo info) => info.Item.grabSFX), $"grab SFX for {targetKey}", ref grabSFX)) { val.Item.grabSFX = grabSFX; Plugin.LogDebug($"Assigned grab SFX {((Object)val.Item.grabSFX).name} to {targetKey}"); } AudioClip dropSFX = default(AudioClip); if (dropSourceKey != null && DawnFindResource.Resolve((Registry)(object)LethalContent.Items, dropSourceKey, (Func)((DawnItemInfo info) => info.Item.dropSFX), $"drop SFX for {targetKey}", ref dropSFX)) { val.Item.dropSFX = dropSFX; Plugin.LogDebug($"Assigned drop SFX {((Object)val.Item.dropSFX).name} to {targetKey}"); } AudioClip pocketSFX = default(AudioClip); if (pocketSourceKey != null && DawnFindResource.Resolve((Registry)(object)LethalContent.Items, pocketSourceKey, (Func)((DawnItemInfo info) => info.Item.pocketSFX), $"pocket SFX for {targetKey}", ref pocketSFX)) { val.Item.pocketSFX = pocketSFX; Plugin.LogDebug($"Assigned pocket SFX {((Object)val.Item.pocketSFX).name} to {targetKey}"); } AudioClip[] array = default(AudioClip[]); if (clinkSourceKey != null && DawnFindResource.Resolve((Registry)(object)LethalContent.Items, clinkSourceKey, (Func)delegate(DawnItemInfo info) { AudioClip[] clinkAudios = info.Item.clinkAudios; return (clinkAudios != null && clinkAudios.Length != 0) ? info.Item.clinkAudios : null; }, $"clink audios for {targetKey}", ref array)) { val.Item.clinkAudios = array; Plugin.LogDebug(string.Format("Assigned clink audios {0} to {1}", string.Join(", ", array.Select((AudioClip clip) => ((Object)clip).name)), targetKey)); } } private static void AssignNoisemakerAudio(NamespacedKey targetKey, NamespacedKey sourceKey) { NoisemakerProp val = default(NoisemakerProp); AudioClip[] noiseSFX = default(AudioClip[]); if (!DawnFindResource.Resolve((Registry)(object)LethalContent.Items, targetKey, (Func)delegate(DawnItemInfo info) { GameObject spawnPrefab = info.Item.spawnPrefab; return (spawnPrefab != null) ? spawnPrefab.GetComponent() : null; }, $"NoisemakerProp target for {targetKey}", ref val)) { Plugin.mls.LogError((object)$"NoisemakerProp audio target item missing: {targetKey}"); } else if (DawnFindResource.Resolve((Registry)(object)LethalContent.Items, sourceKey, (Func)delegate(DawnItemInfo info) { GameObject spawnPrefab = info.Item.spawnPrefab; return (spawnPrefab == null) ? null : spawnPrefab.GetComponent()?.noiseSFX; }, $"NoisemakerProp source noise SFX for {targetKey}", ref noiseSFX)) { val.noiseSFX = noiseSFX; Plugin.LogDebug(string.Format("Assigned NoisemakerProp noise SFX {0} to {1}", string.Join(", ", val.noiseSFX.Select((AudioClip clip) => ((Object)clip).name)), targetKey)); } } private static void AssignFlashlightAudio(NamespacedKey targetKey, NamespacedKey sourceKey) { FlashlightItem val = default(FlashlightItem); if (!DawnFindResource.Resolve((Registry)(object)LethalContent.Items, targetKey, (Func)delegate(DawnItemInfo info) { GameObject spawnPrefab = info.Item.spawnPrefab; return (spawnPrefab != null) ? spawnPrefab.GetComponent() : null; }, $"FlashlightItem target for {targetKey}", ref val)) { Plugin.mls.LogError((object)$"FlashlightItem audio target item missing: {targetKey}"); } else { FlashlightItem val2 = default(FlashlightItem); if (!DawnFindResource.Resolve((Registry)(object)LethalContent.Items, sourceKey, (Func)delegate(DawnItemInfo info) { GameObject spawnPrefab = info.Item.spawnPrefab; return (spawnPrefab != null) ? spawnPrefab.GetComponent() : null; }, $"FlashlightItem source for {targetKey}", ref val2)) { return; } if (val2.flashlightClips == null) { Plugin.mls.LogError((object)$"FlashlightItem clips source field missing for {targetKey}"); return; } val.flashlightClips = val2.flashlightClips; val.outOfBatteriesClip = val2.outOfBatteriesClip; val.flashlightFlicker = val2.flashlightFlicker; Plugin.LogDebug(string.Format("Assigned flashlight clips {0} to {1}", string.Join(", ", val.flashlightClips.Select((AudioClip clip) => ((Object)clip).name)), targetKey)); Plugin.LogDebug($"Assigned flashlight out of batteries clip {((Object)val.outOfBatteriesClip).name} to {targetKey}"); Plugin.LogDebug($"Assigned flashlight flicker clip {((Object)val.flashlightFlicker).name} to {targetKey}"); } } } } namespace MetalItemVariants.MonoBehaviours { public class MetalGiftBox : GrabbableObject { public ParticleSystem PoofParticle = null; public AudioSource presentAudio = null; public AudioClip openGiftAudio = null; [SerializeField] private string[] possibleItemKeys; [SerializeField] private string minimumValueBonusConfigKey; [SerializeField] private string maximumValueBonusConfigKey; private PlayerControllerB? previousHolder; private bool hasOpened; private bool hasLoadedSelectionFromSave; private int loadedSelectedIndex = -1; private int itemIndex = -1; private int selectedScrapValue; private int minimumValueBonus; private int maximumValueBonus; private bool hasNoItem; public override void Start() { ((GrabbableObject)this).Start(); minimumValueBonus = DuskConfigInjector.Read("MrHat.MetalItemVariants", minimumValueBonusConfigKey); maximumValueBonus = DuskConfigInjector.Read("MrHat.MetalItemVariants", maximumValueBonusConfigKey); openGiftAudio = Utility.OpenGiftAudio; if (((NetworkBehaviour)this).IsServer) { CoroutineTools.NextFrame((MonoBehaviour)(object)this, (Action)InitialiseSelection); } } public override void LoadItemSaveData(int saveData) { ((GrabbableObject)this).LoadItemSaveData(saveData); if (possibleItemKeys != null && possibleItemKeys.Length != 0) { loadedSelectedIndex = Mathf.Clamp(saveData, 0, possibleItemKeys.Length - 1); hasLoadedSelectionFromSave = true; } } public override int GetItemDataToSave() { ((GrabbableObject)this).GetItemDataToSave(); return (itemIndex >= 0) ? itemIndex : 0; } public override void EquipItem() { ((GrabbableObject)this).EquipItem(); previousHolder = base.playerHeldBy; } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (!hasNoItem && buttonDown && !((Object)(object)base.playerHeldBy == (Object)null) && !hasOpened) { hasOpened = true; base.playerHeldBy.activatingItem = true; OpenBoxRpc(); } } public override void PocketItem() { ((GrabbableObject)this).PocketItem(); PlayerControllerB playerHeldBy = base.playerHeldBy; if (playerHeldBy != null) { playerHeldBy.activatingItem = false; } } [Rpc(/*Could not decode attribute arguments.*/)] private void OpenBoxRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0081: 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) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3293125562u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3293125562u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!GetItem(out Item item) || (Object)(object)item.spawnPrefab == (Object)null) { Plugin.mls.LogError((object)"MetalGiftBox could not find the selected item"); EndOpenRpc(); return; } Vector3 val4 = ((Component)this).transform.position + Vector3.up * 0.25f; PlayerControllerB? obj = previousHolder; Transform val5 = (((obj != null && obj.isInElevator) || StartOfRound.Instance.inShipPhase) ? StartOfRound.Instance.elevatorTransform : null); GrabbableObject val6 = default(GrabbableObject); NetworkObject val7 = default(NetworkObject); if (!PrefabSpawns.Grabbable(item, val4, Quaternion.identity, ref val6, ref val7, val5)) { Plugin.mls.LogError((object)"MetalGiftBox (somehow) spawned an object without GrabbableObject or NetworkObject"); EndOpenRpc(); return; } val6.SetScrapValue(selectedScrapValue); GrabbablePlacement.DropFrom(val6, val4, val6.GetItemFloorPosition(((Component)this).transform.position)); ((MonoBehaviour)this).StartCoroutine(ResetSpawnedItemFallState(val6)); ApplyShipDropState(val6); val7.Spawn(false); SyncSpawnedItemRpc(NetworkObjectReference.op_Implicit(val7), selectedScrapValue, val4); EndOpenRpc(); } private void InitialiseSelection() { if (possibleItemKeys == null || possibleItemKeys.Length == 0) { return; } if (hasLoadedSelectionFromSave) { itemIndex = loadedSelectedIndex; if (GetItem(out Item item)) { hasNoItem = false; Plugin.LogDebug("MetalGiftBox loaded item: " + item.itemName + " (" + possibleItemKeys[itemIndex] + ")"); selectedScrapValue = RollScrapValue(item); return; } Plugin.mls.LogWarning((object)("MetalGiftBox could not find saved item key '" + possibleItemKeys[itemIndex] + "'. Is item disabled in config? Rerolling...")); } if (GetRandomItem(out Item item2)) { Plugin.LogDebug("MetalGiftBox rolled random item: " + item2.itemName + " (" + possibleItemKeys[itemIndex] + ")"); selectedScrapValue = RollScrapValue(item2); } } private bool GetRandomItem([NotNullWhen(true)] out Item? item) { item = null; if (possibleItemKeys == null || possibleItemKeys.Length == 0) { return false; } int num = possibleItemKeys.Length; bool[] array = new bool[possibleItemKeys.Length]; while (num > 0) { int num2 = Random.Range(0, possibleItemKeys.Length); while (array[num2]) { num2 = Random.Range(0, possibleItemKeys.Length); } array[num2] = true; num--; itemIndex = num2; if (GetItem(out item)) { hasNoItem = false; return true; } Plugin.mls.LogWarning((object)("MetalGiftBox could not find item key '" + possibleItemKeys[num2] + "', is item disabled in config? Rerolling...")); } Plugin.mls.LogError((object)"MetalGiftBox could not find any item keys, are all metal variant items disabled in config?"); itemIndex = -1; hasNoItem = true; return false; } private IEnumerator ResetSpawnedItemFallState(GrabbableObject spawnedItem) { yield return (object)new WaitForEndOfFrame(); spawnedItem.reachedFloorTarget = false; spawnedItem.hasHitGround = false; spawnedItem.fallTime = 0f; } [Rpc(/*Could not decode attribute arguments.*/)] private void EndOpenRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3275437139u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3275437139u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ParticleSystem poofParticle = PoofParticle; if (poofParticle != null) { poofParticle.Play(); } if ((Object)(object)presentAudio != (Object)null && (Object)(object)openGiftAudio != (Object)null && AudioTools.PlayOneShot(presentAudio, openGiftAudio)) { WalkieTalkie.TransmitOneShotAudio(presentAudio, openGiftAudio, 1f); RoundManager.Instance.PlayAudibleNoise(((Component)presentAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0); } if ((Object)(object)base.playerHeldBy != (Object)null) { base.playerHeldBy.activatingItem = false; ((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy); } if (((NetworkBehaviour)this).IsServer) { AudioClip obj = openGiftAudio; float num = ((obj != null) ? obj.length : 0f); if (num <= 0f) { DespawnGift(); } else { CoroutineTools.Delay((MonoBehaviour)(object)this, num, (Action)DespawnGift); } } } private void DespawnGift() { if (((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncSpawnedItemRpc(NetworkObjectReference netObjectRef, int scrapValue, Vector3 spawnPosition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3654392344u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref netObjectRef, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, scrapValue); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPosition); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3654392344u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; int scrapValue2 = scrapValue; Vector3 spawnPosition2 = spawnPosition; if (!((NetworkBehaviour)this).IsServer) { NetworkRefs.WhenReady((MonoBehaviour)(object)this, netObjectRef, (Action)delegate(GrabbableObject spawnedItem) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) ApplySpawnedItemOnClient(spawnedItem, scrapValue2, spawnPosition2); }, 8f, 1); } } private void ApplySpawnedItemOnClient(GrabbableObject spawnedItem, int scrapValue, Vector3 spawnPosition) { //IL_006f: 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_0072: Unknown result type (might be due to invalid IL or missing references) RoundManager instance = RoundManager.Instance; instance.totalScrapValueInLevel -= (float)scrapValue; RoundManager instance2 = RoundManager.Instance; instance2.totalScrapValueInLevel += (float)spawnedItem.scrapValue; spawnedItem.SetScrapValue(scrapValue); Transform transform = ((Component)spawnedItem).transform; PlayerControllerB? obj = previousHolder; transform.SetParent(((obj != null && obj.isInElevator) || StartOfRound.Instance.inShipPhase) ? StartOfRound.Instance.elevatorTransform : null, true); GrabbablePlacement.DropFrom(spawnedItem, spawnPosition, spawnedItem.GetItemFloorPosition(spawnPosition)); ApplyShipDropState(spawnedItem); } private void ApplyShipDropState(GrabbableObject spawnedItem) { PlayerControllerB? obj = previousHolder; if (obj != null && obj.isInHangarShipRoom) { previousHolder.SetItemInElevator(true, true, spawnedItem); } } private bool GetItem([NotNullWhen(true)] out Item? item) { item = null; if (possibleItemKeys == null || itemIndex < 0 || itemIndex >= possibleItemKeys.Length || string.IsNullOrWhiteSpace(possibleItemKeys[itemIndex])) { return false; } NamespacedKey val = NamespacedKey.From("metalitemvariants", possibleItemKeys[itemIndex]); DawnItemInfo val2 = default(DawnItemInfo); if (!DawnFindResource.Resolve((Registry)(object)LethalContent.Items, val, ref val2)) { return false; } item = val2.Item; return (Object)(object)item != (Object)null; } private int RollScrapValue(Item item) { int num = item.minValue + minimumValueBonus; int num2 = item.maxValue + maximumValueBonus; if (num2 <= num) { num2 = num + 1; } return (int)((float)Random.Range(num, num2) * RoundManager.Instance.scrapValueMultiplier); } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3293125562u, new RpcReceiveHandler(__rpc_handler_3293125562), "OpenBoxRpc"); ((NetworkBehaviour)this).__registerRpc(3275437139u, new RpcReceiveHandler(__rpc_handler_3275437139), "EndOpenRpc"); ((NetworkBehaviour)this).__registerRpc(3654392344u, new RpcReceiveHandler(__rpc_handler_3654392344), "SyncSpawnedItemRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_3293125562(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((MetalGiftBox)(object)target).OpenBoxRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3275437139(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((MetalGiftBox)(object)target).EndOpenRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3654392344(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference netObjectRef = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref netObjectRef, default(ForNetworkSerializable)); int scrapValue = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref scrapValue); Vector3 spawnPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition); target.__rpc_exec_stage = (__RpcExecStage)1; ((MetalGiftBox)(object)target).SyncSpawnedItemRpc(netObjectRef, scrapValue, spawnPosition); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "MetalGiftBox"; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace MetalItemVariants.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }