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 System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnhancedPrefabLoader.API;
using EnhancedWorkbenches.Configuration;
using EnhancedWorkbenches.Core;
using EnhancedWorkbenches.Extensions;
using EnhancedWorkbenches.Persistence;
using EnhancedWorkbenches.UI;
using HarmonyLib;
using I2.Loc;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("EnhancedWorkbenches")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("3.0.7.0")]
[assembly: AssemblyInformationalVersion("3.0.7+af866fa9007cf69b54e39fd5af88d40242ba59fd")]
[assembly: AssemblyProduct("Enhanced Workbenches")]
[assembly: AssemblyTitle("EnhancedWorkbenches")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public 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
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("EnhancedWorkbenches", "Enhanced Workbenches", "3.0.7")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony m_Harmony = new Harmony("EnhancedWorkbenches");
public static WorkbenchManager WorkbenchManager { get; private set; } = new WorkbenchManager();
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
ModConfigManager.Instance.Initialize(((BaseUnityPlugin)this).Config);
SceneManager.sceneLoaded += OnSceneLoad;
WorkbenchManager.RegisterConfigs();
m_Harmony.PatchAll();
Logger.LogInfo((object)"Plugin Enhanced Workbenches v:3.0.7 by GhostNarwhal is loaded!");
}
private void OnSceneLoad(Scene scene, LoadSceneMode _)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
WorkbenchManager.OnSceneChange(scene);
}
private void OnDestroy()
{
m_Harmony.UnpatchSelf();
Logger.LogInfo((object)"Plugin Enhanced Workbenches is unloaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EnhancedWorkbenches";
public const string PLUGIN_NAME = "Enhanced Workbenches";
public const string PLUGIN_VERSION = "3.0.7";
}
}
namespace EnhancedWorkbenches.UI
{
internal static class AttachTooltip
{
private static EnhancedWorkbench owner;
private static bool suppressedOpenBoxHint;
public static void Show(EnhancedWorkbench workbench, string text)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)owner == (Object)(object)workbench)
{
return;
}
HideCurrent();
InputTooltipListDisplay inputTooltipListDisplay = CSingleton<InteractionPlayerController>.Instance.m_InputTooltipListDisplay;
foreach (InputTooltipUI item in inputTooltipListDisplay.m_InputTooltipUIPool)
{
if (item.m_IsActive)
{
continue;
}
if (CSingleton<InputManager>.Instance.m_IsControllerActive)
{
List<EGamepadControlBtn> actionBindedGamepadBtnList = InputManager.GetActionBindedGamepadBtnList((EGameAction)9);
if (actionBindedGamepadBtnList.Count == 0)
{
break;
}
item.SetGamepadInputTooltip((EGameAction)0, actionBindedGamepadBtnList[0], text, false);
}
else
{
item.SetInputTooltip((EGameAction)0, (KeyCode)323, text, false);
}
item.m_Transform.SetParent(inputTooltipListDisplay.m_ActiveLayoutParent, true);
item.SetActive(true);
inputTooltipListDisplay.m_ActiveInputTooltipUIList.Add(item);
inputTooltipListDisplay.m_ActiveActionList.Add((EGameAction)0);
inputTooltipListDisplay.m_ActiveIsHoldList.Add(item: false);
inputTooltipListDisplay.m_ActiveSingleKeyOnlyList.Add(item: true);
InteractionPlayerController.RemoveToolTip((EGameAction)9);
suppressedOpenBoxHint = true;
owner = workbench;
break;
}
}
public static void Hide(EnhancedWorkbench workbench)
{
if ((Object)(object)owner == (Object)(object)workbench)
{
HideCurrent();
}
}
private static void HideCurrent()
{
InteractionPlayerController instance = CSingleton<InteractionPlayerController>.Instance;
if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_InputTooltipListDisplay != (Object)null)
{
instance.m_InputTooltipListDisplay.RemoveTooltip((EGameAction)0);
if (suppressedOpenBoxHint)
{
InteractablePackagingBox_Shelf currentHoldingBoxShelf = instance.m_CurrentHoldingBoxShelf;
if ((Object)(object)currentHoldingBoxShelf != (Object)null && !((InteractablePackagingBox)currentHoldingBoxShelf).IsBoxOpened())
{
InteractionPlayerController.RemoveToolTip((EGameAction)9);
InteractionPlayerController.AddToolTip((EGameAction)9, false, false);
}
}
}
suppressedOpenBoxHint = false;
owner = null;
}
}
public class DistanceLineRenderer
{
private readonly LineRenderer lineRenderer;
private readonly Material material;
private readonly Gradient validGradient;
private readonly Gradient invalidGradient;
private InteractableObject startObject;
private InteractableObject endObject;
private readonly float tilesPerMeter = 4f;
private float scrollOffset;
private float lastTilingCount = -1f;
private bool? lastIsValidDistance;
private const float scrollSpeed = 0.5f;
public float MaxDistance { get; set; }
public DistanceLineRenderer(Texture2D stencilTexture, float tilesPerMeter)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
this.tilesPerMeter = tilesPerMeter;
lineRenderer = new GameObject("DistanceLineRenderer", new Type[1] { typeof(LineRenderer) }).GetComponent<LineRenderer>();
lineRenderer.startWidth = 0.3f;
lineRenderer.endWidth = 0.3f;
lineRenderer.positionCount = 2;
lineRenderer.useWorldSpace = true;
lineRenderer.alignment = (LineAlignment)1;
((Component)lineRenderer).transform.eulerAngles = new Vector3(90f, 0f, 0f);
lineRenderer.textureMode = (LineTextureMode)3;
material = new Material(Shader.Find("Legacy Shaders/Particles/Additive"));
((Texture)stencilTexture).wrapMode = (TextureWrapMode)0;
material.mainTexture = (Texture)(object)stencilTexture;
((Renderer)lineRenderer).material = material;
validGradient = CreateSolidGradient(new Color(0f, 2f, 0f, 1f));
invalidGradient = CreateSolidGradient(new Color(2f, 0f, 0f, 1f));
Stop();
}
public void Start(InteractableObject startPoint, InteractableObject endPoint)
{
startObject = startPoint;
endObject = endPoint;
scrollOffset = 0f;
lastTilingCount = -1f;
lastIsValidDistance = null;
((Component)lineRenderer).gameObject.SetActive(true);
}
public void Stop()
{
((Component)lineRenderer).gameObject.SetActive(false);
}
public void Update()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!((Component)lineRenderer).gameObject.activeSelf)
{
return;
}
if ((Object)(object)startObject == (Object)null || (Object)(object)endObject == (Object)null)
{
Stop();
return;
}
Vector3 centerBounds = startObject.GetCenterBounds(snappedToGround: true);
Vector3 centerBounds2 = endObject.GetCenterBounds(snappedToGround: true);
lineRenderer.SetPosition(0, centerBounds);
lineRenderer.SetPosition(1, centerBounds2);
float num = Vector2.Distance(new Vector2(centerBounds.x, centerBounds.z), new Vector2(centerBounds2.x, centerBounds2.z));
float num2 = Mathf.Max(1f, Mathf.Round(num * tilesPerMeter));
if (num2 != lastTilingCount)
{
material.mainTextureScale = new Vector2(num2, 1f);
lastTilingCount = num2;
}
scrollOffset = Mathf.Repeat(scrollOffset - Time.deltaTime * 0.5f, 1f);
material.mainTextureOffset = new Vector2(scrollOffset, 0f);
bool flag = num <= MaxDistance;
if (lastIsValidDistance != flag)
{
lineRenderer.colorGradient = (flag ? validGradient : invalidGradient);
lastIsValidDistance = flag;
}
}
public void Dispose()
{
if ((Object)(object)lineRenderer != (Object)null)
{
Object.Destroy((Object)(object)((Component)lineRenderer).gameObject);
}
if ((Object)(object)material != (Object)null)
{
Object.Destroy((Object)(object)material);
}
}
private static Gradient CreateSolidGradient(Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
Gradient val = new Gradient();
val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(color, 0f),
new GradientColorKey(color, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(1f, 1f)
});
return val;
}
}
public class EnhancedWorkbenchUI : MonoBehaviour
{
private const int MaxBoxCount = 200;
private const float EplFallbackPriceSpread = 2000f;
private const int CardsPerBulkBox = 100;
private readonly List<Action> configUnsubscribers = new List<Action>();
private WorkbenchUIScreen workbenchUIScreen;
private FlowLayoutGroup buttonLayout;
private Slider maxBoxCreateSlider;
private Transform boxCountSliderGrp;
private TextMeshProUGUI boxCountSliderCurrentText;
private TextMeshProUGUI boxCountSliderMaxText;
private ControllerButton startBundleBtn;
private ControllerButton backButton;
private ControllerButton expansionSelectEditBtn;
private ControllerButton raritySelectEditBtn;
private ControllerButton numberOfBoxesSlider;
private ControllerButton minimumPriceSlider;
private ControllerButton maxPriceSlider;
private ControllerButton minCardsSlider;
private ControllerButton minimumPriceInput;
private ControllerButton maxPriceInput;
private ControllerButton rulebookBtn;
private ControllerButton editDeckBtn;
private static readonly List<(EItemType, string)> DefaultTetramonButtons = new List<(EItemType, string)>(5)
{
((EItemType)37, "White Box"),
((EItemType)89, "Yellow Box"),
((EItemType)90, "Pink Box"),
((EItemType)91, "Red Box"),
((EItemType)127, "Green Box")
};
public EnhancedWorkbench CurrentWorkbench { get; set; }
private void Awake()
{
workbenchUIScreen = ((Component)this).GetComponent<WorkbenchUIScreen>();
RegisterConfigs();
Initialize();
}
private void OnDestroy()
{
foreach (Action configUnsubscriber in configUnsubscribers)
{
configUnsubscriber();
}
configUnsubscribers.Clear();
}
private void Initialize()
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
Transform val = workbenchUIScreen.m_ScreenGrp.transform.Find("AnimGrp");
startBundleBtn = ((Component)val.Find("StartBundleCardBtn")).GetComponent<ControllerButton>();
boxCountSliderGrp = Object.Instantiate<GameObject>(((Component)((TMP_Text)workbenchUIScreen.m_MinimumCardText).transform.parent).gameObject).transform;
((Object)((Component)boxCountSliderGrp).gameObject).name = "boxCountSlider";
boxCountSliderGrp.SetParent(val);
((Component)boxCountSliderGrp).transform.localPosition = ModConfigManager.Instance.GetValue<Vector3>("UI", "Box Count Slider Position");
((Component)boxCountSliderGrp).transform.localScale = ModConfigManager.Instance.GetValue<Vector3>("UI", "Box Count Slider Scale");
((TMP_Text)((Component)((Component)boxCountSliderGrp).transform.Find("MinText")).GetComponent<TextMeshProUGUI>()).text = "1";
((TMP_Text)((Component)((Component)boxCountSliderGrp).transform.Find("TitleText")).GetComponent<TextMeshProUGUI>()).text = "Number of Boxes";
maxBoxCreateSlider = ((Component)boxCountSliderGrp.Find("Slider")).GetComponent<Slider>();
maxBoxCreateSlider.minValue = 1f;
maxBoxCreateSlider.value = 1f;
maxBoxCreateSlider.maxValue = 200f;
maxBoxCreateSlider.onValueChanged = new SliderEvent();
((UnityEvent<float>)(object)maxBoxCreateSlider.onValueChanged).AddListener((UnityAction<float>)OnSliderValueChanged);
maxBoxCreateSlider.wholeNumbers = true;
boxCountSliderCurrentText = ((Component)((Component)boxCountSliderGrp).transform.Find("CurrentText")).GetComponent<TextMeshProUGUI>();
((TMP_Text)boxCountSliderCurrentText).text = "1";
boxCountSliderMaxText = ((Component)((Component)boxCountSliderGrp).transform.Find("MaxText")).GetComponent<TextMeshProUGUI>();
((TMP_Text)boxCountSliderMaxText).text = $"{200}";
backButton = ((Component)val.Find("BackBtn")).GetComponent<ControllerButton>();
expansionSelectEditBtn = ((Component)val.Find("CriteriaSliderGrpA2/EditBtn")).GetComponent<ControllerButton>();
raritySelectEditBtn = ((Component)val.Find("CriteriaSliderGrpB2/EditBtn")).GetComponent<ControllerButton>();
numberOfBoxesSlider = ((Component)boxCountSliderGrp.Find("Slider")).GetComponent<ControllerButton>();
minimumPriceSlider = ((Component)val.Find("CriteriaSliderGrpC/Slider")).GetComponent<ControllerButton>();
maxPriceSlider = ((Component)val.Find("CriteriaSliderGrpA/Slider")).GetComponent<ControllerButton>();
minCardsSlider = ((Component)val.Find("CriteriaSliderGrpB/Slider")).GetComponent<ControllerButton>();
Transform obj = val.Find("CriteriaSliderGrpC/InputTextGrp");
minimumPriceInput = ((obj != null) ? ((Component)obj).GetComponent<ControllerButton>() : null);
Transform obj2 = val.Find("CriteriaSliderGrpA/InputTextGrp");
maxPriceInput = ((obj2 != null) ? ((Component)obj2).GetComponent<ControllerButton>() : null);
Transform obj3 = val.Find("RulebookBtn");
rulebookBtn = ((obj3 != null) ? ((Component)obj3).GetComponent<ControllerButton>() : null);
Transform obj4 = val.Find("EditDeckBtn");
editDeckBtn = ((obj4 != null) ? ((Component)obj4).GetComponent<ControllerButton>() : null);
GameObject val2 = FlowLayoutGroup.Create(workbenchUIScreen.m_ScreenGrp.transform, growUpwards: true);
val2.transform.localPosition = new Vector3(540f, 30f, 0f);
buttonLayout = val2.GetComponentInChildren<FlowLayoutGroup>(true);
buttonLayout.CenterContent = false;
buttonLayout.ChildWidth = 125f;
buttonLayout.ChildHeight = 65f;
buttonLayout.ButtonsPerRow = 4;
buttonLayout.SpacingX = 0f;
buttonLayout.SpacingY = 0f;
}
public void OnExpansionUpdate()
{
BuildQuickSetButtons();
}
public void OnEnterWorkbenchMode(EnhancedWorkbench enhancedWorkbench)
{
CurrentWorkbench = enhancedWorkbench;
BuildQuickSetButtons();
CurrentWorkbench.TryPrepareNextEmpty();
}
public void OnTaskComplete()
{
bool num = CurrentWorkbench.OnTaskComplete();
((Selectable)workbenchUIScreen.m_SliderMinCard).interactable = true;
((Selectable)workbenchUIScreen.m_SliderPriceLimit).interactable = true;
((Selectable)workbenchUIScreen.m_SliderPriceMinimum).interactable = true;
workbenchUIScreen.m_TaskFinishCirlceGrp.SetActive(false);
if (num)
{
workbenchUIScreen.CloseScreen(false);
}
else if (maxBoxCreateSlider.value > 1f)
{
Slider obj = maxBoxCreateSlider;
float value = obj.value;
obj.value = value - 1f;
startBundleBtn.OnPressConfirm();
}
}
private void BuildQuickSetButtons()
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_011a: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
ECardExpansionType currentCardExpansionType = workbenchUIScreen.m_CurrentCardExpansionType;
List<(EItemType, string)> list = (((int)currentCardExpansionType == 0) ? DefaultTetramonButtons : (((int)currentCardExpansionType != 1) ? GetEPLButtonsOrDefault(currentCardExpansionType) : new List<(EItemType, string)>(5)
{
((EItemType)38, "White Box"),
((EItemType)92, "Yellow Box"),
((EItemType)93, "Pink Box"),
((EItemType)94, "Red Box"),
((EItemType)128, "Green Box")
}));
buttonLayout.ClearButtons();
foreach (var item2 in list)
{
EItemType itemType = item2.Item1;
string item = item2.Item2;
Transform obj = buttonLayout.AddButtonFromTemplate(((Component)startBundleBtn).transform, arrange: false);
Localize componentInChildren = ((Component)obj).GetComponentInChildren<Localize>(true);
if (componentInChildren != null)
{
componentInChildren.SetTerm(item);
}
Button componentInChildren2 = ((Component)obj).GetComponentInChildren<Button>(true);
if ((Object)(object)componentInChildren2 != (Object)null)
{
componentInChildren2.onClick = new ButtonClickedEvent();
((UnityEvent)componentInChildren2.onClick).AddListener((UnityAction)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
OnQuickSetButtonPressed(itemType);
});
((Selectable)componentInChildren2).navigation = Navigation.defaultNavigation;
}
}
buttonLayout.Arrange();
ControllerScreenUIExtension component = ((Component)this).GetComponent<ControllerScreenUIExtension>();
component.m_ControllerBtnColumnList.Clear();
for (int num = 0; num < buttonLayout.ControllerButtons.Count; num += buttonLayout.ButtonsPerRow)
{
ControllerBtnList val = new ControllerBtnList
{
rowList = new List<ControllerButton>()
};
val.rowList.Add(expansionSelectEditBtn);
val.rowList.AddRange(buttonLayout.ControllerButtons.Skip(num).Take(buttonLayout.ButtonsPerRow));
component.m_ControllerBtnColumnList.Add(val);
}
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = new List<ControllerButton>(3) { expansionSelectEditBtn, startBundleBtn, numberOfBoxesSlider }
});
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = Row(expansionSelectEditBtn, startBundleBtn, minimumPriceSlider, minimumPriceInput)
});
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = Row(expansionSelectEditBtn, startBundleBtn, maxPriceSlider, maxPriceInput)
});
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = new List<ControllerButton>(3) { raritySelectEditBtn, backButton, minCardsSlider }
});
if ((Object)(object)rulebookBtn != (Object)null)
{
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = new List<ControllerButton>(2) { expansionSelectEditBtn, rulebookBtn }
});
}
if ((Object)(object)editDeckBtn != (Object)null)
{
component.m_ControllerBtnColumnList.Add(new ControllerBtnList
{
rowList = new List<ControllerButton>(2) { raritySelectEditBtn, editDeckBtn }
});
}
}
private static List<ControllerButton> Row(params ControllerButton[] buttons)
{
return buttons.Where((ControllerButton b) => (Object)(object)b != (Object)null).ToList();
}
private void OnQuickSetButtonPressed(EItemType itemType)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Invalid comparison between Unknown and I4
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected I4, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
(float, float) tuple;
if (itemType - 37 > 1)
{
switch (itemType - 89)
{
default:
tuple = ((itemType - 127 > 1) ? CheckForEPLButtonConfig(workbenchUIScreen.m_CurrentCardExpansionType, itemType) : (ModConfigManager.Instance.GetValue<float>("UI", "Green Box Min"), ModConfigManager.Instance.GetValue<float>("UI", "Green Box Max")));
break;
case 0:
case 3:
tuple = (ModConfigManager.Instance.GetValue<float>("UI", "Yellow Box Min"), ModConfigManager.Instance.GetValue<float>("UI", "Yellow Box Max"));
break;
case 1:
case 4:
tuple = (ModConfigManager.Instance.GetValue<float>("UI", "Pink Box Min"), ModConfigManager.Instance.GetValue<float>("UI", "Pink Box Max"));
break;
case 2:
case 5:
tuple = (ModConfigManager.Instance.GetValue<float>("UI", "Red Box Min"), ModConfigManager.Instance.GetValue<float>("UI", "Red Box Max"));
break;
}
}
else
{
tuple = (ModConfigManager.Instance.GetValue<float>("UI", "White Box Min"), ModConfigManager.Instance.GetValue<float>("UI", "White Box Max"));
}
var (num, num2) = tuple;
workbenchUIScreen.m_PriceMinimum = num;
workbenchUIScreen.m_PriceLimit = num2;
workbenchUIScreen.m_SliderPriceMinimum.value = num * 100f;
workbenchUIScreen.m_SliderPriceLimit.value = num2 * 100f;
((TMP_Text)workbenchUIScreen.m_PriceLimitText).text = GameInstance.GetPriceString(num2, false, true, false, "F2");
((TMP_Text)workbenchUIScreen.m_PriceMinimumText).text = GameInstance.GetPriceString(num, false, true, false, "F2");
CPlayerData.m_WorkbenchPriceLimit = workbenchUIScreen.m_PriceLimit;
CPlayerData.m_WorkbenchPriceMinimum = workbenchUIScreen.m_PriceMinimum;
}
private void RegisterConfigs()
{
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("UI", "Box Count Slider Position", delegate(Vector3 value)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)boxCountSliderGrp != (Object)null)
{
boxCountSliderGrp.localPosition = value;
}
}));
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("UI", "Box Count Slider Scale", delegate(Vector3 value)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)boxCountSliderGrp != (Object)null)
{
boxCountSliderGrp.localScale = value;
}
}));
}
private void OnSliderValueChanged(float value)
{
((TMP_Text)boxCountSliderCurrentText).text = $"{value}";
}
private unsafe List<(EItemType, string)> GetEPLButtonsOrDefault(ECardExpansionType expansionType)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (!EPLBridge.Instance.TryGetBulkBoxes(expansionType, out IReadOnlyList<(int, EItemType)> bulkBoxes))
{
return DefaultTetramonButtons;
}
return bulkBoxes.Select<(int, EItemType), (EItemType, string)>(((int MinPrice, EItemType ItemType) b) => (ItemType: b.ItemType, ((object)(*(EItemType*)(&b.ItemType))/*cast due to .constrained prefix*/).ToString().Split("_").Last()
.Prettierize())).ToList();
}
private (float, float) CheckForEPLButtonConfig(ECardExpansionType expansionType, EItemType itemType)
{
//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_0012: Unknown result type (might be due to invalid IL or missing references)
if (!EPLBridge.Instance.TryGetBulkBoxes(expansionType, out IReadOnlyList<(int, EItemType)> bulkBoxes) || !bulkBoxes.Any<(int, EItemType)>(((int MinPrice, EItemType ItemType) b) => b.ItemType == itemType))
{
return (0f, 0f);
}
float targetMin = bulkBoxes.First<(int, EItemType)>(((int MinPrice, EItemType ItemType) b) => b.ItemType == itemType).Item1;
if (targetMin == 0f)
{
targetMin += 0.01f;
}
float num = (from b in bulkBoxes
where (float)b.MinPrice > targetMin
orderby b.MinPrice
select b.MinPrice).FirstOrDefault();
if (num < targetMin)
{
num = targetMin + 2000f;
}
return CalculatePerItemRange(targetMin, num, 100);
}
private (float min, float max) CalculatePerItemRange(float absoluteMin, float absoluteMax, int count)
{
if (count <= 0)
{
return (min: 0f, max: 0f);
}
return (min: Mathf.Clamp(absoluteMin / (float)count, 0.01f, float.MaxValue), max: absoluteMax / (float)count);
}
}
public class FlowLayoutGroup : MonoBehaviour
{
public RectOffset padding = new RectOffset(10, 10, 10, 10);
private Vector2 templateSize;
public float SpacingX { get; set; } = 30f;
public float SpacingY { get; set; } = -45f;
public float ChildWidth { get; set; } = 325f;
public float ChildHeight { get; set; } = 184.5f;
public bool CenterContent { get; set; } = true;
public bool GrowUpwards { get; set; }
public int ButtonsPerRow { get; set; } = 1;
public List<ControllerButton> ControllerButtons { get; private set; } = new List<ControllerButton>();
public static GameObject Create(Transform parent, bool growUpwards = false)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_00d6: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("FlowLayoutGroup_Root", new Type[1] { typeof(RectTransform) });
RectTransform component = val.GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
GameObject val2 = new GameObject("FlowContent", new Type[2]
{
typeof(RectTransform),
typeof(FlowLayoutGroup)
});
RectTransform component2 = val2.GetComponent<RectTransform>();
((Transform)component2).SetParent((Transform)(object)component, false);
component2.anchorMin = (growUpwards ? new Vector2(0f, 0f) : new Vector2(0f, 1f));
component2.anchorMax = (growUpwards ? new Vector2(1f, 0f) : new Vector2(1f, 1f));
component2.pivot = (growUpwards ? new Vector2(0.5f, 0f) : new Vector2(0.5f, 1f));
component2.anchoredPosition = Vector2.zero;
component2.sizeDelta = Vector2.zero;
val2.GetComponent<FlowLayoutGroup>().GrowUpwards = growUpwards;
return val;
}
public Transform AddButtonFromTemplate(Transform template, bool arrange = true)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)template == (Object)null)
{
return null;
}
RectTransform component = ((Component)template).GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
templateSize = component.sizeDelta;
}
Transform obj = Object.Instantiate<Transform>(template, ((Component)this).transform);
((Component)obj).gameObject.SetActive(true);
ControllerButton component2 = ((Component)obj).GetComponent<ControllerButton>();
if ((Object)(object)component2 != (Object)null)
{
ControllerButtons.Add(component2);
}
if (arrange)
{
ArrangeChildren();
}
return ((Component)obj).transform;
}
public void Arrange()
{
ArrangeChildren();
}
public void ClearButtons()
{
ControllerButtons.Clear();
for (int num = ((Component)this).transform.childCount - 1; num >= 0; num--)
{
Transform child = ((Component)this).transform.GetChild(num);
child.SetParent((Transform)null, false);
Object.Destroy((Object)(object)((Component)child).gameObject);
}
}
private void ArrangeChildren()
{
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Invalid comparison between Unknown and I4
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
if (((Component)this).transform.childCount == 0)
{
return;
}
float num = (float)ButtonsPerRow * ChildWidth + (float)Mathf.Max(0, ButtonsPerRow - 1) * SpacingX;
float num2 = num + (float)padding.left + (float)padding.right;
List<List<RectTransform>> list = new List<List<RectTransform>>();
List<RectTransform> list2 = new List<RectTransform>();
for (int i = 0; i < ((Component)this).transform.childCount; i++)
{
Transform child = ((Component)this).transform.GetChild(i);
RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null);
if (val != null && ((Component)val).gameObject.activeSelf && (int)((Object)((Component)val).gameObject).hideFlags != 1)
{
if (list2.Count >= ButtonsPerRow)
{
list.Add(list2);
list2 = new List<RectTransform>();
}
list2.Add(val);
}
}
if (list2.Count > 0)
{
list.Add(list2);
}
float num3 = (float)list.Count * ChildHeight + (float)padding.top + (float)padding.bottom;
Transform transform = ((Component)this).transform;
((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta = new Vector2(num2, num3);
Vector3 localScale = (Vector3)((templateSize.x > 0f && templateSize.y > 0f) ? new Vector3(ChildWidth / templateSize.x, ChildHeight / templateSize.y, 1f) : Vector3.one);
for (int j = 0; j < list.Count; j++)
{
List<RectTransform> list3 = list[j];
float num4 = (float)list3.Count * ChildWidth + (float)(list3.Count - 1) * SpacingX;
float num5 = (CenterContent ? ((float)padding.left + (num - num4) / 2f) : ((float)padding.left));
float num7;
if (GrowUpwards)
{
int num6 = list.Count - 1 - j;
num7 = (float)padding.bottom + (float)num6 * ChildHeight;
}
else
{
num7 = (float)(-padding.top) - (float)j * ChildHeight;
}
foreach (RectTransform item in list3)
{
item.anchorMin = new Vector2(0f, 0f);
item.anchorMax = new Vector2(0f, 0f);
item.pivot = new Vector2(0f, 0f);
item.sizeDelta = templateSize;
item.anchoredPosition = new Vector2(num5, num7);
((Transform)item).localScale = localScale;
num5 += ChildWidth + SpacingX;
}
}
}
}
}
namespace EnhancedWorkbenches.Persistence
{
public class EnhancedWorkbenchSaveData
{
public PackagingBoxSaveData PackagingBox { get; set; }
public List<int> WarehouseShelfAttachments { get; set; } = new List<int>();
public int EmptyBoxStorageAttachment { get; set; } = -1;
}
public class PackagingBoxSaveData
{
public EItemType ItemType { get; set; }
public int ItemCount { get; set; }
}
public class SaveFileManager
{
private const string SaveFolderName = "EnhancedWorkbench";
private static SaveFileManager instance;
public static SaveFileManager Instance => instance ?? (instance = new SaveFileManager());
public List<EnhancedWorkbenchSaveData> OnLoad(int savefileIndex)
{
string text = string.Format("{0}_{1}.json", "EnhancedWorkbenches", savefileIndex);
string text2 = Path.Combine(Paths.PluginPath, "EnhancedWorkbench", text);
string text3 = Path.Combine(GetSaveDirectory(), text);
if (File.Exists(text2))
{
if (!File.Exists(text3))
{
Directory.CreateDirectory(GetSaveDirectory());
File.Copy(text2, text3);
}
File.Delete(text2);
}
if (!File.Exists(text3))
{
return new List<EnhancedWorkbenchSaveData>();
}
return JsonConvert.DeserializeObject<List<EnhancedWorkbenchSaveData>>(File.ReadAllText(text3)) ?? new List<EnhancedWorkbenchSaveData>();
}
public void OnSave(int savefileIndex, List<EnhancedWorkbenchSaveData> workbenchSaveData)
{
Directory.CreateDirectory(GetSaveDirectory());
string contents = JsonConvert.SerializeObject((object)workbenchSaveData, (Formatting)1);
File.WriteAllText(Path.Combine(GetSaveDirectory(), string.Format("{0}_{1}.json", "EnhancedWorkbenches", savefileIndex)), contents);
}
private static string GetSaveDirectory()
{
return Path.Combine(Application.persistentDataPath, "EnhancedWorkbench");
}
}
}
namespace EnhancedWorkbenches.Patches
{
[HarmonyPatch(typeof(CSaveLoad))]
public class CSaveLoadPatches
{
[HarmonyPatch("Save")]
[HarmonyPrefix]
private static void SavePrefix(int saveSlotIndex, bool skipJSONSave)
{
List<EnhancedWorkbenchSaveData> workbenchSaveData = (from kvp in Plugin.WorkbenchManager.WorkbenchCache
orderby kvp.Value.WorkbenchNumber
select kvp.Value.SaveData).ToList();
SaveFileManager.Instance.OnSave(saveSlotIndex, workbenchSaveData);
}
[HarmonyPatch("Load")]
[HarmonyPrefix]
private static void LoadPrefix(int slotIndex)
{
List<EnhancedWorkbenchSaveData> saveData = SaveFileManager.Instance.OnLoad(slotIndex);
Plugin.WorkbenchManager.OnEnhancedWorkbenchDataLoaded(saveData);
}
}
[HarmonyPatch(typeof(InteractableObject))]
public class InteractableObjectPatches
{
[HarmonyPatch("OnRaycastEnded")]
[HarmonyPostfix]
private static void OnRaycastEndedPostfix(InteractableObject __instance)
{
InteractableWorkbench val = (InteractableWorkbench)(object)((__instance is InteractableWorkbench) ? __instance : null);
if (val != null)
{
Plugin.WorkbenchManager.OnRaycastEnded(val);
}
}
[HarmonyPatch("BoxUpObject")]
[HarmonyPostfix]
private static void BoxUpObjectPostfix(InteractableObject __instance)
{
Plugin.WorkbenchManager.OnFurniturePlacementCanceled(__instance);
}
[HarmonyPatch("PlaceMovedObject")]
[HarmonyPostfix]
private static void PlaceMovedObjectPostfix(InteractableObject __instance)
{
if (!__instance.m_IsMovingObject)
{
Plugin.WorkbenchManager.OnFurniturePlaced(__instance);
}
}
[HarmonyPatch("StartMoveObject")]
[HarmonyPostfix]
private static void StartMoveObjectPostfix(InteractableObject __instance)
{
Plugin.WorkbenchManager.OnStartMoveObject(__instance);
}
}
[HarmonyPatch(typeof(InteractablePackagingBox_Item))]
public class InteractablePackagingBox_ItemPatches
{
[HarmonyPatch("StartHoldBox")]
[HarmonyPrefix]
private static void StartHoldBoxPrefix(InteractablePackagingBox_Item __instance)
{
Plugin.WorkbenchManager.OnStartHoldingBox(__instance);
}
}
[HarmonyPatch(typeof(InteractablePackagingBox_Shelf))]
public class InteractablePackagingBox_ShelfPatches
{
[HarmonyPatch("OnPressOpenBox")]
[HarmonyPrefix]
private static void OnPressOpenBoxPrefix(InteractablePackagingBox_Shelf __instance)
{
if (!__instance.m_IsOpeningBox)
{
Plugin.WorkbenchManager.OnFurnitureBoxOpening(__instance);
}
}
}
[HarmonyPatch(typeof(InteractableWorkbench))]
public class InteractableWorkbenchPatches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void OnAwakePostfix(InteractableWorkbench __instance)
{
Plugin.WorkbenchManager.OnWorkbenchAwake(__instance);
}
[HarmonyPatch("OnRaycasted")]
[HarmonyPostfix]
private static void OnRaycastedPostfix(InteractableWorkbench __instance)
{
if (!__instance.m_IsEditingDeck)
{
Plugin.WorkbenchManager.OnRaycasted(__instance);
}
}
[HarmonyPatch("Update")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
{
return TranspilerHelpers.MultiplyDeltaTimeByAnimationSpeed(instructions);
}
}
[HarmonyPatch(typeof(InteractionPlayerController))]
public class InteractionPlayerControllerPatches
{
[HarmonyPatch("OnExitWorkbenchMode")]
[HarmonyPostfix]
private static void OnExitWorkbenchModePostfix(InteractableWorkbench ___m_CurrentWorkbench)
{
Plugin.WorkbenchManager.OnExitWorkBenchMode(___m_CurrentWorkbench);
}
[HarmonyPatch("OnEnterWorkbenchMode")]
[HarmonyPostfix]
private static void OnEnterWorkbenchModePostfix(InteractableWorkbench ___m_CurrentWorkbench)
{
Plugin.WorkbenchManager.OnEnterWorkBenchMode(___m_CurrentWorkbench);
}
}
[HarmonyPatch(typeof(ShelfManager))]
public class ShelfManagerPatches
{
[HarmonyPatch("SaveInteractableObjectData")]
[HarmonyPrefix]
private static void SaveInteractableObjectDataPrefix(ShelfManager __instance)
{
Plugin.WorkbenchManager.UpdateWorkbenchSaveData(__instance);
}
}
internal static class TranspilerHelpers
{
internal static IEnumerable<CodeInstruction> MultiplyDeltaTimeByAnimationSpeed(IEnumerable<CodeInstruction> instructions)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(Time), "deltaTime");
FieldInfo fieldInfo = AccessTools.Field(typeof(ConfigCache), "AnimationSpeedMultiplier");
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null)
});
if (val.IsValid)
{
val.Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo),
new CodeInstruction(OpCodes.Mul, (object)null)
});
}
return val.InstructionEnumeration();
}
}
[HarmonyPatch(typeof(WorkbenchUIScreen))]
public class WorkbenchUIScreenPatch
{
[HarmonyPatch("OnTaskCompleted")]
[HarmonyPrefix]
private static bool OnTaskCompletedPrefix()
{
return Plugin.WorkbenchManager.OnTaskComplete();
}
[HarmonyPatch("OnCardExpansionUpdated")]
[HarmonyPostfix]
private static void OnCardExpansionUpdatedPostfix(CEventPlayer_OnCardExpansionSelectScreenUpdated evt)
{
Plugin.WorkbenchManager.OnExpansionUpdated();
}
[HarmonyPatch("Update")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
{
return TranspilerHelpers.MultiplyDeltaTimeByAnimationSpeed(instructions);
}
}
}
namespace EnhancedWorkbenches.Extensions
{
public static class InteractableObjectExtensions
{
public static Vector3 GetCenterBounds(this InteractableObject interactableObject, bool snappedToGround = false)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)interactableObject).transform.TransformPoint(interactableObject.m_BoxCollider.center);
if (snappedToGround)
{
((Vector3)(ref val))..ctor(val.x, 0.2f, val.z);
}
return val;
}
}
public static class StringExtensions
{
public static string Prettierize(this string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return value;
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(value[0]);
for (int i = 1; i < value.Length; i++)
{
char c = value[i];
if (char.IsUpper(c) && (char.IsLower(value[i - 1]) || (i < value.Length - 1 && char.IsLower(value[i + 1]))))
{
stringBuilder.Append(" ");
}
stringBuilder.Append(c);
}
return stringBuilder.ToString();
}
}
}
namespace EnhancedWorkbenches.Core
{
public class EnhancedWorkbench : MonoBehaviour
{
private static readonly Vector3 FillBoxLocalPosition = new Vector3(-0.35f, 0.91f, -0.25f);
private const float PreviewRangeMultiplier = 2f;
private static Texture2D chevronTexture;
private readonly List<Action> configUnsubscribers = new List<Action>();
private DistanceLineRenderer distanceLineRenderer;
private InteractableWorkbench interactableWorkbench;
private Transform fillBoxTransform;
private KeyboardShortcut buyBoxShortcut;
private int maxAttachableShelves;
private float maxAttachableDistance;
private float emptyBoxCost;
private bool showAttachPreview;
private bool isPreviewingAttach;
private InteractableObject pendingAttachObject;
public List<WarehouseShelf> WarehouseShelves { get; private set; } = new List<WarehouseShelf>();
public InteractableEmptyBoxStorage EmptyBoxStorage { get; private set; }
public InteractablePackagingBox_Item CurrentFillBox { get; set; }
public bool IsRaycasted { get; set; }
public ShelfCompartment ShelfCompartment { get; private set; }
public int WorkbenchNumber { get; set; }
public EnhancedWorkbenchSaveData SaveData { get; set; }
private void Awake()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
interactableWorkbench = ((Component)this).GetComponent<InteractableWorkbench>();
emptyBoxCost = ModConfigManager.Instance.GetValue<float>("Workbench", "Empty Box Cost");
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("Workbench", "Empty Box Cost", delegate(float value)
{
emptyBoxCost = value;
}));
buyBoxShortcut = ModConfigManager.Instance.GetValue<KeyboardShortcut>("Workbench", "Buy Empty Box");
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("Workbench", "Buy Empty Box", delegate(KeyboardShortcut value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
buyBoxShortcut = value;
}));
maxAttachableShelves = ModConfigManager.Instance.GetValue<int>("Workbench", "Max Attachable Shelves");
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("Workbench", "Max Attachable Shelves", delegate(int value)
{
maxAttachableShelves = value;
}));
maxAttachableDistance = ModConfigManager.Instance.GetValue<float>("Workbench", "Max Attachable Distance");
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("Workbench", "Max Attachable Distance", delegate(float value)
{
maxAttachableDistance = value;
distanceLineRenderer.MaxDistance = value;
}));
SetAnimationSpeed(ConfigCache.AnimationSpeedMultiplier);
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged<float>("Workbench", "Animation Speed Multiplier", SetAnimationSpeed));
showAttachPreview = ModConfigManager.Instance.GetValue<bool>("Workbench", "Show Attach Preview");
configUnsubscribers.Add(ModConfigManager.Instance.OnSettingChanged("Workbench", "Show Attach Preview", delegate(bool value)
{
showAttachPreview = value;
}));
fillBoxTransform = new GameObject("FillBoxTransform").transform;
fillBoxTransform.SetParent(((Component)this).gameObject.transform);
fillBoxTransform.localPosition = FillBoxLocalPosition;
if (chevronTexture == null)
{
chevronTexture = ResourceLoader.LoadTexture("EnhancedWorkbenches.Resources.chevrons.png");
}
distanceLineRenderer = new DistanceLineRenderer(chevronTexture, 4f)
{
MaxDistance = maxAttachableDistance
};
SaveData = new EnhancedWorkbenchSaveData();
}
private void OnDestroy()
{
foreach (Action configUnsubscriber in configUnsubscribers)
{
configUnsubscriber();
}
configUnsubscribers.Clear();
distanceLineRenderer?.Dispose();
AttachTooltip.Hide(this);
}
private void Update()
{
distanceLineRenderer.Update();
UpdateAttachPreview();
TryClickAttach();
if (IsRaycasted && ((KeyboardShortcut)(ref buyBoxShortcut)).IsDown() && (Object)(object)EmptyBoxStorage != (Object)null)
{
TryCreateEmptyBox();
}
}
private void TryClickAttach()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
if (!IsRaycasted || !UnityInput.Current.GetMouseButtonUp(0))
{
return;
}
InteractionPlayerController instance = CSingleton<InteractionPlayerController>.Instance;
if ((int)instance.m_CurrentGameState == 1 && !instance.m_IsInUIMode)
{
InteractablePackagingBox_Shelf currentHoldingBoxShelf = instance.m_CurrentHoldingBoxShelf;
if ((Object)(object)currentHoldingBoxShelf != (Object)null && !currentHoldingBoxShelf.m_IsOpeningBox && (Object)(object)currentHoldingBoxShelf.m_BoxedObject != (Object)null && CanAttachBoxedObject(currentHoldingBoxShelf.m_BoxedObject))
{
((InteractablePackagingBox)currentHoldingBoxShelf).OnPressOpenBox();
}
}
}
public void TryBeginAttach(InteractablePackagingBox_Shelf furnitureBox)
{
InteractableObject boxedObject = furnitureBox.m_BoxedObject;
if ((Object)(object)boxedObject != (Object)null && CanAttachBoxedObject(boxedObject))
{
isPreviewingAttach = false;
AttachTooltip.Hide(this);
BeginTrackingPlacement(boxedObject);
}
}
private void UpdateAttachPreview()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
InteractionPlayerController instance = CSingleton<InteractionPlayerController>.Instance;
InteractablePackagingBox_Shelf val = ((showAttachPreview && (Object)(object)pendingAttachObject == (Object)null && (int)instance.m_CurrentGameState == 1) ? instance.m_CurrentHoldingBoxShelf : null);
bool flag = (Object)(object)val != (Object)null && CanAttachBoxedObject(val.m_BoxedObject) && IsWithinPreviewRange((InteractableObject)(object)val);
if (flag && !isPreviewingAttach)
{
distanceLineRenderer.Start((InteractableObject)(object)interactableWorkbench, (InteractableObject)(object)val);
isPreviewingAttach = true;
}
else if (!flag && isPreviewingAttach)
{
distanceLineRenderer.Stop();
isPreviewingAttach = false;
}
if (isPreviewingAttach && IsRaycasted)
{
string text = ((val.m_BoxedObject is InteractableEmptyBoxStorage) ? "Attach Box Storage" : "Attach Shelf");
AttachTooltip.Show(this, text);
}
else
{
AttachTooltip.Hide(this);
}
}
private bool CanAttachBoxedObject(InteractableObject boxedObject)
{
if (!(boxedObject is WarehouseShelf))
{
if (boxedObject is InteractableEmptyBoxStorage)
{
return (Object)(object)EmptyBoxStorage == (Object)null;
}
return false;
}
return WarehouseShelves.Count < maxAttachableShelves;
}
private bool IsWithinPreviewRange(InteractableObject heldBox)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_002c: 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)
Vector3 centerBounds = ((InteractableObject)(object)interactableWorkbench).GetCenterBounds();
Vector3 centerBounds2 = heldBox.GetCenterBounds();
return Vector2.Distance(new Vector2(centerBounds.x, centerBounds.z), new Vector2(centerBounds2.x, centerBounds2.z)) <= maxAttachableDistance * 2f;
}
public void UpdateSaveIndexes(ShelfManager shelfManager)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
SaveData.WarehouseShelfAttachments = (from ws in WarehouseShelves
select shelfManager.m_WarehouseShelfList.IndexOf(ws) into index
where index >= 0
select index).ToList();
SaveData.EmptyBoxStorageAttachment = (((Object)(object)EmptyBoxStorage == (Object)null) ? (-1) : shelfManager.m_EmptyBoxStorageList.IndexOf(EmptyBoxStorage));
SaveData.PackagingBox = (((Object)(object)CurrentFillBox == (Object)null) ? null : new PackagingBoxSaveData
{
ItemType = CurrentFillBox.GetItemType(),
ItemCount = CurrentFillBox.m_ItemCompartment.GetItemCount()
});
}
public bool IsConnected(InteractableObject instance)
{
if (!((Object)(object)EmptyBoxStorage == (Object)(object)instance))
{
return WarehouseShelves.Any((WarehouseShelf ws) => (Object)(object)ws == (Object)(object)instance);
}
return true;
}
public void OnStartMoveAttachedObject(InteractableObject interactableObject)
{
InteractableEmptyBoxStorage val = (InteractableEmptyBoxStorage)(object)((interactableObject is InteractableEmptyBoxStorage) ? interactableObject : null);
if (val == null)
{
WarehouseShelf val2 = (WarehouseShelf)(object)((interactableObject is WarehouseShelf) ? interactableObject : null);
if (val2 != null)
{
WarehouseShelves.Remove(val2);
}
}
else if ((Object)(object)EmptyBoxStorage == (Object)(object)val)
{
EmptyBoxStorage = null;
}
BeginTrackingPlacement(interactableObject);
}
public void OnFurniturePlaced(InteractableObject furniture)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)furniture == (Object)null || (Object)(object)furniture != (Object)(object)pendingAttachObject)
{
return;
}
Vector3 centerBounds = ((InteractableObject)(object)interactableWorkbench).GetCenterBounds();
Vector3 centerBounds2 = furniture.GetCenterBounds();
float num = Vector2.Distance(new Vector2(centerBounds.x, centerBounds.z), new Vector2(centerBounds2.x, centerBounds2.z));
bool flag = false;
if (num <= maxAttachableDistance)
{
WarehouseShelf val = (WarehouseShelf)(object)((furniture is WarehouseShelf) ? furniture : null);
if (val == null)
{
InteractableEmptyBoxStorage val2 = (InteractableEmptyBoxStorage)(object)((furniture is InteractableEmptyBoxStorage) ? furniture : null);
if (val2 != null && (Object)(object)EmptyBoxStorage == (Object)null)
{
EmptyBoxStorage = val2;
flag = true;
}
}
else if (WarehouseShelves.Count < maxAttachableShelves && !WarehouseShelves.Contains(val))
{
WarehouseShelves.Add(val);
flag = true;
}
}
Plugin.Logger.LogInfo((object)string.Format("Workbench {0}: {1} placed {2:F2}m away (max {3:F2}m) - {4}.", WorkbenchNumber, ((object)furniture).GetType().Name, num, maxAttachableDistance, flag ? "attached" : "not attached"));
StopTrackingPlacement();
}
public void OnFurniturePlacementCanceled(InteractableObject furniture)
{
if ((Object)(object)furniture != (Object)null && (Object)(object)furniture == (Object)(object)pendingAttachObject)
{
StopTrackingPlacement();
}
}
private void BeginTrackingPlacement(InteractableObject furniture)
{
pendingAttachObject = furniture;
distanceLineRenderer.Start((InteractableObject)(object)interactableWorkbench, furniture);
Plugin.Logger.LogInfo((object)$"Workbench {WorkbenchNumber}: tracking placement of {((object)furniture).GetType().Name} for attach.");
}
private void StopTrackingPlacement()
{
pendingAttachObject = null;
distanceLineRenderer.Stop();
}
public void InitFromSaveData(EnhancedWorkbenchSaveData saveData)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (saveData.PackagingBox != null && (Object)(object)fillBoxTransform != (Object)null)
{
InteractablePackagingBox_Item val = RestockManager.SpawnPackageBoxItem(saveData.PackagingBox.ItemType, saveData.PackagingBox.ItemCount, true);
RestockManager.RemoveItemPackageBox(val);
((Component)val).transform.SetParent(fillBoxTransform.parent);
((Component)val).transform.localPosition = fillBoxTransform.localPosition;
((Component)val).transform.localRotation = fillBoxTransform.localRotation;
((InteractablePackagingBox)val).m_Rigidbody.isKinematic = true;
val.SetOpenCloseBox(true, false);
CurrentFillBox = val;
}
ShelfManager instance = CSingleton<ShelfManager>.Instance;
foreach (int warehouseShelfAttachment in saveData.WarehouseShelfAttachments)
{
if (warehouseShelfAttachment >= 0 && warehouseShelfAttachment < instance.m_WarehouseShelfList.Count)
{
WarehouseShelves.Add(instance.m_WarehouseShelfList[warehouseShelfAttachment]);
}
}
if (saveData.EmptyBoxStorageAttachment >= 0 && saveData.EmptyBoxStorageAttachment < instance.m_EmptyBoxStorageList.Count)
{
EmptyBoxStorage = instance.m_EmptyBoxStorageList[saveData.EmptyBoxStorageAttachment];
}
}
public void TryPrepareNextEmpty()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)CurrentFillBox != (Object)null) && !((Object)(object)EmptyBoxStorage == (Object)null) && EmptyBoxStorage.GetBoxStoredCount() != 0)
{
InteractablePackagingBox_Item val = RestockManager.SpawnPackageBoxItem((EItemType)(-1), 0, true);
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Remove(val);
((Component)val).transform.position = EmptyBoxStorage.m_EmptyBoxSpawnLoc.position;
((Component)val).transform.rotation = EmptyBoxStorage.m_EmptyBoxSpawnLoc.rotation;
((InteractableObject)val).LerpToTransform(fillBoxTransform, fillBoxTransform.parent, 3f);
val.SetOpenCloseBox(true, true);
((InteractablePackagingBox)val).m_Rigidbody.isKinematic = true;
InteractableEmptyBoxStorage emptyBoxStorage = EmptyBoxStorage;
emptyBoxStorage.m_StoredBoxCount--;
EmptyBoxStorage.EvaluateStoredBoxStackHeight();
CurrentFillBox = val;
}
}
public bool OnTaskComplete()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
InteractableWorkbench val = interactableWorkbench;
((Component)val.m_JankBoxAnim).gameObject.SetActive(false);
val.m_JankBoxAnim.SetBool("IsClosing", false);
for (int i = 0; i < val.m_CardEnterBoxAnimList.Count; i++)
{
val.m_InteractableCard3dList[i].m_Card3dUI.SetVisibility(false);
((Component)val.m_CardEnterBoxAnimList[i]).gameObject.SetActive(false);
}
val.m_IsPlayCardEnterAnim = false;
val.m_CardEnterIndex = 0;
val.m_CardEnterTimer = 0f;
EItemType currentItemTypeSpawn = val.m_CurrentItemTypeSpawn;
ItemMeshData itemMeshData = InventoryBase.GetItemMeshData(currentItemTypeSpawn);
Item item = ItemSpawnManager.GetItem(val.m_SpawnItemPos);
item.SetMesh(itemMeshData.mesh, itemMeshData.material, currentItemTypeSpawn, itemMeshData.meshSecondary, itemMeshData.materialSecondary, itemMeshData.materialList);
((Component)item).transform.position = val.m_SpawnItemPos.position;
((Component)item).transform.rotation = val.m_SpawnItemPos.rotation;
((Component)item).gameObject.SetActive(true);
if (!TryAddToCurrentFillBox(item))
{
if (interactableWorkbench.HasEnoughSlot())
{
interactableWorkbench.AddItem(item, true);
return false;
}
CSingleton<InteractionPlayerController>.Instance.AddHoldItemToFront(item);
return true;
}
return false;
}
private void SetAnimationSpeed(float value)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
interactableWorkbench.m_JankBoxAnim.speed = value;
foreach (Animation cardEnterBoxAnim in interactableWorkbench.m_CardEnterBoxAnimList)
{
foreach (AnimationState item in cardEnterBoxAnim)
{
item.speed = value;
}
}
}
private void TryCreateEmptyBox()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
if (!EmptyBoxStorage.HasStorageSpace())
{
NotEnoughResourceTextPopup.ShowText((ENotEnoughResourceText)6);
return;
}
if (CPlayerData.m_CoinAmountDouble < (double)emptyBoxCost)
{
NotEnoughResourceTextPopup.ShowText((ENotEnoughResourceText)0);
return;
}
InteractableEmptyBoxStorage emptyBoxStorage = EmptyBoxStorage;
emptyBoxStorage.m_StoredBoxCount++;
EmptyBoxStorage.EvaluateStoredBoxStackHeight();
PriceChangeManager.AddTransaction(0f - emptyBoxCost, (ETransactionType)0, 0, 1, (CardData)null);
CEventManager.QueueEvent((CEvent)new CEventPlayer_ReduceCoin(emptyBoxCost, false));
SoundManager.PlayAudio("SFX_CustomerBuy", 0.6f, 1f);
}
private bool TryAddToCurrentFillBox(Item item)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_004a: 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_0037: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)CurrentFillBox == (Object)null)
{
return false;
}
ShelfCompartment itemCompartment = CurrentFillBox.m_ItemCompartment;
EItemType itemType = item.GetItemType();
if (itemCompartment.GetItemCount() > 0 && CurrentFillBox.GetItemType() != itemType)
{
return false;
}
CurrentFillBox.SetItemType(itemType);
itemCompartment.CheckItemType(itemType);
if (!itemCompartment.HasEnoughSlot())
{
return false;
}
item.LerpToTransform(itemCompartment.GetLastEmptySlotTransform(), itemCompartment.GetEmptySlotParent(), false);
itemCompartment.AddItem(item, true);
itemCompartment.SetPriceTagVisibility(false);
if (!itemCompartment.HasEnoughSlot())
{
OnCurrentFillBoxFull();
}
return true;
}
private void OnCurrentFillBoxFull()
{
CurrentFillBox.SetOpenCloseBox(false, true);
ShelfCompartment val = FindShelfCompartmentForFillBox();
if (!((Object)(object)val == (Object)null))
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(CurrentFillBox);
CurrentFillBox.DispenseItem(true, val);
CurrentFillBox = null;
TryPrepareNextEmpty();
}
}
private ShelfCompartment FindShelfCompartmentForFillBox()
{
//IL_000d: 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)
EItemType itemType = CurrentFillBox.GetItemType();
bool isBigBox = CurrentFillBox.m_IsBigBox;
ShelfCompartment val = WarehouseShelves.Select((WarehouseShelf ws) => ws.GetNonFullItemCompartment(itemType, isBigBox, true)).FirstOrDefault((Func<ShelfCompartment, bool>)((ShelfCompartment c) => (Object)(object)c != (Object)null));
if ((Object)(object)val != (Object)null)
{
return val;
}
return WarehouseShelves.SelectMany((WarehouseShelf ws) => ((InteractableObject)ws).m_ItemCompartmentList).FirstOrDefault((Func<ShelfCompartment, bool>)((ShelfCompartment c) => (int)c.GetItemType() == -1));
}
}
public class EPLBridge
{
private static EPLBridge instance;
private static bool? isApiPluginCompatible;
public static EPLBridge Instance => instance ?? (instance = new EPLBridge());
public bool IsLoaded
{
get
{
bool valueOrDefault = isApiPluginCompatible == true;
if (!isApiPluginCompatible.HasValue)
{
valueOrDefault = CheckApiPluginCompatible();
isApiPluginCompatible = valueOrDefault;
}
if (!isApiPluginCompatible.Value)
{
return false;
}
try
{
return IsApiAvailable();
}
catch
{
return false;
}
}
}
public bool TryGetBulkBoxes(ECardExpansionType expansionType, out IReadOnlyList<(int MinPrice, EItemType ItemType)> bulkBoxes)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
bulkBoxes = null;
if (!IsLoaded)
{
return false;
}
return TryGetBulkBoxesInternal(expansionType, out bulkBoxes);
}
private static bool CheckApiPluginCompatible()
{
if (!Chainloader.PluginInfos.TryGetValue("EnhancedPrefabLoader.API", out var value))
{
Plugin.Logger.LogInfo((object)"Enhanced Prefab Loader API is not installed; EPL features disabled.");
return false;
}
Version version = new Version("6.0.1");
if (value.Metadata.Version < version)
{
Plugin.Logger.LogWarning((object)string.Format("{0} v{1} is older than the v{2} this mod was built against; EPL features disabled.", "Enhanced Prefab Loader API", value.Metadata.Version, version));
return false;
}
return true;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool IsApiAvailable()
{
return Epl.IsAvailable;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool TryGetBulkBoxesInternal(ECardExpansionType expansionType, out IReadOnlyList<(int MinPrice, EItemType ItemType)> bulkBoxes)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
return Epl.Api.Assets.Items.GetBulkBoxes().TryGetValue(expansionType, out bulkBoxes);
}
}
public static class ResourceLoader
{
public static Texture2D LoadTexture(string resourcePath)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath);
if (stream == null)
{
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2);
return ImageConversion.LoadImage(val, array) ? val : null;
}
}
public class WorkbenchManager
{
public readonly Dictionary<InteractableWorkbench, EnhancedWorkbench> WorkbenchCache = new Dictionary<InteractableWorkbench, EnhancedWorkbench>();
public List<EnhancedWorkbenchSaveData> tempSaveData = new List<EnhancedWorkbenchSaveData>();
private EnhancedWorkbenchUI enhancedWorkbenchUI;
private int nextWorkbenchNumber;
public bool IsEnhancedWorkbenchDataLoaded { get; set; }
public bool IsGameDataLoaded { get; private set; }
public void RegisterConfigs()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
ModConfigManager.Instance.BindSetting("Workbench", "Animation Speed Multiplier", 1f, "", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f));
ModConfigManager.Instance.BindSetting("Workbench", "Empty Box Cost", 50f, "", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, float.MaxValue));
ModConfigManager.Instance.BindSetting<KeyboardShortcut>("Workbench", "Buy Empty Box", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()));
ModConfigManager.Instance.BindSetting("Workbench", "Max Attachable Shelves", 2);
ModConfigManager.Instance.BindSetting("Workbench", "Max Attachable Distance", 4f, "", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f));
ModConfigManager.Instance.BindSetting("Workbench", "Show Attach Preview", value: true, "Show a guide line and hint while carrying a boxed shelf or box storage near a workbench.");
ModConfigManager.Instance.BindSetting("UI", "White Box Min", 0.01f);
ModConfigManager.Instance.BindSetting("UI", "White Box Max", 1f);
ModConfigManager.Instance.BindSetting("UI", "Yellow Box Min", 1f);
ModConfigManager.Instance.BindSetting("UI", "Yellow Box Max", 2f);
ModConfigManager.Instance.BindSetting("UI", "Pink Box Min", 2f);
ModConfigManager.Instance.BindSetting("UI", "Pink Box Max", 4f);
ModConfigManager.Instance.BindSetting("UI", "Red Box Min", 4f);
ModConfigManager.Instance.BindSetting("UI", "Red Box Max", 12f);
ModConfigManager.Instance.BindSetting("UI", "Green Box Min", 12f);
ModConfigManager.Instance.BindSetting("UI", "Green Box Max", 20f);
ModConfigManager.Instance.BindSetting<Vector3>("UI", "Box Count Slider Position", new Vector3(500f, -65f, 0f));
ModConfigManager.Instance.BindSetting<Vector3>("UI", "Box Count Slider Scale", new Vector3(0.75f, 0.75f, 0.75f));
ConfigCache.AnimationSpeedMultiplier = ModConfigManager.Instance.GetValue<float>("Workbench", "Animation Speed Multiplier");
ModConfigManager.Instance.OnSettingChanged("Workbench", "Animation Speed Multiplier", delegate(float value)
{
ConfigCache.AnimationSpeedMultiplier = value;
});
}
public void OnSceneChange(Scene scene)
{
if (((Scene)(ref scene)).name == "Title")
{
IsEnhancedWorkbenchDataLoaded = false;
IsGameDataLoaded = false;
enhancedWorkbenchUI = null;
nextWorkbenchNumber = 0;
WorkbenchCache.Clear();
}
}
public void OnWorkbenchAwake(InteractableWorkbench workbench)
{
if (IsGameDataLoaded)
{
InitializeWorkbench(workbench, nextWorkbenchNumber);
nextWorkbenchNumber++;
}
}
public void OnEnterWorkBenchMode(InteractableWorkbench workbench)
{
if (WorkbenchCache.TryGetValue(workbench, out var value) && (Object)(object)enhancedWorkbenchUI != (Object)null)
{
enhancedWorkbenchUI.OnEnterWorkbenchMode(value);
}
}
public void OnExitWorkBenchMode(InteractableWorkbench workbench)
{
if ((Object)(object)enhancedWorkbenchUI != (Object)null)
{
enhancedWorkbenchUI.CurrentWorkbench = null;
}
}
public void OnStartHoldingBox(InteractablePackagingBox_Item packagingBox)
{
foreach (EnhancedWorkbench value in WorkbenchCache.Values)
{
if ((Object)(object)value.CurrentFillBox == (Object)(object)packagingBox)
{
CSingleton<RestockManager>.Instance.m_ItemPackagingBoxList.Add(packagingBox);
((InteractablePackagingBox)packagingBox).m_Rigidbody.isKinematic = false;
value.CurrentFillBox = null;
break;
}
}
}
public void OnFurnitureBoxOpening(InteractablePackagingBox_Shelf furnitureBox)
{
if ((Object)(object)CSingleton<InteractionPlayerController>.Instance.m_CurrentHoldingBoxShelf != (Object)(object)furnitureBox)
{
return;
}
foreach (EnhancedWorkbench value in WorkbenchCache.Values)
{
if (value.IsRaycasted)
{
value.TryBeginAttach(furnitureBox);
break;
}
}
}
public void OnStartMoveObject(InteractableObject interactableObject)
{
foreach (EnhancedWorkbench value in WorkbenchCache.Values)
{
if (value.IsConnected(interactableObject))
{
value.OnStartMoveAttachedObject(interactableObject);
break;
}
}
}
public void OnFurniturePlaced(InteractableObject interactableObject)
{
foreach (EnhancedWorkbench value in WorkbenchCache.Values)
{
value.OnFurniturePlaced(interactableObject);
}
}
public void OnFurniturePlacementCanceled(InteractableObject interactableObject)
{
foreach (EnhancedWorkbench value in WorkbenchCache.Values)
{
value.OnFurniturePlacementCanceled(interactableObject);
}
}
public void OnRaycasted(InteractableWorkbench workbench)
{
if (WorkbenchCache.TryGetValue(workbench, out var value))
{
value.IsRaycasted = true;
}
}
public void OnRaycastEnded(InteractableWorkbench workbench)
{
if (WorkbenchCache.TryGetValue(workbench, out var value))
{
value.IsRaycasted = false;
}
}
public bool OnTaskComplete()
{
if ((Object)(object)enhancedWorkbenchUI == (Object)null || (Object)(object)enhancedWorkbenchUI.CurrentWorkbench == (Object)null)
{
return true;
}
enhancedWorkbenchUI.OnTaskComplete();
return false;
}
public void OnEnhancedWorkbenchDataLoaded(List<EnhancedWorkbenchSaveData> saveData)
{
CEventManager.AddListener<CEventPlayer_GameDataFinishLoaded>((EventDelegate<CEventPlayer_GameDataFinishLoaded>)OnGameDataFinishLoaded);
if (!IsEnhancedWorkbenchDataLoaded)
{
tempSaveData = saveData ?? new List<EnhancedWorkbenchSaveData>();
enhancedWorkbenchUI = ((Component)CSingleton<WorkbenchUIScreen>.Instance).gameObject.AddComponent<EnhancedWorkbenchUI>();
IsEnhancedWorkbenchDataLoaded = true;
}
}
public void OnGameDataFinishLoaded(CEventPlayer_GameDataFinishLoaded e)
{
if (IsGameDataLoaded)
{
return;
}
if (IsEnhancedWorkbenchDataLoaded)
{
foreach (InteractableWorkbench workbench in CSingleton<ShelfManager>.Instance.m_WorkbenchList)
{
InitializeWorkbench(workbench, nextWorkbenchNumber);
nextWorkbenchNumber++;
}
}
IsGameDataLoaded = true;
}
public void UpdateWorkbenchSaveData(ShelfManager shelfManager)
{
foreach (KeyValuePair<InteractableWorkbench, EnhancedWorkbench> item in WorkbenchCache)
{
item.Value.UpdateSaveIndexes(shelfManager);
}
}
public void OnExpansionUpdated()
{
if ((Object)(object)enhancedWorkbenchUI != (Object)null)
{
enhancedWorkbenchUI.OnExpansionUpdate();
}
}
private void InitializeWorkbench(InteractableWorkbench workbench, int workbenchNumber)
{
if (!WorkbenchCache.ContainsKey(workbench))
{
EnhancedWorkbench enhancedWorkbench = ((Component)workbench).gameObject.AddComponent<EnhancedWorkbench>();
enhancedWorkbench.WorkbenchNumber = workbenchNumber;
if (workbenchNumber < tempSaveData.Count)
{
enhancedWorkbench.InitFromSaveData(tempSaveData[workbenchNumber]);
}
WorkbenchCache.Add(workbench, enhancedWorkbench);
}
}
}
}
namespace EnhancedWorkbenches.Configuration
{
public static class ConfigCache
{
public static float AnimationSpeedMultiplier = 1f;
}
public class ModConfigManager
{
private static ModConfigManager instance;
private ConfigFile config;
private readonly Dictionary<string, ConfigEntryBase> entries = new Dictionary<string, ConfigEntryBase>();
public static ModConfigManager Instance => instance ?? (instance = new ModConfigManager());
private ModConfigManager()
{
}
public void Initialize(ConfigFile config)
{
this.config = config;
}
public ConfigEntry<T> BindSetting<T>(string category, string key, T value, string description = "", AcceptableValueBase acceptableValueBase = null, ConfigurationManagerAttributes configurationManagerAttributes = null)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
ConfigDescription val = new ConfigDescription(description, acceptableValueBase, new object[1] { configurationManagerAttributes });
ConfigEntry<T> val2 = config.Bind<T>(category, key, value, val);
string key2 = category + "." + key;
entries[key2] = (ConfigEntryBase)(object)val2;
return val2;
}
public T GetValue<T>(string category, string key)
{
string key2 = category + "." + key;
if (!entries.TryGetValue(key2, out var value) || !(value is ConfigEntry<T> val))
{
return default(T);
}
return val.Value;
}
public void SetValue<T>(string category, string key, T value)
{
string key2 = category + "." + key;
if (entries.TryGetValue(key2, out var value2) && value2 is ConfigEntry<T> val)
{
val.Value = value;
}
}
public ConfigEntry<T> GetEntry<T>(string category, string key)
{
string key2 = category + "." + key;
if (!entries.TryGetValue(key2, out var value) || !(value is ConfigEntry<T> result))
{
return null;
}
return result;
}
public Action OnSettingChanged<T>(string category, string key, Action<T> callback)
{
ConfigEntry<T> entry = GetEntry<T>(category, key);
if (entry == null)
{
return delegate
{
};
}
EventHandler handler = delegate
{
callback(entry.Value);
};
entry.SettingChanged += handler;
return delegate
{
entry.SettingChanged -= handler;
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}