-
Notifications
You must be signed in to change notification settings - Fork 0
/
NeedleCleanupMod.cs
39 lines (36 loc) · 972 Bytes
/
NeedleCleanupMod.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
using BepInEx;
using System.Security.Permissions;
using UnityEngine;
#pragma warning disable CS0618
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
#pragma warning restore CS0618
namespace NeedleCleanup
{
[BepInPlugin("sabreml.needlecleanup", "NeedleCleanup", "1.0.1")]
public class NeedleCleanupMod : BaseUnityPlugin
{
public void OnEnable()
{
On.Room.Loaded += Room_LoadedHK;
}
private void Room_LoadedHK(On.Room.orig_Loaded orig, Room self)
{
if (self.abstractRoom.firstTimeRealized && self.abstractRoom.shelter)
{
int spearsRemoved = self.abstractRoom.entities.RemoveAll(entity =>
{
if (entity is AbstractSpear abstractSpear && abstractSpear.needle && !abstractSpear.stuckInWall)
{
return true;
}
return false;
});
if (spearsRemoved > 0)
{
Debug.Log($"(NeedleCleanup) {spearsRemoved} spears removed from shelter");
}
}
orig(self);
}
}
}