-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeathCleaner.cs
More file actions
67 lines (59 loc) · 1.99 KB
/
DeathCleaner.cs
File metadata and controls
67 lines (59 loc) · 1.99 KB
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
using Oxide.Core.Plugins;
using System.Collections.Generic;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("DeathCleaner", "YourName", "1.4.0")]
[Description("Удаляет стартовые предметы при смерти")]
public class DeathCleaner : RustPlugin
{
private readonly HashSet<string> _itemsToRemove = new HashSet<string>
{
"burlap.headwrap",
"burlap.shirt",
"burlap.gloves.new",
"burlap.trousers",
"burlap.shoes",
"concretehatchet",
"concretepickaxe"
};
private const float CleanRadius = 3f;
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
var player = entity as BasePlayer;
if (player == null) return;
CleanPlayerInventory(player.inventory);
CleanNearbyItems(player.transform.position);
}
private void CleanPlayerInventory(PlayerInventory inventory)
{
CleanContainer(inventory.containerWear);
CleanContainer(inventory.containerBelt);
CleanContainer(inventory.containerMain);
}
private void CleanContainer(ItemContainer container)
{
var items = container.itemList.ToArray();
foreach (var item in items)
{
if (_itemsToRemove.Contains(item.info.shortname))
{
item.RemoveFromContainer();
item.Remove();
}
}
}
private void CleanNearbyItems(Vector3 position)
{
var entities = new List<BaseEntity>();
Vis.Entities(position, CleanRadius, entities);
foreach (var entity in entities)
{
if (entity is DroppedItem droppedItem && _itemsToRemove.Contains(droppedItem.item.info.shortname))
{
droppedItem.Kill();
}
}
}
}
}