-
Notifications
You must be signed in to change notification settings - Fork 1
/
Scanner_Patch.cs
98 lines (89 loc) · 4.03 KB
/
Scanner_Patch.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
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
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tweaks_Fixes;
using UnityEngine;
namespace Tweaks_Fixes
{
internal class Scanner_Patch
{
[HarmonyPatch(typeof(ScannerTool))]
class ScannerTool_Patch
{
static bool scanning = false;
static bool finishedScan = false;
[HarmonyPrefix]
[HarmonyPatch("Update")]// Show power when equipped
private static bool UpdatePrefix(ScannerTool __instance)
{
//PlayerTool playerTool =
//bool isDrawn = (bool)PlayerTool_get_isDrawn.Invoke(__instance, new object[] { });
if (__instance.isDrawn)
{
//float idleTimer = (float)ScannerTool_idleTimer.GetValue(__instance);
//AddDebug("useText1 " + HandReticle.main.useText1);
//AddDebug("useText2 " + HandReticle.main.useText2);
if (__instance.idleTimer > 0f)
{
__instance.idleTimer = Mathf.Max(0f, __instance.idleTimer - Time.deltaTime);
//string buttonFormat = LanguageCache.GetButtonFormat("ScannerSelfScanFormat", GameInput.Button.AltTool);
// HandReticle.main.SetUseTextRaw(buttonFormat, null);
}
}
return false;
}
[HarmonyPostfix]
[HarmonyPatch("Scan")]
private static void ScanPostfix(ScannerTool __instance, PDAScanner.Result __result)
{ // -57 -23 -364
//if (__result != PDAScanner.Result.None)
// AddDebug("Scan " + __result.ToString());
if (ConfigToEdit.removeFragmentCrate.Value && finishedScan && PDAScanner.scanTarget.techType == TechType.StarshipCargoCrate)
{ // destroy crate
//AddDebug("finished scan " + __result.ToString() + " " + PDAScanner.scanTarget.gameObject.name);
UnityEngine.Object.Destroy(PDAScanner.scanTarget.gameObject);
scanning = false;
finishedScan = false;
return;
}
if (scanning && __result == PDAScanner.Result.Done || __result == PDAScanner.Result.Researched)
finishedScan = true;
else
finishedScan = false;
scanning = PDAScanner.IsFragment(PDAScanner.scanTarget.techType);
}
}
[HarmonyPatch(typeof(PDAScanner))]
class PDAScanner_Patch
{
[HarmonyPostfix]
[HarmonyPatch("Initialize")]
static void InitializePostfix()
{
if (PDAScanner.mapping.ContainsKey(TechType.MediumKoosh))
{
PDAScanner.EntryData entryData = PDAScanner.mapping[TechType.MediumKoosh];
//Main.logger.LogDebug("PDAScanner Initialize " + entryData);
if (!PDAScanner.mapping.ContainsKey(TechType.LargeKoosh))
PDAScanner.mapping.Add(TechType.LargeKoosh, entryData);
if (!PDAScanner.mapping.ContainsKey(TechType.SmallKoosh))
PDAScanner.mapping.Add(TechType.SmallKoosh, entryData);
}
}
[HarmonyPostfix]
[HarmonyPatch("Unlock")]
static void UnlockPostfix(PDAScanner.EntryData entryData, bool unlockBlueprint, bool unlockEncyclopedia, bool verbose)
{
//AddDebug("Unlock " + entryData.key);
if (entryData.key == TechType.MediumKoosh || entryData.key == TechType.SmallKoosh || entryData.key == TechType.LargeKoosh)
{
PDAScanner.complete.Add(TechType.LargeKoosh);
PDAScanner.complete.Add(TechType.SmallKoosh);
PDAScanner.complete.Add(TechType.MediumKoosh);
}
}
}
}
}