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 System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ContainerResizer.Assets;
using ContainerResizer.Components;
using ContainerResizer.Network;
using ContainerResizer.Objects;
using ContainerResizer.Systems;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Mirror;
using Mirror.RemoteCalls;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using VLB;
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: Guid("3D348066-65A5-4A6D-9281-03F13F85F052")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyProduct("ContainerResizer")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("Resize individual chests on-the-fly to restrict how a chest can hold.")]
[assembly: AssemblyTitle("ContainerResizer")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Vapok Gaming")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ContainerResizer
{
[BepInPlugin("com.vapok.ContainerResizer", "ContainerResizer", "1.0.2")]
public class ContainerResizer : BaseUnityPlugin
{
private const string MyGUID = "com.vapok.ContainerResizer";
private const string PluginName = "ContainerResizer";
private const string VersionString = "1.0.2";
public static ManualLogSource Log = new ManualLogSource("ContainerResizer");
public static readonly TTModAssets Assets = new TTModAssets();
private static ContainerResizer _instance;
private static Harmony _harmony = new Harmony("com.vapok.ContainerResizer");
private string _saveFolder = Path.Combine(Application.persistentDataPath, "ContainerResizer");
public MachineInstanceList<ChestInstance, ChestDefinition> ChestManager;
public static ContainerResizer Instance => _instance;
private void Awake()
{
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
_instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"ContainerResizer [1.0.2] is loading...");
Log = ((BaseUnityPlugin)this).Logger;
Directory.CreateDirectory(_saveFolder);
LoadAssets();
_harmony.PatchAll();
}
private void LoadAssets()
{
AssetBundle val = Utils.LoadAssetBundle("vapokttmods");
Assets.LabeledSlider = val.LoadAsset<GameObject>("LabeledSliderWithValue");
}
}
public static class Utils
{
public static AssetBundle LoadAssetBundle(string filename, bool loadFromPath = false)
{
if (loadFromPath)
{
string assetPath = GetAssetPath(filename);
if (!string.IsNullOrEmpty(assetPath))
{
return AssetBundle.LoadFromFile(assetPath);
}
}
Assembly callingAssembly = Assembly.GetCallingAssembly();
return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + ".Assets." + filename));
}
public static string GetAssetPath(string assetName)
{
string text = Path.Combine(Paths.PluginPath, "ContainerResizer", assetName);
if (!File.Exists(text))
{
text = Path.Combine(Path.GetDirectoryName(typeof(ContainerResizer).Assembly.Location) ?? string.Empty, assetName);
if (!File.Exists(text))
{
ContainerResizer.Log.LogError((object)("Could not find asset (" + assetName + ")"));
return null;
}
}
return text;
}
public static Sprite LoadNewSprite(string filePath, float pixelsPerUnit = 100f, SpriteMeshType spriteType = 1)
{
//IL_0020: 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_0036: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = LoadTexture(filePath);
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), pixelsPerUnit, 0u, spriteType);
}
public static Texture2D LoadTexture(string filePath)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (File.Exists(filePath))
{
byte[] array = File.ReadAllBytes(filePath);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
return val;
}
}
return null;
}
}
}
namespace ContainerResizer.Systems
{
public static class ContainerManager
{
private static readonly Dictionary<uint, ContainerRecord> _containerRegistry = new Dictionary<uint, ContainerRecord>();
private static string _saveFolder = Path.Combine(Application.persistentDataPath, "ContainerResizer");
public static bool TryGetContainer(uint instanceId, out ContainerRecord record)
{
record = null;
if (!_containerRegistry.ContainsKey(instanceId))
{
return false;
}
record = _containerRegistry[instanceId];
return true;
}
public static bool AddContainer(uint instanceId, int index, ChestInstance chest, out ContainerRecord record)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
record = null;
if (_containerRegistry.ContainsKey(instanceId))
{
record = _containerRegistry[instanceId];
return false;
}
record = new ContainerRecord(instanceId, index, chest);
_containerRegistry.Add(instanceId, record);
return true;
}
public static bool RemoveContainer(uint instanceId)
{
if (_containerRegistry.ContainsKey(instanceId))
{
_containerRegistry.Remove(instanceId);
}
return !_containerRegistry.ContainsKey(instanceId);
}
public static bool IsInContainerRegistry(uint instanceId)
{
return _containerRegistry.ContainsKey(instanceId);
}
public static int RegistryCount()
{
return _containerRegistry.Count;
}
public static bool TryResizeChest(uint instanceId, int newSlotSize, out int newMinimumSlots)
{
bool result = false;
newMinimumSlots = 0;
if (TryGetContainer(instanceId, out var record))
{
result = TryResizeChest(record.IndexId, newSlotSize, out var _);
}
return result;
}
public static bool TryResizeChest(int machineIndex, int newSlotSize, out int newMinimumSlots)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return TryResizeChest(MachineManager.instance.GetMachineList<ChestInstance, ChestDefinition>((MachineTypeEnum)3).GetIndex(machineIndex), newSlotSize, out newMinimumSlots);
}
public static bool TryResizeChest(ChestInstance chest, int newSlotSize, out int newMinimumSlots)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_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_003c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_010e: Unknown result type (might be due to invalid IL or missing references)
newMinimumSlots = 0;
if (chest.commonInfo.instanceId == 0)
{
return false;
}
if (!TryGetContainer(chest.commonInfo.instanceId, out var record))
{
AddContainer(chest.commonInfo.instanceId, chest.commonInfo.index, chest, out record);
}
record.SetSlotCount(newSlotSize);
if (chest.commonInfo.inventories[0].numSlots == newSlotSize)
{
return false;
}
chest.commonInfo.inventories[0].numSlots = newSlotSize;
Array.Resize(ref chest.commonInfo.inventories[0].myStacks, chest.commonInfo.inventories[0].numSlots);
Array.Resize(ref chest.commonInfo.inventories[0].customSlotOverrides, chest.commonInfo.inventories[0].numSlots);
((Inventory)(ref chest.commonInfo.inventories[0])).SortAndConsolidate();
newMinimumSlots = chest.commonInfo.inventories[0].numSlots - ((Inventory)(ref chest.commonInfo.inventories[0])).GetNumberOfEmptySlots();
if (ContainerNetwork.IsServer)
{
ContainerNetwork.Instance.UpdateContainerFromServer(record.InstanceId, record.SlotCount);
}
return true;
}
public static List<ContainerRecord> ExportRegistry()
{
List<ContainerRecord> list = new List<ContainerRecord>();
foreach (KeyValuePair<uint, ContainerRecord> item in _containerRegistry)
{
list.Add(item.Value);
}
return list;
}
public static void ImportRegistry(List<ContainerRecord> importedRecords)
{
_containerRegistry.Clear();
foreach (ContainerRecord importedRecord in importedRecords)
{
_containerRegistry.Add(importedRecord.InstanceId, importedRecord);
}
}
public static void ImportRegistry(List<string> importedRecords)
{
_containerRegistry.Clear();
foreach (string importedRecord in importedRecords)
{
ContainerRecord containerRecord = new ContainerRecord(importedRecord);
_containerRegistry.Add(containerRecord.InstanceId, containerRecord);
}
}
public static void SaveRegistry(string worldName)
{
if (_containerRegistry != null)
{
string path = Path.Combine(_saveFolder, worldName + ".bin");
BinaryFormatter binaryFormatter = new BinaryFormatter();
FileStream fileStream = File.Create(path);
ContainerResizer.Log.LogDebug((object)("Saving Container Registry to " + worldName + ".bin"));
binaryFormatter.Serialize(fileStream, _containerRegistry);
fileStream.Close();
}
}
public static void LoadRegistry(string worldName)
{
string path = Path.Combine(_saveFolder, worldName + ".bin");
if (!File.Exists(path))
{
return;
}
ContainerResizer.Log.LogDebug((object)("Loading Container Registry from " + worldName + ".bin"));
try
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
FileStream fileStream = File.Open(path, FileMode.Open);
Dictionary<uint, ContainerRecord> dictionary = binaryFormatter.Deserialize(fileStream) as Dictionary<uint, ContainerRecord>;
fileStream.Close();
if (dictionary == null)
{
return;
}
foreach (KeyValuePair<uint, ContainerRecord> item in dictionary)
{
_containerRegistry[item.Key] = item.Value;
}
}
catch (Exception ex)
{
ContainerResizer.Log.LogError((object)("Unable to Load Container Registry: " + ex.Message));
}
}
}
}
namespace ContainerResizer.Patches
{
public static class InventoryNavigatorPatches
{
[HarmonyPatch(typeof(InventoryNavigator), "Open")]
public static class InventoryNavigatorOpen
{
public static void Prefix(InventoryNavigator __instance, MachineInstanceRef<ChestInstance> machineRef)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Utils.GetOrAddComponent<SliderComponent>((MonoBehaviour)(object)__instance).OpenChest(machineRef, __instance);
}
}
[HarmonyPatch(typeof(InventoryNavigator), "OnClose")]
public static class InventoryNavigatorOnClose
{
public static void Postfix(InventoryNavigator __instance)
{
Utils.GetOrAddComponent<SliderComponent>((MonoBehaviour)(object)__instance).CloseChest();
}
}
}
public static class MachineDefinitionPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class MachineDefinitionBuildTypedInstancePatch
{
public static void Postfix(MachineDefinition<ChestInstance, ChestDefinition> __instance, ref ChestInstance newInstance)
{
//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_0015: 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_006d: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
ChestInstance val = newInstance;
int index = __instance.myMachineList.curCount - 1;
if (!ContainerManager.TryGetContainer(val.commonInfo.instanceId, out var record))
{
ContainerManager.AddContainer(val.commonInfo.instanceId, index, val, out record);
ContainerRecord containerRecord = record;
Vector2Int val2 = ((BuilderInfo)__instance).inventorySizes[0];
int x = ((Vector2Int)(ref val2)).x;
val2 = ((BuilderInfo)__instance).inventorySizes[0];
containerRecord.OriginalSlotCount = x * ((Vector2Int)(ref val2)).y;
}
ContainerManager.TryResizeChest(val, record.SlotCount, out var _);
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class MachineDefinitionOnDeconstruct
{
public static void Postfix(ref ChestInstance erasedInstance)
{
ContainerManager.RemoveContainer(erasedInstance.commonInfo.instanceId);
}
}
}
public static class NetworkIdentityPatches
{
[HarmonyPatch(typeof(NetworkIdentity), "Awake")]
public static class NetworkIdentityAwakeChanges
{
[UsedImplicitly]
public static void Prefix(NetworkIdentity __instance)
{
Utils.GetOrAddComponent<ContainerNetwork>((MonoBehaviour)(object)__instance);
}
}
}
public static class SaveStatePatches
{
[HarmonyPatch(typeof(SaveState), "LoadFileData", new Type[]
{
typeof(SaveMetadata),
typeof(string)
})]
public static class SaveStateLoadFileData
{
public static void Postfix(SaveState __instance, SaveMetadata saveMetadata)
{
ContainerManager.LoadRegistry(saveMetadata.worldName);
}
}
[HarmonyPatch(typeof(SaveState), "SaveToFile")]
public static class SaveStateSaveToFile
{
[UsedImplicitly]
public static void Postfix(SaveState __instance)
{
if (__instance != null && __instance.metadata?.worldName != null)
{
ContainerManager.SaveRegistry(__instance.metadata.worldName);
}
}
}
}
}
namespace ContainerResizer.Objects
{
[Serializable]
public class ContainerRecord
{
private uint _instanceId;
private int _indexId;
private int _slotCount;
private int _originalSlotCount;
public bool AdjustedSlotCount => SlotCount != OriginalSlotCount;
public int OriginalSlotCount
{
get
{
return _originalSlotCount;
}
set
{
_originalSlotCount = value;
}
}
public int SlotCount => _slotCount;
public int IndexId => _indexId;
public uint InstanceId => _instanceId;
public ContainerRecord(ChestInstance chest)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
_instanceId = chest.commonInfo.instanceId;
_indexId = chest.commonInfo.index;
_slotCount = chest.commonInfo.inventories[0].numSlots;
OriginalSlotCount = chest.commonInfo.inventories[0].numSlots;
}
public ContainerRecord(uint instanceID, int index, ChestInstance chest)
{
//IL_0015: 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_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)
_instanceId = instanceID;
_indexId = index;
_slotCount = chest.commonInfo.inventories[0].numSlots;
OriginalSlotCount = chest.commonInfo.inventories[0].numSlots;
}
public ContainerRecord(uint instanceID, int index, int slotCount, int originalSlotCount)
{
_instanceId = instanceID;
_indexId = index;
_slotCount = slotCount;
OriginalSlotCount = originalSlotCount;
}
public ContainerRecord(string csvValue)
{
string[] array = csvValue.Split(new char[1] { ',' });
_instanceId = uint.Parse(array[0]);
_indexId = int.Parse(array[1]);
_slotCount = int.Parse(array[2]);
OriginalSlotCount = int.Parse(array[3]);
}
public void SetSlotCount(int newSlotCount)
{
_slotCount = newSlotCount;
}
public int GetMaxSlots()
{
return OriginalSlotCount;
}
public override string ToString()
{
return $"{_instanceId},{_indexId},{_slotCount},{_originalSlotCount}";
}
}
}
namespace ContainerResizer.Network
{
public class ContainerNetwork : NetworkBehaviour
{
private static bool _isClient;
private static bool _isServer;
private static bool _isLocal;
private static ContainerNetwork _instance;
[SyncVar]
public string NetworkID;
public PlatformUserId playerID;
private HashSet<NetworkConnection> _clients = new HashSet<NetworkConnection>();
public static bool IsClient => _isClient;
public static bool IsServer => _isServer;
public static bool IsLocal => _isLocal;
public static ContainerNetwork Instance => _instance;
private NetworkedPlayer _player => Player.instance.networkedPlayer;
public string NetworkNetworkID
{
get
{
return NetworkID;
}
[param: In]
set
{
if (!((NetworkBehaviour)this).SyncVarEqual<string>(value, ref NetworkID))
{
_ = NetworkID;
((NetworkBehaviour)this).SetSyncVar<string>(value, ref NetworkID, 1uL);
}
}
}
protected override bool SerializeSyncVars(NetworkWriter writer, bool forceAll)
{
bool result = ((NetworkBehaviour)this).SerializeSyncVars(writer, forceAll);
if (forceAll)
{
NetworkWriterExtensions.WriteString(writer, NetworkID);
return true;
}
NetworkWriterExtensions.WriteULong(writer, ((NetworkBehaviour)this).syncVarDirtyBits);
if ((((NetworkBehaviour)this).syncVarDirtyBits & 1) != 0L)
{
NetworkWriterExtensions.WriteString(writer, NetworkID);
result = true;
}
return result;
}
protected override void DeserializeSyncVars(NetworkReader reader, bool initialState)
{
((NetworkBehaviour)this).DeserializeSyncVars(reader, initialState);
if (initialState)
{
_ = NetworkID;
NetworkNetworkID = NetworkReaderExtensions.ReadString(reader);
}
else if ((NetworkReaderExtensions.ReadULong(reader) & 1) != 0L)
{
_ = NetworkID;
NetworkNetworkID = NetworkReaderExtensions.ReadString(reader);
}
}
static ContainerNetwork()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
RemoteCallHelper.RegisterCommandDelegate(typeof(ContainerNetwork), "RequestContainerRegistry", new CmdDelegate(InvokeUserCode_RequestContainerRegistry), true);
RemoteCallHelper.RegisterCommandDelegate(typeof(ContainerNetwork), "UpdateContainer", new CmdDelegate(InvokeUserCode_UpdateContainer), true);
RemoteCallHelper.RegisterRpcDelegate(typeof(ContainerNetwork), "LoadContainerRegistryFromServer", new CmdDelegate(InvokeUserCode_LoadContainerRegistryFromServer));
RemoteCallHelper.RegisterRpcDelegate(typeof(ContainerNetwork), "UpdateContainerFromServer", new CmdDelegate(InvokeUserCode_UpdateContainerFromServer));
}
private static void InvokeUserCode_RequestContainerRegistry(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection)
{
if (!NetworkServer.active)
{
ContainerResizer.Log.LogError((object)"Command RequestContainerRegistry called on client.");
}
else
{
((ContainerNetwork)(object)obj).UserCode_RequestContainerRegistry(senderConnection);
}
}
private static void InvokeUserCode_UpdateContainer(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection)
{
if (!NetworkServer.active)
{
ContainerResizer.Log.LogError((object)"Command UpdateContainer called on client.");
}
else
{
((ContainerNetwork)(object)obj).UserCode_UpdateContainer(NetworkReaderExtensions.ReadUInt(reader), NetworkReaderExtensions.ReadInt(reader), senderConnection);
}
}
protected static void InvokeUserCode_LoadContainerRegistryFromServer(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection)
{
if (!NetworkClient.active)
{
ContainerResizer.Log.LogError((object)"TargetRPC LoadContainerRegistryFromServer called on server.");
}
else
{
((ContainerNetwork)(object)obj).UserCode_LoadContainerRegistryFromServer(NetworkClient.connection, NetworkReaderExtensions.ReadList<string>(reader));
}
}
protected static void InvokeUserCode_UpdateContainerFromServer(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection)
{
if (!NetworkClient.active)
{
ContainerResizer.Log.LogError((object)"TargetRPC LoadContainerRegistryFromServer called on server.");
}
else
{
((ContainerNetwork)(object)obj).UserCode_UpdateContainerFromServer(NetworkClient.connection, NetworkReaderExtensions.ReadUInt(reader), NetworkReaderExtensions.ReadInt(reader));
}
}
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
_instance = this;
base.syncMode = (SyncMode)1;
}
public override void OnStartClient()
{
ContainerResizer.Log.LogDebug((object)$"OnStartClient() for Network ID {((NetworkBehaviour)this).netId}");
if (((NetworkBehaviour)this).connectionToClient != null)
{
_isClient = ((NetworkBehaviour)this).isClient;
_isServer = ((NetworkBehaviour)this).isServer;
_isLocal = ((NetworkBehaviour)this).isLocalPlayer;
if (IsClient)
{
_clients.Add(((NetworkBehaviour)this).connectionToClient);
}
}
}
public override void OnStartLocalPlayer()
{
ContainerResizer.Log.LogDebug((object)$"OnStartLocalPlayer() for Network ID {((NetworkBehaviour)this).netId}");
RequestContainerRegistry();
}
public override void OnStartServer()
{
//IL_0099: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)this).connectionToClient != null)
{
ContainerResizer.Log.LogDebug((object)$"OnStartServer() for Network ID {((NetworkBehaviour)this).netId}");
if (!((NetworkBehaviour)this).hasAuthority)
{
NetworkNetworkID = (string)((NetworkBehaviour)this).connectionToClient.authenticationData;
playerID = Platform.mgr.ClientIdFromString(NetworkID);
ContainerResizer.Log.LogDebug((object)$"No Authority for Network ID {((NetworkBehaviour)this).netId} / Player ID {playerID}");
}
else
{
NetworkNetworkID = "host";
playerID = Platform.mgr.LocalPlayerId();
ContainerResizer.Log.LogDebug((object)$"Has Authority for Network ID {((NetworkBehaviour)this).netId} / Player ID {playerID}");
}
_isClient = ((NetworkBehaviour)this).isClient;
_isServer = ((NetworkBehaviour)this).isServer;
_isLocal = ((NetworkBehaviour)this).isLocalPlayer;
}
}
public override void OnStopClient()
{
if (((NetworkBehaviour)this).connectionToClient != null)
{
ContainerResizer.Log.LogDebug((object)$"OnStopClient() for Network ID {((NetworkBehaviour)this).netId}");
if (IsClient)
{
_clients.Remove(((NetworkBehaviour)this).connectionToClient);
}
}
}
[Command]
public void UpdateContainer(uint instanceId, int slotCount, NetworkConnectionToClient sender = null)
{
if (!((NetworkBehaviour)this).isServer)
{
ContainerResizer.Log.LogDebug((object)$"Updating Container {instanceId}...");
PooledNetworkWriter writer = NetworkWriterPool.GetWriter();
NetworkWriterExtensions.WriteUInt((NetworkWriter)(object)writer, instanceId);
NetworkWriterExtensions.WriteInt((NetworkWriter)(object)writer, slotCount);
((NetworkBehaviour)this).SendCommandInternal(typeof(ContainerNetwork), "UpdateContainer", (NetworkWriter)(object)writer, 0, true);
NetworkWriterPool.Recycle(writer);
}
}
[Command]
public void RequestContainerRegistry(NetworkConnectionToClient sender = null)
{
if (!((NetworkBehaviour)this).isServer)
{
ContainerResizer.Log.LogDebug((object)"Requesting Container Registry...");
PooledNetworkWriter writer = NetworkWriterPool.GetWriter();
((NetworkBehaviour)this).SendCommandInternal(typeof(ContainerNetwork), "RequestContainerRegistry", (NetworkWriter)(object)writer, 0, true);
NetworkWriterPool.Recycle(writer);
}
}
[TargetRpc]
public void LoadContainerRegistryFromServer(NetworkConnection connection)
{
ContainerResizer.Log.LogDebug((object)"Container Registry Requested by NetworkedPlayer");
PooledNetworkWriter writer = NetworkWriterPool.GetWriter();
List<string> list = new List<string>();
foreach (ContainerRecord item in ContainerManager.ExportRegistry())
{
list.Add(item.ToString());
}
NetworkWriterExtensions.WriteList<string>((NetworkWriter)(object)writer, list);
((NetworkBehaviour)this).SendTargetRPCInternal(connection, typeof(ContainerNetwork), "LoadContainerRegistryFromServer", (NetworkWriter)(object)writer, 0);
NetworkWriterPool.Recycle(writer);
}
[TargetRpc]
public void UpdateContainerFromServer(uint instanceId, int slotCount, NetworkConnection connection = null)
{
ContainerResizer.Log.LogDebug((object)"Sending Updated Container...");
PooledNetworkWriter writer = NetworkWriterPool.GetWriter();
NetworkWriterExtensions.WriteUInt((NetworkWriter)(object)writer, instanceId);
NetworkWriterExtensions.WriteInt((NetworkWriter)(object)writer, slotCount);
foreach (NetworkConnection client in _clients)
{
if (client != connection)
{
((NetworkBehaviour)this).SendTargetRPCInternal(connection, typeof(ContainerNetwork), "UpdateContainerFromServer", (NetworkWriter)(object)writer, 0);
}
}
NetworkWriterPool.Recycle(writer);
}
private void UserCode_UpdateContainer(uint instanceId, int slotCount, NetworkConnectionToClient sender = null)
{
if (ContainerManager.TryResizeChest(instanceId, slotCount, out var _))
{
UpdateContainerFromServer(instanceId, slotCount, (NetworkConnection)(object)sender);
}
}
private void UserCode_RequestContainerRegistry(NetworkConnectionToClient sender)
{
((MonoBehaviour)this).StartCoroutine(PackageCoreCount(sender));
}
private void UserCode_LoadContainerRegistryFromServer(NetworkConnection connection, List<string> importList)
{
ContainerResizer.Log.LogDebug((object)"Container Registry Received by Host/Server");
ContainerManager.ImportRegistry(importList);
}
private void UserCode_UpdateContainerFromServer(NetworkConnection connection, uint instanceId, int slotCount)
{
ContainerResizer.Log.LogDebug((object)"Container Update Received by Host/Server");
ContainerManager.TryResizeChest(instanceId, slotCount, out var _);
}
private IEnumerator PackageCoreCount(NetworkConnectionToClient sender)
{
while (SaveState.isSaving)
{
yield return null;
}
LoadContainerRegistryFromServer((NetworkConnection)(object)sender);
}
}
}
namespace ContainerResizer.Extensions
{
public static class CanvasGroupExtensions
{
public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha)
{
canvasGroup.alpha = alpha;
return canvasGroup;
}
public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts)
{
canvasGroup.blocksRaycasts = blocksRaycasts;
return canvasGroup;
}
}
public static class ColorExtensions
{
public static Color SetAlpha(this Color color, float alpha)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
color.a = alpha;
return color;
}
}
public static class ContentSizeFitterExtensions
{
public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
fitter.horizontalFit = fitMode;
return fitter;
}
public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
fitter.verticalFit = fitMode;
return fitter;
}
}
public static class GameObjectExtensions
{
public static T SetEnabled<T>(this T behaviour, bool enabled) where T : Behaviour
{
((Behaviour)behaviour).enabled = enabled;
return behaviour;
}
public static GameObject SetName(this GameObject gameObject, string name)
{
((Object)gameObject).name = name;
return gameObject;
}
public static T SetName<T>(this T component, string name) where T : Component
{
((Object)((Component)component).gameObject).name = name;
return component;
}
public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false)
{
gameObject.transform.SetParent(transform, worldPositionStays);
return gameObject;
}
public static IEnumerable<GameObject> Children(this GameObject gameObject)
{
if (!Object.op_Implicit((Object)(object)gameObject))
{
return Enumerable.Empty<GameObject>();
}
return from Transform t in (IEnumerable)gameObject.transform
select ((Component)t).gameObject;
}
public static Button Button(this GameObject gameObject)
{
if (!Object.op_Implicit((Object)(object)gameObject))
{
return null;
}
return gameObject.GetComponent<Button>();
}
public static Image Image(this GameObject gameObject)
{
if (!Object.op_Implicit((Object)(object)gameObject))
{
return null;
}
return gameObject.GetComponent<Image>();
}
public static LayoutElement LayoutElement(this GameObject gameObject)
{
if (!Object.op_Implicit((Object)(object)gameObject))
{
return null;
}
return gameObject.GetComponent<LayoutElement>();
}
public static RectTransform RectTransform(this GameObject gameObject)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
return (RectTransform)gameObject.transform;
}
}
public static class GridLayoutGroupExtensions
{
public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
layoutGroup.cellSize = cellSize;
return layoutGroup;
}
public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
layoutGroup.constraint = constraint;
return layoutGroup;
}
public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount)
{
layoutGroup.constraintCount = constraintCount;
return layoutGroup;
}
public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
layoutGroup.startAxis = startAxis;
return layoutGroup;
}
public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
layoutGroup.startCorner = startCorner;
return layoutGroup;
}
public static GridLayoutGroup SetPadding(this GridLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
{
if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
{
throw new ArgumentException("Value for left, right, top or bottom must be provided.");
}
if (left.HasValue)
{
((LayoutGroup)layoutGroup).padding.left = left.Value;
}
if (right.HasValue)
{
((LayoutGroup)layoutGroup).padding.right = right.Value;
}
if (top.HasValue)
{
((LayoutGroup)layoutGroup).padding.top = top.Value;
}
if (bottom.HasValue)
{
((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
}
return layoutGroup;
}
public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
layoutGroup.spacing = spacing;
return layoutGroup;
}
}
public static class HorizontalLayoutGroupExtensions
{
public static HorizontalLayoutGroup SetChildControl(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value;
}
if (height.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value;
}
return layoutGroup;
}
public static HorizontalLayoutGroup SetChildForceExpand(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value;
}
if (height.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value;
}
return layoutGroup;
}
public static HorizontalLayoutGroup SetChildAlignment(this HorizontalLayoutGroup layoutGroup, TextAnchor alignment)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((LayoutGroup)layoutGroup).childAlignment = alignment;
return layoutGroup;
}
public static HorizontalLayoutGroup SetPadding(this HorizontalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
{
if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
{
throw new ArgumentException("Value for left, right, top or bottom must be provided.");
}
if (left.HasValue)
{
((LayoutGroup)layoutGroup).padding.left = left.Value;
}
if (right.HasValue)
{
((LayoutGroup)layoutGroup).padding.right = right.Value;
}
if (top.HasValue)
{
((LayoutGroup)layoutGroup).padding.top = top.Value;
}
if (bottom.HasValue)
{
((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
}
return layoutGroup;
}
public static HorizontalLayoutGroup SetSpacing(this HorizontalLayoutGroup layoutGroup, float spacing)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
return layoutGroup;
}
}
public static class ImageExtensions
{
public static Image SetColor(this Image image, Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Graphic)image).color = color;
return image;
}
public static Image SetFillAmount(this Image image, float amount)
{
image.fillAmount = amount;
return image;
}
public static Image SetFillCenter(this Image image, bool fillCenter)
{
image.fillCenter = fillCenter;
return image;
}
public static Image SetFillMethod(this Image image, FillMethod fillMethod)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
image.fillMethod = fillMethod;
return image;
}
public static Image SetFillOrigin(this Image image, OriginHorizontal origin)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected I4, but got Unknown
image.fillOrigin = (int)origin;
return image;
}
public static Image SetFillOrigin(this Image image, OriginVertical origin)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected I4, but got Unknown
image.fillOrigin = (int)origin;
return image;
}
public static Image SetMaskable(this Image image, bool maskable)
{
((MaskableGraphic)image).maskable = maskable;
return image;
}
public static Image SetPreserveAspect(this Image image, bool preserveAspect)
{
image.preserveAspect = preserveAspect;
return image;
}
public static Image SetRaycastTarget(this Image image, bool raycastTarget)
{
((Graphic)image).raycastTarget = raycastTarget;
return image;
}
public static Image SetSprite(this Image image, Sprite sprite)
{
image.sprite = sprite;
return image;
}
public static Image SetType(this Image image, Type type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
image.type = type;
return image;
}
}
public static class InputFieldExtensions
{
public static InputField SetTextComponent(this InputField inputField, Text textComponent)
{
inputField.textComponent = textComponent;
return inputField;
}
}
public static class LayoutElementExtensions
{
public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
layoutElement.preferredWidth = width.Value;
}
if (height.HasValue)
{
layoutElement.preferredHeight = height.Value;
}
return layoutElement;
}
public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
layoutElement.flexibleWidth = width.Value;
}
if (height.HasValue)
{
layoutElement.flexibleHeight = height.Value;
}
return layoutElement;
}
public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
layoutElement.minWidth = width.Value;
}
if (height.HasValue)
{
layoutElement.minHeight = height.Value;
}
return layoutElement;
}
public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
{
layoutElement.ignoreLayout = ignoreLayout;
return layoutElement;
}
}
public static class MaskExtensions
{
public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic)
{
mask.showMaskGraphic = showMaskGraphic;
return mask;
}
}
public static class OutlineExtensions
{
public static Outline SetEffectColor(this Outline outline, Color effectColor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Shadow)outline).effectColor = effectColor;
return outline;
}
public static Outline SetEffectDistance(this Outline outline, Vector2 effectDistance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Shadow)outline).effectDistance = effectDistance;
return outline;
}
public static Outline SetUseGraphicAlpha(this Outline outline, bool useGraphicAlpha)
{
((Shadow)outline).useGraphicAlpha = useGraphicAlpha;
return outline;
}
}
public static class RectTransformExtensions
{
public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchorMin = anchorMin;
return rectTransform;
}
public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchorMax = anchorMax;
return rectTransform;
}
public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
rectTransform.pivot = pivot;
return rectTransform;
}
public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchoredPosition = position;
return rectTransform;
}
public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
rectTransform.sizeDelta = sizeDelta;
return rectTransform;
}
}
public static class SelectableExtensions
{
public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Selectable)selectable).colors = colors;
return selectable;
}
public static T SetImage<T>(this T selectable, Image image) where T : Selectable
{
((Selectable)selectable).image = image;
return selectable;
}
public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable
{
((Selectable)selectable).interactable = interactable;
return selectable;
}
public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable
{
((Selectable)selectable).targetGraphic = graphic;
return selectable;
}
public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Selectable)selectable).transition = transition;
return selectable;
}
public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Navigation navigation = ((Selectable)selectable).navigation;
((Navigation)(ref navigation)).mode = mode;
((Selectable)selectable).navigation = navigation;
return selectable;
}
}
public static class ShadowExtensions
{
public static Shadow SetEffectColor(this Shadow shadow, Color effectColor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
shadow.effectColor = effectColor;
return shadow;
}
public static Shadow SetEffectDistance(this Shadow shadow, Vector2 effectDistance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
shadow.effectDistance = effectDistance;
return shadow;
}
}
public static class ScrollRectExtensions
{
public static ScrollRect SetScrollSensitivity(this ScrollRect scrollRect, float sensitivity)
{
scrollRect.scrollSensitivity = sensitivity;
return scrollRect;
}
public static ScrollRect SetVerticalScrollPosition(this ScrollRect scrollRect, float position)
{
scrollRect.verticalNormalizedPosition = position;
return scrollRect;
}
public static ScrollRect SetViewport(this ScrollRect scrollRect, RectTransform viewport)
{
scrollRect.viewport = viewport;
return scrollRect;
}
public static ScrollRect SetContent(this ScrollRect scrollRect, RectTransform content)
{
scrollRect.content = content;
return scrollRect;
}
public static ScrollRect SetHorizontal(this ScrollRect scrollRect, bool horizontal)
{
scrollRect.horizontal = horizontal;
return scrollRect;
}
public static ScrollRect SetVertical(this ScrollRect scrollRect, bool vertical)
{
scrollRect.vertical = vertical;
return scrollRect;
}
}
public static class SpriteExtensions
{
public static Sprite SetName(this Sprite sprite, string name)
{
((Object)sprite).name = name;
return sprite;
}
}
public static class TextExtensions
{
public static Text SetAlignment(this Text text, TextAnchor alignment)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
text.alignment = alignment;
return text;
}
public static Text SetColor(this Text text, Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Graphic)text).color = color;
return text;
}
public static Text SetFont(this Text text, Font font)
{
text.font = font;
return text;
}
public static Text SetFontStyle(this Text text, FontStyle fontStyle)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
text.fontStyle = fontStyle;
return text;
}
public static Text SetFontSize(this Text text, int fontSize)
{
text.fontSize = fontSize;
return text;
}
public static Text SetResizeTextForBestFit(this Text text, bool resizeTextForBestFit)
{
text.resizeTextForBestFit = resizeTextForBestFit;
return text;
}
public static Text SetSupportRichText(this Text text, bool supportRichText)
{
text.supportRichText = supportRichText;
return text;
}
public static Text SetText(this Text text, string value)
{
text.text = value;
return text;
}
}
public static class TMPTextExtensions
{
public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)(object)tmpText).color = color;
return tmpText;
}
}
public static class Texture2DExtensions
{
public static Texture2D SetName(this Texture2D texture, string name)
{
((Object)texture).name = name;
return texture;
}
public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Texture)texture).wrapMode = wrapMode;
return texture;
}
public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((Texture)texture).filterMode = filterMode;
return texture;
}
}
public static class ToggleExtensions
{
public static Toggle SetIsOn(this Toggle toggle, bool isOn)
{
toggle.SetIsOnWithoutNotify(isOn);
((UnityEvent<bool>)(object)toggle.onValueChanged)?.Invoke(isOn);
return toggle;
}
}
public static class VerticalLayoutGroupExtensions
{
public static VerticalLayoutGroup SetChildControl(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value;
}
if (height.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value;
}
return layoutGroup;
}
public static VerticalLayoutGroup SetChildForceExpand(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
{
if (!width.HasValue && !height.HasValue)
{
throw new ArgumentException("Value for width or height must be provided.");
}
if (width.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value;
}
if (height.HasValue)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value;
}
return layoutGroup;
}
public static VerticalLayoutGroup SetChildAlignment(this VerticalLayoutGroup layoutGroup, TextAnchor alignment)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
((LayoutGroup)layoutGroup).childAlignment = alignment;
return layoutGroup;
}
public static VerticalLayoutGroup SetPadding(this VerticalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
{
if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
{
throw new ArgumentException("Value for left, right, top or bottom must be provided.");
}
if (left.HasValue)
{
((LayoutGroup)layoutGroup).padding.left = left.Value;
}
if (right.HasValue)
{
((LayoutGroup)layoutGroup).padding.right = right.Value;
}
if (top.HasValue)
{
((LayoutGroup)layoutGroup).padding.top = top.Value;
}
if (bottom.HasValue)
{
((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
}
return layoutGroup;
}
public static VerticalLayoutGroup SetSpacing(this VerticalLayoutGroup layoutGroup, float spacing)
{
((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
return layoutGroup;
}
}
}
namespace ContainerResizer.Components
{
public class SliderComponent : MonoBehaviour
{
public GameObject storageUnit;
public GameObject sliderContainer;
public GameObject sliderLabel;
public GameObject sliderValue;
public TMP_Text sliderLabelText;
public TMP_Text sliderValueText;
public Slider storageSlider;
private TextMeshProUGUI _sortText;
private int _machineIndex;
private bool _initalOpen = true;
private InventoryNavigator _inventoryNavigator;
private void Awake()
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
Transform obj = ((Component)this).transform.Find("Top Level Container/Container/Storage Unit");
storageUnit = ((obj != null) ? ((Component)obj).gameObject : null);
Transform val = ((Component)this).transform.Find("Top Level Container/Container/Storage Unit/Storage Sort Button/Sort Text");
if ((Object)(object)val != (Object)null)
{
_sortText = ((Component)val).GetComponent<TextMeshProUGUI>();
}
if ((Object)(object)storageUnit != (Object)null)
{
sliderContainer = Object.Instantiate<GameObject>(ContainerResizer.Assets.LabeledSlider, storageUnit.transform);
sliderContainer.GetComponent<RectTransform>().anchoredPosition = new Vector2(300f, 50f);
sliderLabel = ((Component)sliderContainer.transform.Find("TMP Label")).gameObject;
sliderLabelText = (TMP_Text)(object)sliderLabel.GetComponent<TextMeshProUGUI>();
sliderValue = ((Component)sliderContainer.transform.Find("TMP ValueLabel")).gameObject;
sliderValueText = (TMP_Text)(object)sliderValue.GetComponent<TextMeshProUGUI>();
storageSlider = ((Component)sliderContainer.transform.Find("Slider")).GetComponent<Slider>();
sliderLabelText.text = "Adjust Storage Size:";
sliderLabelText.font = ((TMP_Text)_sortText).font;
sliderLabelText.fontSize = 17f;
sliderLabelText.fontSizeMax = 18f;
sliderLabelText.fontSizeMin = 3f;
sliderLabelText.enableAutoSizing = true;
sliderValueText.font = ((TMP_Text)_sortText).font;
sliderValueText.fontSize = 20f;
sliderValueText.fontSizeMax = 30f;
sliderValueText.fontSizeMin = 3f;
sliderValueText.enableAutoSizing = true;
sliderValueText.text = $"{storageSlider.value}";
((UnityEvent<float>)(object)storageSlider.onValueChanged).AddListener((UnityAction<float>)UpdateValue);
}
}
private void UpdateValue(float value)
{
int num = (int)value;
if (_machineIndex >= 0)
{
sliderValueText.text = $"{num}";
int newMinimumSlots;
if (_initalOpen)
{
_initalOpen = false;
}
else if (ContainerManager.TryResizeChest(_machineIndex, num, out newMinimumSlots))
{
storageSlider.minValue = ((newMinimumSlots == 0) ? 1 : newMinimumSlots);
_inventoryNavigator.Refresh(true);
}
}
}
public void OpenChest(MachineInstanceRef<ChestInstance> machineRef, InventoryNavigator invNavigator)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
_inventoryNavigator = invNavigator;
_machineIndex = machineRef.index;
ChestInstance index = MachineManager.instance.GetMachineList<ChestInstance, ChestDefinition>((MachineTypeEnum)3).GetIndex(_machineIndex);
if (!ContainerManager.TryGetContainer(machineRef._instanceId, out var record))
{
ContainerManager.AddContainer(machineRef.instanceId, machineRef.index, index, out record);
}
int num = index.commonInfo.inventories[0].numSlots - ((Inventory)(ref index.commonInfo.inventories[0])).GetNumberOfEmptySlots();
storageSlider.maxValue = record.GetMaxSlots();
storageSlider.value = index.commonInfo.inventories[0].numSlots;
storageSlider.minValue = ((num == 0) ? 1 : num);
UpdateValue(index.commonInfo.inventories[0].numSlots);
}
public void CloseChest()
{
_machineIndex = -1;
_initalOpen = true;
storageSlider.value = -1f;
}
}
}
namespace ContainerResizer.Assets
{
public class TTModAssets
{
public GameObject LabeledSlider;
}
}