using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnhancedWorkbenches.Extensions;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("EnhancedWorkbenches")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+70852490dac63b2c65a2d67a10c99714c65a3836")]
[assembly: AssemblyProduct("Enhanced Workbenches")]
[assembly: AssemblyTitle("EnhancedWorkbenches")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class IsReadOnlyAttribute : Attribute
{
}
[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;
}
}
}
internal sealed class ConfigurationManagerAttributes
{
public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public CustomHotkeyDrawerFunc CustomHotkeyDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
public Func<object, string> ObjToStr;
public Func<string, object> StrToObj;
}
namespace EnhancedWorkbenches
{
public enum EBulkBoxGrade
{
WhiteBox,
YellowBox,
PinkBox,
RedBox
}
public class EnhancedWorkbench : CSingleton<EnhancedWorkbench>
{
private bool m_ApplicationQuiting;
private InteractableWorkbench m_Workbench;
private readonly Dictionary<InteractableWorkbench, EnhancedWorkbenchData> m_WorkbenchDataMap = new Dictionary<InteractableWorkbench, EnhancedWorkbenchData>();
private EnhancedWorkbenchSaveFileManager m_SavefileManager = new EnhancedWorkbenchSaveFileManager();
private void Awake()
{
Settings.Instance.isEnabled.SettingChanged += delegate
{
((Behaviour)this).enabled = Settings.Instance.isEnabled.Value;
};
Settings.Instance.emptyBoxStorageLocation.SettingChanged += delegate
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
foreach (InteractableWorkbench key in m_WorkbenchDataMap.Keys)
{
if (m_WorkbenchDataMap[key].ShelfCompartment != null)
{
((Component)m_WorkbenchDataMap[key].ShelfCompartment).transform.localPosition = Settings.Instance.emptyBoxStorageLocation.Value;
}
}
};
}
private void OnEnable()
{
if (!GameInstance.m_FinishedSavefileLoading)
{
return;
}
int num = 0;
foreach (InteractableWorkbench workbench in CSingleton<ShelfManager>.Instance.m_WorkbenchList)
{
InitializeWorkbenchData(workbench);
if (m_SavefileManager.LoadSoftSave && num < m_SavefileManager.TempWorkbenchSaveData.Count)
{
m_WorkbenchDataMap[workbench].LoadFromSaveData(m_SavefileManager.TempWorkbenchSaveData[num]);
m_SavefileManager.LoadSoftSave = false;
}
else if (num < m_SavefileManager.WorkbenchSaveData.Count)
{
Plugin.Logger.LogError((object)"Loading save");
m_WorkbenchDataMap[workbench].LoadFromSaveData(m_SavefileManager.WorkbenchSaveData[num]);
}
num++;
}
}
private void OnDisable()
{
//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)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Start" && !m_ApplicationQuiting)
{
m_SavefileManager.OnSoftSave(m_WorkbenchDataMap);
}
if (m_ApplicationQuiting)
{
return;
}
foreach (InteractableWorkbench key in m_WorkbenchDataMap.Keys)
{
if (!((Object)(object)m_WorkbenchDataMap[key].ShelfCompartment != (Object)null))
{
continue;
}
foreach (InteractablePackagingBox_Item interactablePackagingBox in m_WorkbenchDataMap[key].ShelfCompartment.GetInteractablePackagingBoxList())
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(interactablePackagingBox);
((InteractableObject)interactablePackagingBox).OnDestroyed();
}
if (m_WorkbenchDataMap[key].PackagingBox != null)
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(m_WorkbenchDataMap[key].PackagingBox);
((InteractableObject)m_WorkbenchDataMap[key].PackagingBox).OnDestroyed();
}
Object.Destroy((Object)(object)m_WorkbenchDataMap[key].ShelfCompartment);
Object.Destroy((Object)(object)((Component)m_WorkbenchDataMap[key].BoxToFillTransform).gameObject);
Object.Destroy((Object)(object)((Component)m_WorkbenchDataMap[key].BoxEjectionTransform).gameObject);
}
m_WorkbenchDataMap.Clear();
}
private void Update()
{
if (m_Workbench != null && UnityInput.Current.GetMouseButtonDown(0))
{
InteractablePackagingBox_Item currentHeldBox = CSingleton<InteractionPlayerController>.Instance.GetCurrentHeldBox();
if (currentHeldBox != null && m_WorkbenchDataMap.TryGetValue(m_Workbench, out var value))
{
AttemptStoreBox(currentHeldBox, value.ShelfCompartment);
}
}
}
public override void OnApplicationQuit()
{
m_ApplicationQuiting = true;
}
public void OnWorkbenchAwake(InteractableWorkbench workbench)
{
if (((Behaviour)this).enabled)
{
InitializeWorkbenchData(workbench);
if (m_WorkbenchDataMap.Count - 1 < m_SavefileManager.WorkbenchSaveData.Count)
{
m_WorkbenchDataMap[workbench].LoadFromSaveData(m_SavefileManager.WorkbenchSaveData[m_WorkbenchDataMap.Count - 1]);
}
}
}
public void OnSave(int savefileIndex)
{
m_SavefileManager.OnSave(savefileIndex, m_WorkbenchDataMap);
}
public void OnLoad(int savefileIndex)
{
m_SavefileManager.OnLoad(savefileIndex);
}
public void OnShelfCompartmentAwake(ShelfCompartment shelfCompartment)
{
//IL_0017: 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_0067: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_0157: 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_0198: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
if (((Behaviour)this).enabled && shelfCompartment.m_PosListGrp == null)
{
shelfCompartment.m_StartLoc = new GameObject().GetComponent<Transform>();
shelfCompartment.m_StartLoc.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_StartLoc.localPosition = new Vector3(0f, -0.1f, -0.25f);
((Object)shelfCompartment.m_StartLoc).name = "StartLoc";
shelfCompartment.m_EndWidthLoc = new GameObject().GetComponent<Transform>();
shelfCompartment.m_EndWidthLoc.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_EndWidthLoc.localPosition = new Vector3(0.75f, -0.1f, -0.25f);
((Object)shelfCompartment.m_EndWidthLoc).name = "EndWidthLoc";
shelfCompartment.m_EndDepthLoc = new GameObject().GetComponent<Transform>();
shelfCompartment.m_EndDepthLoc.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_EndDepthLoc.localPosition = new Vector3(0f, -0.1f, 0.5f);
((Object)shelfCompartment.m_EndDepthLoc).name = "EndDepthLoc";
shelfCompartment.m_EndHeightLoc = new GameObject().GetComponent<Transform>();
shelfCompartment.m_EndHeightLoc.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_EndHeightLoc.localPosition = new Vector3(0f, 1.68f, -0.25f);
((Object)shelfCompartment.m_EndHeightLoc).name = "EndHeightLoc";
shelfCompartment.m_PosListGrp = new GameObject().GetComponent<Transform>();
shelfCompartment.m_PosListGrp.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_PosListGrp.localPosition = Vector3.zero;
((Object)shelfCompartment.m_PosListGrp).name = "PosListGrp";
shelfCompartment.m_StoredItemListGrp = new GameObject().GetComponent<Transform>();
shelfCompartment.m_StoredItemListGrp.SetParent(((Component)shelfCompartment).transform);
shelfCompartment.m_StoredItemListGrp.localPosition = Vector3.zero;
((Object)shelfCompartment.m_StoredItemListGrp).name = "StoredItemListGrp";
for (int i = 0; i < 12; i++)
{
Transform component = new GameObject().GetComponent<Transform>();
component.SetParent(shelfCompartment.m_PosListGrp);
((Component)component).gameObject.SetActive(false);
((Object)component).name = "postListGrpItem";
}
shelfCompartment.m_CanPutItem = false;
shelfCompartment.m_CanPutBox = true;
shelfCompartment.m_ItemNotForSale = true;
shelfCompartment.m_SizeX = 4;
shelfCompartment.m_SizeY = 8;
shelfCompartment.m_SizeZ = 12;
shelfCompartment.m_HeightGoesUp = true;
}
}
public bool OnLeftMouseButtonUp(InteractableWorkbench workbench)
{
if (((Behaviour)this).enabled && m_WorkbenchDataMap.TryGetValue(workbench, out var value) && value.ShelfCompartment.GetItemCount() > 0)
{
InteractablePackagingBox_Item lastInteractablePackagingBox = value.ShelfCompartment.GetLastInteractablePackagingBox();
if (lastInteractablePackagingBox != null && (lastInteractablePackagingBox.IsBeingClosed() || lastInteractablePackagingBox.IsLerping()))
{
return false;
}
if (value.PackagingBox == null)
{
PrepareNextEmptyBox(value);
}
}
return true;
}
public bool OnTaskComplete(WorkbenchUIScreen workbenchUIScreen)
{
//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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
if (((Behaviour)this).enabled)
{
InteractableWorkbench currentWorkbench = workbenchUIScreen.GetCurrentWorkbench();
((Component)currentWorkbench.m_JankBoxAnim).gameObject.SetActive(false);
ItemMeshData itemMeshData = InventoryBase.GetItemMeshData(currentWorkbench.GetCurrentItemType());
Item item = ItemSpawnManager.GetItem(currentWorkbench.m_SpawnItemPos);
item.SetMesh(itemMeshData.mesh, itemMeshData.material, currentWorkbench.GetCurrentItemType(), itemMeshData.meshSecondary, itemMeshData.materialSecondary);
((Component)item).transform.position = currentWorkbench.m_SpawnItemPos.position;
((Component)item).transform.rotation = currentWorkbench.m_SpawnItemPos.rotation;
((Component)item).gameObject.SetActive(true);
((Selectable)workbenchUIScreen.m_SliderPriceLimit).interactable = true;
((Selectable)workbenchUIScreen.m_SliderPriceMinimum).interactable = true;
((Selectable)workbenchUIScreen.m_SliderMinCard).interactable = true;
workbenchUIScreen.m_TaskFinishCirlceGrp.SetActive(false);
if (m_WorkbenchDataMap.TryGetValue(currentWorkbench, out var value) && value.PackagingBox != null && value.PackagingBox.m_ItemCompartment.HasEnoughSlot())
{
EItemType val = value.PackagingBox.m_ItemCompartment.CheckItemType(item.GetItemType());
value.PackagingBox.SetItemType(val);
if (val == item.GetItemType())
{
item.LerpToTransform(value.PackagingBox.m_ItemCompartment.GetLastEmptySlotTransform(), value.PackagingBox.m_ItemCompartment.GetEmptySlotParent(), false);
value.PackagingBox.m_ItemCompartment.AddItem(item, true);
value.PackagingBox.m_ItemCompartment.SetPriceTagVisibility(false);
foreach (InteractableCard3d interactableCard3d in currentWorkbench.m_InteractableCard3dList)
{
interactableCard3d.m_Card3dUI.SetVisibility(false);
}
if (!value.PackagingBox.m_ItemCompartment.HasEnoughSlot())
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(value.PackagingBox);
value.PackagingBox.SetOpenCloseBox(false, true);
((InteractableObject)value.PackagingBox).LerpToTransform(value.BoxEjectionTransform, value.PackagingBox.GetOriginalParent());
((InteractablePackagingBox)value.PackagingBox).SetPhysicsEnabled(true);
value.PackagingBox = null;
if (value.ShelfCompartment.GetInteractablePackagingBoxList().Count != 0)
{
PrepareNextEmptyBox(value);
}
}
Slider boxCountSlider = CSingleton<EnhancedWorkbenchUI>.Instance.GetBoxCountSlider();
float num2 = (boxCountSlider.value -= 1f);
if (num2 >= 1f)
{
CSingleton<EnhancedWorkbenchUI>.Instance.PressBundleCardsButton();
}
return false;
}
}
if (currentWorkbench.HasEnoughSlot())
{
currentWorkbench.AddItem(item, true);
foreach (InteractableCard3d interactableCard3d2 in currentWorkbench.m_InteractableCard3dList)
{
interactableCard3d2.m_Card3dUI.SetVisibility(false);
}
Slider boxCountSlider2 = CSingleton<EnhancedWorkbenchUI>.Instance.GetBoxCountSlider();
float num2 = (boxCountSlider2.value -= 1f);
if (num2 >= 1f)
{
CSingleton<EnhancedWorkbenchUI>.Instance.PressBundleCardsButton();
}
}
else
{
CSingleton<InteractionPlayerController>.Instance.AddHoldItemToFront(item);
workbenchUIScreen.CloseScreen(false);
}
return false;
}
return true;
}
public void OnRaycasted(InteractableWorkbench workbench)
{
if (((Behaviour)this).enabled)
{
m_Workbench = workbench;
}
}
public void OnRaycastEnded()
{
if (((Behaviour)this).enabled)
{
m_Workbench = null;
}
}
public void OnExitWorkbenchMode(InteractableWorkbench m_CurrentWorkbench)
{
if (((Behaviour)this).enabled && m_WorkbenchDataMap.TryGetValue(m_CurrentWorkbench, out var value) && value.PackagingBox != null)
{
((InteractablePackagingBox)value.PackagingBox).m_Collider.enabled = true;
}
}
public void OnStartHoldingBox(InteractablePackagingBox_Item packagingBox)
{
if (!((Behaviour)this).enabled)
{
return;
}
foreach (InteractableWorkbench key in m_WorkbenchDataMap.Keys)
{
if ((Object)(object)m_WorkbenchDataMap[key].PackagingBox == (Object)(object)packagingBox)
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(packagingBox);
m_WorkbenchDataMap[key].PackagingBox = null;
}
}
}
private void AttemptStoreBox(InteractablePackagingBox_Item currentBox, ShelfCompartment shelfCompartment)
{
if (!currentBox.IsLerping() && currentBox.m_IsBigBox && currentBox.m_ItemCompartment.GetItemCount() == 0 && shelfCompartment.HasEnoughSlot())
{
if (((InteractablePackagingBox)currentBox).IsBoxOpened())
{
currentBox.SetOpenCloseBox(false, true);
}
((InteractableObject)currentBox).LerpToTransform(shelfCompartment.GetEmptySlotTransform(), shelfCompartment.GetEmptySlotParent());
shelfCompartment.AddBox(currentBox);
((Component)((InteractableObject)currentBox).m_MoveStateValidArea).gameObject.SetActive(false);
currentBox.SetIsBeingHold(value: false);
CSingleton<InteractionPlayerController>.Instance.OnExitHoldBoxMode();
RestockManager.RemoveItemPackageBox(currentBox);
SoundManager.GenericPop(1f, 1f);
}
}
private void PrepareNextEmptyBox(EnhancedWorkbenchData workbenchData)
{
InteractablePackagingBox_Item lastInteractablePackagingBox = workbenchData.ShelfCompartment.GetLastInteractablePackagingBox();
workbenchData.ShelfCompartment.RemoveBox(lastInteractablePackagingBox);
((InteractableObject)lastInteractablePackagingBox).LerpToTransform(workbenchData.BoxToFillTransform, workbenchData.BoxToFillTransform.parent);
lastInteractablePackagingBox.SetOpenCloseBox(true, true);
workbenchData.PackagingBox = lastInteractablePackagingBox;
}
private void InitializeWorkbenchData(InteractableWorkbench workbench)
{
//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
if (!m_WorkbenchDataMap.TryGetValue(workbench, out var value) || value == null)
{
m_WorkbenchDataMap[workbench] = new EnhancedWorkbenchData
{
ShelfCompartment = new GameObject().AddComponent<ShelfCompartment>(),
BoxEjectionTransform = new GameObject().transform,
BoxToFillTransform = new GameObject().transform,
PackagingBox = null
};
((Object)((Component)m_WorkbenchDataMap[workbench].ShelfCompartment).gameObject).name = ((Object)workbench).name + "-empties";
((Component)m_WorkbenchDataMap[workbench].ShelfCompartment).gameObject.transform.SetParent(((Component)workbench).transform);
((Component)m_WorkbenchDataMap[workbench].ShelfCompartment).transform.localPosition = Settings.Instance.emptyBoxStorageLocation.Value;
((Component)m_WorkbenchDataMap[workbench].ShelfCompartment).transform.localRotation = Quaternion.identity;
m_WorkbenchDataMap[workbench].ShelfCompartment.SetCompartmentBoxType(true);
m_WorkbenchDataMap[workbench].ShelfCompartment.CalculatePositionList();
m_WorkbenchDataMap[workbench].BoxEjectionTransform.SetParent(((Component)workbench).transform);
m_WorkbenchDataMap[workbench].BoxEjectionTransform.localPosition = new Vector3(-0.6f, 0.9f, 0.15f);
((Object)m_WorkbenchDataMap[workbench].BoxEjectionTransform).name = "EjectBoxesTransform";
m_WorkbenchDataMap[workbench].BoxToFillTransform.SetParent(((Component)workbench).transform);
m_WorkbenchDataMap[workbench].BoxToFillTransform.localPosition = new Vector3(-0.35f, 0.91f, -0.25f);
((Object)m_WorkbenchDataMap[workbench].BoxToFillTransform).name = "FillBoxTransform";
}
}
}
public class EnhancedWorkbenchData
{
public ShelfCompartment ShelfCompartment { get; set; }
public Transform BoxEjectionTransform { get; set; }
public Transform BoxToFillTransform { get; set; }
public InteractablePackagingBox_Item PackagingBox { get; set; }
public WorkbenchSaveData ToWorkbenchSaveData()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
WorkbenchSaveData result = default(WorkbenchSaveData);
result.EmptyBoxCount = ((ShelfCompartment != null) ? ShelfCompartment.GetItemCount() : 0);
result.PackagingBox = ((PackagingBox == null) ? null : new PackagingBoxSaveData?(new PackagingBoxSaveData
{
ItemCount = PackagingBox.m_ItemCompartment.GetItemCount(),
ItemType = PackagingBox.m_ItemCompartment.GetItemType()
}));
return result;
}
public void LoadFromSaveData(WorkbenchSaveData workbenchSaveData)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < workbenchSaveData.EmptyBoxCount; i++)
{
InteractablePackagingBox_Item val = RestockManager.SpawnPackageBoxItem((EItemType)(-1), 0, true);
RestockManager.RemoveItemPackageBox(val);
((InteractablePackagingBox)val).SetPhysicsEnabled(false);
Transform emptySlotTransform = ShelfCompartment.GetEmptySlotTransform();
((Component)val).transform.SetParent(emptySlotTransform.parent);
((Component)val).transform.localPosition = emptySlotTransform.localPosition;
((Component)val).transform.localRotation = emptySlotTransform.localRotation;
ShelfCompartment.AddBox(val);
}
if (workbenchSaveData.PackagingBox.HasValue)
{
PackagingBoxSaveData value = workbenchSaveData.PackagingBox.Value;
InteractablePackagingBox_Item val2 = RestockManager.SpawnPackageBoxItem((EItemType)(-1), 0, true);
RestockManager.RemoveItemPackageBox(val2);
((Component)val2).transform.SetParent(BoxToFillTransform.parent);
((Component)val2).transform.localPosition = BoxToFillTransform.localPosition;
((Component)val2).transform.rotation = BoxToFillTransform.rotation;
val2.SetOpenCloseBox(true, false);
((InteractablePackagingBox)val2).SetPhysicsEnabled(false);
((InteractablePackagingBox)val2).m_Collider.enabled = true;
PackagingBox = val2;
EItemType itemType = val2.m_ItemCompartment.CheckItemType(value.ItemType);
val2.SetItemType(itemType);
val2.m_ItemCompartment.SpawnItem(value.ItemCount, false);
val2.m_ItemCompartment.SetPriceTagVisibility(false);
}
}
}
public class EnhancedWorkbenchSaveFileManager
{
public List<WorkbenchSaveData> WorkbenchSaveData { get; private set; } = new List<WorkbenchSaveData>();
public List<WorkbenchSaveData> TempWorkbenchSaveData { get; private set; } = new List<WorkbenchSaveData>();
public bool LoadSoftSave { get; set; }
public void OnLoad(int savefileIndex)
{
WorkbenchSaveData.Clear();
if (File.Exists(string.Format("{0}/{1}_{2}.json", GetBaseDirectory(), "EnhancedWorkbenches", savefileIndex)))
{
string text = File.ReadAllText(string.Format("{0}/{1}_{2}.json", GetBaseDirectory(), "EnhancedWorkbenches", savefileIndex));
WorkbenchSaveData = JsonConvert.DeserializeObject<List<WorkbenchSaveData>>(text);
TempWorkbenchSaveData = WorkbenchSaveData;
}
}
public void OnSave(int savefileIndex, Dictionary<InteractableWorkbench, EnhancedWorkbenchData> dataMap)
{
if (dataMap.Count <= 0)
{
return;
}
WorkbenchSaveData.Clear();
foreach (InteractableWorkbench key in dataMap.Keys)
{
WorkbenchSaveData.Add(dataMap[key].ToWorkbenchSaveData());
}
string contents = JsonConvert.SerializeObject((object)WorkbenchSaveData);
File.WriteAllText(string.Format("{0}/{1}_{2}.json", GetBaseDirectory(), "EnhancedWorkbenches", savefileIndex), contents);
}
public void OnSoftSave(Dictionary<InteractableWorkbench, EnhancedWorkbenchData> dataMap)
{
TempWorkbenchSaveData.Clear();
foreach (InteractableWorkbench key in dataMap.Keys)
{
TempWorkbenchSaveData.Add(dataMap[key].ToWorkbenchSaveData());
}
LoadSoftSave = true;
}
private string GetBaseDirectory()
{
return Path.GetDirectoryName(GetType().Assembly.Location);
}
}
public class EnhancedWorkbenchUI : CSingleton<EnhancedWorkbenchUI>
{
private ControllerButton m_WhiteBoxButton;
private ControllerButton m_YellowBoxButton;
private ControllerButton m_PinkBoxButton;
private ControllerButton m_RedBoxButton;
private ControllerButton m_BundleCardsButton;
private Transform m_BoxCountSliderGrp;
private bool m_Initialized;
private void Awake()
{
Settings.Instance.isEnabled.SettingChanged += delegate
{
((Behaviour)this).enabled = Settings.Instance.isEnabled.Value;
};
Settings.Instance.whiteButtonPosition.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_WhiteBoxButton != null)
{
((Component)m_WhiteBoxButton).transform.localPosition = Settings.Instance.whiteButtonPosition.Value;
}
};
Settings.Instance.whiteButtonScale.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_WhiteBoxButton != null)
{
((Component)m_WhiteBoxButton).transform.localScale = Settings.Instance.whiteButtonScale.Value;
}
};
Settings.Instance.pinkButtonPosition.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_PinkBoxButton != null)
{
((Component)m_PinkBoxButton).transform.localPosition = Settings.Instance.pinkButtonPosition.Value;
}
};
Settings.Instance.pinkButtonScale.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_PinkBoxButton != null)
{
((Component)m_PinkBoxButton).transform.localScale = Settings.Instance.pinkButtonScale.Value;
}
};
Settings.Instance.yellowButtonPosition.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_YellowBoxButton != null)
{
((Component)m_YellowBoxButton).transform.localPosition = Settings.Instance.yellowButtonPosition.Value;
}
};
Settings.Instance.yellowButtonScale.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_YellowBoxButton != null)
{
((Component)m_YellowBoxButton).transform.localScale = Settings.Instance.yellowButtonScale.Value;
}
};
Settings.Instance.redButtonPosition.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_RedBoxButton != null)
{
((Component)m_RedBoxButton).transform.localPosition = Settings.Instance.redButtonPosition.Value;
}
};
Settings.Instance.redButtonScale.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_RedBoxButton != null)
{
((Component)m_RedBoxButton).transform.localScale = Settings.Instance.redButtonScale.Value;
}
};
Settings.Instance.boxNumberSliderPosition.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_BoxCountSliderGrp != null)
{
((Component)m_BoxCountSliderGrp).transform.localPosition = Settings.Instance.boxNumberSliderPosition.Value;
}
};
Settings.Instance.boxNumberSliderScale.SettingChanged += delegate
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (m_BoxCountSliderGrp != null)
{
((Component)m_BoxCountSliderGrp).transform.localScale = Settings.Instance.boxNumberSliderScale.Value;
}
};
}
private void OnButtonPress(WorkbenchUIScreen workbenchUIScreen, EBulkBoxGrade boxGrade)
{
switch (boxGrade)
{
case EBulkBoxGrade.WhiteBox:
workbenchUIScreen.m_SliderPriceMinimum.value = 1f;
workbenchUIScreen.m_SliderPriceLimit.value = 100f;
break;
case EBulkBoxGrade.YellowBox:
workbenchUIScreen.m_SliderPriceMinimum.value = 100f;
workbenchUIScreen.m_SliderPriceLimit.value = 200f;
break;
case EBulkBoxGrade.PinkBox:
workbenchUIScreen.m_SliderPriceMinimum.value = 200f;
workbenchUIScreen.m_SliderPriceLimit.value = 300f;
break;
case EBulkBoxGrade.RedBox:
workbenchUIScreen.m_SliderPriceMinimum.value = 300f;
workbenchUIScreen.m_SliderPriceLimit.value = 500f;
break;
}
workbenchUIScreen.SetPriceMinimum(Mathf.RoundToInt(workbenchUIScreen.m_SliderPriceMinimum.value / 100f));
workbenchUIScreen.SetPriceLimit(Mathf.RoundToInt(workbenchUIScreen.m_SliderPriceLimit.value / 100f));
((TMP_Text)workbenchUIScreen.m_PriceLimitText).text = GameInstance.GetPriceString(workbenchUIScreen.GetPriceLimit(), false, true, false, "F2");
((TMP_Text)workbenchUIScreen.m_PriceMinimumText).text = GameInstance.GetPriceString(workbenchUIScreen.GetPriceMinimum(), false, true, false, "F2");
CPlayerData.m_WorkbenchPriceLimit = workbenchUIScreen.GetPriceLimit();
CPlayerData.m_WorkbenchPriceMinimum = workbenchUIScreen.GetPriceMinimum();
}
private void OnEnable()
{
Initialize();
}
private void OnDisable()
{
if (m_Initialized)
{
((UnityEventBase)m_RedBoxButton.m_Button.onClick).RemoveAllListeners();
((UnityEventBase)m_PinkBoxButton.m_Button.onClick).RemoveAllListeners();
((UnityEventBase)m_YellowBoxButton.m_Button.onClick).RemoveAllListeners();
((UnityEventBase)m_WhiteBoxButton.m_Button.onClick).RemoveAllListeners();
Object.Destroy((Object)(object)m_RedBoxButton);
Object.Destroy((Object)(object)m_PinkBoxButton);
Object.Destroy((Object)(object)m_YellowBoxButton);
Object.Destroy((Object)(object)m_WhiteBoxButton);
Object.Destroy((Object)(object)m_BundleCardsButton);
m_RedBoxButton = null;
m_PinkBoxButton = null;
m_YellowBoxButton = null;
m_WhiteBoxButton = null;
m_BundleCardsButton = null;
m_BoxCountSliderGrp = null;
}
}
public void OnOpenScreen(WorkbenchUIScreen workbenchUIScreen)
{
if (((Behaviour)this).enabled && !m_Initialized)
{
Initialize(workbenchUIScreen);
}
}
public Slider GetBoxCountSlider()
{
return ((Component)m_BoxCountSliderGrp).GetComponentInChildren<Slider>();
}
public void PressBundleCardsButton()
{
m_BundleCardsButton.OnPressConfirm();
}
private void OnBoxCountSliderValueChange()
{
Slider componentInChildren = ((Component)m_BoxCountSliderGrp).GetComponentInChildren<Slider>();
((TMP_Text)((Component)m_BoxCountSliderGrp.Find("CurrentText")).GetComponent<TextMeshProUGUI>()).SetText(componentInChildren.value.ToString(), true);
}
private void Initialize(WorkbenchUIScreen workbenchUIScreen = null)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: 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_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Expected O, but got Unknown
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Expected O, but got Unknown
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Expected O, but got Unknown
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_0483: Expected O, but got Unknown
if (workbenchUIScreen == null)
{
workbenchUIScreen = Object.FindFirstObjectByType<WorkbenchUIScreen>();
}
Transform val = workbenchUIScreen.m_ScreenGrp.transform.Find("AnimGrp");
ControllerButton component = ((Component)((Component)val).transform.Find("StartBundleCardBtn")).GetComponent<ControllerButton>();
Transform val2 = ((Component)val).transform.Find("CriteriaSliderGrpB");
m_BundleCardsButton = component;
m_BoxCountSliderGrp = Object.Instantiate<Transform>(val2, ((Component)val).transform);
((Component)m_BoxCountSliderGrp).transform.localPosition = Settings.Instance.boxNumberSliderPosition.Value;
((Component)m_BoxCountSliderGrp).transform.localScale = Settings.Instance.boxNumberSliderScale.Value;
Slider componentInChildren = ((Component)m_BoxCountSliderGrp).GetComponentInChildren<Slider>();
componentInChildren.maxValue = 96f;
componentInChildren.minValue = 0f;
componentInChildren.value = 1f;
componentInChildren.wholeNumbers = true;
((UnityEventBase)componentInChildren.onValueChanged).SetPersistentListenerState(0, (UnityEventCallState)0);
((UnityEvent<float>)(object)componentInChildren.onValueChanged).AddListener((UnityAction<float>)delegate
{
OnBoxCountSliderValueChange();
});
((TMP_Text)((Component)m_BoxCountSliderGrp.Find("MinText")).GetComponent<TextMeshProUGUI>()).SetText(componentInChildren.minValue.ToString(), true);
((TMP_Text)((Component)m_BoxCountSliderGrp.Find("MaxText")).GetComponent<TextMeshProUGUI>()).SetText(componentInChildren.maxValue.ToString(), true);
((TMP_Text)((Component)m_BoxCountSliderGrp.Find("TitleText")).GetComponent<TextMeshProUGUI>()).SetText("Number of boxes to make", true);
((TMP_Text)((Component)m_BoxCountSliderGrp.Find("CurrentText")).GetComponent<TextMeshProUGUI>()).SetText(componentInChildren.value.ToString(), true);
((Component)m_BoxCountSliderGrp).gameObject.SetActive(true);
m_WhiteBoxButton = Object.Instantiate<ControllerButton>(component, ((Component)val).transform);
((Component)m_WhiteBoxButton).transform.localPosition = Settings.Instance.whiteButtonPosition.Value;
((Component)m_WhiteBoxButton).transform.localScale = Settings.Instance.whiteButtonScale.Value;
((TMP_Text)((Component)m_WhiteBoxButton).gameObject.GetComponentInChildren<TextMeshProUGUI>(true)).SetText("White Box", true);
((Component)m_WhiteBoxButton).gameObject.SetActive(true);
m_YellowBoxButton = Object.Instantiate<ControllerButton>(component, ((Component)val).transform);
((Component)m_YellowBoxButton).transform.localPosition = Settings.Instance.yellowButtonPosition.Value;
((Component)m_YellowBoxButton).transform.localScale = Settings.Instance.yellowButtonScale.Value;
((TMP_Text)((Component)m_YellowBoxButton).gameObject.GetComponentInChildren<TextMeshProUGUI>(true)).SetText("Yellow Box", true);
((Component)m_YellowBoxButton).gameObject.SetActive(true);
m_PinkBoxButton = Object.Instantiate<ControllerButton>(component, ((Component)val).transform);
((Component)m_PinkBoxButton).transform.localPosition = Settings.Instance.pinkButtonPosition.Value;
((Component)m_PinkBoxButton).transform.localScale = Settings.Instance.pinkButtonScale.Value;
((TMP_Text)((Component)m_PinkBoxButton).gameObject.GetComponentInChildren<TextMeshProUGUI>(true)).SetText("Pink Box", true);
m_RedBoxButton = Object.Instantiate<ControllerButton>(component, ((Component)val).transform);
((Component)m_RedBoxButton).transform.localPosition = Settings.Instance.redButtonPosition.Value;
((Component)m_RedBoxButton).transform.localScale = Settings.Instance.redButtonScale.Value;
((TMP_Text)((Component)m_RedBoxButton).gameObject.GetComponentInChildren<TextMeshProUGUI>(true)).SetText("Red Box", true);
((UnityEventBase)m_RedBoxButton.m_Button.onClick).SetPersistentListenerState(0, (UnityEventCallState)0);
((UnityEvent)m_RedBoxButton.m_Button.onClick).AddListener((UnityAction)delegate
{
OnButtonPress(workbenchUIScreen, EBulkBoxGrade.RedBox);
});
((UnityEventBase)m_PinkBoxButton.m_Button.onClick).SetPersistentListenerState(0, (UnityEventCallState)0);
((UnityEvent)m_PinkBoxButton.m_Button.onClick).AddListener((UnityAction)delegate
{
OnButtonPress(workbenchUIScreen, EBulkBoxGrade.PinkBox);
});
((UnityEventBase)m_YellowBoxButton.m_Button.onClick).SetPersistentListenerState(0, (UnityEventCallState)0);
((UnityEvent)m_YellowBoxButton.m_Button.onClick).AddListener((UnityAction)delegate
{
OnButtonPress(workbenchUIScreen, EBulkBoxGrade.YellowBox);
});
((UnityEventBase)m_WhiteBoxButton.m_Button.onClick).SetPersistentListenerState(0, (UnityEventCallState)0);
((UnityEvent)m_WhiteBoxButton.m_Button.onClick).AddListener((UnityAction)delegate
{
OnButtonPress(workbenchUIScreen, EBulkBoxGrade.WhiteBox);
});
m_Initialized = true;
}
}
public struct PackagingBoxSaveData
{
public EItemType ItemType { get; set; }
public int ItemCount { get; set; }
}
[BepInPlugin("EnhancedWorkbenches", "Enhanced Workbenches", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony m_Harmony = new Harmony("EnhancedWorkbenches");
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Settings.Instance.Load(this);
m_Harmony.PatchAll();
SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode _)
{
((Behaviour)CSingleton<EnhancedWorkbench>.Instance).enabled = ((Scene)(ref scene)).name == "Start";
};
Logger.LogInfo((object)"Plugin Enhanced Workbenches v:1.2.1 by GhostNarwhal is loaded!");
}
private void OnDestroy()
{
m_Harmony.UnpatchSelf();
Logger.LogInfo((object)"Plugin Enhanced Workbenches is unloaded!");
}
}
public class Settings
{
public ConfigEntry<bool> isEnabled;
public ConfigEntry<Vector3> emptyBoxStorageLocation;
public ConfigEntry<Vector3> whiteButtonPosition;
public ConfigEntry<Vector3> whiteButtonScale;
public ConfigEntry<Vector3> yellowButtonPosition;
public ConfigEntry<Vector3> yellowButtonScale;
public ConfigEntry<Vector3> pinkButtonPosition;
public ConfigEntry<Vector3> pinkButtonScale;
public ConfigEntry<Vector3> redButtonPosition;
public ConfigEntry<Vector3> redButtonScale;
public ConfigEntry<Vector3> boxNumberSliderPosition;
public ConfigEntry<Vector3> boxNumberSliderScale;
private static Settings m_instance;
public static Settings Instance
{
get
{
if (m_instance == null)
{
m_instance = new Settings();
}
return m_instance;
}
}
public void Load(Plugin plugin)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0062: 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_0092: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_010c: 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_013c: Expected O, but got Unknown
//IL_0161: 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: Expected O, but got Unknown
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Expected O, but got Unknown
//IL_020b: 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_023b: Expected O, but got Unknown
//IL_0260: 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)
//IL_0290: Expected O, but got Unknown
//IL_02b5: 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_02e5: Expected O, but got Unknown
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Expected O, but got Unknown
//IL_035f: 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: Expected O, but got Unknown
//IL_03b4: 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_03e4: Expected O, but got Unknown
isEnabled = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Enhanced Workbench", "Enabled", true, new ConfigDescription("Enables oor disables Enhanced Workbenches", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 25
}
}));
emptyBoxStorageLocation = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("Enhanced Workbench", "Empties Storage Location", new Vector3(1.25f, 0.13f, -0.5f), new ConfigDescription("Where to store the empties.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 24
}
}));
whiteButtonPosition = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "White Box Button Position", new Vector3(250f, 30f, 0f), new ConfigDescription("Where to place the button", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 23
}
}));
whiteButtonScale = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "White Box Button Scale", new Vector3(0.25f, 0.25f, 0.25f), new ConfigDescription("How big should button be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 22
}
}));
yellowButtonPosition = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Yellow Box Button Position", new Vector3(400f, 30f, 0f), new ConfigDescription("Where to place the button", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 21
}
}));
yellowButtonScale = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Yellow Box Button Scale", new Vector3(0.25f, 0.25f, 0.25f), new ConfigDescription("How big should button be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 20
}
}));
pinkButtonPosition = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Pink Box Button Position", new Vector3(550f, 30f, 0f), new ConfigDescription("Where to place the button", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 19
}
}));
pinkButtonScale = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Pink Box Button Scale", new Vector3(0.25f, 0.25f, 0.25f), new ConfigDescription("How big should button be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 18
}
}));
redButtonPosition = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Red Box Button Position", new Vector3(700f, 30f, 0f), new ConfigDescription("Where to place the button", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 17
}
}));
redButtonScale = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Red Box Button Scale", new Vector3(0.25f, 0.25f, 0.25f), new ConfigDescription("How big should button be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 16
}
}));
boxNumberSliderPosition = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Number of boxes to make slider position", new Vector3(500f, -65f, 0f), new ConfigDescription("Where should the slider be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 15
}
}));
boxNumberSliderScale = ((BaseUnityPlugin)plugin).Config.Bind<Vector3>("UI", "Number of boxes to make slider scale", new Vector3(0.75f, 0.75f, 0.75f), new ConfigDescription("How big should the slider be", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 15
}
}));
}
private Settings()
{
}
}
public struct WorkbenchSaveData
{
public int EmptyBoxCount { get; set; }
public PackagingBoxSaveData? PackagingBox { get; set; }
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EnhancedWorkbenches";
public const string PLUGIN_NAME = "Enhanced Workbenches";
public const string PLUGIN_VERSION = "1.2.1";
}
}
namespace EnhancedWorkbenches.Patches
{
[HarmonyPatch(typeof(CGameManager))]
public class CGameManagerPatch
{
[HarmonyPatch("LoadData")]
[HarmonyPrefix]
private static void LoadDataPrefix(int ___m_CurrentSaveLoadSlotSelectedIndex)
{
CSingleton<EnhancedWorkbench>.Instance.OnLoad(___m_CurrentSaveLoadSlotSelectedIndex);
}
[HarmonyPatch("SaveGameData")]
[HarmonyPrefix]
private static void SaveGameDataPrefix(int saveSlotIndex)
{
CSingleton<EnhancedWorkbench>.Instance.OnSave(saveSlotIndex);
}
}
[HarmonyPatch]
public class FastWorkbenchCompatibilityPatch
{
private static PluginInfo m_PluginInfo;
private static bool Prepare()
{
return Chainloader.PluginInfos.TryGetValue("FastWorkbench", out m_PluginInfo);
}
private static MethodBase TargetMethod()
{
return (from method in AccessTools.GetTypesFromAssembly(((object)m_PluginInfo.Instance).GetType().Assembly).SelectMany((Type type) => type.GetMethods())
where method.Name == "InteractableWorkbench_OnMouseButtonUp_Prefix"
select method).Cast<MethodBase>().FirstOrDefault();
}
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instruction)
{
yield return new CodeInstruction(OpCodes.Ldc_I4, (object)1);
yield return new CodeInstruction(OpCodes.Ret, (object)null);
}
}
[HarmonyPatch(typeof(InteractableObject))]
public class InteractableObjectPatch
{
[HarmonyPatch("OnRaycasted")]
[HarmonyPostfix]
private static void OnRaycastedPostfix(InteractableWorkbench __instance)
{
CSingleton<EnhancedWorkbench>.Instance.OnRaycasted(__instance);
}
[HarmonyPatch("OnRaycastEnded")]
[HarmonyPostfix]
private static void OnRaycastEndedPostfix(InteractableWorkbench __instance)
{
CSingleton<EnhancedWorkbench>.Instance.OnRaycastEnded();
}
}
[HarmonyPatch(typeof(InteractablePackagingBox_Item))]
public class InteractablePackagingBox_ItemPatch
{
[HarmonyPatch("StartHoldBox")]
[HarmonyPostfix]
private static void OnStartHoldBoxPostfix(bool isPlayer, Transform holdItemPos, InteractablePackagingBox_Item __instance)
{
CSingleton<EnhancedWorkbench>.Instance.OnStartHoldingBox(__instance);
}
}
[HarmonyPatch(typeof(InteractableWorkbench))]
public class InteractableWorkbenchPatch
{
[HarmonyPatch("OnMouseButtonUp")]
[HarmonyPrefix]
private static bool OnMouseButtonUpPrefix(InteractableWorkbench __instance)
{
return CSingleton<EnhancedWorkbench>.Instance.OnLeftMouseButtonUp(__instance);
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void OnAwakePostfix(InteractableWorkbench __instance)
{
CSingleton<EnhancedWorkbench>.Instance.OnWorkbenchAwake(__instance);
}
}
[HarmonyPatch(typeof(InteractionPlayerController))]
public class InteractionPlayerControllerPatch
{
[HarmonyPatch("OnExitWorkbenchMode")]
[HarmonyPostfix]
private static void OnExitWorkbenchModePostfix(InteractableWorkbench ___m_CurrentWorkbench)
{
CSingleton<EnhancedWorkbench>.Instance.OnExitWorkbenchMode(___m_CurrentWorkbench);
}
}
[HarmonyPatch(typeof(ShelfCompartment))]
public class ShelfCompartmentPatch
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void OnAwakePrefix(ShelfCompartment __instance)
{
CSingleton<EnhancedWorkbench>.Instance.OnShelfCompartmentAwake(__instance);
}
}
[HarmonyPatch(typeof(WorkbenchUIScreen))]
public class WorkbenchUIScreenPatch
{
[HarmonyPatch("OpenScreen")]
[HarmonyPostfix]
private static void OpenScreenPostfix(WorkbenchUIScreen __instance)
{
CSingleton<EnhancedWorkbenchUI>.Instance.OnOpenScreen(__instance);
}
[HarmonyPatch("OnTaskCompleted")]
[HarmonyPrefix]
private static bool OnTaskCompletedPrefix(WorkbenchUIScreen __instance)
{
return CSingleton<EnhancedWorkbench>.Instance.OnTaskComplete(__instance);
}
}
}
namespace EnhancedWorkbenches.Extensions
{
public static class InteractablePackagingBox_ItemExt
{
public static bool IsLerping(this InteractablePackagingBox_Item interactablePackagingBox_Item)
{
return (bool)AccessTools.Field(typeof(InteractablePackagingBox_Item), "m_IsLerpingToPos").GetValue(interactablePackagingBox_Item);
}
public static void SetIsBeingHold(this InteractablePackagingBox_Item interactablePackagingBox_Item, bool value)
{
AccessTools.Field(typeof(InteractablePackagingBox_Item), "m_IsBeingHold").SetValue(interactablePackagingBox_Item, value);
}
public static Transform GetOriginalParent(this InteractablePackagingBox_Item interactablePackagingBox_Item)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
return (Transform)AccessTools.Field(typeof(InteractablePackagingBox_Item), "m_OriginalParent").GetValue(interactablePackagingBox_Item);
}
public static bool IsBeingClosed(this InteractablePackagingBox_Item interactablePackagingBox_Item)
{
return (bool)AccessTools.Field(typeof(InteractablePackagingBox_Item), "m_IsTogglingOpenClose").GetValue(interactablePackagingBox_Item);
}
}
public static class InteractableWorkbenchExt
{
public static EItemType GetCurrentItemType(this InteractableWorkbench interactableWorkbench)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
return (EItemType)AccessTools.Field(typeof(InteractableWorkbench), "m_CurrentItemTypeSpawn").GetValue(interactableWorkbench);
}
}
public static class InteractionPlayerControllerExt
{
public static InteractablePackagingBox_Item GetCurrentHeldBox(this InteractionPlayerController playerController)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
return (InteractablePackagingBox_Item)AccessTools.Field(typeof(InteractionPlayerController), "m_CurrentHoldingItemBox").GetValue(playerController);
}
}
public static class ShelfManagerExt
{
public static List<InteractablePackagingBox_Item> GetSpawnedPackageBoxItemList(this ShelfManager shelfManager)
{
return (List<InteractablePackagingBox_Item>)AccessTools.Field(typeof(ShelfManager), "m_SpawnedPackageBoxItemList").GetValue(shelfManager);
}
}
public static class test
{
public static Transform getTest(this InteractablePackagingBox_Item box)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
return (Transform)AccessTools.Field(typeof(InteractablePackagingBox_Item), "m_Shelf_WorldUIGrp").GetValue(box);
}
}
public static class WorkbenchUIScreenExt
{
public static InteractableWorkbench GetCurrentWorkbench(this WorkbenchUIScreen workbenchUIScreen)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
return (InteractableWorkbench)AccessTools.Field(typeof(WorkbenchUIScreen), "m_CurrentInteractableWorkbench").GetValue(workbenchUIScreen);
}
public static void SetPriceMinimum(this WorkbenchUIScreen workbenchUIScreen, float priceMinimum)
{
AccessTools.Field(typeof(WorkbenchUIScreen), "m_PriceMinimum").SetValue(workbenchUIScreen, priceMinimum);
}
public static void SetPriceLimit(this WorkbenchUIScreen workbenchUIScreen, float priceMax)
{
AccessTools.Field(typeof(WorkbenchUIScreen), "m_PriceLimit").SetValue(workbenchUIScreen, priceMax);
}
public static float GetPriceMinimum(this WorkbenchUIScreen workbenchUIScreen)
{
return (float)AccessTools.Field(typeof(WorkbenchUIScreen), "m_PriceMinimum").GetValue(workbenchUIScreen);
}
public static float GetPriceLimit(this WorkbenchUIScreen workbenchUIScreen)
{
return (float)AccessTools.Field(typeof(WorkbenchUIScreen), "m_PriceLimit").GetValue(workbenchUIScreen);
}
}
}