-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fragment_Patch.cs
47 lines (43 loc) · 1.47 KB
/
Fragment_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
using HarmonyLib;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static ErrorMessage;
namespace Tweaks_Fixes
{
class Fragment_Patch
{
static bool IsFragmentCrate(Transform transform)
{
if (transform.name.EndsWith("InCrate(Clone)") || transform.name.EndsWith("Fragment(Clone)"))
{
return true;
}
return false;
}
[HarmonyPatch(typeof(ResourceTracker), "Start")]
class ResourceTracker_Start_Patch
{
static void Postfix(ResourceTracker __instance)
{
if (ConfigToEdit.dontSpawnKnownFragments.Value && __instance.techType == TechType.Fragment)
{
TechType tt = CraftData.GetTechType(__instance.gameObject);
if (PDAScanner.complete.Contains(tt))
{
//AddDebug("ResourceTracker start " + tt);
__instance.Unregister();
if (IsFragmentCrate(__instance.transform.parent))
{ // destroy fragment and crate
UnityEngine.Object.Destroy(__instance.transform.parent.gameObject);
}
else
UnityEngine.Object.Destroy(__instance.gameObject);
}
}
}
}
}
}