Repository navigation
Expand file tree
/
Copy pathPatch.cs
More file actions
133 lines (116 loc) · 4.67 KB
/
Copy pathPatch.cs
File metadata and controls
133 lines (116 loc) · 4.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using DV;
using DV.Booklets;
using DV.Logic.Job;
using DV.Printers;
using DV.ServicePenalty;
using DV.ThingTypes;
using DV.Utils;
using HarmonyLib;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace dvRadioJobControl
{
[HarmonyPatch(typeof(JobValidator), "ValidateJob")]
static class JobValidator_ValidateJob_Patch
{
static bool completed = false;
public static bool Prefix(JobBooklet jobBooklet)
{
if (jobBooklet != null && jobBooklet.job != null && jobBooklet.job.State == JobState.Completed)
{
completed = true;
}
return true;
}
static void Postfix(JobValidator __instance,
PrinterController ___bookletPrinter,
MoneyPrinterJobValidator ___moneyPrinter,
AudioClip ___jobValidatedSound,
JobBooklet jobBooklet)
{
if (jobBooklet == null || completed == false)
{
return;
}
completed = false;
Job job = jobBooklet.job;
if (job != null)
{
if (!SingletonBehaviour<JobsManager>.Instance.currentJobs.Contains(job))
{
DisplayableDebt debt = SingletonBehaviour<JobDebtController>.Instance.LastStagedJobDebt;
if (debt != null && !debt.IsStaged)
debt.UpdateDebtState();
BookletCreator.CreateJobReport(job, debt, ___bookletPrinter.spawnAnchor.position, ___bookletPrinter.spawnAnchor.rotation, (Transform)null);
CommsRadioController.PlayAudioFromRadio(___jobValidatedSound, __instance.transform);
___bookletPrinter.Print();
___moneyPrinter.PrintPayment(job);
}
else
___bookletPrinter.PlayErrorSound();
}
else
___bookletPrinter.PlayErrorSound();
jobBooklet.DestroyJobBooklet();
}
}
[HarmonyPatch(typeof(CommsRadioController), "Awake")]
static class CommsRadio_Awake_Patch
{
public static RadioJobControl jobControl;
static void Postfix(CommsRadioController __instance, List<ICommsRadioMode> ___allModes)
{
RadioJobControl.Controller = __instance;
jobControl = __instance.gameObject.AddComponent<RadioJobControl>();
___allModes.Add(jobControl);
}
}
//set booklet distance slightly smaller than job distance to ensure the booklets exist no matter where in the station the player is, so the mod can accept a job
[HarmonyPatch(typeof(StationJobGenerationRange), "Awake")]
public static class StationJobGenerationRange_Awake_Patch
{
static void Postfix(StationJobGenerationRange __instance)
{
__instance.jobOverviewBookletGenerationSqrDistance = __instance.generateJobsSqrDistance - 1000f;
}
}
[HarmonyPatch(typeof(StationJobGenerationRange), "IsPlayerInRangeForBookletGeneration")]
public static class StationJobGenerationRange_IsPlayerInRangeForBookletGeneration_Patch
{
public static StationController? scToOverride = null;
static void Postfix(StationController __instance, ref bool __result)
{
if (__instance == scToOverride) __result = true;
}
}
[HarmonyPatch(typeof(MoneyPrinterJobValidator), "Awake")]
public static class MoneyPrinterJobValidator_Awake_Patch
{
public static AudioClip? MoneySound;
static void Postfix(MoneyPrinterJobValidator __instance)
{
MoneySound ??= Traverse.Create(__instance).Field("moneyOutputSound")?.GetValue<AudioClip>();
}
}
[HarmonyPatch(typeof(JobValidator), "Awake")]
public static class JobValidator_Awake_Patch
{
public static AudioClip? ValidateSound;
static void Postfix(JobValidator __instance)
{
ValidateSound ??= Traverse.Create(__instance).Field("jobValidatedSound")?.GetValue<AudioClip>();
}
}
[HarmonyPatch(typeof(PrinterController), "Awake")]
public static class PrinterController_Awake_Patch
{
public static AudioClip? PrintingSound;
public static AudioClip? ErrorSound;
static void Postfix(PrinterController __instance)
{
PrintingSound ??= Traverse.Create(__instance).Field("printingSound")?.GetValue<AudioClip>();
ErrorSound ??= Traverse.Create(__instance).Field("ErrorSound")?.GetValue<AudioClip>();
}
}
}