private void OnLootEntityEnd(BasePlayer player, LootContainer lootContainer) { if (lootContainer?.net == null || player == null) { return; } if (lootContainer?.inventory?.itemList == null) { return; } var entityID = lootContainer.net.ID; if (lootContainer.inventory.itemList.Count <= 0) { if (lootEntities.ContainsKey(entityID)) { lootEntities.Remove(entityID); } if (entityPlayers.ContainsKey(entityID)) { entityPlayers[entityID].Remove(player.userID); } return; } if (lootEntities.ContainsKey(entityID) && entityPlayers.ContainsKey(entityID)) { if (lootContainer.inventory.itemList.Count < lootEntities[entityID]) { if (!lootDestroyTimer.ContainsKey(entityID)) { lootDestroyTimer.Add(entityID, timer.Once(configData.timeBeforeLootEmpty, () => { if (lootContainer?.inventory?.itemList == null) { return; } DropUtil.DropItems(lootContainer.inventory, lootContainer.transform.position); lootContainer.RemoveMe(); })); } } else { entityPlayers[entityID].Remove(player.userID); } lootEntities.Remove(entityID); EmptyJunkPile(lootContainer); } }