-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrateDestroyerInteractionSystem.cs
56 lines (48 loc) · 1.51 KB
/
CrateDestroyerInteractionSystem.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
using Kitchen;
using KitchenMods;
using Unity.Entities;
namespace KitchenOverstocked
{
internal class CrateDestroyerInteractionSystem : ItemInteractionSystem, IModSystem
{
protected override InteractionType RequiredType => InteractionType.Act;
protected override bool RequireHold => false;
protected override void Initialise()
{
base.Initialise();
// Only run in franchise mode
RequireSingletonForUpdate<SFranchiseMarker>();
}
protected override bool IsPossible(ref InteractionData data)
{
if (!Mod.DestroyCratesEnabled)
{
return false;
}
if (
Has<CPersistentItemStorageLocation>(data.Target)
&& Require<CItemHolder>(data.Target, out CItemHolder holder)
&& holder.HeldItem != default(Entity)
)
{
return true;
}
return false;
}
protected override void Perform(ref InteractionData data)
{
if (Has<CCrateItemProvider>(data.Target))
{
data.Context.Remove<CCrateItemProvider>(data.Target);
}
if (Require<CItemHolder>(data.Target, out CItemHolder holder))
{
var item = holder.HeldItem;
if (item != default(Entity))
{
data.Context.Destroy(item);
}
}
}
}
}