using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SossMultipliers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SossMultipliers")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0d875b7-3a4f-4fbb-bc25-d82bde2ed4d9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(Bedroom), "OnCustomerEnter")]
public class BedroomTimer
{
private static void Postfix(Bedroom __instance)
{
FieldInfo field = typeof(Bedroom).GetField("restTime", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
int num = (int)field.GetValue(__instance);
float bedroomTimerMultiplier = MainValues.Instance.bedroomTimerMultiplier;
ushort restTime = (ushort)((float)num * bedroomTimerMultiplier);
__instance.SetRestTime(restTime);
}
}
}
[HarmonyPatch]
public class BedroomRewards
{
[HarmonyPatch(typeof(BedroomManager), "GetExpReward")]
[HarmonyPostfix]
private static void Postfix_GetExpReward(ref uint __result)
{
float bedroomXpMultiplier = MainValues.Instance.bedroomXpMultiplier;
__result = (uint)((float)__result * bedroomXpMultiplier);
}
[HarmonyPatch(typeof(BedroomManager), "GetMoneyReward")]
[HarmonyPostfix]
private static void Postfix_GetMoneyReward(ref ulong __result)
{
float bedroomMoneyMultiplier = MainValues.Instance.bedroomMoneyMultiplier;
__result = (ulong)((float)__result * bedroomMoneyMultiplier);
}
}
[HarmonyPatch(typeof(GardenBed), "UpdateC")]
public class GrowTimer
{
[CompilerGenerated]
private sealed class <CustomUpdate>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public GardenBed gardenBed;
private FieldInfo <growPercentField>5__1;
private FieldInfo <plantTotalGrowTimeField>5__2;
private object <growPercent>5__3;
private float <plantTotalGrowTime>5__4;
private float <num>5__5;
private BannerData <bannerData>5__6;
private byte <percent>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CustomUpdate>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<growPercentField>5__1 = null;
<plantTotalGrowTimeField>5__2 = null;
<growPercent>5__3 = null;
<bannerData>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Invalid comparison between Unknown and I4
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<growPercentField>5__1 = typeof(GardenBed).GetField("growPercent", BindingFlags.Instance | BindingFlags.NonPublic);
<plantTotalGrowTimeField>5__2 = typeof(GardenBed).GetField("plantTotalGrowTime", BindingFlags.Instance | BindingFlags.NonPublic);
if (<growPercentField>5__1 == null || <plantTotalGrowTimeField>5__2 == null)
{
Debug.LogWarning((object)"GrowTimer patch: Impossible d'accéder à growPercent ou plantTotalGrowTime");
return false;
}
<growPercent>5__3 = <growPercentField>5__1.GetValue(gardenBed);
<plantTotalGrowTime>5__4 = (float)<plantTotalGrowTimeField>5__2.GetValue(gardenBed);
break;
case 1:
<>1__state = -1;
<num>5__5 = 1f;
if (gardenBed.isWatered.Value)
{
<num>5__5 *= 2f;
}
if (BannerManager.Instance.IsBannerActive((BannerType)10) && BannerManager.Instance.TryGetBannerData((BannerType)13, ref <bannerData>5__6))
{
<num>5__5 *= <bannerData>5__6.effectMultiplier;
}
<num>5__5 /= MainValues.Instance.growTimerMultiplier;
if (gardenBed.remainingGrowTime > <num>5__5)
{
GardenBed obj = gardenBed;
obj.remainingGrowTime -= <num>5__5;
<percent>5__7 = (byte)(100f * (<plantTotalGrowTime>5__4 - gardenBed.remainingGrowTime) / <plantTotalGrowTime>5__4);
<growPercentField>5__1.FieldType.GetProperty("Value").SetValue(<growPercent>5__3, <percent>5__7);
}
else
{
gardenBed.remainingGrowTime = 0f;
<growPercentField>5__1.FieldType.GetProperty("Value").SetValue(<growPercent>5__3, (byte)100);
gardenBed.state.Value = (State)3;
}
<bannerData>5__6 = null;
break;
}
if ((int)gardenBed.state.Value == 2)
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool Prefix(GardenBed __instance, ref IEnumerator __result)
{
__result = CustomUpdate(__instance);
return false;
}
[IteratorStateMachine(typeof(<CustomUpdate>d__1))]
private static IEnumerator CustomUpdate(GardenBed gardenBed)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CustomUpdate>d__1(0)
{
gardenBed = gardenBed
};
}
}
[HarmonyPatch(typeof(HelperSupplier), "TakeLootServerRpc")]
public class FluffyLoot
{
private static void Postfix(HelperSupplier __instance)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
float fluffyLootMultiplier = MainValues.Instance.fluffyLootMultiplier;
FieldInfo fieldInfo = AccessTools.Field(typeof(HelperSupplier), "lootItems");
if (!(fieldInfo.GetValue(__instance) is IEnumerable<object> enumerable))
{
Debug.LogWarning((object)"[FluffyLoot] lootItems is null or inaccessible.");
return;
}
foreach (object item in enumerable)
{
FieldInfo fieldInfo2 = AccessTools.Field(item.GetType(), "amount");
Vector2Int val = (Vector2Int)fieldInfo2.GetValue(item);
int num = Mathf.RoundToInt((float)((Vector2Int)(ref val)).x * fluffyLootMultiplier);
int num2 = Mathf.RoundToInt((float)((Vector2Int)(ref val)).y * fluffyLootMultiplier);
num = Mathf.Max(1, num);
num2 = Mathf.Max(num, num2);
fieldInfo2.SetValue(item, (object)new Vector2Int(num, num2));
}
}
}
[HarmonyPatch(typeof(HelperSupplier), "SearchForLoot")]
public class FluffyTimer
{
[CompilerGenerated]
private sealed class <Postfix>d__0 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public IEnumerator __result;
public HelperSupplier __instance;
private float <multiplier>5__1;
private FieldInfo <searchDurationField>5__2;
private int <baseSearchDuration>5__3;
private float <modifiedDuration>5__4;
private object <current>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Postfix>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<searchDurationField>5__2 = null;
<current>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<multiplier>5__1 = MainValues.Instance.fluffyTimerMultiplier;
<searchDurationField>5__2 = AccessTools.Field(typeof(HelperSupplier), "searchDuration");
<baseSearchDuration>5__3 = 3;
if (<searchDurationField>5__2 != null)
{
<baseSearchDuration>5__3 = (int)<searchDurationField>5__2.GetValue(__instance);
}
<modifiedDuration>5__4 = (float)<baseSearchDuration>5__3 * <multiplier>5__1;
break;
case 1:
<>1__state = -1;
goto IL_011b;
case 2:
<>1__state = -1;
goto IL_011b;
case 3:
{
<>1__state = -1;
<current>5__5 = null;
break;
}
IL_011b:
if (__result.MoveNext())
{
<>2__current = __result.Current;
<>1__state = 2;
return true;
}
return false;
}
if (__result.MoveNext())
{
<current>5__5 = __result.Current;
if (<current>5__5 is WaitForSeconds)
{
<>2__current = (object)new WaitForSeconds(<modifiedDuration>5__4);
<>1__state = 1;
return true;
}
<>2__current = <current>5__5;
<>1__state = 3;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<Postfix>d__0))]
private static IEnumerator Postfix(IEnumerator __result, HelperSupplier __instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Postfix>d__0(0)
{
__result = __result,
__instance = __instance
};
}
}
[HarmonyPatch]
public static class QuestDisplay
{
[HarmonyPatch(typeof(QuestBoardUI), "UpdTasks")]
[HarmonyPostfix]
public static void QuestBoardUI_UpdTasks_Postfix(ushort questId, QuestBoardUI __instance)
{
QuestData val = default(QuestData);
if (questId == 0 || !QuestManager.Instance.GetQuestData(questId, ref val) || val.moneyReward <= 0)
{
return;
}
int num = Mathf.CeilToInt((float)(int)val.moneyReward * MainValues.Instance.questMoneyMultiplier);
FieldInfo field = typeof(QuestBoardUI).GetField("rewardItems", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(QuestBoardUI).GetField("moneyItemData", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null && field2 != null)
{
ItemUI[] array = field.GetValue(__instance) as ItemUI[];
object? value = field2.GetValue(__instance);
ItemData val2 = (ItemData)((value is ItemData) ? value : null);
if (array != null && array.Length != 0 && (Object)(object)val2 != (Object)null)
{
array[0].Set(val2, num);
}
}
}
[HarmonyPatch(typeof(QuestUI), "UpdTasks")]
[HarmonyPostfix]
public static void QuestUI_UpdTasks_Postfix(ushort questId, QuestUI __instance)
{
QuestData val = default(QuestData);
if (questId == 0 || !QuestManager.Instance.GetQuestData(questId, ref val) || val.moneyReward <= 0)
{
return;
}
int num = Mathf.CeilToInt((float)(int)val.moneyReward * MainValues.Instance.questMoneyMultiplier);
FieldInfo field = typeof(QuestUI).GetField("rewardItems", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(QuestUI).GetField("moneyItemData", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null && field2 != null)
{
ItemUI[] array = field.GetValue(__instance) as ItemUI[];
object? value = field2.GetValue(__instance);
ItemData val2 = (ItemData)((value is ItemData) ? value : null);
if (array != null && array.Length != 0 && (Object)(object)val2 != (Object)null)
{
array[0].Set(val2, num);
}
}
}
}
[HarmonyPatch(typeof(QuestManager), "OnQuestComplete")]
public class QuestRewards
{
private static void Prefix(ushort questId, bool fail)
{
QuestData val = default(QuestData);
if (!fail && !((Object)(object)QuestManager.Instance == (Object)null) && QuestManager.Instance.GetQuestData(questId, ref val) && val.moneyReward > 0)
{
float questMoneyMultiplier = MainValues.Instance.questMoneyMultiplier;
ulong num = val.moneyReward;
ulong num2 = (ulong)((float)num * questMoneyMultiplier);
val.moneyReward = (ushort)num2;
}
}
}
[HarmonyPatch(typeof(RecipeMenuElement), "SetItem")]
public static class RecipeMenuElement_SetItem_Patch
{
public static void Postfix(RecipeMenuElement __instance, RecipeData recipeData, ItemData itemData, bool isOn, bool isLocked, FoodMenuUI fm, int exp)
{
try
{
Traverse val = Traverse.Create((object)__instance);
TextMeshProUGUI value = val.Field<TextMeshProUGUI>("_reward").Value;
TextMeshProUGUI value2 = val.Field<TextMeshProUGUI>("_variety").Value;
float num = MainValues.Instance?.dishXpMultiplier ?? 1f;
float num2 = MainValues.Instance?.dishMoneyMultiplier ?? 1f;
int num3 = Mathf.RoundToInt((float)exp * num);
((TMP_Text)value).text = Mathf.RoundToInt((float)recipeData.moneyReward * num2).ToString();
((TMP_Text)value2).text = $"{num3} xp";
}
catch (Exception arg)
{
Debug.LogError((object)$"[MainValues] Error in SetItem Patch : {arg}");
}
}
}
[HarmonyPatch(typeof(Customer), "GetReward")]
public class Patch_GetReward
{
private static void Prefix(Customer __instance)
{
Traverse val = Traverse.Create((object)__instance);
ulong value = val.Field<ulong>("currentMoneyReward").Value;
int value2 = val.Field<int>("currentExpReward").Value;
ulong num = (ulong)((float)value * MainValues.Instance.dishMoneyMultiplier);
int num2 = (int)((float)value2 * MainValues.Instance.dishXpMultiplier);
val.Field("currentMoneyReward").SetValue((object)num);
val.Field("currentExpReward").SetValue((object)num2);
}
}
[BepInPlugin("Soss.Multipliers", "Soss Multipliers", "1.0.0")]
public class MainValues : BaseUnityPlugin
{
public static MainValues Instance;
public ConfigEntry<float> DishXPMultiplierCfg;
public ConfigEntry<float> DishMoneyMultiplierCfg;
public ConfigEntry<float> BedroomTimerMultiplierCfg;
public ConfigEntry<float> BedroomXPMultiplierCfg;
public ConfigEntry<float> BedroomMoneyMultiplierCfg;
public ConfigEntry<float> QuestMoneyMultiplierCfg;
public ConfigEntry<float> FluffyTimerMultiplierCfg;
public ConfigEntry<float> FluffyLootMultiplierCfg;
public ConfigEntry<float> GrowTimerMultiplierCfg;
public float dishXpMultiplier => DishXPMultiplierCfg.Value;
public float dishMoneyMultiplier => DishMoneyMultiplierCfg.Value;
public float bedroomTimerMultiplier => BedroomTimerMultiplierCfg.Value;
public float bedroomXpMultiplier => BedroomXPMultiplierCfg.Value;
public float bedroomMoneyMultiplier => BedroomMoneyMultiplierCfg.Value;
public float questMoneyMultiplier => QuestMoneyMultiplierCfg.Value;
public float fluffyTimerMultiplier => FluffyTimerMultiplierCfg.Value;
public float fluffyLootMultiplier => FluffyLootMultiplierCfg.Value;
public float growTimerMultiplier => GrowTimerMultiplierCfg.Value;
private void Awake()
{
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
Instance = this;
DishXPMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Dish Multipliers", "Recipe XP", 0.3f, "Multiplier applied to experience points earned per dish.");
DishMoneyMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Dish Multipliers", "Recipe Money", 0.4f, "Multiplier applied to money earned per dish.");
BedroomTimerMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Bedroom Multipliers", "Bedroom Time", 0.5f, "Multiplier applied to time spent in bedroom by customers. Base time is 10 minutes.");
BedroomXPMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Bedroom Multipliers", "Bedroom XP", 0.4f, "Multiplier applied to xp earned per bedrooms.");
BedroomMoneyMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Bedroom Multipliers", "Bedroom Money", 0.4f, "Multiplier applied to money earned per bedrooms.");
QuestMoneyMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Quest Multipliers", "Quest Money", 0.5f, "Multiplier applied to money earned per quests.");
FluffyTimerMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Fluffy Multipliers", "Looting Time", 1.5f, "Multiplier applied to time spent by Fluffy searching for loot. Base time is 8 minutes.");
FluffyLootMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Fluffy Multipliers", "Loot Quantity", 0.5f, "Multiplier applied to the quantity of loot gathered by Fluffy.");
GrowTimerMultiplierCfg = ((BaseUnityPlugin)this).Config.Bind<float>("Garden Multipliers", "Growth Time", 3f, "Multiplier applied to time for plants to grow.");
Harmony val = new Harmony("Soss.MainValues");
val.PatchAll();
}
private void LogModLoaded()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Soss Multipliers 1.0.0 Mod Loaded!");
}
}