Initial commit

This commit is contained in:
pan.codes 2024-05-02 19:16:26 +02:00
commit 0afdc1d02f
93 changed files with 2453 additions and 0 deletions

View file

@ -0,0 +1,27 @@
using HarmonyLib;
using System.Collections.Generic;
using System.Reflection.Emit;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(CheckoutChangeManager), "AddOrRemoveMoney")]
public static class CheckoutChangeManager_AddOrRemoveMoney_Patch
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (var instruction in instructions)
{
// Check if the instruction loads the constant 1f onto the stack
if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 1f)
{
// Replace the constant 1f with your desired value (e.g., 2f)
yield return new CodeInstruction(OpCodes.Ldc_R4, Plugin.LowestBill.Value);
}
else
{
yield return instruction;
}
}
}
}
}

View file

@ -0,0 +1,35 @@
using HarmonyLib;
using MyBox;
using System.Linq;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(CheckoutChangeManager), "SpawnMoney")]
public static class CheckoutChangeManager_SpawnMoney_Patch
{
public static void Prefix(CheckoutChangeManager __instance, MoneyPack moneyPack)
{
var log = Plugin.StaticLogger.LogInfo;
log("moneyPack");
log(moneyPack);
}
}
[HarmonyPatch(typeof(CheckoutChangeManager), "DespawnMoney")]
public static class CheckoutChangeManager_DespawnMoney_Patch
{
public static void Prefix(CheckoutChangeManager __instance)
{
return;
var log = Plugin.StaticLogger.LogInfo;
log("m_SpawnedMoney");
__instance.m_SpawnedMoney.ForEach(x => log(x.m_Value));
log("m_SpawnedCoin");
__instance.m_SpawnedCoin.ForEach(x => log(x.m_Value));
log("m_MoneyPacks");
__instance.m_MoneyPacks.ToList().ForEach(x => log(x.m_Value));
log("m_MoneyPrefabs");
log(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs);
Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs.ForEach(x => log(x.m_Value));
}
}
}

View file

@ -0,0 +1,61 @@
using HarmonyLib;
using MyBox;
using TMPro;
using UnityEngine;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(CheckoutDrawer), "Awake")]
public static class CheckoutDrawer_Awake_Patch
{
public static void Postfix(CheckoutDrawer __instance)
{
Plugin.StaticLogger.LogInfo("CheckoutDrawer_Awake_Patch");
Plugin.StaticLogger.LogInfo(Plugin.EnableAdditionalCoinCompartments.Value);
var Case = __instance.gameObject.transform.GetChild(0).gameObject;
var Bill1 = __instance.gameObject.transform.GetChild(1).gameObject;
var Bill2 = __instance.gameObject.transform.GetChild(2).gameObject;
var Bill3 = __instance.gameObject.transform.GetChild(3).gameObject;
var Bill4 = __instance.gameObject.transform.GetChild(4).gameObject;
var Bill5 = __instance.gameObject.transform.GetChild(5).gameObject;
var Coin1 = __instance.gameObject.transform.GetChild(6).gameObject;
var Coin2 = __instance.gameObject.transform.GetChild(7).gameObject;
var Coin3 = __instance.gameObject.transform.GetChild(8).gameObject;
var Coin4 = __instance.gameObject.transform.GetChild(9).gameObject;
var Coin5 = __instance.gameObject.transform.GetChild(10).gameObject;
GameObject Coin6 = null;
GameObject Coin7 = null;
Money Coin6Prefab = null;
Money Coin7Prefab = null;
TextMeshProUGUI Coin6Text = null;
TextMeshProUGUI Coin7Text = null;
if (!Plugin.MoneyGeneratorDone)
{
Plugin.Bill1.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[5]);
Plugin.Bill2.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[6]);
Plugin.Bill3.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[7]);
Plugin.Bill4.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[8]);
Plugin.Bill5.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[9]);
Plugin.Coin1.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[0]);
Plugin.Coin2.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[1]);
Plugin.Coin3.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[2]);
Plugin.Coin4.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[3]);
Plugin.Coin5.Apply(Singleton<MoneyGenerator>.Instance.m_MoneyPrefabs[4]);
}
if (Plugin.EnableAdditionalCoinCompartments.Value)
{
Plugin.InitExtraCompartments(__instance, Bill1, Case, Coin5, out Coin6, out Coin7, out Coin6Prefab, out Coin7Prefab, out Coin6Text, out Coin7Text);
}
Plugin.ApplyConfig(__instance, Bill1, Bill2, Bill3, Bill4, Bill5, Coin1, Coin2, Coin3, Coin4, Coin5, Coin6, Coin7, Coin6Text, Coin7Text, Coin6Prefab, Coin7Prefab);
}
}
}

View file

@ -0,0 +1,37 @@
using HarmonyLib;
using System;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(Extensions), "ToMoneyText")]
public static class Extensions_ToMoneyText_Patch
{
public static void Postfix(ref string __result, ref float money, ref float fontSize)
{
string p = Plugin.CurrencyPrefix.Value;
string s = Plugin.CurrencySuffix.Value;
string d = Plugin.CurrencyDecimalSeperator.Value;
string text;
if (money < 0f)
{
text = "-$" + Math.Abs((float)Math.Round((double)money, 2)).ToString("0.00");
}
else
{
text = "$" + ((float)Math.Round((double)money, 2)).ToString("0.00");
}
text = text.Replace(',', '.');
text = text.Replace(".", d);
text = text.Replace("$", p);
text = text + s;
int num = text.IndexOf(d);
if (num != -1)
{
string text2 = "<size=" + (fontSize * 20f / 25f).ToString() + ">";
text2 = text2.Replace(',', '.');
text = text.Insert(num + 1, text2);
}
__result = text;
}
}
}

View file

@ -0,0 +1,18 @@
using HarmonyLib;
using UnityEngine;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(MoneyGenerator), "SpawnCreditCard")]
public static class MoneyGenerator_SpawnCreditCard_Patch
{
public static void Prefix(MoneyGenerator __instance)
{
var card = __instance.m_CustomerCreditCard;
var tex = Plugin.GetCreditCardTextures();
if (Plugin.CreditCardFront.Value != Plugin.CardTextureType.DEFAULT) card.transform.GetChild(0).GetComponent<MeshRenderer>().material.mainTexture = tex.front;
if (Plugin.CreditCardBack.Value != Plugin.CardTextureType.DEFAULT) card.transform.GetChild(1).GetComponent<MeshRenderer>().material.mainTexture = tex.back;
}
}
}

View file

@ -0,0 +1,17 @@
using HarmonyLib;
using TMPro;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(PosTerminal), "Start")]
public static class PosTerminal_Start_Patch
{
public static void Postfix(PosTerminal __instance)
{
string p = Plugin.TerminalSymbol.Value;
var tmp = __instance.gameObject.transform.GetChild(2).GetChild(2).GetChild(1).GetComponent<TextMeshProUGUI>();
tmp.text = p;
tmp.enableWordWrapping = false;
}
}
}

View file

@ -0,0 +1,13 @@
using HarmonyLib;
namespace CurrencyChanger2.Patches
{
[HarmonyPatch(typeof(PriceManager), "CurrentCost")]
public static class PriceManager_CurrentCost_Patch
{
public static void Postfix(ref float __result)
{
__result *= Plugin.CurrencyValueFactor.Value;
}
}
}