Example #1
0
        void BackpackShow(BasePlayer player)
        {
            if (BackpackHide(player.userID))
            {
                return;
            }

            if (player.inventory.loot?.entitySource != null)
            {
                return;
            }

            timer.Once(0.1f, () =>
            {
                if (!player.IsOnGround())
                {
                    return;
                }
                List <SavedItem> savedItems;
                List <Item> items = new List <Item>();
                if (savedBackpacks.TryGetValue(player.userID, out savedItems))
                {
                    items = RestoreItems(savedItems);
                }
                var backpackSize = GetBackpackSize(player);
                BackpackBox box  = BackpackBox.Spawn(player, backpackSize);
                openedBackpacks.Add(player.userID, box);
                if (items.Count > 0)
                {
                    box.Push(items);
                }
                box.StartLoot();
            });
        }
Example #2
0
        void OnEntityDeath(BaseCombatEntity ent, HitInfo info)
        {
            if (!(ent is BasePlayer))
            {
                return;
            }
            var player = (BasePlayer)ent;

            if (InDuel(player))
            {
                return;
            }
            BackpackHide(player.userID);

            List <SavedItem> savedItems;
            List <Item>      items = new List <Item>();

            if (savedBackpacks.TryGetValue(player.userID, out savedItems))
            {
                items = RestoreItems(savedItems);
                savedBackpacks.Remove(player.userID);
            }
            if (items.Count <= 0)
            {
                return;
            }
            var container = BackpackBox.SpawnContainer(player, GetBackpackSize(player), true);

            if (container == null)
            {
                return;
            }
            for (int i = items.Count - 1; i >= 0; i--)
            {
                items[i].MoveToContainer(container.inventory);
            }
            timer.Once(300f, () =>
            {
                if (container != null && !container.IsDestroyed)
                {
                    container.Kill();
                }
            });
            Effect.server.Run("assets/bundled/prefabs/fx/dig_effect.prefab", container.transform.position);
        }