-
Notifications
You must be signed in to change notification settings - Fork 1
/
Planter_Patch.cs
52 lines (44 loc) · 1.55 KB
/
Planter_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
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace Tweaks_Fixes
{
[HarmonyPatch(typeof(Planter))]
internal class Planter_Patch
{
[HarmonyPrefix]
[HarmonyPatch("RemoveItem", new Type[1] { typeof(int) })]
static bool RemoveItemPrefix(Planter __instance, int slotID)
{
Planter.PlantSlot slotById = __instance.GetSlotByID(slotID);
if (slotById == null)
return false;
Plantable plantable = slotById.plantable;
plantable.currentPlanter = null;
if (plantable.eatable)
{
TechType tt = CraftData.GetTechType(plantable.gameObject);
if (tt == TechType.JellyPlant)
{
plantable.eatable.SetDecomposes(false);
//plantable.eatable.kDecayRate = .01f;
}
else
plantable.eatable.SetDecomposes(true);
}
if (plantable.linkedGrownPlant)
UnityEngine.Object.Destroy(plantable.linkedGrownPlant.gameObject);
GameObject plantModel = slotById.plantModel;
slotById.Clear();
ResourceTracker component = plantModel.GetComponent<ResourceTracker>();
if (component)
component.OnPickedUp(null);
UnityEngine.Object.Destroy(plantModel);
__instance.SetSlotOccupiedState(slotID, false);
return false;
}
}
}