using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.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 CargoBackpackMod { public sealed class CargoBackpackController : MonoBehaviour { private static readonly FieldInfo OwnerId = AccessTools.Field(typeof(ItemEquippable), "ownerPlayerId"); private static readonly FieldInfo Tumbling = AccessTools.Field(typeof(PlayerAvatar), "isTumbling"); private static readonly FieldInfo Crawling = AccessTools.Field(typeof(PlayerAvatar), "isCrawling"); private static readonly FieldInfo Crouching = AccessTools.Field(typeof(PlayerAvatar), "isCrouching"); private static readonly FieldInfo GrabbedObject = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject"); private static readonly FieldInfo InputDisabled = AccessTools.Field(typeof(PlayerController), "InputDisableTimer"); private ItemAttributes _attributes; private ItemEquippable _equippable; private PhotonView _view; private readonly ItemEquippable[] _items = (ItemEquippable[])(object)new ItemEquippable[4]; private readonly CargoSlotLedger _ledger = new CargoSlotLedger(); private float _nextInput; private float _equipCheckAt; private int _requestedEquipSlot = -1; private bool _localUse; private GameObject _wornModel; private PlayerAvatar _wornOwner; private readonly float[] _nextRecoveryAttempt = new float[4]; private float _recoveryReadyAt; private float _recoveryGiveUpAt; private int _activeRecoverySlot = -1; private GameObject _activeRecoveryObject; private float _activeRecoveryDeadline; internal ItemEquippable Equippable => _equippable; internal string PersistentName => CargoPersistence.GetInstanceName(_attributes); internal bool IsOwnedByLocalPlayer() { if ((Object)(object)_equippable == (Object)null || !_equippable.IsEquipped()) { return false; } if (!SemiFunc.IsMultiplayer()) { return true; } if (OwnerId == null || (Object)(object)PhysGrabber.instance == (Object)null || (Object)(object)PhysGrabber.instance.photonView == (Object)null) { return false; } return (int)OwnerId.GetValue(_equippable) == PhysGrabber.instance.photonView.ViewID; } private void Awake() { _attributes = ((Component)this).GetComponent(); _equippable = ((Component)this).GetComponent(); _view = ((Component)this).GetComponent(); } private void Start() { CargoPersistence.RegisterItem(_attributes); CargoItemFactory.ApplyRuntimeIcon(_attributes); _recoveryReadyAt = Time.unscaledTime + 5f; _recoveryGiveUpAt = Time.unscaledTime + 30f; } internal void BeginLocalUse() { _localUse = true; } internal void EndLocalUse() { _localUse = false; } internal void PrepareDrop() { _localUse = false; } internal int GetCargoHash(int slot) { if (slot < 0 || slot >= 4) { return 0; } return _ledger.Read(slot, CargoPersistence.Read(PersistentName, slot)); } internal ItemEquippable GetCargoItem(int slot) { if (slot < 0 || slot >= 4) { return null; } if ((Object)(object)_items[slot] == (Object)null) { _items[slot] = CargoPersistence.FindItem(GetCargoHash(slot)); } return _items[slot]; } internal bool IsCargoSlotOccupied(int slot) { return GetCargoHash(slot) != 0; } internal void RuntimeTick() { UpdateWearable(); if ((Object)(object)_wornModel != (Object)null) { CargoBackpackVisuals.UpdateSlotLights(_wornModel, IsCargoSlotOccupied); } CheckEquipAttempt(); for (int i = 0; i < 4; i++) { ItemEquippable cargoItem = GetCargoItem(i); if ((Object)(object)cargoItem != (Object)null && !cargoItem.IsEquipped() && (Object)(object)((Component)cargoItem).GetComponent() == (Object)null) { if (CargoStoredItemState.CanAttach(cargoItem, this)) { CargoStoredItemState.Store(cargoItem, this, i); continue; } _items[i] = null; RecoverMissingItem(i); } else if ((Object)(object)cargoItem == (Object)null && GetCargoHash(i) != 0) { RecoverMissingItem(i); } } } internal void ToggleVirtualCargoSlot(int slot) { if (!_localUse || slot < 0 || slot > 3 || Time.unscaledTime < _nextInput || (Object)(object)PlayerController.instance == (Object)null || SemiFunc.RunIsArena() || (InputDisabled != null && (float)InputDisabled.GetValue(PlayerController.instance) > 0f)) { return; } _nextInput = Time.unscaledTime + 0.3f; int cargoHash = GetCargoHash(slot); ItemEquippable val = CargoRuntime.FindHeldItem(); if ((cargoHash == 0 && (Object)(object)val == (Object)null) || ((Object)(object)val != (Object)null && (val.IsEquipped() || (Object)(object)((Component)val).GetComponent() != (Object)null || CargoStoredItemState.Contains(val)))) { return; } if (SemiFunc.IsMultiplayer()) { if ((Object)(object)_view != (Object)null && ((Object)(object)val == (Object)null || (Object)(object)((MonoBehaviourPun)val).photonView != (Object)null)) { _view.RPC("CargoRequestSlotRPC", (RpcTarget)2, new object[3] { slot, cargoHash, ((Object)(object)val != (Object)null) ? ((MonoBehaviourPun)val).photonView.ViewID : 0 }); } } else { CommitRequest(slot, cargoHash, val, PlayerAvatar.instance); } } [PunRPC] private void CargoRequestSlotRPC(int slot, int expected, int itemViewId, PhotonMessageInfo info) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient) { return; } PlayerAvatar val = ResolveOwner(); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.photonView == (Object)null) && info.Sender == val.photonView.Owner) { PhotonView val2 = ((itemViewId != 0) ? PhotonView.Find(itemViewId) : null); if (itemViewId == 0 || !((Object)(object)val2 == (Object)null)) { ItemEquippable incoming = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); CommitRequest(slot, expected, incoming, val); } } } private void CommitRequest(int slot, int expected, ItemEquippable incoming, PlayerAvatar owner) { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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) if (slot < 0 || slot > 3 || (Object)(object)owner == (Object)null || !_equippable.IsEquipped() || expected != GetCargoHash(slot)) { return; } ItemEquippable val = ((expected != 0) ? GetCargoItem(slot) : null); if ((expected != 0 && ((Object)(object)val == (Object)null || val.IsEquipped() || CargoPersistence.GetItemHash(val) != expected)) || ((Object)(object)incoming == (Object)null && (Object)(object)val == (Object)null)) { return; } PhysGrabber val2 = (((Object)(object)owner == (Object)(object)PlayerAvatar.instance) ? PhysGrabber.instance : owner.physGrabber); PhysGrabObject val3 = (PhysGrabObject)(((Object)(object)val2 != (Object)null && val2.grabbed && GrabbedObject != null) ? /*isinst with value type is only supported in some contexts*/: null); int itemHash = CargoPersistence.GetItemHash(incoming); if ((Object)(object)incoming != (Object)null) { if (incoming.IsEquipped() || (Object)(object)((Component)incoming).GetComponent() != (Object)null || itemHash == 0 || CargoStoredItemState.Contains(incoming) || (Object)(object)val3 == (Object)null || (Object)(object)((Component)val3).GetComponent() != (Object)(object)incoming) { return; } CargoBackpackController[] array = Object.FindObjectsOfType(); foreach (CargoBackpackController cargoBackpackController in array) { for (int j = 0; j < 4; j++) { if (cargoBackpackController.GetCargoHash(j) == itemHash) { return; } } } } else if ((Object)(object)val3 != (Object)null) { return; } Vector3 val4 = CargoHandTransfer.ReleasePosition(owner, incoming, val); int num = _ledger.Revision + 1; if (SemiFunc.IsMultiplayer()) { _view.RPC("CargoCommitSlotRPC", (RpcTarget)0, new object[7] { num, slot, itemHash, ((Object)(object)incoming != (Object)null) ? ((MonoBehaviourPun)incoming).photonView.ViewID : 0, ((Object)(object)val != (Object)null) ? ((MonoBehaviourPun)val).photonView.ViewID : 0, val4, owner.photonView.ViewID }); } else { ApplyCommit(num, slot, itemHash, incoming, val, val4, owner); } CargoPersistence.WriteSlot(PersistentName, slot, incoming); } private void RecoverMissingItem(int slot) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (unscaledTime < _recoveryReadyAt || (_activeRecoverySlot >= 0 && _activeRecoverySlot != slot)) { return; } int cargoHash = GetCargoHash(slot); ItemEquippable val = CargoPersistence.FindItem(cargoHash); if (_activeRecoverySlot < 0 && (Object)(object)val != (Object)null && CargoStoredItemState.CanAttach(val, this)) { CompleteRecovery(slot, val, cargoHash); } else { if (SemiFunc.IsMultiplayer() && !PhotonNetwork.IsMasterClient) { return; } if (_activeRecoverySlot == slot) { ItemEquippable val2 = (((Object)(object)_activeRecoveryObject != (Object)null) ? _activeRecoveryObject.GetComponent() : null); if ((Object)(object)val2 != (Object)null && CargoPersistence.GetItemHash(val2) != 0) { if (CompleteRecovery(slot, val2, cargoHash)) { FinishRecovery(); } } else if (unscaledTime >= _activeRecoveryDeadline) { DestroyFailedRecoveryObject(); ClearUnrecoverableSlot(slot, "the single replacement did not initialize"); FinishRecovery(); } } else if (unscaledTime >= _recoveryGiveUpAt) { ClearUnrecoverableSlot(slot, "saved item could not be recreated"); } else { if (unscaledTime < _nextRecoveryAttempt[slot]) { return; } _nextRecoveryAttempt[slot] = unscaledTime + 4f; if (CargoPersistence.TrySpawnMissing(PersistentName, slot, cargoHash, ((Component)this).transform.position, out var spawned, out var reason)) { _activeRecoverySlot = slot; _activeRecoveryObject = spawned; _activeRecoveryDeadline = unscaledTime + 5f; ItemEquippable component = spawned.GetComponent(); if ((Object)(object)component != (Object)null) { CargoStoredItemState.Store(component, this, slot); } CargoBackpackPlugin.Log.LogWarning((object)("CARGO creating one replacement for slot " + (slot + 4))); } else { _nextRecoveryAttempt[slot] = unscaledTime + 1f; CargoBackpackPlugin.Log.LogWarning((object)("CARGO recovery waiting for slot " + (slot + 4) + ": " + reason)); } } } } private bool CompleteRecovery(int slot, ItemEquippable item, int previousHash) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) int itemHash = CargoPersistence.GetItemHash(item); if ((Object)(object)item == (Object)null || itemHash == 0) { return false; } PlayerAvatar val = ResolveOwner(); int num = _ledger.Revision + 1; if (SemiFunc.IsMultiplayer()) { if ((Object)(object)_view == (Object)null || (Object)(object)((MonoBehaviourPun)item).photonView == (Object)null) { return false; } _view.RPC("CargoCommitSlotRPC", (RpcTarget)0, new object[7] { num, slot, itemHash, ((MonoBehaviourPun)item).photonView.ViewID, 0, Vector3.zero, ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null) ? val.photonView.ViewID : 0 }); } else { ApplyCommit(num, slot, itemHash, item, null, Vector3.zero, val); } CargoPersistence.WriteSlot(PersistentName, slot, item); CargoBackpackPlugin.Log.LogInfo((object)("CARGO restored slot " + (slot + 4) + ": " + ((Object)item).name + "; identity " + previousHash + " -> " + itemHash)); return true; } private void DestroyFailedRecoveryObject() { if (!((Object)(object)_activeRecoveryObject == (Object)null)) { if (SemiFunc.IsMultiplayer() && PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(_activeRecoveryObject); } else { Object.Destroy((Object)(object)_activeRecoveryObject); } } } private void FinishRecovery() { _activeRecoverySlot = -1; _activeRecoveryObject = null; _activeRecoveryDeadline = 0f; } private void ClearUnrecoverableSlot(int slot, string reason) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) int num = _ledger.Revision + 1; PlayerAvatar val = ResolveOwner(); if (SemiFunc.IsMultiplayer() && (Object)(object)_view != (Object)null) { _view.RPC("CargoCommitSlotRPC", (RpcTarget)0, new object[7] { num, slot, 0, 0, 0, Vector3.zero, ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null) ? val.photonView.ViewID : 0 }); } else { _ledger.Commit(num, slot, 0); } _items[slot] = null; CargoPersistence.ApplyLocal(PersistentName, slot, 0); CargoPersistence.WriteSlot(PersistentName, slot, null); CargoBackpackPlugin.Log.LogWarning((object)("CARGO cleared unavailable slot " + (slot + 4) + ": " + reason)); } [PunRPC] private void CargoCommitSlotRPC(int revision, int slot, int hash, int incomingId, int outgoingId, Vector3 releasePosition, int ownerViewId, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { PhotonView val = ((incomingId != 0) ? PhotonView.Find(incomingId) : null); PhotonView val2 = ((outgoingId != 0) ? PhotonView.Find(outgoingId) : null); PhotonView val3 = ((ownerViewId != 0) ? PhotonView.Find(ownerViewId) : null); ItemEquippable incoming = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); ItemEquippable outgoing = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); PlayerAvatar owner = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent() : null); ApplyCommit(revision, slot, hash, incoming, outgoing, releasePosition, owner); } } private void ApplyCommit(int revision, int slot, int hash, ItemEquippable incoming, ItemEquippable outgoing, Vector3 releasePosition, PlayerAvatar owner) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!_ledger.Commit(revision, slot, hash)) { return; } _items[slot] = incoming; CargoPersistence.ApplyLocal(PersistentName, slot, hash); if ((Object)(object)incoming != (Object)null) { CargoHandTransfer.ReleaseIncoming(incoming); CargoStoredItemState.Store(incoming, this, slot); } if ((Object)(object)outgoing != (Object)null) { CargoStoredItemState.Unstore(outgoing, releasePosition); if ((Object)(object)owner == (Object)(object)PlayerAvatar.instance && (Object)(object)PhysGrabber.instance != (Object)null) { CargoHandTransfer cargoHandTransfer = ((Component)this).GetComponent(); if ((Object)(object)cargoHandTransfer == (Object)null) { cargoHandTransfer = ((Component)this).gameObject.AddComponent(); } cargoHandTransfer.Begin(outgoing); } } CargoBackpackPlugin.Log.LogInfo((object)("CARGO commit " + revision + ": slot " + (slot + 4) + (((Object)(object)incoming != (Object)null && (Object)(object)outgoing != (Object)null) ? " swapped" : ((hash == 0) ? " retrieved" : " stored")) + "; bag=" + PersistentName)); } internal void TrackEquipAttempt(int slot) { _requestedEquipSlot = slot; _equipCheckAt = Time.unscaledTime + 0.75f; } internal void PrepareForEquip() { if ((Object)(object)_equippable == (Object)null || _equippable.IsEquipped()) { return; } foreach (InventorySpot item in CargoRuntime.GetAllSpots() ?? Array.Empty()) { if ((Object)(object)item != (Object)null && (Object)(object)item.CurrentItem == (Object)(object)_equippable) { item.UnequipItem(); } } FieldInfo fieldInfo = AccessTools.Field(typeof(ItemEquippable), "currentState"); if (fieldInfo != null) { fieldInfo.SetValue(_equippable, Enum.ToObject(fieldInfo.FieldType, 0)); } SetEquipField("equippedSpot", null); SetEquipField("stateStart", true); SetEquipField("isEquipped", false); SetEquipField("isUnequipping", false); SetEquipField("isForceUnequipping", false); SetEquipField("isEquipping", false); SetEquipField("ownerPlayerId", -1); } private void SetEquipField(string name, object value) { FieldInfo fieldInfo = AccessTools.Field(typeof(ItemEquippable), name); if (fieldInfo != null) { fieldInfo.SetValue(_equippable, value); } } private void CheckEquipAttempt() { if (_requestedEquipSlot >= 0 && !(Time.unscaledTime < _equipCheckAt)) { CargoBackpackPlugin.Log.LogInfo((object)("CARGO base slot " + (_requestedEquipSlot + 1) + ": equipped=" + ((Object)(object)_equippable != (Object)null && _equippable.IsEquipped()))); _requestedEquipSlot = -1; } } private void LateUpdate() { UpdateWearable(); } private void UpdateWearable() { if ((Object)(object)_equippable == (Object)null || !_equippable.IsEquipped()) { DestroyWearable(); return; } PlayerAvatar val = ResolveOwner(); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)_wornModel == (Object)null || (Object)(object)_wornOwner != (Object)(object)val) { DestroyWearable(); _wornOwner = val; _wornModel = CargoBackpackVisuals.CreateWornModel(val); } bool tumbling = Tumbling != null && (bool)Tumbling.GetValue(val); bool crawling = Crawling != null && (bool)Crawling.GetValue(val); bool crouching = Crouching != null && (bool)Crouching.GetValue(val); _wornModel.GetComponent().SetFolded(CargoFoldLayout.ShouldFold(crouching, crawling, tumbling)); } } private PlayerAvatar ResolveOwner() { if (!SemiFunc.IsMultiplayer()) { return PlayerAvatar.instance; } if (OwnerId == null || (Object)(object)_equippable == (Object)null) { return null; } PhotonView val = PhotonView.Find((int)OwnerId.GetValue(_equippable)); if ((Object)(object)val == (Object)null) { return null; } PlayerAvatar component = ((Component)val).GetComponent(); PhysGrabber component2 = ((Component)val).GetComponent(); if (!((Object)(object)component != (Object)null)) { if (!((Object)(object)component2 != (Object)null)) { return null; } return component2.playerAvatar; } return component; } private void DestroyWearable() { if ((Object)(object)_wornModel != (Object)null) { Object.Destroy((Object)(object)_wornModel); } _wornModel = null; _wornOwner = null; } private void OnDestroy() { DestroyWearable(); } } [BepInPlugin("uz.cherdak.repo.cargobackpack", "C.A.R.G.O. Backpack", "1.0.23")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class CargoBackpackPlugin : BaseUnityPlugin { public const string PluginGuid = "uz.cherdak.repo.cargobackpack"; public const string PluginName = "C.A.R.G.O. Backpack"; public const string PluginVersion = "1.0.23"; public const string BuildVariant = "1.0.23 — multiplayer ownership fix"; internal static ManualLogSource Log; private bool _registered; private float _nextRegistrationAttempt; private void LateUpdate() { CargoStoredItemState.Tick(); CargoInventoryUI.SetBackpackSlot(CargoRuntime.GetLocalBagBaseSlot()); } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("uz.cherdak.repo.cargobackpack").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"C.A.R.G.O. Backpack 1.0.23 loaded."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"1.0.23 — multiplayer ownership fix"); if (Chainloader.PluginInfos.ContainsKey("com.Nyoh.backpack") || Chainloader.PluginInfos.ContainsKey("com.BellaModsGames.backpack")) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Another backpack mod is enabled. Disable it to prevent its F/Z storage controls from interfering with C.A.R.G.O. slots."); } } private void Update() { CargoPersistence.EnsureRegistered(); if (!_registered && Time.unscaledTime >= _nextRegistrationAttempt) { _nextRegistrationAttempt = Time.unscaledTime + 1f; try { _registered = CargoItemFactory.TryRegister(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create the C.A.R.G.O. Backpack: " + ex)); _nextRegistrationAttempt = Time.unscaledTime + 5f; } } CargoRuntime.Tick(); } } public sealed class CargoBackpackVisuals : MonoBehaviour { private static Material _yellow; private static Material _darkYellow; private static Material _black; private static Material _metal; private static Material _light; private static Material _lightOff; private static Material _healthLens; private CargoBackpackController _controller; private GameObject _groundModel; private float _nextLightUpdate; internal static void ConfigurePhysics(GameObject prefab) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0143: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_017b: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = (from collider in prefab.GetComponentsInChildren(true) where (Object)(object)collider != (Object)null && !((Collider)collider).isTrigger orderby Volume(collider.size, ((Component)collider).transform.lossyScale) descending select collider).FirstOrDefault(); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("The source prefab has no physical BoxCollider."); } Vector3 val2 = prefab.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val.center)); Collider[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && !val3.isTrigger) { val3.enabled = false; } } GameObject val4 = new GameObject("CARGO Compound Colliders") { layer = ((Component)val).gameObject.layer, tag = ((Component)val).gameObject.tag }; val4.transform.SetParent(prefab.transform, false); val4.transform.localPosition = val2; AddBoxCollider(val4, Vector3.zero + new Vector3(0f, -0.01f, -0.05f), new Vector3(0.49f, 0.53f, 0.38f)); AddBoxCollider(val4, Vector3.zero + new Vector3(0f, -0.01f, -0.05f), new Vector3(0.39f, 0.67f, 0.38f)); AddBoxCollider(val4, new Vector3(-0.265f, -0.035f, 0f), new Vector3(0.12f, 0.32f, 0.23f)); AddBoxCollider(val4, new Vector3(0.265f, -0.035f, 0f), new Vector3(0.12f, 0.32f, 0.23f)); AddBoxCollider(val4, new Vector3(-0.13f, 0.36f, 0.03f), new Vector3(0.075f, 0.16f, 0.12f)); AddBoxCollider(val4, new Vector3(0.13f, 0.36f, 0.03f), new Vector3(0.075f, 0.16f, 0.12f)); AddBoxCollider(val4, new Vector3(0f, 0.43f, 0.03f), new Vector3(0.29f, 0.1f, 0.11f)); Rigidbody component = prefab.GetComponent(); if ((Object)(object)component != (Object)null) { component.centerOfMass = val2 + new Vector3(0f, -0.08f, 0f); component.maxAngularVelocity = 12f; } } private static void AddBoxCollider(GameObject target, Vector3 center, Vector3 size) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CARGO Shape " + target.transform.childCount); val.transform.SetParent(target.transform, false); val.transform.localPosition = center; val.layer = LayerMask.NameToLayer("PhysGrabObject"); val.tag = "Phys Grab Object"; val.AddComponent().size = size; val.AddComponent(); } private static float Volume(Vector3 size, Vector3 scale) { //IL_0000: 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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(size.x * scale.x * size.y * scale.y * size.z * scale.z); } private void Start() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((Component)this).transform.Find("CARGO Backpack Model") != (Object)null)) { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); EnsureMaterials(componentsInChildren.Select((Renderer renderer) => renderer.sharedMaterial).FirstOrDefault((Func)((Material material) => (Object)(object)material != (Object)null))); Renderer[] array = componentsInChildren; for (int num = 0; num < array.Length; num++) { array[num].enabled = false; } GameObject val = new GameObject("CARGO Backpack Model"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = FindPhysicalCentre(((Component)this).transform); val.transform.localScale = Vector3.one * 0.34f; BuildPack(val.transform, groundModel: true); _groundModel = val; _controller = ((Component)this).GetComponent(); UpdateSlotLights(_groundModel, ((Object)(object)_controller != (Object)null) ? new Func(_controller.IsCargoSlotOccupied) : null); } } private void Update() { if ((Object)(object)_groundModel != (Object)null && (Object)(object)_controller != (Object)null && (Object)(object)_controller.Equippable != (Object)null) { _groundModel.SetActive(!_controller.Equippable.IsEquipped()); } if (!(Time.unscaledTime < _nextLightUpdate)) { _nextLightUpdate = Time.unscaledTime + 0.1f; if ((Object)(object)_groundModel != (Object)null && (Object)(object)_controller != (Object)null) { UpdateSlotLights(_groundModel, _controller.IsCargoSlotOccupied); } } } private static Vector3 FindPhysicalCentre(Transform root) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Transform val = root.Find("CARGO Compound Colliders"); if ((Object)(object)val != (Object)null) { return val.localPosition; } BoxCollider val2 = (from collider in ((Component)root).GetComponentsInChildren(true) where (Object)(object)collider != (Object)null && ((Collider)collider).enabled && !((Collider)collider).isTrigger orderby Volume(collider.size, ((Component)collider).transform.lossyScale) descending select collider).FirstOrDefault(); if ((Object)(object)val2 == (Object)null) { return Vector3.zero; } return root.InverseTransformPoint(((Component)val2).transform.TransformPoint(val2.center)); } internal static GameObject CreateWornModel(PlayerAvatar avatar) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e5: 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_010d: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01f2: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) EnsureMaterials(null); Transform val = (((Object)(object)avatar.playerTransform != (Object)null) ? avatar.playerTransform : ((Component)avatar).transform); GameObject val2 = new GameObject("CARGO Backpack Worn"); val2.transform.SetParent(val, false); val2.transform.localPosition = new Vector3(0f, 0.38f, -0.31f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one * 0.37f; GameObject val3 = new GameObject("CARGO Folding Shell"); val3.transform.SetParent(val2.transform, false); BuildPack(val3.transform, groundModel: false); GameObject val4 = new GameObject("CARGO Front Straps"); val4.transform.SetParent(val2.transform, false); CreatePart("Left Front Strap", (PrimitiveType)1, val4.transform, new Vector3(-0.43f, 0.05f, 0.92f), new Vector3(0.14f, 0.79f, 0.08f), new Vector3(0f, 0f, -7f), _black); CreatePart("Right Front Strap", (PrimitiveType)1, val4.transform, new Vector3(0.43f, 0.05f, 0.92f), new Vector3(0.14f, 0.79f, 0.08f), new Vector3(0f, 0f, 7f), _black); CreatePart("Left Strap Safety Edge", (PrimitiveType)3, val4.transform, new Vector3(-0.43f, 0.05f, 0.965f), new Vector3(0.045f, 1.48f, 0.025f), new Vector3(0f, 0f, -7f), _yellow); CreatePart("Right Strap Safety Edge", (PrimitiveType)3, val4.transform, new Vector3(0.43f, 0.05f, 0.965f), new Vector3(0.045f, 1.48f, 0.025f), new Vector3(0f, 0f, 7f), _yellow); CreatePart("Chest Strap", (PrimitiveType)1, val4.transform, new Vector3(0f, -0.12f, 0.97f), new Vector3(0.08f, 0.39f, 0.07f), new Vector3(0f, 0f, 90f), _black); CreatePart("Chest Buckle", (PrimitiveType)3, val4.transform, new Vector3(0f, -0.12f, 1.025f), new Vector3(0.22f, 0.19f, 0.07f), Vector3.zero, _yellow); CreatePart("Buckle Centre", (PrimitiveType)3, val4.transform, new Vector3(0f, -0.12f, 1.07f), new Vector3(0.11f, 0.1f, 0.04f), Vector3.zero, _black); val2.AddComponent().Initialize(val3.transform, val4.transform, avatar); val2.AddComponent().Initialize(avatar, val3.transform); return val2; } private static void BuildPack(Transform root, bool groundModel) { //IL_0006: 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_0024: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_07ea: Unknown result type (might be due to invalid IL or missing references) //IL_07ef: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: Unknown result type (might be due to invalid IL or missing references) //IL_08ce: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0921: Unknown result type (might be due to invalid IL or missing references) //IL_0935: Unknown result type (might be due to invalid IL or missing references) //IL_0949: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_0a00: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0a19: Unknown result type (might be due to invalid IL or missing references) //IL_0a59: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Unknown result type (might be due to invalid IL or missing references) //IL_0a72: Unknown result type (might be due to invalid IL or missing references) //IL_0aee: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0b16: Unknown result type (might be due to invalid IL or missing references) //IL_0b65: Unknown result type (might be due to invalid IL or missing references) //IL_0b79: Unknown result type (might be due to invalid IL or missing references) //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0ba8: Unknown result type (might be due to invalid IL or missing references) //IL_0bbc: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0c0d: Unknown result type (might be due to invalid IL or missing references) //IL_0c21: Unknown result type (might be due to invalid IL or missing references) //IL_0c2b: Unknown result type (might be due to invalid IL or missing references) //IL_0c62: Unknown result type (might be due to invalid IL or missing references) //IL_0c76: Unknown result type (might be due to invalid IL or missing references) //IL_0c8a: Unknown result type (might be due to invalid IL or missing references) //IL_0cc3: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0d02: Unknown result type (might be due to invalid IL or missing references) //IL_0d16: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Unknown result type (might be due to invalid IL or missing references) CreateBevelledBox("Hard Shell", root, Vector3.zero, new Vector3(1.38f, 1.92f, 0.78f), 0.15f, Vector3.zero, _black); CreateBevelledBox("CARGO Header Panel", root, new Vector3(0f, 0.69f, -0.45f), new Vector3(1.1f, 0.43f, 0.16f), 0.1f, Vector3.zero, _yellow); CreatePaintedPanel("C.A.R.G.O. Painted Header", root, "C.A.R.G.O.", new Vector3(0f, 0.69f, -0.536f), new Vector2(0.92f, 0.25f), 31); float[] array = new float[4] { 0.32f, 0.01f, -0.3f, -0.61f }; for (int i = 0; i < array.Length; i++) { CreateBevelledBox("Module Frame " + (i + 1), root, new Vector3(0.06f, array[i], -0.46f), new Vector3(1.02f, 0.285f, 0.15f), 0.055f, Vector3.zero, _metal); CreateBevelledBox("Cargo Module " + (i + 1), root, new Vector3(0.02f, array[i], -0.565f), new Vector3(0.88f, 0.225f, 0.13f), 0.045f, Vector3.zero, _yellow); CreateBevelledBox("Module Light Housing " + (i + 1), root, new Vector3(0.39f, array[i], -0.655f), new Vector3(0.13f, 0.15f, 0.055f), 0.025f, Vector3.zero, _black); CreatePart("Module Light " + (i + 1), (PrimitiveType)3, root, new Vector3(0.39f, array[i], -0.692f), new Vector3(0.055f, 0.105f, 0.018f), Vector3.zero, _lightOff); CreatePaintedPanel("Painted Module Face " + (i + 1), root, (i + 1).ToString(), new Vector3(0f, array[i], -0.637f), new Vector2(0.68f, 0.145f), 80 + i); CreatePart("Module Left Bolt " + (i + 1), (PrimitiveType)2, root, new Vector3(-0.35f, array[i] + 0.065f, -0.65f), new Vector3(0.022f, 0.014f, 0.022f), new Vector3(90f, 0f, 0f), _metal); CreatePart("Module Right Bolt " + (i + 1), (PrimitiveType)2, root, new Vector3(0.28f, array[i] - 0.065f, -0.65f), new Vector3(0.022f, 0.014f, 0.022f), new Vector3(90f, 0f, 0f), _metal); } CreateBevelledBox("Left Side Container", root, new Vector3(-0.78f, -0.1f, 0.02f), new Vector3(0.34f, 0.9f, 0.59f), 0.08f, Vector3.zero, _yellow); CreateBevelledBox("Right Side Container", root, new Vector3(0.78f, -0.1f, 0.02f), new Vector3(0.34f, 0.9f, 0.59f), 0.08f, Vector3.zero, _yellow); CreateBevelledBox("Left Side Container Inset", root, new Vector3(-0.955f, -0.1f, 0.01f), new Vector3(0.035f, 0.58f, 0.34f), 0.012f, Vector3.zero, _darkYellow); CreateBevelledBox("Right Side Container Inset", root, new Vector3(0.955f, -0.1f, 0.01f), new Vector3(0.035f, 0.58f, 0.34f), 0.012f, Vector3.zero, _darkYellow); CreatePart("Left Side Spine", (PrimitiveType)3, root, new Vector3(-0.66f, -0.05f, -0.05f), new Vector3(0.1f, 1.55f, 0.62f), Vector3.zero, _metal); CreatePart("Right Side Spine", (PrimitiveType)3, root, new Vector3(0.66f, -0.05f, -0.05f), new Vector3(0.1f, 1.55f, 0.62f), Vector3.zero, _metal); float[] array2 = new float[2] { -0.57f, 0.57f }; float[] array3 = new float[2] { -0.76f, 0.78f }; float[] array4 = array2; foreach (float num in array4) { float[] array5 = array3; foreach (float num2 in array5) { CreateBevelledBox("Front Corner Armour", root, new Vector3(num, num2, -0.445f), new Vector3(0.2f, 0.28f, 0.13f), 0.045f, Vector3.zero, _metal); CreatePart("Corner Armour Rivet", (PrimitiveType)2, root, new Vector3(num, num2, -0.523f), new Vector3(0.025f, 0.012f, 0.025f), new Vector3(90f, 0f, 0f), _black); } } CreatePart("Left Retention Webbing", (PrimitiveType)3, root, new Vector3(-0.805f, -0.1f, -0.305f), new Vector3(0.22f, 0.055f, 0.055f), Vector3.zero, _black); CreatePart("Right Retention Webbing", (PrimitiveType)3, root, new Vector3(0.805f, -0.1f, -0.305f), new Vector3(0.22f, 0.055f, 0.055f), Vector3.zero, _black); CreateBevelledBox("Top Rail", root, new Vector3(0f, 0.91f, 0f), new Vector3(1.1f, 0.17f, 0.7f), 0.045f, Vector3.zero, _metal); for (int l = 0; l < 6; l++) { float num3 = CargoHealthGauge.LampX(l); CreatePart("Health Socket " + (l + 1), (PrimitiveType)2, root, new Vector3(num3, 1.001f, -0.21f), new Vector3(0.078f, 0.009f, 0.078f), Vector3.zero, _metal); CreatePart("Health Lens " + (l + 1), (PrimitiveType)0, root, new Vector3(num3, 1.011f, -0.21f), new Vector3(0.055f, 0.035f, 0.055f), Vector3.zero, _healthLens); } CreateBevelledBox("Bottom Rail", root, new Vector3(0f, -0.91f, 0f), new Vector3(1.12f, 0.16f, 0.7f), 0.045f, Vector3.zero, _metal); CreatePart("Left Shell Wear Strip", (PrimitiveType)3, root, new Vector3(-0.53f, -0.08f, -0.422f), new Vector3(0.055f, 1.46f, 0.025f), Vector3.zero, _darkYellow); CreatePart("Right Shell Wear Strip", (PrimitiveType)3, root, new Vector3(0.53f, -0.08f, -0.422f), new Vector3(0.055f, 1.46f, 0.025f), Vector3.zero, _darkYellow); for (int m = 0; m < array.Length; m++) { CreatePart("Module Lower Lip " + (m + 1), (PrimitiveType)3, root, new Vector3(0.02f, array[m] - 0.105f, -0.642f), new Vector3(0.74f, 0.025f, 0.025f), Vector3.zero, _metal); } CreateBevelledBox("Handle Left Mount", root, new Vector3(-0.38f, 1.09f, 0.08f), new Vector3(0.18f, 0.4f, 0.22f), 0.045f, new Vector3(0f, 0f, -15f), _metal); CreateBevelledBox("Handle Right Mount", root, new Vector3(0.38f, 1.09f, 0.08f), new Vector3(0.18f, 0.4f, 0.22f), 0.045f, new Vector3(0f, 0f, 15f), _metal); CreatePart("Rubber Carry Handle", (PrimitiveType)1, root, new Vector3(0f, 1.26f, 0.08f), new Vector3(0.14f, 0.39f, 0.16f), new Vector3(0f, 0f, 90f), _black); for (int n = -3; n <= 3; n++) { CreatePart("Handle Grip Rib " + n, (PrimitiveType)2, root, new Vector3((float)n * 0.075f, 1.26f, 0.08f), new Vector3(0.152f, 0.013f, 0.172f), new Vector3(0f, 0f, 90f), _black); } for (int num4 = -1; num4 <= 1; num4 += 2) { CreatePart(((num4 < 0) ? "Left" : "Right") + " Upper Hinge", (PrimitiveType)2, root, new Vector3((float)num4 * 0.67f, 0.48f, -0.2f), new Vector3(0.055f, 0.1f, 0.055f), Vector3.zero, _metal); CreatePart(((num4 < 0) ? "Left" : "Right") + " Lower Hinge", (PrimitiveType)2, root, new Vector3((float)num4 * 0.67f, -0.5f, -0.2f), new Vector3(0.055f, 0.1f, 0.055f), Vector3.zero, _metal); } float[] array6 = new float[2] { -0.46f, 0.46f }; float[] array7 = new float[2] { 0.82f, 0.56f }; array4 = array6; foreach (float num5 in array4) { float[] array5 = array7; foreach (float num6 in array5) { CreatePart("Header Bolt", (PrimitiveType)2, root, new Vector3(num5, num6, -0.555f), new Vector3(0.032f, 0.018f, 0.032f), new Vector3(90f, 0f, 0f), _metal); } } for (int num7 = -5; num7 <= 5; num7++) { CreatePart("Header Reinforced Stitch", (PrimitiveType)3, root, new Vector3((float)num7 * 0.082f, 0.515f, -0.542f), new Vector3(0.044f, 0.01f, 0.01f), Vector3.zero, _darkYellow); CreatePart("Lower Reinforced Stitch", (PrimitiveType)3, root, new Vector3((float)num7 * 0.082f, -0.805f, -0.423f), new Vector3(0.044f, 0.01f, 0.01f), Vector3.zero, _metal); } for (int num8 = 0; num8 < array.Length; num8++) { CreateBevelledBox("Module Release Latch " + (num8 + 1), root, new Vector3(-0.34f, array[num8], -0.657f), new Vector3(0.115f, 0.115f, 0.035f), 0.025f, Vector3.zero, _darkYellow); CreatePart("Module Latch Pin " + (num8 + 1), (PrimitiveType)2, root, new Vector3(-0.34f, array[num8], -0.683f), new Vector3(0.022f, 0.013f, 0.022f), new Vector3(90f, 0f, 0f), _metal); } if (groundModel) { CreatePart("Left Back Strap", (PrimitiveType)1, root, new Vector3(-0.38f, 0f, 0.48f), new Vector3(0.17f, 0.78f, 0.12f), Vector3.zero, _black); CreatePart("Right Back Strap", (PrimitiveType)1, root, new Vector3(0.38f, 0f, 0.48f), new Vector3(0.17f, 0.78f, 0.12f), Vector3.zero, _black); } } private static GameObject CreatePart(string name, PrimitiveType primitive, Transform parent, Vector3 position, Vector3 scale, Vector3 rotation, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(primitive); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localScale = scale; obj.transform.localRotation = Quaternion.Euler(rotation); Renderer component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.sharedMaterial = material; } Collider component2 = obj.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } return obj; } private static GameObject CreateBevelledBox(string name, Transform parent, Vector3 position, Vector3 size, float bevel, Vector3 rotation, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_02a4: Expected O, but got Unknown //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown float num = size.x * 0.5f; float num2 = size.y * 0.5f; float num3 = size.z * 0.5f; bevel = Mathf.Clamp(bevel, 0.001f, Mathf.Min(num, num2) * 0.8f); Vector2[] array = (Vector2[])(object)new Vector2[8] { new Vector2(0f - num + bevel, 0f - num2), new Vector2(num - bevel, 0f - num2), new Vector2(num, 0f - num2 + bevel), new Vector2(num, num2 - bevel), new Vector2(num - bevel, num2), new Vector2(0f - num + bevel, num2), new Vector2(0f - num, num2 - bevel), new Vector2(0f - num, 0f - num2 + bevel) }; List list = new List(); List list2 = new List(); for (int i = 1; i < array.Length - 1; i++) { AddTriangle(list, list2, new Vector3(array[0].x, array[0].y, 0f - num3), new Vector3(array[i + 1].x, array[i + 1].y, 0f - num3), new Vector3(array[i].x, array[i].y, 0f - num3)); AddTriangle(list, list2, new Vector3(array[0].x, array[0].y, num3), new Vector3(array[i].x, array[i].y, num3), new Vector3(array[i + 1].x, array[i + 1].y, num3)); } for (int j = 0; j < array.Length; j++) { int num4 = (j + 1) % array.Length; AddQuad(list, list2, new Vector3(array[j].x, array[j].y, 0f - num3), new Vector3(array[num4].x, array[num4].y, 0f - num3), new Vector3(array[num4].x, array[num4].y, num3), new Vector3(array[j].x, array[j].y, num3)); } Mesh val = new Mesh { name = "CARGO " + name + " Mesh" }; val.SetVertices(list); val.SetTriangles(list2, 0); List list3 = new List(list.Count); foreach (Vector3 item in list) { list3.Add(new Vector2(item.x / size.x + 0.5f, item.y / size.y + 0.5f)); } val.SetUVs(0, list3); val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name, new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }); val2.transform.SetParent(parent, false); val2.transform.localPosition = position; val2.transform.localRotation = Quaternion.Euler(rotation); val2.GetComponent().sharedMesh = val; ((Renderer)val2.GetComponent()).sharedMaterial = material; return val2; } private static GameObject CreatePaintedPanel(string name, Transform parent, string text, Vector3 position, Vector2 size, int seed) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0059: 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_006c: 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_0085: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0155: 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: Expected O, but got Unknown Mesh val = new Mesh { name = name + " Mesh" }; float num = size.x * 0.5f; float num2 = size.y * 0.5f; val.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(0f - num, 0f - num2, 0f), new Vector3(num, 0f - num2, 0f), new Vector3(num, num2, 0f), new Vector3(0f - num, num2, 0f) }; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val.triangles = new int[6] { 0, 2, 1, 0, 3, 2 }; val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name, new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }); val2.transform.SetParent(parent, false); val2.transform.localPosition = position; val2.GetComponent().sharedMesh = val; ((Renderer)val2.GetComponent()).sharedMaterial = CreatePaintedPanelMaterial(text, seed); return val2; } internal static void UpdateSlotLights(GameObject model, Func occupied) { if (!((Object)(object)model == (Object)null) && !((Object)(object)_light == (Object)null) && !((Object)(object)_lightOff == (Object)null)) { Renderer[] array = (from renderer in model.GetComponentsInChildren(true) where (Object)(object)renderer != (Object)null && ((Object)((Component)renderer).gameObject).name.StartsWith("Module Light ", StringComparison.Ordinal) && !((Object)((Component)renderer).gameObject).name.Contains("Housing") orderby ((Object)((Component)renderer).gameObject).name select renderer).ToArray(); CargoWornPose component = model.GetComponent(); bool flag = (Object)(object)component != (Object)null && component.Folded; bool flag2 = occupied != null && (occupied(0) || occupied(1) || occupied(2) || occupied(3)); for (int num = 0; num < array.Length && num < 4; num++) { array[num].sharedMaterial = ((occupied != null && ((flag && num == 0) ? flag2 : occupied(num))) ? _light : _lightOff); } } } private static void AddTriangle(List vertices, List triangles, Vector3 a, Vector3 b, Vector3 c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(a); vertices.Add(b); vertices.Add(c); triangles.Add(count); triangles.Add(count + 1); triangles.Add(count + 2); } private static void AddQuad(List vertices, List triangles, Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(a); vertices.Add(b); vertices.Add(c); vertices.Add(d); triangles.Add(count); triangles.Add(count + 1); triangles.Add(count + 2); triangles.Add(count); triangles.Add(count + 2); triangles.Add(count + 3); } private static void EnsureMaterials(Material fallback) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_yellow != (Object)null)) { Shader val = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)val == (Object)null && (Object)(object)fallback != (Object)null) { val = fallback.shader; } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("No compatible shader was found for the backpack."); } _yellow = MakeMaterial(val, "Safety Fabric Yellow", new Color(0.95f, 0.61f, 0.025f, 1f), 0.06f); _darkYellow = MakeMaterial(val, "Dark Fabric Yellow", new Color(0.58f, 0.3f, 0.012f, 1f), 0.04f); _black = MakeMaterial(val, "Woven Black", new Color(0.012f, 0.015f, 0.018f, 1f), 0.03f); _metal = MakeMaterial(val, "Gunmetal", new Color(0.075f, 0.085f, 0.09f, 1f), 0.8f); _light = MakeMaterial(val, "Amber Module Light", new Color(1f, 0.42f, 0.015f, 1f), 0.15f); _lightOff = MakeMaterial(val, "Unlit Module Light", new Color(0.12f, 0.055f, 0.008f, 1f), 0.05f); _healthLens = MakeMaterial(val, "Health Indicator Light", new Color(0.025f, 0.032f, 0.028f, 1f), 0.08f); _healthLens.EnableKeyword("_EMISSION"); if (_healthLens.HasProperty("_EmissionColor")) { _healthLens.SetColor("_EmissionColor", Color.black); } if (_healthLens.HasProperty("_Glossiness")) { _healthLens.SetFloat("_Glossiness", 0.72f); } if (_healthLens.HasProperty("_Smoothness")) { _healthLens.SetFloat("_Smoothness", 0.72f); } if (_light.HasProperty("_EmissionColor")) { _light.EnableKeyword("_EMISSION"); _light.SetColor("_EmissionColor", new Color(1f, 0.18f, 0.005f, 1f) * 2.2f); } } } private static Material MakeMaterial(Shader shader, string name, Color color, float metallic) { //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_0018: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_00a3: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader) { name = "CARGO " + name }; if (name.IndexOf("Light", StringComparison.OrdinalIgnoreCase) < 0) { Texture2D val2 = CreateSurfaceTexture(color, StableSeed(name), metallic > 0.5f); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } if (val.HasProperty("_BumpMap")) { val.SetTexture("_BumpMap", (Texture)(object)CreateNormalTexture(StableSeed(name), metallic)); if (val.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", (metallic > 0.5f) ? 0.34f : 0.62f); } val.EnableKeyword("_NORMALMAP"); } } else { if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } float num = ((metallic > 0.5f) ? 0.42f : 0.16f); if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", num); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", num); } return val; } private static Material CreatePaintedPanelMaterial(string text, int seed) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(((Object)(object)_yellow != (Object)null) ? _yellow.shader : Shader.Find("Standard")) { name = "CARGO Painted " + text }; Texture2D val2 = CreatePaintedTexture(text, seed); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.12f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.19f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.19f); } Object.DontDestroyOnLoad((Object)(object)val); return val; } private static Texture2D CreatePaintedTexture(string text, int seed) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00af: Expected O, but got Unknown //IL_00b0: Expected O, but got Unknown int num = ((text.Length > 2) ? 256 : 128); int num2 = ((text.Length > 2) ? 80 : 64); Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false) { name = "CARGO Painted Panel " + text, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color32[] array = CreateSurfacePixels(num, num2, new Color(0.96f, 0.6f, 0.018f, 1f), seed, metal: false, bordered: true); int scale = ((text.Length > 2) ? 5 : 6); DrawBitmapText(array, num, num2, text, scale, new Color32((byte)19, (byte)17, (byte)13, byte.MaxValue)); val.SetPixels32(array); val.Apply(false, true); Object.DontDestroyOnLoad((Object)val); return val; } private static Texture2D CreateSurfaceTexture(Color baseColor, int seed, bool metal) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0046: Expected O, but got Unknown Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false) { name = "CARGO Worn Surface", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; val.SetPixels32(CreateSurfacePixels(96, 96, baseColor, seed, metal, bordered: false)); val.Apply(false, true); Object.DontDestroyOnLoad((Object)val); return val; } private static Texture2D CreateNormalTexture(int seed, float metallic) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_00e1: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0113: 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_014c: 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) Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false) { name = "CARGO Micro Surface Normal", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color32[] array = (Color32[])(object)new Color32[9216]; float num = ((metallic > 0.5f) ? 0.16f : 0.3f); for (int i = 0; i < 96; i++) { for (int j = 0; j < 96; j++) { float num2 = (float)(PixelHash((j + 96 - 1) % 96, i, seed) & 0xFF) / 255f; float num3 = (float)(PixelHash((j + 1) % 96, i, seed) & 0xFF) / 255f; float num4 = (float)(PixelHash(j, (i + 96 - 1) % 96, seed) & 0xFF) / 255f; float num5 = (float)(PixelHash(j, (i + 1) % 96, seed) & 0xFF) / 255f; Vector3 val2 = new Vector3((num2 - num3) * num, (num4 - num5) * num, 1f); Vector3 normalized = ((Vector3)(ref val2)).normalized; array[i * 96 + j] = new Color32((byte)((normalized.x * 0.5f + 0.5f) * 255f), (byte)((normalized.y * 0.5f + 0.5f) * 255f), (byte)((normalized.z * 0.5f + 0.5f) * 255f), byte.MaxValue); } } val.SetPixels32(array); val.Apply(false, true); Object.DontDestroyOnLoad((Object)(object)val); return val; } private static Color32[] CreateSurfacePixels(int width, int height, Color baseColor, int seed, bool metal, bool bordered) { //IL_017b: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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) Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { uint num = PixelHash(j, i, seed); float num2 = ((float)(num & 0xFF) / 255f - 0.5f) * (metal ? 0.14f : 0.1f); float num3 = Mathf.Sin((float)(j + seed) * 0.075f) * 0.025f + Mathf.Cos((float)(i - seed) * 0.093f) * 0.025f; float num4 = Mathf.PerlinNoise((float)(j + (seed & 0x1F)) * 0.055f, (float)(i + ((seed >> 5) & 0x1F)) * 0.055f); float num5 = Mathf.Lerp(0.78f, 1.08f, (float)i / Mathf.Max(1f, (float)height - 1f)); float num6 = 1f - Mathf.Clamp01((float)i / Mathf.Max(1f, (float)height * 0.42f)); float num7 = num5 + num2 + num3 + (num4 - 0.5f) * 0.34f - num6 * 0.12f; float num8 = Mathf.Min(Mathf.Min(j, width - 1 - j), Mathf.Min(i, height - 1 - i)); if (bordered && num8 < 5f) { num7 *= Mathf.Lerp(0.55f, 0.88f, num8 / 5f); } if (num % 283 < 4) { num7 *= 0.32f; } if ((j * 5 + i * 2 + seed * 11) % 173 == 0) { num7 *= 1.22f; } array[i * width + j] = ToColor32(baseColor * num7); } } int num9 = (bordered ? 14 : 9); for (int k = 0; k < num9; k++) { int num10 = (int)(PixelHash(k, seed, 17) % (uint)width); int num11 = (int)(PixelHash(seed, k, 29) % (uint)height); int num12 = (int)(6 + PixelHash(k, 31, seed) % (uint)Mathf.Max(7, width / 4)); for (int l = 0; l < num12; l++) { int num13 = num10 + l; int num14 = num11 + l / 5; if (num13 >= 0 && num13 < width && num14 >= 0 && num14 < height) { array[num14 * width + num13] = ToColor32(baseColor * (metal ? 1.42f : 0.25f)); } } } return array; } private static void DrawBitmapText(Color32[] pixels, int width, int height, string text, int scale, Color32 ink) { //IL_00c7: 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) int num = 0; for (int i = 0; i < text.Length; i++) { string[] array = Glyph(text[i]); num += array[0].Length * scale; if (i + 1 < text.Length) { num += scale; } } int num2 = (width - num) / 2; int num3 = (height - 7 * scale) / 2; int num4 = num2; for (int j = 0; j < text.Length; j++) { string[] array2 = Glyph(text[j]); for (int k = 0; k < array2.Length; k++) { for (int l = 0; l < array2[k].Length; l++) { if (array2[k][l] != '1') { continue; } for (int m = 0; m < scale; m++) { for (int n = 0; n < scale; n++) { int num5 = num4 + l * scale + n; int num6 = num3 + (6 - k) * scale + m; if (num5 >= 0 && num5 < width && num6 >= 0 && num6 < height) { pixels[num6 * width + num5] = ink; } } } } } num4 += (array2[0].Length + 1) * scale; } } private static string[] Glyph(char character) { return character switch { 'A' => new string[7] { "01110", "10001", "10001", "11111", "10001", "10001", "10001" }, 'C' => new string[7] { "01111", "10000", "10000", "10000", "10000", "10000", "01111" }, 'G' => new string[7] { "01110", "10001", "10000", "10111", "10001", "10001", "01110" }, 'O' => new string[7] { "01110", "10001", "10001", "10001", "10001", "10001", "01110" }, 'R' => new string[7] { "11110", "10001", "10001", "11110", "10100", "10010", "10001" }, '1' => new string[7] { "00100", "01100", "00100", "00100", "00100", "00100", "01110" }, '2' => new string[7] { "01110", "10001", "00001", "00010", "00100", "01000", "11111" }, '3' => new string[7] { "11110", "00001", "00001", "01110", "00001", "00001", "11110" }, '4' => new string[7] { "00010", "00110", "01010", "10010", "11111", "00010", "00010" }, '.' => new string[7] { "0", "0", "0", "0", "0", "1", "1" }, _ => new string[7] { "000", "000", "000", "000", "000", "000", "000" }, }; } private static uint PixelHash(int x, int y, int seed) { int num = x * 374761393 + y * 668265263 + seed * 1442695041; int num2 = (num ^ (num >>> 13)) * 1274126177; return (uint)(num2 ^ (num2 >>> 16)); } private static int StableSeed(string value) { int num = 23; foreach (char c in value) { num = num * 31 + c; } return num; } private static Color32 ToColor32(Color color) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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) return Color32.op_Implicit(new Color(Mathf.Clamp01(color.r), Mathf.Clamp01(color.g), Mathf.Clamp01(color.b), Mathf.Clamp01(color.a))); } internal static Sprite CreateInventoryIcon() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CargoBackpack.InventoryConcept.png")) { if (stream != null) { using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray())) { throw new InvalidOperationException("CARGO concept icon could not be decoded."); } ((Object)val).name = "CARGO Concept Icon"; ((Texture)val).filterMode = (FilterMode)1; Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width); Object.DontDestroyOnLoad((Object)(object)val); Object.DontDestroyOnLoad((Object)(object)obj); return obj; } } } Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[16384]; Color val3 = default(Color); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { bool flag = j >= 30 && j <= 97 && i >= 10 && i <= 108; bool flag2 = j >= 45 && j <= 82 && i >= 108 && i <= 120 && (j < 51 || j > 76 || i > 114); bool flag3 = ((j >= 16 && j < 30) || (j > 97 && j <= 111)) && i >= 32 && i <= 78; if (!flag && !flag2 && !flag3) { continue; } ((Color)(ref val3))..ctor(0.085f, 0.092f, 0.09f, 1f); if (flag && j >= 37 && j <= 90 && i >= 16 && i <= 103) { int num = (i - 16) % 19; if (i >= 93 || num < 15) { float num2 = ((num < 2) ? 0.48f : ((num > 12) ? 1.15f : 1f)); float num3 = Mathf.Lerp(0.8f, 1f, (90f - (float)j) / 53f) * num2; ((Color)(ref val3))..ctor(0.9f * num3, 0.57f * num3, 0.065f * num3, 1f); if (j >= 82 && j <= 86 && i < 93 && num > 3 && num < 12) { ((Color)(ref val3))..ctor(0.19f, 0.14f, 0.065f, 1f); } } } if (flag3) { ((Color)(ref val3))..ctor(0.58f, 0.37f, 0.065f, 1f); } if ((j == 31 || j == 96) && flag) { ((Color)(ref val3))..ctor(0.3f, 0.32f, 0.28f, 1f); } float num4 = 0.94f + (float)(PixelHash(j, i, 21) & 0x1F) / 255f; array[i * 128 + j] = Color32.op_Implicit(new Color(val3.r * num4, val3.g * num4, val3.b * num4, 1f)); } } val2.SetPixels32(array); val2.Apply(); ((Object)val2).name = "CARGO Backpack Icon"; Object.DontDestroyOnLoad((Object)(object)val2); Sprite obj2 = Sprite.Create(val2, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); ((Object)obj2).name = "CARGO Backpack Icon"; Object.DontDestroyOnLoad((Object)(object)obj2); return obj2; } } internal static class CargoFoldLayout { internal static float BackZ => 0.39f; internal static bool ShouldFold(bool crouching, bool crawling, bool tumbling) { return crouching || crawling || tumbling; } internal static float BottomY(float fold) { return -0.99f + 0.465f * Math.Max(0f, Math.Min(1f, fold)); } internal static bool IsModule(string name) { if (!name.StartsWith("Module ", StringComparison.Ordinal) && !name.StartsWith("Cargo Module ", StringComparison.Ordinal)) { return name.StartsWith("Painted Module Face ", StringComparison.Ordinal); } return true; } internal static bool HiddenWhenFolded(string name) { if (IsModule(name)) { if (name.EndsWith(" 1", StringComparison.Ordinal)) { return name == "Painted Module Face 1"; } return true; } return false; } internal static float Y(string name, float y) { if (IsModule(name)) { return y - 0.465f; } if (y > 0.48f) { return y - 0.465f; } if (y < -0.48f) { return y + 0.465f; } return y * (33f / 64f); } internal static float HeightScale(string name) { if (!(name == "Hard Shell") && !name.Contains("Side Container") && !name.Contains("Side Spine") && !name.Contains("Shell Wear Strip")) { return 1f; } return 33f / 64f; } } public sealed class CargoHandTransfer : MonoBehaviour { private static readonly FieldInfo Held = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject"); private static readonly FieldInfo Disabled = AccessTools.Field(typeof(PhysGrabber), "grabDisableTimer"); private static readonly FieldInfo Offset = AccessTools.Field(typeof(PhysGrabObject), "midPointOffset"); private static readonly FieldInfo Midpoint = AccessTools.Field(typeof(PhysGrabObject), "midPoint"); private static readonly MethodInfo Release = AccessTools.Method(typeof(PhysGrabber), "ReleaseObject", (Type[])null, (Type[])null); private static readonly MethodInfo Grab = AccessTools.Method(typeof(PhysGrabber), "ForceGrabPhysObject", (Type[])null, (Type[])null); private Coroutine _pending; private static Vector3 Centre(ItemEquippable item) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); if (!((Object)(object)val != (Object)null)) { return Vector3.zero; } return ((Component)item).transform.TransformPoint((Vector3)Offset.GetValue(val)); } internal static Vector3 ReleasePosition(PlayerAvatar owner, ItemEquippable incoming, ItemEquippable outgoing) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)outgoing == (Object)null) { return Vector3.zero; } Transform val = (((Object)(object)owner.localCamera != (Object)null) ? owner.localCamera.GetOverrideTransform() : ((Component)owner).transform); Vector3 val2 = (((Object)(object)incoming != (Object)null) ? Centre(incoming) : (val.position + val.forward * 1.25f)); return ((Component)outgoing).transform.position + val2 - Centre(outgoing); } internal static void RefreshCentre(ItemEquippable item) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); if ((Object)(object)val != (Object)null) { Midpoint.SetValue(val, Centre(item)); } } internal static void ReleaseIncoming(ItemEquippable incoming) { PhysGrabber instance = PhysGrabber.instance; PhysGrabObject val = (((Object)(object)incoming != (Object)null) ? ((Component)incoming).GetComponent() : null); if (!((Object)(object)instance == (Object)null) && !((Object)(object)val == (Object)null) && instance.grabbed && !((Object)/*isinst with value type is only supported in some contexts*/ != (Object)(object)val)) { Release.Invoke(instance, new object[2] { ((Object)(object)((MonoBehaviourPun)incoming).photonView != (Object)null) ? ((MonoBehaviourPun)incoming).photonView.ViewID : (-1), 0.15f }); } } internal void Begin(ItemEquippable item) { if (_pending != null) { ((MonoBehaviour)this).StopCoroutine(_pending); } _pending = ((MonoBehaviour)this).StartCoroutine(Acquire(item)); } private IEnumerator Acquire(ItemEquippable item) { yield return null; PhysGrabber grabber = PhysGrabber.instance; PhysGrabObject physical = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); float deadline = Time.unscaledTime + 1f; while ((Object)(object)grabber != (Object)null && (Object)(object)physical != (Object)null && Time.unscaledTime < deadline && !CargoStoredItemState.Contains(item) && !item.IsEquipped()) { object? value = Held.GetValue(grabber); PhysGrabObject val = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if (grabber.grabbed) { if ((Object)(object)val == (Object)(object)physical) { CargoBackpackPlugin.Log.LogInfo((object)("CARGO handoff confirmed: " + ((Object)item).name)); } break; } if ((float)Disabled.GetValue(grabber) <= 0f) { RefreshCentre(item); Physics.SyncTransforms(); Grab.Invoke(grabber, new object[1] { physical }); if (grabber.grabbed && (Object)/*isinst with value type is only supported in some contexts*/ == (Object)(object)physical) { CargoBackpackPlugin.Log.LogInfo((object)("CARGO handoff confirmed: " + ((Object)item).name)); break; } } yield return null; } _pending = null; } } internal static class CargoHealthGauge { internal const int LampCount = 6; internal const float LensDiameter = 0.055f; internal const float SocketDiameter = 0.078f; internal static int LitCount(int health, int maximum) { if (maximum <= 0 || health <= 0) { return 0; } return (int)(((long)Math.Min(health, maximum) * 6L + maximum - 1) / maximum); } internal static float Fraction(int health, int maximum) { if (maximum <= 0) { return 0f; } return (float)Math.Max(0, Math.Min(health, maximum)) / (float)maximum; } internal static float LampX(int index) { return ((float)index - 2.5f) * 0.16f; } } public sealed class CargoHealthLights : MonoBehaviour { private static readonly FieldInfo Current = AccessTools.Field(typeof(PlayerHealth), "health"); private static readonly FieldInfo Maximum = AccessTools.Field(typeof(PlayerHealth), "maxHealth"); private static readonly FieldInfo Palette = AccessTools.Field(typeof(PlayerHealth), "healthMaterialColor"); private static readonly Color Off = new Color(0.025f, 0.032f, 0.028f, 1f); private PlayerAvatar _owner; private Renderer[] _lenses; private MaterialPropertyBlock _properties; private float _nextUpdate; internal void Initialize(PlayerAvatar owner, Transform body) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown _owner = owner; _lenses = (from renderer in ((Component)body).GetComponentsInChildren(true) where ((Object)renderer).name.StartsWith("Health Lens ", StringComparison.Ordinal) orderby ((Object)renderer).name select renderer).ToArray(); _properties = new MaterialPropertyBlock(); Refresh(); } private void Update() { if (_properties != null && !(Time.unscaledTime < _nextUpdate)) { _nextUpdate = Time.unscaledTime + 0.1f; Refresh(); } } private void Refresh() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) PlayerHealth val = (((Object)(object)_owner != (Object)null) ? _owner.playerHealth : null); int health = (((Object)(object)val != (Object)null && Current != null) ? ((int)Current.GetValue(val)) : 0); int maximum = (((Object)(object)val != (Object)null && Maximum != null) ? ((int)Maximum.GetValue(val)) : 0); Gradient val2 = (Gradient)(((Object)(object)val != (Object)null && Palette != null) ? /*isinst with value type is only supported in some contexts*/: null); int num = ((val2 != null) ? CargoHealthGauge.LitCount(health, maximum) : 0); Color val3 = ((val2 != null) ? val2.Evaluate(CargoHealthGauge.Fraction(health, maximum)) : Off); val3.a = 1f; for (int i = 0; i < _lenses.Length; i++) { if (!((Object)(object)_lenses[i] == (Object)null)) { bool flag = i < num; _properties.Clear(); _properties.SetColor("_Color", flag ? val3 : Off); _properties.SetColor("_BaseColor", flag ? val3 : Off); _properties.SetColor("_EmissionColor", flag ? (val3 * 2.2f) : Color.black); _lenses[i].SetPropertyBlock(_properties); } } } } internal static class CargoInventoryUI { private static RectTransform _root; private static readonly RectTransform[] Slots = (RectTransform[])(object)new RectTransform[4]; private static readonly Image[] Icons = (Image[])(object)new Image[4]; private static readonly TextMeshProUGUI[] Numbers = (TextMeshProUGUI[])(object)new TextMeshProUGUI[4]; private static readonly RectTransform[] Lines = (RectTransform[])(object)new RectTransform[3]; private static readonly Color Gold = new Color(1f, 0.72f, 0.12f, 0.9f); internal static void EnsureBuilt() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown if ((Object)(object)_root != (Object)null) { return; } IList allSpots = CargoRuntime.GetAllSpots(); if (allSpots == null || allSpots.Count < 3 || (Object)(object)allSpots[1] == (Object)null) { return; } Transform transform = ((Component)allSpots[1]).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val == (Object)null || (Object)(object)((Transform)val).parent == (Object)null) { return; } _root = Rect("CARGO HUD", ((Transform)val).parent); _root.anchoredPosition = Vector2.zero; ((Transform)_root).SetAsFirstSibling(); TMP_Text componentInChildren = ((Component)val).GetComponentInChildren(true); for (int i = 0; i < Lines.Length; i++) { Lines[i] = ((Graphic)Panel("Connector", (Transform)(object)_root, Gold)).rectTransform; } for (int j = 0; j < 4; j++) { Slots[j] = ((Graphic)Panel("Cargo " + (j + 4), (Transform)(object)_root, Gold)).rectTransform; Stretch(((Graphic)Panel("Recess", (Transform)(object)Slots[j], new Color(0.025f, 0.028f, 0.024f, 0.94f))).rectTransform, 1.3f); Icons[j] = Panel("Item", (Transform)(object)Slots[j], Color.white); Icons[j].preserveAspect = true; Stretch(((Graphic)Icons[j]).rectTransform, 7f); ((Graphic)Icons[j]).rectTransform.offsetMax = new Vector2(-7f, -16f); GameObject val2 = new GameObject("Key", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val2.transform.SetParent((Transform)(object)Slots[j], false); Numbers[j] = val2.GetComponent(); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)Numbers[j]).font = componentInChildren.font; } ((TMP_Text)Numbers[j]).fontSize = 13f; ((TMP_Text)Numbers[j]).alignment = (TextAlignmentOptions)258; ((TMP_Text)Numbers[j]).text = (j + 4).ToString(); ((Graphic)Numbers[j]).raycastTarget = false; Stretch(((TMP_Text)Numbers[j]).rectTransform, 2f); } ((Component)_root).gameObject.SetActive(false); CargoBackpackPlugin.Log.LogInfo((object)"CARGO HUD: four presentation-only slots; vanilla inventory untouched."); } internal static void SetBackpackSlot(int baseSlot) { //IL_009d: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0183: 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_0191: 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_01a5: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_02a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return; } IList allSpots = CargoRuntime.GetAllSpots(); CargoBackpackController cargoBackpackController = CargoRuntime.FindLocalBag(); bool flag = baseSlot >= 0 && (Object)(object)cargoBackpackController != (Object)null && allSpots != null && allSpots.Count >= 3; ((Component)_root).gameObject.SetActive(flag); if (!flag) { return; } Transform transform = ((Component)allSpots[1]).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val == (Object)null || (Object)(object)allSpots[0] == (Object)null || (Object)(object)allSpots[2] == (Object)null) { return; } Transform transform2 = ((Component)allSpots[2]).transform; RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); Vector2 val3 = Centre(val2); Rect val4 = val.rect; float num = Mathf.Max(36f, ((Rect)(ref val4)).width * ((Transform)val).localScale.x * 0.82f); val4 = val.rect; float num2 = Mathf.Max(42f, ((Rect)(ref val4)).height * ((Transform)val).localScale.y * 0.82f); float num3 = 5f; float x = val3.x; val4 = val2.rect; float num4 = x + ((Rect)(ref val4)).width * ((Transform)val2).localScale.x * 0.5f + 12f + num * 0.5f; float num5 = val3.y + num2 * 0.5f; Canvas componentInParent = ((Component)_root).GetComponentInParent(); Camera val5 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); RectTransform root = _root; val4 = Screen.safeArea; float x2 = ((Rect)(ref val4)).center.x; val4 = Screen.safeArea; Vector2 val6 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(root, new Vector2(x2, ((Rect)(ref val4)).yMin + 16f), val5, ref val6)) { num5 = Mathf.Max(num5, val6.y + num2 * 0.5f); } for (int i = 0; i < 4; i++) { Slots[i].sizeDelta = new Vector2(num, num2); Slots[i].anchoredPosition = new Vector2(num4 + (float)i * (num + num3), num5); ItemEquippable cargoItem = cargoBackpackController.GetCargoItem(i); ItemAttributes val7 = (((Object)(object)cargoItem != (Object)null) ? ((Component)cargoItem).GetComponent() : null); Sprite val8 = (((Object)(object)val7 != (Object)null) ? val7.icon : null); if ((Object)(object)val8 == (Object)null && (Object)(object)cargoItem != (Object)null) { val8 = cargoItem.ItemIcon; } Icons[i].sprite = val8; ((Behaviour)Icons[i]).enabled = (Object)(object)val8 != (Object)null; ((Graphic)Numbers[i]).color = (Color)(cargoBackpackController.IsCargoSlotOccupied(i) ? Gold : new Color(0.72f, 0.68f, 0.49f, 0.85f)); } RectTransform[] lines = Lines; for (int j = 0; j < lines.Length; j++) { ((Component)lines[j]).gameObject.SetActive(false); } } private static Vector2 Centre(RectTransform rect) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rect != (Object)null)) { return Vector2.zero; } RectTransform root = _root; Rect rect2 = rect.rect; return Vector2.op_Implicit(((Transform)root).InverseTransformPoint(((Transform)rect).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).center)))); } private static RectTransform Rect(string name, Transform parent) { //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_002b: 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_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_0044: 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_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; ((Transform)val2).localScale = Vector3.one; return val2; } private static Image Panel(string name, Transform parent, Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) Image obj = ((Component)Rect(name, parent)).gameObject.AddComponent(); ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = false; return obj; } private static void Stretch(RectTransform rect, float inset) { //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.one * inset; rect.offsetMax = Vector2.one * (0f - inset); } private static void Segment(RectTransform rect, Vector2 a, Vector2 b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) rect.anchoredPosition = (a + b) * 0.5f; rect.sizeDelta = new Vector2(Mathf.Max(1.4f, Mathf.Abs(b.x - a.x)), Mathf.Max(1.4f, Mathf.Abs(b.y - a.y))); } } internal static class CargoItemFactory { internal const string ItemName = "Item C.A.R.G.O. Backpack"; private const string PrefabName = "Item C.A.R.G.O. Backpack"; private static bool _loggedMissingSource; private static bool _registrationComplete; private static Sprite _inventoryIcon; internal static void ApplyRuntimeIcon(ItemAttributes attributes) { if (!((Object)(object)attributes == (Object)null)) { if ((Object)(object)_inventoryIcon == (Object)null) { _inventoryIcon = CargoBackpackVisuals.CreateInventoryIcon(); } Sprite itemIcon = (attributes.icon = Object.Instantiate(_inventoryIcon)); AccessTools.Field(typeof(ItemAttributes), "hasIcon").SetValue(attributes, true); ItemEquippable component = ((Component)attributes).GetComponent(); if ((Object)(object)component != (Object)null) { component.ItemIcon = itemIcon; } } } internal static bool TryRegister() { //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) if (_registrationComplete) { return true; } List list = new List(); list.AddRange(Items.AllItems.Where((Item item) => (Object)(object)item != (Object)null)); list.AddRange(from item in Resources.LoadAll("ScriptableObjects") where (Object)(object)item != (Object)null select item); list.AddRange(from item in Resources.FindObjectsOfTypeAll() where (Object)(object)item != (Object)null select item); if ((Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary != null) { list.AddRange(StatsManager.instance.itemDictionary.Values.Where((Item item) => (Object)(object)item != (Object)null)); } if ((Object)(object)ShopManager.instance != (Object)null) { list.AddRange(ShopManager.instance.potentialItems.Where((Item item) => (Object)(object)item != (Object)null)); list.AddRange(ShopManager.instance.potentialItemConsumables.Where((Item item) => (Object)(object)item != (Object)null)); list.AddRange(ShopManager.instance.potentialItemUpgrades.Where((Item item) => (Object)(object)item != (Object)null)); list.AddRange(ShopManager.instance.potentialItemHealthPacks.Where((Item item) => (Object)(object)item != (Object)null)); } list = list.Distinct().ToList(); if (Items.AllItems.Any((Item item) => IsNamed(item, "Item C.A.R.G.O. Backpack"))) { return true; } Item val = Resources.Load("Items/Item Drone Indestructible") ?? ((IEnumerable)list).FirstOrDefault((Func)((Item item) => IsNamed(item, "Item Drone Indestructible"))); if ((Object)(object)val == (Object)null || val.prefab == null || (Object)(object)((PrefabRef)(object)val.prefab).Prefab == (Object)null) { if (!_loggedMissingSource) { _loggedMissingSource = true; string text = string.Join(", ", (from item in list where ContainsDrone(((Object)item).name) || ContainsDrone(item.itemName) select "[" + ((Object)item).name + " | " + item.itemName + "]").Distinct().Take(20).ToArray()); CargoBackpackPlugin.Log.LogWarning((object)("Waiting for the built-in Item Drone Indestructible prefab. Loaded item candidates: " + list.Count + ". Drone candidates: " + text)); } return false; } GameObject obj = Object.Instantiate(((PrefabRef)(object)val.prefab).Prefab); ((Object)obj).name = "Item C.A.R.G.O. Backpack"; obj.SetActive(false); Object.DontDestroyOnLoad((Object)(object)obj); RemoveDroneBehaviour(obj); CargoBackpackVisuals.ConfigurePhysics(obj); Item val2 = ScriptableObject.CreateInstance(); CopyItem(val, val2); ((Object)val2).name = "Item C.A.R.G.O. Backpack"; val2.itemName = "C.A.R.G.O. Backpack"; val2.spawnRotationOffset = Quaternion.Euler(90f, 0f, 0f); val2.description = "One rugged backpack, four cargo slots. Equip it in slot 1, 2, or 3 and use slots 4-7. No charging required."; val2.maxAmountInShop = 1; Value val3 = ScriptableObject.CreateInstance(); ((Object)val3).name = "Value - C.A.R.G.O. Backpack"; val3.valueMin = 30000f; val3.valueMax = 40000f; val2.value = val3; ItemAttributes component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("The source item has no ItemAttributes component."); } component.item = val2; Sprite itemIcon = (component.icon = CargoBackpackVisuals.CreateInventoryIcon()); ItemEquippable component2 = obj.GetComponent(); if ((Object)(object)component2 == (Object)null) { throw new InvalidOperationException("The source item has no ItemEquippable component."); } component2.ItemIcon = itemIcon; obj.AddComponent(); obj.AddComponent(); if (Items.RegisterItem(component) == null) { throw new InvalidOperationException("REPOLib rejected the backpack prefab."); } _registrationComplete = true; CargoBackpackPlugin.Log.LogInfo((object)"Registered Item C.A.R.G.O. Backpack with shop price 30000-40000 and maximum one per visit."); return true; } private static bool IsNamed(Item item, string expected) { if ((Object)(object)item != (Object)null) { if (!string.Equals(((Object)item).name, expected, StringComparison.Ordinal)) { return string.Equals(item.itemName, expected, StringComparison.Ordinal); } return true; } return false; } private static bool ContainsDrone(string value) { if (!string.IsNullOrEmpty(value)) { return value.IndexOf("Drone", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static void RemoveDroneBehaviour(GameObject prefab) { List removed = new List(); MonoBehaviour[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Type type = ((object)val).GetType(); if (val is ItemBattery || val is ItemToggle || type.Name.StartsWith("ItemDrone", StringComparison.Ordinal)) { removed.Add((Component)(object)val); Object.DestroyImmediate((Object)(object)val); } } } PhotonView[] componentsInChildren2 = prefab.GetComponentsInChildren(true); foreach (PhotonView val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && val2.ObservedComponents != null) { val2.ObservedComponents.RemoveAll((Component component) => (Object)(object)component == (Object)null || removed.Contains(component)); } } } private static void CopyItem(Item source, Item destination) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) destination.disabled = false; destination.itemNameLocalized = null; destination.itemType = source.itemType; destination.emojiIcon = source.emojiIcon; destination.itemVolume = source.itemVolume; destination.itemSecretShopType = source.itemSecretShopType; destination.colorPreset = source.colorPreset; destination.maxAmount = Math.Max(1, source.maxAmount); destination.maxAmountInShop = 1; destination.minPlayerCount = source.minPlayerCount; destination.maxPurchase = source.maxPurchase; destination.maxPurchaseAmount = source.maxPurchaseAmount; destination.spawnRotationOffset = source.spawnRotationOffset; destination.physicalItem = true; } } [HarmonyPatch(typeof(ItemEquippable), "RequestEquip")] internal static class RequestEquipPatch { [HarmonyPrefix] private static bool Prefix(ItemEquippable __instance, int spot) { CargoBackpackController cargoBackpackController = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent() : null); if ((Object)(object)cargoBackpackController == (Object)null) { return true; } if ((Object)(object)cargoBackpackController.Equippable != (Object)null && cargoBackpackController.Equippable.IsEquipped()) { return true; } if (CargoRuntime.HasDifferentLocalBag(cargoBackpackController)) { return false; } cargoBackpackController.PrepareForEquip(); cargoBackpackController.TrackEquipAttempt(spot); return true; } } [HarmonyPatch(typeof(ItemEquippable), "RequestUnequip")] internal static class RequestUnequipPatch { [HarmonyPrefix] private static bool Prefix(ItemEquippable __instance) { CargoBackpackController component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return true; } if ((Object)(object)component.Equippable != (Object)null && component.Equippable.IsEquipped() && !component.IsOwnedByLocalPlayer()) { return false; } component.PrepareDrop(); return true; } } [HarmonyPatch(typeof(ItemEquippable), "ForceUnequip")] internal static class ForceUnequipPatch { [HarmonyPrefix] private static void Prefix(ItemEquippable __instance) { CargoBackpackController component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.PrepareDrop(); } } } [HarmonyPatch(typeof(StatsManager), "Start")] internal static class StatsStartPatch { [HarmonyPostfix] private static void Postfix() { CargoPersistence.EnsureRegistered(); } } [HarmonyPatch(typeof(StatsManager), "RunStartStats")] internal static class RunStartStatsPatch { [HarmonyPostfix] private static void Postfix() { CargoPersistence.EnsureRegistered(); } } [HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")] internal static class VanillaItemsLoadedPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { try { CargoItemFactory.TryRegister(); } catch (Exception ex) { CargoBackpackPlugin.Log.LogError((object)("Could not register C.A.R.G.O. after vanilla items loaded: " + ex)); } } } [HarmonyPatch(typeof(StatsManager), "LoadGame")] internal static class LoadGamePatch { [HarmonyPostfix] private static void Postfix() { CargoPersistence.EnsureRegistered(); } } [HarmonyPatch(typeof(PunManager), "SetItemNameLOGIC")] internal static class SetItemNamePatch { [HarmonyPostfix] private static void Postfix(ItemAttributes _itemAttributes) { CargoPersistence.RegisterItem(_itemAttributes); } } [HarmonyPatch(typeof(PunManager), "SyncAllDictionaries")] internal static class SyncAllDictionariesPatch { [HarmonyPrefix] private static void Prefix() { CargoPersistence.EnsureRegistered(); } } [HarmonyPatch(typeof(StatsManager), "SaveGame")] internal static class SaveGamePatch { [HarmonyPrefix] private static void Prefix() { CargoPersistence.EnsureRegistered(); } } internal static class CargoPersistence { internal const string DictionaryName = "cargoBackpackContents"; private static readonly FieldInfo DictionariesField = AccessTools.Field(typeof(StatsManager), "dictionaryOfDictionaries"); private static readonly FieldInfo InstanceNameField = AccessTools.Field(typeof(ItemAttributes), "instanceName"); private static readonly Dictionary ItemsByHash = new Dictionary(); internal static void EnsureRegistered() { if (!((Object)(object)StatsManager.instance == (Object)null) && !(DictionariesField == null) && DictionariesField.GetValue(StatsManager.instance) is SortedDictionary> sortedDictionary && !sortedDictionary.ContainsKey("cargoBackpackContents")) { sortedDictionary.Add("cargoBackpackContents", new Dictionary()); CargoBackpackPlugin.Log.LogInfo((object)"Registered persistent backpack content storage."); } } internal static string GetInstanceName(ItemAttributes attributes) { if ((Object)(object)attributes == (Object)null || InstanceNameField == null) { return string.Empty; } return (InstanceNameField.GetValue(attributes) as string) ?? string.Empty; } internal static int GetItemHash(ItemEquippable item) { if ((Object)(object)item == (Object)null) { return 0; } string instanceName = GetInstanceName(((Component)item).GetComponent()); if (!string.IsNullOrEmpty(instanceName)) { return instanceName.GetHashCode(); } return 0; } internal static void RegisterItem(ItemAttributes attributes) { if (!((Object)(object)attributes == (Object)null)) { ItemEquippable component = ((Component)attributes).GetComponent(); string instanceName = GetInstanceName(attributes); if (!((Object)(object)component == (Object)null) && !string.IsNullOrEmpty(instanceName)) { ItemsByHash[instanceName.GetHashCode()] = component; } } } internal static ItemEquippable FindItem(int hash) { if (hash == 0) { return null; } if (ItemsByHash.TryGetValue(hash, out var value) && (Object)(object)value != (Object)null) { return value; } ItemsByHash.Remove(hash); return null; } internal static int Read(string bagName, int cargoSlot) { Dictionary dictionary = GetDictionary(); if (dictionary == null || string.IsNullOrEmpty(bagName)) { return 0; } if (!dictionary.TryGetValue(Key(bagName, cargoSlot), out var value)) { return 0; } return value; } internal static void WriteSlot(string bagName, int cargoSlot, ItemEquippable item) { Dictionary dictionary = GetDictionary(); if (dictionary != null && !string.IsNullOrEmpty(bagName)) { int itemHash = GetItemHash(item); int itemType = GetItemType(item); if ((Object)(object)PunManager.instance != (Object)null) { PunManager.instance.UpdateStat("cargoBackpackContents", Key(bagName, cargoSlot), itemHash); PunManager.instance.UpdateStat("cargoBackpackContents", TypeKey(bagName, cargoSlot), itemType); } else { dictionary[Key(bagName, cargoSlot)] = itemHash; dictionary[TypeKey(bagName, cargoSlot)] = itemType; } } } internal static void ApplyLocal(string bagName, int slot, int hash) { Dictionary dictionary = GetDictionary(); if (dictionary != null && !string.IsNullOrEmpty(bagName)) { dictionary[Key(bagName, slot)] = hash; } } private static Dictionary GetDictionary() { EnsureRegistered(); if ((Object)(object)StatsManager.instance == (Object)null || DictionariesField == null) { return null; } if (!(DictionariesField.GetValue(StatsManager.instance) is SortedDictionary> sortedDictionary)) { return null; } if (!sortedDictionary.TryGetValue("cargoBackpackContents", out var value)) { return null; } return value; } private static string Key(string bagName, int cargoSlot) { return bagName + "|cargo-" + cargoSlot; } private static string TypeKey(string bagName, int cargoSlot) { return bagName + "|cargo-type-" + cargoSlot; } private static int GetItemType(ItemEquippable item) { ItemAttributes val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); string instanceName = GetInstanceName(val); if ((Object)(object)val == (Object)null || (Object)(object)StatsManager.instance == (Object)null) { return -1; } if (!string.IsNullOrEmpty(instanceName) && StatsManager.instance.item != null && StatsManager.instance.item.TryGetValue(instanceName, out var value)) { return value; } if ((Object)(object)val.item != (Object)null && StatsManager.instance.itemDictionary != null) { foreach (KeyValuePair item2 in StatsManager.instance.itemDictionary) { if ((Object)(object)item2.Value == (Object)(object)val.item) { return StatsManager.instance.GetIndexThatHoldsThisItemFromItemDictionary(item2.Key); } } } return -1; } internal static bool TrySpawnMissing(string bagName, int slot, int hash, Vector3 position, out GameObject spawned, out string reason) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) spawned = null; reason = null; if ((Object)(object)StatsManager.instance == (Object)null) { reason = "stats are not ready"; return false; } int num = -1; Dictionary dictionary = GetDictionary(); if (dictionary != null && dictionary.TryGetValue(TypeKey(bagName, slot), out var value)) { num = value; } if (num < 0 && StatsManager.instance.item != null) { foreach (KeyValuePair item in StatsManager.instance.item) { if (item.Key.GetHashCode() == hash) { num = item.Value; break; } } } string itemNameFromIndexInItemDictionary = StatsManager.instance.GetItemNameFromIndexInItemDictionary(num); if (string.IsNullOrEmpty(itemNameFromIndexInItemDictionary) || !StatsManager.instance.itemDictionary.TryGetValue(itemNameFromIndexInItemDictionary, out var value2) || (Object)(object)value2 == (Object)null || value2.prefab == null) { reason = "the saved item type is unavailable"; return false; } try { if (SemiFunc.IsMultiplayer()) { if (!PhotonNetwork.IsMasterClient) { reason = "waiting for host"; return false; } spawned = PhotonNetwork.InstantiateRoomObject(((PrefabRef)(object)value2.prefab).ResourcePath, position, value2.spawnRotationOffset, (byte)0, (object[])null); } else { spawned = Object.Instantiate(((PrefabRef)(object)value2.prefab).Prefab, position, value2.spawnRotationOffset); } if ((Object)(object)spawned == (Object)null) { reason = "item creation returned no object"; } return (Object)(object)spawned != (Object)null; } catch (Exception ex) { reason = ex.GetType().Name + ": " + ex.Message; return false; } } } internal static class CargoRuntime { private static readonly FieldInfo InventorySpotsField = AccessTools.Field(typeof(Inventory), "inventorySpots"); private static readonly MethodInfo HandleInputMethod = AccessTools.Method(typeof(InventorySpot), "HandleInput", (Type[])null, (Type[])null); private static readonly FieldInfo GrabbedPhysObjectField = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject"); private static CargoBackpackController _activeBag; private static float _nextSlowTick; internal static void Tick() { CargoInventoryUI.EnsureBuilt(); CargoStoredItemState.Tick(); PruneForeignBagsFromLocalInventory(); CargoBackpackController cargoBackpackController = FindLocalBag(); if ((Object)(object)cargoBackpackController != (Object)(object)_activeBag) { if ((Object)(object)_activeBag != (Object)null) { _activeBag.EndLocalUse(); } _activeBag = cargoBackpackController; if ((Object)(object)_activeBag != (Object)null) { _activeBag.BeginLocalUse(); } } HandleExtraSlotKeys(); if (!(Time.unscaledTime < _nextSlowTick)) { _nextSlowTick = Time.unscaledTime + 0.1f; CargoBackpackController[] array = Object.FindObjectsOfType(); for (int i = 0; i < array.Length; i++) { array[i].RuntimeTick(); } } } internal static bool HasLocalBag() { return (Object)(object)FindLocalBag() != (Object)null; } internal static bool HasDifferentLocalBag(CargoBackpackController candidate) { CargoBackpackController cargoBackpackController = FindLocalBag(); if ((Object)(object)cargoBackpackController != (Object)null) { return (Object)(object)cargoBackpackController != (Object)(object)candidate; } return false; } internal static CargoBackpackController FindLocalBag() { if ((Object)(object)Inventory.instance == (Object)null) { return null; } for (int i = 0; i < 3; i++) { InventorySpot val = SafeGetSpot(i); ItemEquippable val2 = (((Object)(object)val != (Object)null) ? val.CurrentItem : null); CargoBackpackController cargoBackpackController = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)cargoBackpackController != (Object)null && cargoBackpackController.IsOwnedByLocalPlayer()) { return cargoBackpackController; } } return null; } internal static int GetLocalBagBaseSlot() { if ((Object)(object)Inventory.instance == (Object)null) { return -1; } for (int i = 0; i < 3; i++) { InventorySpot val = SafeGetSpot(i); ItemEquippable val2 = (((Object)(object)val != (Object)null) ? val.CurrentItem : null); CargoBackpackController cargoBackpackController = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)cargoBackpackController != (Object)null && cargoBackpackController.IsOwnedByLocalPlayer()) { return i; } } return -1; } internal static InventorySpot GetExtraSpot(int cargoIndex) { return null; } internal static IList GetAllSpots() { if (!((Object)(object)Inventory.instance != (Object)null) || !(InventorySpotsField != null)) { return null; } return InventorySpotsField.GetValue(Inventory.instance) as IList; } internal static CargoBackpackController FindHeldBag() { PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null || !instance.grabbed || GrabbedPhysObjectField == null) { return null; } object? value = GrabbedPhysObjectField.GetValue(instance); PhysGrabObject val = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if ((Object)(object)val == (Object)null) { return null; } return FindBagOnPhysicsObject(val); } private static CargoBackpackController FindBagOnPhysicsObject(PhysGrabObject held) { if ((Object)(object)held == (Object)null) { return null; } CargoBackpackController cargoBackpackController = ((Component)held).GetComponent(); if ((Object)(object)cargoBackpackController == (Object)null) { cargoBackpackController = ((Component)held).GetComponentInParent(); } if ((Object)(object)cargoBackpackController == (Object)null) { cargoBackpackController = ((Component)held).GetComponentInChildren(true); } return cargoBackpackController; } private static InventorySpot SafeGetSpot(int index) { IList allSpots = GetAllSpots(); if (allSpots == null || index < 0 || index >= allSpots.Count) { return null; } return allSpots[index]; } private static void PruneForeignBagsFromLocalInventory() { for (int i = 0; i < 3; i++) { InventorySpot val = SafeGetSpot(i); ItemEquippable val2 = (((Object)(object)val != (Object)null) ? val.CurrentItem : null); CargoBackpackController cargoBackpackController = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); if (!((Object)(object)cargoBackpackController == (Object)null) && !cargoBackpackController.IsOwnedByLocalPlayer()) { val.UnequipItem(); CargoBackpackPlugin.Log.LogWarning((object)("Removed a foreign CARGO backpack from local inventory slot " + (i + 1))); } } } private static void HandleExtraSlotKeys() { if ((Object)(object)_activeBag == (Object)null || HandleInputMethod == null || Keyboard.current == null || !SemiFunc.NoTextInputsActive() || (Object)(object)PlayerController.instance == (Object)null || (Object)(object)FindHeldBag() != (Object)null) { return; } Keyboard current = Keyboard.current; bool[] array = new bool[4] { ((ButtonControl)current.digit4Key).wasPressedThisFrame || ((ButtonControl)current.numpad4Key).wasPressedThisFrame, ((ButtonControl)current.digit5Key).wasPressedThisFrame || ((ButtonControl)current.numpad5Key).wasPressedThisFrame, ((ButtonControl)current.digit6Key).wasPressedThisFrame || ((ButtonControl)current.numpad6Key).wasPressedThisFrame, ((ButtonControl)current.digit7Key).wasPressedThisFrame || ((ButtonControl)current.numpad7Key).wasPressedThisFrame }; for (int i = 0; i < array.Length; i++) { if (array[i]) { _activeBag.ToggleVirtualCargoSlot(i); } } } internal static ItemEquippable FindHeldItem() { PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null || !instance.grabbed || GrabbedPhysObjectField == null) { return null; } object? value = GrabbedPhysObjectField.GetValue(instance); PhysGrabObject val = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if ((Object)(object)val == (Object)null) { return null; } ItemEquippable val2 = ((Component)val).GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).GetComponentInParent(); } if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).GetComponentInChildren(true); } return val2; } } internal sealed class CargoSlotLedger { private readonly int[] _hashes = new int[4]; private readonly bool[] _known = new bool[4]; internal int Revision { get; private set; } internal int Read(int slot, int persisted) { if (slot >= 0 && slot < 4) { if (!_known[slot]) { return persisted; } return _hashes[slot]; } return 0; } internal bool Commit(int revision, int slot, int hash) { if (slot < 0 || slot >= 4 || revision <= Revision) { return false; } Revision = revision; _known[slot] = true; _hashes[slot] = hash; return true; } } [HarmonyPatch] internal static class StoredItemInputAndBatteryPatch { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(ItemToggle), "Update", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemBattery), "Update", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemBattery), "FixedUpdate", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemBattery), "BatteryLookAt", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemBattery), "OverrideBatteryShow", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemBattery), "Drain", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ItemAttributes), "Update", (Type[])null, (Type[])null); } [HarmonyPrefix] private static bool Prefix(Component __instance) { return !CargoStoredItemState.Contains(__instance.GetComponentInParent()); } } [HarmonyPatch(typeof(ItemToggle), "ToggleItemLogic")] internal static class StoredItemActivationPatch { [HarmonyPrefix] private static bool Prefix(ItemToggle __instance, bool __0) { if (__0) { return !CargoStoredItemState.Contains(((Component)__instance).GetComponentInParent()); } return true; } } [HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")] internal static class StoredPhysicsTickPatch { [HarmonyPrefix] private static bool Prefix(PhysGrabObject __instance) { return !CargoStoredItemState.Contains(((Component)__instance).GetComponent()); } } [HarmonyPatch(typeof(PhysGrabObject), "Update")] internal static class StoredPhysicsUpdatePatch { [HarmonyPrefix] private static bool Prefix(PhysGrabObject __instance) { return !CargoStoredItemState.Contains(((Component)__instance).GetComponent()); } } [HarmonyPatch(typeof(ItemEquippable), "Update")] internal static class StoredEquippableTickPatch { [HarmonyPrefix] private static bool Prefix(ItemEquippable __instance) { return !CargoStoredItemState.Contains(__instance); } } [HarmonyPatch(typeof(ItemDroneFeather), "FixedUpdate")] internal static class CargoFeatherPatch { private static readonly FieldInfo Drone = AccessTools.Field(typeof(ItemDroneFeather), "itemDrone"); private static readonly FieldInfo Target = AccessTools.Field(typeof(ItemDrone), "magnetTargetPhysGrabObject"); private static readonly FieldInfo Active = AccessTools.Field(typeof(ItemDrone), "itemActivated"); private static readonly FieldInfo Magnet = AccessTools.Field(typeof(ItemDrone), "magnetActive"); private static readonly FieldInfo OriginalMass = AccessTools.Field(typeof(PhysGrabObject), "massOriginal"); [HarmonyPostfix] private static void Postfix(ItemDroneFeather __instance) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } object? value = Drone.GetValue(__instance); ItemDrone val = (ItemDrone)((value is ItemDrone) ? value : null); if ((Object)(object)val == (Object)null || !(bool)Active.GetValue(val) || !(bool)Magnet.GetValue(val)) { return; } object? value2 = Target.GetValue(val); PhysGrabObject val2 = (PhysGrabObject)((value2 is PhysGrabObject) ? value2 : null); if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).GetComponent() == (Object)null) { return; } Rigidbody component = ((Component)val2).GetComponent(); if ((Object)(object)component == (Object)null || component.isKinematic) { return; } float num = (float)OriginalMass.GetValue(val2); if (!(num <= 0f)) { float num2 = Mathf.Max(0.02f, Mathf.Min(1f, num * 0.15f)); val2.OverrideMass(num2, 0.15f); AccessTools.Field(typeof(PhysGrabObject), "alterMassValue").SetValue(val2, num2); component.mass = num2; CargoPhysicsDiagnostic cargoPhysicsDiagnostic = ((Component)val2).GetComponent(); if ((Object)(object)cargoPhysicsDiagnostic == (Object)null) { cargoPhysicsDiagnostic = ((Component)val2).gameObject.AddComponent(); } cargoPhysicsDiagnostic.Record(num, component.mass); } } } public sealed class CargoPhysicsDiagnostic : MonoBehaviour { private float _nextLog; internal void Record(float original, float applied) { if (!(Time.unscaledTime < _nextLog)) { _nextLog = Time.unscaledTime + 15f; CargoBackpackPlugin.Log.LogInfo((object)("CARGO Feather target=" + ((Object)this).name + "; base mass=" + original + "; actual mass=" + applied)); } } } internal static class CargoStoredItemState { private sealed class State { internal ItemEquippable Item; internal CargoBackpackController Bag; internal int Slot; internal Renderer[] Renderers; internal bool[] RendererEnabled; internal Collider[] Colliders; internal bool[] ColliderEnabled; internal Rigidbody Body; internal bool Kinematic; internal bool Gravity; internal bool Collisions; internal GameObject BatteryVisual; internal bool BatteryWasActive; internal ItemMelee[] Melee; internal bool[] MeleeEnabled; internal HurtCollider[] HurtColliders; internal bool[] HurtColliderEnabled; } private static readonly Dictionary Stored = new Dictionary(); internal static bool Contains(ItemEquippable item) { if ((Object)(object)item != (Object)null) { return Stored.ContainsKey(item); } return false; } internal static bool CanAttach(ItemEquippable item, CargoBackpackController bag) { if ((Object)(object)item == (Object)null || (Object)(object)bag == (Object)null) { return false; } if (Stored.TryGetValue(item, out var value) && !((Object)(object)value.Bag == (Object)null)) { return (Object)(object)value.Bag == (Object)(object)bag; } return true; } internal static void Store(ItemEquippable item, CargoBackpackController bag, int slot) { if ((Object)(object)item == (Object)null || (Object)(object)bag == (Object)null) { return; } if (!Stored.TryGetValue(item, out var value)) { value = new State { Item = item, Bag = bag, Slot = slot, Renderers = ((Component)item).GetComponentsInChildren(true), Colliders = ((Component)item).GetComponentsInChildren(true), Body = ((Component)item).GetComponent(), Melee = ((Component)item).GetComponentsInChildren(true), HurtColliders = ((Component)item).GetComponentsInChildren(true) }; value.RendererEnabled = new bool[value.Renderers.Length]; for (int i = 0; i < value.Renderers.Length; i++) { value.RendererEnabled[i] = value.Renderers[i].enabled; } value.ColliderEnabled = new bool[value.Colliders.Length]; for (int j = 0; j < value.Colliders.Length; j++) { value.ColliderEnabled[j] = value.Colliders[j].enabled; } value.MeleeEnabled = new bool[value.Melee.Length]; for (int k = 0; k < value.Melee.Length; k++) { value.MeleeEnabled[k] = ((Behaviour)value.Melee[k]).enabled; ((Behaviour)value.Melee[k]).enabled = false; } value.HurtColliderEnabled = new bool[value.HurtColliders.Length]; for (int l = 0; l < value.HurtColliders.Length; l++) { value.HurtColliderEnabled[l] = ((Behaviour)value.HurtColliders[l]).enabled; ((Behaviour)value.HurtColliders[l]).enabled = false; } if ((Object)(object)value.Body != (Object)null) { value.Kinematic = value.Body.isKinematic; value.Gravity = value.Body.useGravity; value.Collisions = value.Body.detectCollisions; } Stored.Add(item, value); PhysGrabObject component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { AccessTools.Field(typeof(PhysGrabObject), "heldByLocalPlayer").SetValue(component, false); AccessTools.Field(typeof(PhysGrabObject), "grabbedLocal").SetValue(component, false); } ItemToggle component2 = ((Component)item).GetComponent(); if ((Object)(object)component2 != (Object)null) { AccessTools.Method(typeof(ItemToggle), "ToggleItemLogic", (Type[])null, (Type[])null).Invoke(component2, new object[2] { false, -1 }); } ItemBattery component3 = ((Component)item).GetComponent(); if ((Object)(object)component3 != (Object)null) { object? value2 = AccessTools.Field(typeof(ItemBattery), "batteryTransform").GetValue(component3); Transform val = (Transform)((value2 is Transform) ? value2 : null); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)(object)((Component)item).gameObject) { value.BatteryVisual = ((Component)val).gameObject; value.BatteryWasActive = ((Component)val).gameObject.activeSelf; } AccessTools.Field(typeof(ItemBattery), "showBattery").SetValue(component3, false); } } else { value.Bag = bag; value.Slot = slot; } Position(value); } internal static void Unstore(ItemEquippable item, Vector3 position) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || !Stored.TryGetValue(item, out var value)) { return; } Stored.Remove(item); if ((Object)(object)value.BatteryVisual != (Object)null) { value.BatteryVisual.SetActive(value.BatteryWasActive); } ((Component)item).transform.position = position; if ((Object)(object)value.Body != (Object)null) { value.Body.position = position; value.Body.isKinematic = value.Kinematic; value.Body.useGravity = value.Gravity; value.Body.detectCollisions = value.Collisions; if (!value.Kinematic) { value.Body.velocity = Vector3.zero; value.Body.angularVelocity = Vector3.zero; } } for (int i = 0; i < value.Renderers.Length; i++) { if ((Object)(object)value.Renderers[i] != (Object)null) { value.Renderers[i].enabled = value.RendererEnabled[i]; } } for (int j = 0; j < value.Colliders.Length; j++) { if ((Object)(object)value.Colliders[j] != (Object)null) { value.Colliders[j].enabled = value.ColliderEnabled[j]; } } for (int k = 0; k < value.Melee.Length; k++) { if ((Object)(object)value.Melee[k] != (Object)null) { ((Behaviour)value.Melee[k]).enabled = value.MeleeEnabled[k]; } } for (int l = 0; l < value.HurtColliders.Length; l++) { if ((Object)(object)value.HurtColliders[l] != (Object)null) { ((Behaviour)value.HurtColliders[l]).enabled = value.HurtColliderEnabled[l]; } } CargoHandTransfer.RefreshCentre(item); Physics.SyncTransforms(); } internal static void Tick() { List list = new List(); foreach (KeyValuePair item in Stored) { if ((Object)(object)item.Key == (Object)null) { list.Add(item.Key); } else if ((Object)(object)item.Value.Bag == (Object)null) { Suppress(item.Value); } else { Position(item.Value); } } foreach (ItemEquippable item2 in list) { Stored.Remove(item2); } } private static void Suppress(State state) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)state.Item == (Object)null) { return; } if ((Object)(object)state.BatteryVisual != (Object)null) { state.BatteryVisual.SetActive(false); } ItemMelee[] melee = state.Melee; foreach (ItemMelee val in melee) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } HurtCollider[] hurtColliders = state.HurtColliders; foreach (HurtCollider val2 in hurtColliders) { if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; } } Renderer[] renderers = state.Renderers; foreach (Renderer val3 in renderers) { if ((Object)(object)val3 != (Object)null) { val3.enabled = false; } } Collider[] colliders = state.Colliders; foreach (Collider val4 in colliders) { if ((Object)(object)val4 != (Object)null) { val4.enabled = false; } } if ((Object)(object)state.Body != (Object)null) { if (!state.Body.isKinematic) { state.Body.velocity = Vector3.zero; state.Body.angularVelocity = Vector3.zero; } state.Body.isKinematic = true; state.Body.useGravity = false; state.Body.detectCollisions = false; } } private static void Position(State state) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)state.Item == (Object)null) && !((Object)(object)state.Bag == (Object)null)) { Suppress(state); Vector3 position = ((Component)state.Bag).transform.position; ((Component)state.Item).transform.SetPositionAndRotation(position, ((Component)state.Bag).transform.rotation); if ((Object)(object)state.Body != (Object)null) { state.Body.position = position; } } } } [DefaultExecutionOrder(10000)] public sealed class CargoWornPose : MonoBehaviour { private sealed class Part { internal Transform Transform; internal Vector3 Position; internal Vector3 Scale; internal Vector3 FoldPosition; internal Vector3 FoldScale; internal bool Hidden; } private readonly List _parts = new List(); private Transform _straps; private Vector3 _restPosition; private PlayerAvatar _owner; private MeshFilter _bodyMesh; private float _nextBodyLookup; private float _amount; private bool _initialized; internal bool Folded { get; private set; } internal void Initialize(Transform body, Transform straps, PlayerAvatar owner) { //IL_0015: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0038: 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) //IL_0046: 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_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) _owner = owner; _straps = straps; _restPosition = ((Component)this).transform.localPosition; foreach (Transform item in body) { Transform val = item; Vector3 localPosition = val.localPosition; localPosition.y = CargoFoldLayout.Y(((Object)val).name, localPosition.y); Vector3 localScale = val.localScale; localScale.y *= CargoFoldLayout.HeightScale(((Object)val).name); _parts.Add(new Part { Transform = val, Position = val.localPosition, Scale = val.localScale, FoldPosition = localPosition, FoldScale = localScale, Hidden = CargoFoldLayout.HiddenWhenFolded(((Object)val).name) }); } } internal void SetFolded(bool folded) { Folded = folded; ((Component)_straps).gameObject.SetActive(!folded && _amount <= 0.001f); if (!_initialized) { _initialized = true; _amount = (folded ? 1f : 0f); Apply(); } } private void LateUpdate() { if (_initialized) { _amount = Mathf.MoveTowards(_amount, Folded ? 1f : 0f, Time.deltaTime / 0.2f); Apply(); } } private void Apply() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b8: 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_00c4: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.SmoothStep(0f, 1f, _amount); FollowTorso(num); ((Component)_straps).gameObject.SetActive(!Folded && _amount <= 0.001f); foreach (Part part in _parts) { ((Component)part.Transform).gameObject.SetActive(!part.Hidden || (!Folded && _amount <= 0.001f)); part.Transform.localPosition = Vector3.Lerp(part.Position, part.FoldPosition, num); part.Transform.localScale = Vector3.Lerp(part.Scale, part.FoldScale, num); } } private void FollowTorso(float blend) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0117: 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) //IL_0120: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_bodyMesh == (Object)null && (Object)(object)_owner != (Object)null && Time.unscaledTime >= _nextBodyLookup) { _nextBodyLookup = Time.unscaledTime + 1f; PlayerAvatarVisuals playerAvatarVisuals = _owner.playerAvatarVisuals; if ((Object)(object)playerAvatarVisuals != (Object)null) { MeshFilter[] componentsInChildren = ((Component)playerAvatarVisuals).GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if (((Object)val).name == "mesh_body_bot" && (Object)(object)val.sharedMesh != (Object)null) { _bodyMesh = val; break; } } } } if ((Object)(object)_bodyMesh == (Object)null || (Object)(object)_bodyMesh.sharedMesh == (Object)null) { ((Component)this).transform.localPosition = _restPosition + Vector3.down * (0.18f * blend); ((Component)this).transform.localRotation = Quaternion.identity; return; } Transform transform = ((Component)_bodyMesh).transform; Bounds bounds = _bodyMesh.sharedMesh.bounds; Vector3 val2 = transform.TransformPoint(new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).min.z)); ((Component)this).transform.rotation = transform.rotation; Vector3 lossyScale = ((Component)this).transform.lossyScale; ((Component)this).transform.position = val2 - transform.up * (CargoFoldLayout.BottomY(blend) * Mathf.Abs(lossyScale.y)) - transform.forward * (CargoFoldLayout.BackZ * Mathf.Abs(lossyScale.z)); } } }