-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatcher.cs
71 lines (63 loc) · 2.15 KB
/
Patcher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using ColossalFramework;
using ColossalFramework.Globalization;
using ColossalFramework.UI;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
namespace TollPriceIncreaserMod
{
public static class Patcher
{
private const string HarmonyId = "RCK.TollPriceIncreaserMod";
private static bool patched = false;
public static void PatchAll()
{
if (patched) return;
patched = true;
Debug.Log("TollPriceIncreaser Patching");
var harmony = new Harmony(HarmonyId);
//harmony.PatchAll(Assembly.GetExecutingAssembly());
harmony.PatchAll(typeof(Patcher).GetType().Assembly);
}
public static void UnpatchAll()
{
if (!patched) return;
var harmony = new Harmony(HarmonyId);
harmony.UnpatchAll(HarmonyId);
patched = false;
}
}
[HarmonyPatch(typeof(TollBoothAI), "GetTollPrice")]
public static class TollBoothAIGetTollPricePatch
{
public static bool Prefix(ref int __result, ushort buildingID, ref Building data)
{
__result = data.m_education1;
return false;
}
}
[HarmonyPatch(typeof(TollBoothAI), "SetTollPrice")]
public static class TollBoothAIGSetTollPricePatch
{
public static bool Prefix(ushort buildingID, ref Building data, int price)
{
data.m_education1 = (byte)Mathf.Clamp(price, 0, 255);
return false;
}
}
[HarmonyPatch(typeof(CityServiceWorldInfoPanel), "OnTicketPriceChanged")]
public static class CityServiceWorldInfoPanelOnTicketPriceChangedPatch
{
public static void Postfix(ref UILabel ___m_TicketPrice1, ref UILabel ___m_TicketPrice2,
UIComponent component, float value)
{
float num = value / 10f;
___m_TicketPrice1.text = num.ToString(Settings.moneyFormat, LocaleManager.cultureInfo);
___m_TicketPrice2.text = (num * 2f).ToString(Settings.moneyFormat, LocaleManager.cultureInfo);
}
}
}