using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterTweaks.Configuration;
using BetterTweaks.Localization;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterTweaks")]
[assembly: AssemblyDescription("Better Tweaks mod for Old Market Simulator by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("BetterTweaks")]
[assembly: AssemblyCopyright("Copyright © 2025 Ice Box Studio All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3F2504E0-4F89-11D3-9A0C-0305E82C3301")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace BetterTweaks
{
[BepInPlugin("IceBoxStudio.BetterTweaks", "BetterTweaks", "1.0.1")]
public class BetterTweaks : BaseUnityPlugin
{
public static BetterTweaks _Instance;
private Harmony _harmony;
private bool patchesApplied;
public static BetterTweaks Instance => _Instance;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
_Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
try
{
Logger.LogInfo((object)"=============================================");
Logger.LogInfo((object)("BetterTweaks " + LocalizationManager.Instance.GetLocalizedText("plugin.initializing")));
Logger.LogInfo((object)(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)"));
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
ApplyPatches();
Logger.LogInfo((object)("BetterTweaks " + LocalizationManager.Instance.GetLocalizedText("plugin.initialized")));
Logger.LogInfo((object)"=============================================");
}
catch (Exception ex)
{
Logger.LogError((object)("BetterTweaks 初始化错误: " + ex.Message + "\n" + ex.StackTrace));
}
}
private void ApplyPatches()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (!patchesApplied)
{
try
{
_harmony = new Harmony("IceBoxStudio.BetterTweaks");
_harmony.PatchAll();
patchesApplied = true;
return;
}
catch (Exception ex)
{
Logger.LogError((object)("BetterTweaks 应用补丁错误: " + ex.Message + "\n" + ex.StackTrace));
return;
}
}
Logger.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped"));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "IceBoxStudio.BetterTweaks";
public const string PLUGIN_NAME = "BetterTweaks";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace BetterTweaks.Patches
{
[HarmonyPatch(typeof(CustomCharacterController))]
public static class CharacterStatPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start_Postfix(CustomCharacterController __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("CharacterEnableOverride"))
{
float @float = ConfigManager.Instance.GetFloat("CharacterWalkSpeed", 10f);
float float2 = ConfigManager.Instance.GetFloat("CharacterJumpHeight", 10f);
float float3 = ConfigManager.Instance.GetFloat("CharacterSwimSpeed", 4f);
__instance.MaxStableMoveSpeed = @float;
__instance.JumpSpeed = float2;
__instance.SwimmingSpeed = float3;
__instance.MaxAirMoveSpeed = @float;
}
}
}
[HarmonyPatch(typeof(Checkout), "SpawnProducts")]
public static class CheckoutFixPatch
{
[HarmonyPrefix]
public static bool Prefix(Checkout __instance)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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_00d2: 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)
if (!ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride"))
{
return true;
}
if (__instance.spawnedProducts)
{
return false;
}
List<CustomerController> value = Traverse.Create((object)__instance).Field("customers").GetValue<List<CustomerController>>();
if (value == null || value.Count == 0)
{
return false;
}
List<ProductSO> shoppingCart = value[0].shoppingCart;
Transform productSlots = __instance.productSlots;
int childCount = productSlots.childCount;
if (childCount == 0)
{
return false;
}
for (int i = 0; i < shoppingCart.Count; i++)
{
int num = i % childCount;
Transform child = productSlots.GetChild(num);
ProductSO val = shoppingCart[i];
Vector3 val2 = child.position;
if (i >= childCount)
{
int num2 = i / childCount;
float num3 = (float)(num2 % 3 - 1) * 0.15f;
float num4 = (float)(num2 / 3 + 1) * 0.15f;
val2 += child.right * num3 + child.forward * num4;
}
NetworkObject component = Object.Instantiate<GameObject>(GameManager.Instance.checkoutItem, val2, child.rotation).GetComponent<NetworkObject>();
component.Spawn(false);
((Component)component).GetComponent<CheckoutItem>().ServerSetupItem(((ItemSO)val).id, __instance);
component.TrySetParent(((Component)__instance).transform, true);
}
__instance.spawnedProducts = true;
CheckoutEmployee value2 = Traverse.Create((object)__instance).Field("checkoutEmployee").GetValue<CheckoutEmployee>();
if (value2 != null)
{
value2.Work();
}
return false;
}
}
[HarmonyPatch(typeof(CheckoutEmployee), "Update")]
public static class CheckoutSpeedPatch
{
public static void Postfix(CheckoutEmployee __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("CheckoutEnableOverride") && !((Object)(object)__instance == (Object)null) && ((NetworkBehaviour)__instance).IsSpawned && (Object)(object)__instance.animator != (Object)null)
{
float @float = ConfigManager.Instance.GetFloat("CheckoutSpeedMultiplier", 2f);
if (Mathf.Abs(__instance.animator.GetFloat("speedMultiplier") - @float) > 0.01f)
{
__instance.animator.SetFloat("speedMultiplier", @float);
}
}
}
}
[HarmonyPatch(typeof(CustomerController), "SetupShoppingList")]
public static class CustomerBuyLimitPatch
{
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
bool flag = false;
for (int i = 0; i < list.Count; i++)
{
if ((list[i].opcode == OpCodes.Ldc_I4_6 || (list[i].opcode == OpCodes.Ldc_I4_S && (sbyte)list[i].operand == 6) || (list[i].opcode == OpCodes.Ldc_I4 && (int)list[i].operand == 6)) && i > 0 && list[i - 1].opcode == OpCodes.Ldc_I4_1)
{
list[i] = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CustomerBuyLimitPatch), "GetMaxBuyLimit", (Type[])null, (Type[])null));
flag = true;
break;
}
}
return list.AsEnumerable();
}
public static int GetMaxBuyLimit()
{
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride"))
{
int num = ConfigManager.Instance.GetInt("CustomerMaxBuyLimit", 5);
if (num < 1)
{
num = 1;
}
return num + 1;
}
return 6;
}
}
[HarmonyPatch]
public static class CustomerControllerPatch
{
private const float DefaultBaseSpeed = 3.5f;
[HarmonyPatch(typeof(CustomerController), "OnNetworkSpawn")]
[HarmonyPostfix]
public static void CustomerController_OnNetworkSpawn_Postfix(CustomerController __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride"))
{
float @float = ConfigManager.Instance.GetFloat("CustomerWalkSpeed", 3.5f);
NavMeshAgent component = ((Component)__instance).GetComponent<NavMeshAgent>();
if ((Object)(object)component != (Object)null)
{
component.speed = @float;
}
Animator component2 = ((Component)__instance).GetComponent<Animator>();
if ((Object)(object)component2 != (Object)null)
{
float num = @float / 3.5f;
component2.SetFloat("speedMultiplier", num);
}
}
}
[HarmonyPatch(typeof(StateSearchProduct), "OnUpdate")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> StateSearchProduct_OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(Time), "deltaTime");
MethodInfo methodInfo2 = AccessTools.Method(typeof(CustomerControllerPatch), "GetModifiedDeltaTime", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], methodInfo))
{
list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo2);
}
}
return list;
}
public static float GetModifiedDeltaTime()
{
float deltaTime = Time.deltaTime;
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride"))
{
float @float = ConfigManager.Instance.GetFloat("CustomerPickingSpeedMultiplier", 1f);
return deltaTime * @float;
}
return deltaTime;
}
}
[HarmonyPatch(typeof(GameManager))]
public static class ReputationPatch
{
[HarmonyPatch("IncrementReputationServer")]
[HarmonyPrefix]
public static bool IncrementReputationServer_Prefix(GameManager __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("ReputationEnableOverride"))
{
int @int = ConfigManager.Instance.GetInt("ReputationMaxCap", 200);
Traverse.Create((object)__instance).Field("maxReputation").SetValue((object)@int);
}
return true;
}
[HarmonyPatch("IncrementBlockReputationServer")]
[HarmonyPrefix]
public static bool IncrementBlockReputationServer_Prefix(GameManager __instance, BlockSO blockSO)
{
if (!ConfigManager.Instance.IsPatchEnabled("ReputationEnableOverride"))
{
return true;
}
if (!((NetworkBehaviour)__instance).IsServer)
{
return false;
}
NetworkVariable<int> value = Traverse.Create((object)__instance).Field("maintenance").GetValue<NetworkVariable<int>>();
NetworkVariable<int> value2 = Traverse.Create((object)__instance).Field("totalBlockReputation").GetValue<NetworkVariable<int>>();
List<long> value3 = Traverse.Create((object)__instance).Field("reputationBlockIds").GetValue<List<long>>();
if (value != null)
{
value.Value += blockSO.maintenanceCost;
}
if (value2 != null)
{
value2.Value += blockSO.blockReputation;
}
value3?.Add(((ItemSO)blockSO).id);
return false;
}
[HarmonyPatch("DecrementBlockReputationServer")]
[HarmonyPrefix]
public static bool DecrementBlockReputationServer_Prefix(GameManager __instance, BlockSO blockSO)
{
if (!ConfigManager.Instance.IsPatchEnabled("ReputationEnableOverride"))
{
return true;
}
if (!((NetworkBehaviour)__instance).IsServer)
{
return false;
}
NetworkVariable<int> value = Traverse.Create((object)__instance).Field("maintenance").GetValue<NetworkVariable<int>>();
NetworkVariable<int> value2 = Traverse.Create((object)__instance).Field("totalBlockReputation").GetValue<NetworkVariable<int>>();
List<long> value3 = Traverse.Create((object)__instance).Field("reputationBlockIds").GetValue<List<long>>();
if (NetworkManager.Singleton.ShutdownInProgress || !NetworkManager.Singleton.IsConnectedClient || !((NetworkBehaviour)__instance).IsSpawned || value == null)
{
return false;
}
value.Value -= blockSO.maintenanceCost;
if (value2 != null)
{
value2.Value -= blockSO.blockReputation;
}
if (value3 != null && value3.Contains(((ItemSO)blockSO).id))
{
value3.Remove(((ItemSO)blockSO).id);
}
return false;
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Awake_Postfix(GameManager __instance)
{
ApplyReputationCap(__instance);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start_Postfix(GameManager __instance)
{
ApplyReputationCap(__instance);
NetworkVariable<int> value = Traverse.Create((object)__instance).Field("totalBlockReputation").GetValue<NetworkVariable<int>>();
if (value != null)
{
value.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)value.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnBlockReputationChanged));
value.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)value.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnBlockReputationChanged));
}
}
private static void OnBlockReputationChanged(int previous, int current)
{
if (!((Object)(object)UIManager.Instance == (Object)null))
{
if ((Object)(object)GameManager.Instance != (Object)null)
{
UIManager.Instance.SetReputationText(GameManager.Instance.GetReputationValue());
}
int value = Traverse.Create((object)GameManager.Instance).Field("maxReputation").GetValue<int>();
UIManager.Instance.SetReputationTooltip(value);
}
}
public static void ApplyReputationCap(GameManager instance)
{
if (!((Object)(object)instance == (Object)null) && ConfigManager.Instance.IsPatchEnabled("ReputationEnableOverride"))
{
int @int = ConfigManager.Instance.GetInt("ReputationMaxCap", 200);
AccessTools.Field(typeof(GameManager), "maxReputation").SetValue(instance, @int);
}
}
}
[HarmonyPatch(typeof(PlayerInventory))]
public static class InventoryPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Awake_Postfix(PlayerInventory __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("InventoryEnableExpansion"))
{
__instance.initialActiveSlots = 4;
int @int = ConfigManager.Instance.GetInt("InventorySmallBagSlots", 6);
int int2 = ConfigManager.Instance.GetInt("InventoryMediumBagSlots", 8);
int int3 = ConfigManager.Instance.GetInt("InventoryLargeBagSlots", 10);
int maxSlots = Mathf.Max(@int, Mathf.Max(int2, int3));
__instance.maxSlots = maxSlots;
FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerInventory), "activeSlots");
if ((int)fieldInfo.GetValue(__instance) < 4)
{
fieldInfo.SetValue(__instance, 4);
}
}
}
[HarmonyPatch("OnNetworkSpawn")]
[HarmonyPostfix]
public static void OnNetworkSpawn_Postfix(PlayerInventory __instance)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
if (!ConfigManager.Instance.IsPatchEnabled("InventoryEnableExpansion") || (Object)(object)__instance == (Object)null || !((NetworkBehaviour)__instance).IsLocalPlayer || (Object)(object)__instance.itemSlots == (Object)null)
{
return;
}
GameObject itemSlots = __instance.itemSlots;
RectTransform component = itemSlots.GetComponent<RectTransform>();
if (!((Object)(object)component == (Object)null))
{
bool num = component.anchorMin.x > 0.8f;
bool flag = component.anchorMin.x < 0.2f;
float y = component.anchoredPosition.y;
component.anchorMin = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1f, 0f);
component.pivot = new Vector2(0.5f, 0f);
component.offsetMin = new Vector2(0f, 0f);
component.offsetMax = new Vector2(0f, 0f);
component.anchoredPosition = new Vector2(0f, y);
LayoutGroup component2 = itemSlots.GetComponent<LayoutGroup>();
if ((Object)(object)component2 != (Object)null && !(component2 is GridLayoutGroup))
{
Object.DestroyImmediate((Object)(object)component2);
}
GridLayoutGroup val = itemSlots.GetComponent<GridLayoutGroup>() ?? itemSlots.AddComponent<GridLayoutGroup>();
val.cellSize = new Vector2(64f, 64f);
val.spacing = new Vector2(8f, 8f);
((LayoutGroup)val).padding = new RectOffset(20, 20, 0, 0);
val.startCorner = (Corner)0;
val.startAxis = (Axis)0;
if (num)
{
((LayoutGroup)val).childAlignment = (TextAnchor)8;
}
else if (flag)
{
((LayoutGroup)val).childAlignment = (TextAnchor)6;
}
else
{
((LayoutGroup)val).childAlignment = (TextAnchor)7;
}
val.constraint = (Constraint)0;
ContentSizeFitter val2 = itemSlots.GetComponent<ContentSizeFitter>() ?? itemSlots.AddComponent<ContentSizeFitter>();
if ((Object)(object)val2 != (Object)null)
{
val2.horizontalFit = (FitMode)0;
val2.verticalFit = (FitMode)2;
}
LayoutRebuilder.ForceRebuildLayoutImmediate(component);
InventoryHintAdjuster obj = ((Component)component).GetComponent<InventoryHintAdjuster>() ?? ((Component)component).gameObject.AddComponent<InventoryHintAdjuster>();
obj.itemSlotsRect = component;
obj.inventory = __instance;
obj.UpdatePosition();
}
}
}
public class InventoryHintAdjuster : MonoBehaviour
{
public RectTransform itemSlotsRect;
public RectTransform hintPanelRect;
public RectTransform textCurrentItemRect;
public RectTransform hudNotificationRect;
public PlayerInventory inventory;
public float baseMargin = 10f;
private Vector2? defaultHintPos;
private Vector2? defaultTextPos;
private Vector2? defaultNotificationPos;
private static FieldRef<PlayerInventory, int> activeSlotsRef;
private void Start()
{
if ((Object)(object)itemSlotsRect == (Object)null)
{
itemSlotsRect = ((Component)this).GetComponent<RectTransform>();
}
if (activeSlotsRef == null)
{
activeSlotsRef = AccessTools.FieldRefAccess<PlayerInventory, int>("activeSlots");
}
}
public void UpdatePosition()
{
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: 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)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: 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_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0484: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)itemSlotsRect == (Object)null)
{
return;
}
if ((Object)(object)inventory != (Object)null)
{
Transform val = ((Component)inventory).transform.Find("Canvas");
if ((Object)(object)val != (Object)null)
{
if ((Object)(object)hintPanelRect == (Object)null)
{
Transform val2 = val.Find("ControlHintPanel");
if ((Object)(object)val2 != (Object)null)
{
hintPanelRect = ((Component)val2).GetComponent<RectTransform>();
}
}
if ((Object)(object)textCurrentItemRect == (Object)null)
{
Transform val3 = val.Find("TextCurrentItem");
if ((Object)(object)val3 != (Object)null)
{
textCurrentItemRect = ((Component)val3).GetComponent<RectTransform>();
}
}
if ((Object)(object)hudNotificationRect == (Object)null && (Object)(object)UIManager.Instance != (Object)null && (Object)(object)UIManager.Instance.panelNotifications != (Object)null)
{
hudNotificationRect = UIManager.Instance.panelNotifications.GetComponent<RectTransform>();
}
}
}
int num = 0;
if ((Object)(object)inventory != (Object)null && activeSlotsRef != null)
{
num = activeSlotsRef.Invoke(inventory);
}
Rect rect = itemSlotsRect.rect;
float height = ((Rect)(ref rect)).height;
if (height <= 1f && num > 0)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(itemSlotsRect);
rect = itemSlotsRect.rect;
height = ((Rect)(ref rect)).height;
}
float num2 = itemSlotsRect.anchoredPosition.y + height * (1f - itemSlotsRect.pivot.y);
if ((Object)(object)hintPanelRect != (Object)null && !defaultHintPos.HasValue)
{
defaultHintPos = hintPanelRect.anchoredPosition;
}
if ((Object)(object)textCurrentItemRect != (Object)null && !defaultTextPos.HasValue)
{
defaultTextPos = textCurrentItemRect.anchoredPosition;
}
if ((Object)(object)hudNotificationRect != (Object)null && !defaultNotificationPos.HasValue)
{
defaultNotificationPos = hudNotificationRect.anchoredPosition;
}
if (num <= 11)
{
if ((Object)(object)hintPanelRect != (Object)null && defaultHintPos.HasValue && Vector2.Distance(hintPanelRect.anchoredPosition, defaultHintPos.Value) > 0.1f)
{
hintPanelRect.anchoredPosition = defaultHintPos.Value;
}
if ((Object)(object)textCurrentItemRect != (Object)null && defaultTextPos.HasValue && Vector2.Distance(textCurrentItemRect.anchoredPosition, defaultTextPos.Value) > 0.1f)
{
textCurrentItemRect.anchoredPosition = defaultTextPos.Value;
}
if ((Object)(object)hudNotificationRect != (Object)null && defaultNotificationPos.HasValue && Vector2.Distance(hudNotificationRect.anchoredPosition, defaultNotificationPos.Value) > 0.1f)
{
hudNotificationRect.anchoredPosition = defaultNotificationPos.Value;
}
return;
}
if ((Object)(object)textCurrentItemRect != (Object)null)
{
float num3 = baseMargin;
float num4 = num2 + num3;
rect = textCurrentItemRect.rect;
float num5 = num4 + ((Rect)(ref rect)).height * textCurrentItemRect.pivot.y;
if (Mathf.Abs(textCurrentItemRect.anchoredPosition.y - num5) > 0.5f)
{
textCurrentItemRect.anchoredPosition = new Vector2(textCurrentItemRect.anchoredPosition.x, num5);
}
}
if ((Object)(object)hintPanelRect != (Object)null)
{
float num6 = baseMargin;
float num7 = num2 + num6;
rect = hintPanelRect.rect;
float num8 = num7 + ((Rect)(ref rect)).height * hintPanelRect.pivot.y;
if (Mathf.Abs(hintPanelRect.anchoredPosition.y - num8) > 0.5f)
{
hintPanelRect.anchoredPosition = new Vector2(hintPanelRect.anchoredPosition.x, num8);
}
}
if ((Object)(object)hudNotificationRect != (Object)null)
{
float num9 = baseMargin;
float num10 = num2 + num9;
rect = hudNotificationRect.rect;
float num11 = num10 + ((Rect)(ref rect)).height * hudNotificationRect.pivot.y;
if (Mathf.Abs(hudNotificationRect.anchoredPosition.y - num11) > 0.5f)
{
hudNotificationRect.anchoredPosition = new Vector2(hudNotificationRect.anchoredPosition.x, num11);
}
}
}
private void LateUpdate()
{
UpdatePosition();
}
}
[HarmonyPatch(typeof(GameManager))]
public static class GameManagerInventoryPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start_Postfix(GameManager __instance)
{
if ((Object)(object)__instance == (Object)null || !ConfigManager.Instance.IsPatchEnabled("InventoryEnableExpansion"))
{
return;
}
int @int = ConfigManager.Instance.GetInt("InventorySmallBagSlots", 6);
int int2 = ConfigManager.Instance.GetInt("InventoryMediumBagSlots", 8);
int int3 = ConfigManager.Instance.GetInt("InventoryLargeBagSlots", 10);
foreach (KeyValuePair<long, int> item in new Dictionary<long, int>
{
{ 1762012561374L, @int },
{ 1762012563854L, int2 },
{ 1762012566188L, int3 },
{ 1723119578732L, @int },
{ 1724065582831L, int2 },
{ 1724065590030L, int3 }
})
{
long key = item.Key;
int value = item.Value;
ItemSO itemById = __instance.GetItemById(key);
BagSO val = (BagSO)(object)((itemById is BagSO) ? itemById : null);
if (val != null && val.activeSlots != value)
{
val.activeSlots = value;
}
}
}
}
[HarmonyPatch]
public static class NPCSpeedPatch
{
private const float DefaultBaseSpeed = 3.5f;
[HarmonyPatch(typeof(RestockerController), "UpdateEmployee")]
[HarmonyPostfix]
public static void RestockerController_UpdateEmployee_Postfix(RestockerController __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride"))
{
float @float = ConfigManager.Instance.GetFloat("NPCWalkSpeed", 3.5f);
if ((Object)(object)__instance.agent != (Object)null)
{
__instance.agent.speed = @float;
}
Animator component = ((Component)__instance).GetComponent<Animator>();
if ((Object)(object)component != (Object)null)
{
float num = @float / 3.5f;
component.SetFloat("speedMultiplier", num);
}
}
}
[HarmonyPatch(typeof(CleanerController), "OnNetworkSpawn")]
[HarmonyPostfix]
public static void CleanerController_OnNetworkSpawn_Postfix(CleanerController __instance)
{
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride") && ((NetworkBehaviour)__instance).IsServer && (Object)(object)__instance.agent != (Object)null)
{
float @float = ConfigManager.Instance.GetFloat("NPCWalkSpeed", 3.5f);
__instance.agent.speed = @float;
}
}
[HarmonyPatch(typeof(CleanerController), "Update")]
[HarmonyPrefix]
public static void CleanerController_Update_Prefix(CleanerController __instance)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.Instance.IsPatchEnabled("NPCEnableOverride") && (Object)(object)__instance.animator != (Object)null)
{
float speed = ConfigManager.Instance.GetFloat("NPCWalkSpeed", 3.5f) / 3.5f;
AnimatorStateInfo currentAnimatorStateInfo = __instance.animator.GetCurrentAnimatorStateInfo(0);
if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Standard Walking"))
{
__instance.animator.speed = speed;
}
else
{
__instance.animator.speed = 1f;
}
}
}
}
}
namespace BetterTweaks.Localization
{
public static class LocalizationHelper
{
public static Dictionary<string, string> GetDefaultTranslations(string language)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
switch (language)
{
case "zh":
dictionary.Add("plugin.initializing", "开始初始化...");
dictionary.Add("plugin.author_prefix", "作者:");
dictionary.Add("plugin.initialized", "初始化成功!");
dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过...");
dictionary.Add("config.inventory_enable_expansion", "启用背包扩展功能");
dictionary.Add("config.inventory_small_bag_slots", "小袋格子数\n铺满一行:26");
dictionary.Add("config.inventory_medium_bag_slots", "中袋格子数\n铺满一行:26");
dictionary.Add("config.inventory_large_bag_slots", "大袋格子数\n铺满一行:26");
dictionary.Add("config.reputation_enable_override", "启用声誉上限修改功能");
dictionary.Add("config.reputation_max_cap", "设置声誉上限数值\n默认上限:200");
dictionary.Add("config.character_enable_override", "启用角色属性修改功能");
dictionary.Add("config.character_walk_speed", "角色移动速度\n默认:10.0");
dictionary.Add("config.character_jump_height", "角色跳跃高度\n默认:10.0");
dictionary.Add("config.character_swim_speed", "角色游泳速度\n默认:4.0");
dictionary.Add("config.npc_enable_override", "启用 NPC 属性修改功能");
dictionary.Add("config.npc_walk_speed", "雇员 NPC 移动速度\n默认:3.5");
dictionary.Add("config.customer_walk_speed", "顾客 NPC 移动速度\n默认:3.5");
dictionary.Add("config.customer_max_buy_limit", "顾客 NPC 最大购买数量\n默认:5");
dictionary.Add("config.customer_picking_speed_multiplier", "顾客 NPC 拿取物品速度倍率\n默认:1.0");
dictionary.Add("config.checkout_enable_override", "启用结账速度调整功能");
dictionary.Add("config.checkout_speed_multiplier", "结账速度倍率\n默认:2.0");
break;
case "zh-Hant":
dictionary.Add("plugin.initializing", "開始初始化...");
dictionary.Add("plugin.author_prefix", "作者:");
dictionary.Add("plugin.initialized", "初始化成功!");
dictionary.Add("plugin.patches_skipped", "補丁已應用,跳過...");
dictionary.Add("config.inventory_enable_expansion", "啟用背包擴展功能");
dictionary.Add("config.inventory_small_bag_slots", "小袋格子數\n鋪滿一行:26");
dictionary.Add("config.inventory_medium_bag_slots", "中袋格子數\n鋪滿一行:26");
dictionary.Add("config.inventory_large_bag_slots", "大袋格子數\n鋪滿一行:26");
dictionary.Add("config.reputation_enable_override", "啟用聲譽上限修改功能");
dictionary.Add("config.reputation_max_cap", "設置聲譽上限數值\n默認上限:200");
dictionary.Add("config.character_enable_override", "啟用角色屬性修改功能");
dictionary.Add("config.character_walk_speed", "角色移動速度\n默認:10.0");
dictionary.Add("config.character_jump_height", "角色跳躍高度\n默認:10.0");
dictionary.Add("config.character_swim_speed", "角色游泳速度\n默認:4.0");
dictionary.Add("config.npc_enable_override", "啟用 NPC 屬性修改功能");
dictionary.Add("config.npc_walk_speed", "僱員 NPC 移動速度\n默認:3.5");
dictionary.Add("config.customer_walk_speed", "顧客 NPC 移動速度\n默認:3.5");
dictionary.Add("config.customer_max_buy_limit", "顧客 NPC 最大購買數量\n默認:5");
dictionary.Add("config.customer_picking_speed_multiplier", "顧客 NPC 拿取物品速度倍率\n默認:1.0");
dictionary.Add("config.checkout_enable_override", "啟用結賬速度調整功能");
dictionary.Add("config.checkout_speed_multiplier", "結賬速度倍率\n默認:2.0");
break;
case "en":
dictionary.Add("plugin.initializing", "Initializing...");
dictionary.Add("plugin.author_prefix", "Author: ");
dictionary.Add("plugin.initialized", "Initialized successfully!");
dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping...");
dictionary.Add("config.inventory_enable_expansion", "Enable Backpack Expansion");
dictionary.Add("config.inventory_small_bag_slots", "Small Bag Slots\nFull row: 26");
dictionary.Add("config.inventory_medium_bag_slots", "Medium Bag Slots\nFull row: 26");
dictionary.Add("config.inventory_large_bag_slots", "Large Bag Slots\nFull row: 26");
dictionary.Add("config.reputation_enable_override", "Enable Reputation Cap Modification");
dictionary.Add("config.reputation_max_cap", "Set Reputation Cap\nDefault cap: 200");
dictionary.Add("config.character_enable_override", "Enable Character Attributes Modification");
dictionary.Add("config.character_walk_speed", "Character Walk Speed\nDefault: 10.0");
dictionary.Add("config.character_jump_height", "Character Jump Height\nDefault: 10.0");
dictionary.Add("config.character_swim_speed", "Character Swim Speed\nDefault: 4.0");
dictionary.Add("config.npc_enable_override", "Enable NPC Attributes Modification");
dictionary.Add("config.npc_walk_speed", "Employee NPC Walk Speed\nDefault: 3.5");
dictionary.Add("config.customer_walk_speed", "Customer NPC Walk Speed\nDefault: 3.5");
dictionary.Add("config.customer_max_buy_limit", "Customer NPC Max Buy Limit\nDefault: 5");
dictionary.Add("config.customer_picking_speed_multiplier", "Customer NPC Item Picking Speed Multiplier\nDefault: 1.0");
dictionary.Add("config.checkout_enable_override", "Enable Checkout Speed Modification");
dictionary.Add("config.checkout_speed_multiplier", "Checkout Speed Multiplier\nDefault: 2.0");
break;
case "ja":
dictionary.Add("plugin.initializing", "初期化中...");
dictionary.Add("plugin.author_prefix", "作者:");
dictionary.Add("plugin.initialized", "初期化成功!");
dictionary.Add("plugin.patches_skipped", "パッチは既に適用されています、スキップします...");
dictionary.Add("config.inventory_enable_expansion", "バックパック拡張機能を有効にする");
dictionary.Add("config.inventory_small_bag_slots", "小バッグのスロット数\n1行:26");
dictionary.Add("config.inventory_medium_bag_slots", "中バッグのスロット数\n1行:26");
dictionary.Add("config.inventory_large_bag_slots", "大バッグのスロット数\n1行:26");
dictionary.Add("config.reputation_enable_override", "評判上限変更機能を有効にする");
dictionary.Add("config.reputation_max_cap", "評判上限を設定\nデフォルト上限:200");
dictionary.Add("config.character_enable_override", "キャラクター属性変更機能を有効にする");
dictionary.Add("config.character_walk_speed", "キャラクターの移動速度\nデフォルト:10.0");
dictionary.Add("config.character_jump_height", "キャラクターのジャンプ力\nデフォルト:10.0");
dictionary.Add("config.character_swim_speed", "キャラクターの泳ぐ速度\nデフォルト:4.0");
dictionary.Add("config.npc_enable_override", "NPC属性変更機能を有効にする");
dictionary.Add("config.npc_walk_speed", "従業員NPCの移動速度\nデフォルト:3.5");
dictionary.Add("config.customer_walk_speed", "顧客NPCの移動速度\nデフォルト:3.5");
dictionary.Add("config.customer_max_buy_limit", "顧客NPCの最大購入数\nデフォルト:5");
dictionary.Add("config.customer_picking_speed_multiplier", "顧客NPCのアイテム取得速度倍率\nデフォルト:1.0");
dictionary.Add("config.checkout_enable_override", "レジ速度調整機能を有効にする");
dictionary.Add("config.checkout_speed_multiplier", "レジ速度倍率\nデフォルト:2.0");
break;
}
return dictionary;
}
}
public class LocalizationManager
{
private static LocalizationManager _instance;
private readonly Dictionary<string, Dictionary<string, string>> _localizations = new Dictionary<string, Dictionary<string, string>>();
private string _currentLocale = "zh";
public static readonly string[] SupportedLanguages = new string[12]
{
"zh", "zh-Hant", "en", "fr", "de", "ja", "ko", "pt", "ru", "es",
"tr", "uk"
};
public static LocalizationManager Instance => _instance ?? (_instance = new LocalizationManager());
private LocalizationManager()
{
Initialize();
}
public void Initialize()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)LocalizationSettings.SelectedLocale != (Object)null)
{
LocaleIdentifier identifier = LocalizationSettings.SelectedLocale.Identifier;
_currentLocale = ((LocaleIdentifier)(ref identifier)).Code;
}
string[] supportedLanguages = SupportedLanguages;
foreach (string text in supportedLanguages)
{
Dictionary<string, string> defaultTranslations = LocalizationHelper.GetDefaultTranslations(text);
if (defaultTranslations != null && defaultTranslations.Count > 0)
{
_localizations[text] = defaultTranslations;
}
}
LocalizationSettings.SelectedLocaleChanged += OnGameLanguageChanged;
}
private void OnGameLanguageChanged(Locale locale)
{
//IL_000a: 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)
if ((Object)(object)locale != (Object)null)
{
LocaleIdentifier identifier = locale.Identifier;
string code = ((LocaleIdentifier)(ref identifier)).Code;
if (_localizations.ContainsKey(code))
{
_currentLocale = code;
}
else
{
_currentLocale = "en";
}
}
}
public string GetLocalizedText(string key, params object[] args)
{
if (string.IsNullOrEmpty(_currentLocale) || !_localizations.ContainsKey(_currentLocale))
{
_currentLocale = "en";
}
if (_localizations.ContainsKey(_currentLocale) && _localizations[_currentLocale].TryGetValue(key, out var value))
{
if (args.Length == 0)
{
return value;
}
return string.Format(value, args);
}
if (_currentLocale != "en" && _localizations.ContainsKey("en") && _localizations["en"].TryGetValue(key, out var value2))
{
if (args.Length == 0)
{
return value2;
}
return string.Format(value2, args);
}
if (_localizations.ContainsKey("zh") && _localizations["zh"].TryGetValue(key, out var value3))
{
if (args.Length == 0)
{
return value3;
}
return string.Format(value3, args);
}
return key;
}
}
}
namespace BetterTweaks.Configuration
{
public class ConfigManager
{
private static ConfigManager _instance;
private readonly ConfigFile _configFile;
private readonly Dictionary<string, ConfigEntry<bool>> _patchConfigs;
private readonly Dictionary<string, ConfigEntry<string>> _hotkeyConfigs;
private readonly Dictionary<string, ConfigEntry<int>> _intConfigs;
private readonly Dictionary<string, ConfigEntry<float>> _floatConfigs;
public static ConfigManager Instance => _instance;
private ConfigManager(ConfigFile configFile)
{
_configFile = configFile;
_patchConfigs = new Dictionary<string, ConfigEntry<bool>>();
_hotkeyConfigs = new Dictionary<string, ConfigEntry<string>>();
_intConfigs = new Dictionary<string, ConfigEntry<int>>();
_floatConfigs = new Dictionary<string, ConfigEntry<float>>();
InitializeDefaultConfigs();
}
public static void Initialize(ConfigFile configFile)
{
if (_instance == null)
{
_instance = new ConfigManager(configFile);
}
}
private void InitializeDefaultConfigs()
{
RegisterPatch("背包相关 - Backpack related", "InventoryEnableExpansion", GetLocalizedDescription("config.inventory_enable_expansion"), defaultValue: true);
RegisterInt("背包相关 - Backpack related", "InventorySmallBagSlots", GetLocalizedDescription("config.inventory_small_bag_slots"), 6);
RegisterInt("背包相关 - Backpack related", "InventoryMediumBagSlots", GetLocalizedDescription("config.inventory_medium_bag_slots"), 8);
RegisterInt("背包相关 - Backpack related", "InventoryLargeBagSlots", GetLocalizedDescription("config.inventory_large_bag_slots"), 10);
RegisterPatch("声誉相关 - Reputation related", "ReputationEnableOverride", GetLocalizedDescription("config.reputation_enable_override"), defaultValue: false);
RegisterInt("声誉相关 - Reputation related", "ReputationMaxCap", GetLocalizedDescription("config.reputation_max_cap"), 200);
RegisterPatch("角色相关 - Character related", "CharacterEnableOverride", GetLocalizedDescription("config.character_enable_override"), defaultValue: false);
RegisterFloat("角色相关 - Character related", "CharacterWalkSpeed", GetLocalizedDescription("config.character_walk_speed"), 10f);
RegisterFloat("角色相关 - Character related", "CharacterJumpHeight", GetLocalizedDescription("config.character_jump_height"), 10f);
RegisterFloat("角色相关 - Character related", "CharacterSwimSpeed", GetLocalizedDescription("config.character_swim_speed"), 4f);
RegisterPatch("NPC相关 - NPC related", "NPCEnableOverride", GetLocalizedDescription("config.npc_enable_override"), defaultValue: false);
RegisterFloat("NPC相关 - NPC related", "NPCWalkSpeed", GetLocalizedDescription("config.npc_walk_speed"), 3.5f);
RegisterFloat("NPC相关 - NPC related", "CustomerWalkSpeed", GetLocalizedDescription("config.customer_walk_speed"), 3.5f);
RegisterInt("NPC相关 - NPC related", "CustomerMaxBuyLimit", GetLocalizedDescription("config.customer_max_buy_limit"), 5);
RegisterFloat("NPC相关 - NPC related", "CustomerPickingSpeedMultiplier", GetLocalizedDescription("config.customer_picking_speed_multiplier"), 1f);
RegisterPatch("结账相关 - Checkout related", "CheckoutEnableOverride", GetLocalizedDescription("config.checkout_enable_override"), defaultValue: false);
RegisterFloat("结账相关 - Checkout related", "CheckoutSpeedMultiplier", GetLocalizedDescription("config.checkout_speed_multiplier"), 2f);
}
private string GetLocalizedDescription(string key)
{
return LocalizationManager.Instance?.GetLocalizedText(key);
}
public void RegisterPatch(string section, string patchName, string description, bool defaultValue)
{
ConfigEntry<bool> value = _configFile.Bind<bool>(section, patchName, defaultValue, description);
_patchConfigs[patchName] = value;
}
public void RegisterHotkey(string section, string hotkeyName, string description, string defaultValue)
{
ConfigEntry<string> value = _configFile.Bind<string>(section, hotkeyName, defaultValue, description);
_hotkeyConfigs[hotkeyName] = value;
}
public void RegisterInt(string section, string name, string description, int defaultValue)
{
ConfigEntry<int> value = _configFile.Bind<int>(section, name, defaultValue, description);
_intConfigs[name] = value;
}
public void RegisterFloat(string section, string name, string description, float defaultValue)
{
ConfigEntry<float> value = _configFile.Bind<float>(section, name, defaultValue, description);
_floatConfigs[name] = value;
}
public bool IsPatchEnabled(string patchName)
{
if (_patchConfigs.TryGetValue(patchName, out var value))
{
return value.Value;
}
return false;
}
public string GetHotkey(string hotkeyName)
{
if (!_hotkeyConfigs.TryGetValue(hotkeyName, out var value))
{
return null;
}
return value.Value;
}
public int GetInt(string name, int fallback)
{
if (!_intConfigs.TryGetValue(name, out var value))
{
return fallback;
}
return value.Value;
}
public float GetFloat(string name, float fallback)
{
if (!_floatConfigs.TryGetValue(name, out var value))
{
return fallback;
}
return value.Value;
}
}
public static class PatchNames
{
public const string InventoryEnableExpansion = "InventoryEnableExpansion";
public const string InventorySmallBagSlots = "InventorySmallBagSlots";
public const string InventoryMediumBagSlots = "InventoryMediumBagSlots";
public const string InventoryLargeBagSlots = "InventoryLargeBagSlots";
public const string ReputationEnableOverride = "ReputationEnableOverride";
public const string ReputationMaxCap = "ReputationMaxCap";
public const string CharacterEnableOverride = "CharacterEnableOverride";
public const string CharacterWalkSpeed = "CharacterWalkSpeed";
public const string CharacterJumpHeight = "CharacterJumpHeight";
public const string CharacterSwimSpeed = "CharacterSwimSpeed";
public const string NPCEnableOverride = "NPCEnableOverride";
public const string NPCWalkSpeed = "NPCWalkSpeed";
public const string CustomerWalkSpeed = "CustomerWalkSpeed";
public const string CustomerMaxBuyLimit = "CustomerMaxBuyLimit";
public const string CustomerPickingSpeedMultiplier = "CustomerPickingSpeedMultiplier";
public const string CheckoutEnableOverride = "CheckoutEnableOverride";
public const string CheckoutSpeedMultiplier = "CheckoutSpeedMultiplier";
}
}