-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropitizePatch.cs
More file actions
73 lines (62 loc) · 2.18 KB
/
PropitizePatch.cs
File metadata and controls
73 lines (62 loc) · 2.18 KB
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
72
73
using System.Reflection;
using UnityEngine;
using MoveIt;
using HarmonyLib;
using ColossalFramework;
namespace Propitize
{
public static class PropitizePatch
{
private const string HarmonyId = "Propitize";
private static bool patched = false;
public static void PatchAll()
{
if (patched) return;
patched = true;
var harmony = new Harmony(HarmonyId);
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
public static void UnpatchAll()
{
if (!patched) return;
var harmony = new Harmony(HarmonyId);
harmony.UnpatchAll(HarmonyId);
patched = false;
}
}
[HarmonyPatch(typeof(UIToolOptionPanel), "Start")]
public static class PropitizeInstallation
{
// Attach button to MoveIt mod panel
public static void Postfix()
{
if (UIToolOptionPanel.instance == null) return;
// Initilization
ToolController toolController = Object.FindObjectOfType<ToolController>();
PropitizeTool.instance = toolController.gameObject.AddComponent<PropitizeTool>();
PropitizeButton.CreateSubButton(UIToolOptionPanel.instance, "Propitize", "Propitize", "Propitize");
}
}
// Get selection list and perform conversion
[HarmonyPatch(typeof(SelectAction), "Add")]
public static class PropitizeMoveItSelectionBinderPatch
{
private static void Postfix()
{
PropitizeTool.ExtractPropsFromMoveItSelection();
}
}
[HarmonyPatch(typeof(RenderManager), "Managers_CheckReferences")]
public static class LoadingHook
{
public static void Prefix()
{
if (!PropitizeMod.PrefabsInitialized)
{
PropitizeMod.PrefabsInitialized = true;
Singleton<LoadingManager>.instance.QueueLoadingAction(PropitizeTool.GeneratePropitizedTreeFromFile());
Singleton<LoadingManager>.instance.QueueLoadingAction(PropitizeTool.InitializeAndBindPrefab());
}
}
}
}