Exemple #1
0
            private void GroundMissing()
            {
                recycler.Kill();

                if (config.destroy.destroyItem)
                {
                    plugin.GiveRecycler(recycler.transform.position);
                }

                foreach (var effect in config.destroy.effects)
                {
                    Effect.server.Run(effect, recycler.transform.position);
                }
            }
Exemple #2
0
        /// <param name="unloading">Specify true if the plugin is unloading.</param>
        public void Destroy(bool destroyOutputContainer, bool unloading = false)
        {
            resetDespawnTimer.DestroyToPool();

            foreach (var player in NearbyPlayers)
            {
                OnPlayerLeave(player);
            }

            if (!unloading)
            {
                // Drop queue items
                if (CraftingTasks.Count > 0)
                {
                    var container = new ItemContainer();
                    container.ServerInitialize(null, 36);

                    foreach (var task in CraftingTasks)
                    {
                        foreach (var ingredient in task.Blueprint.ingredients)
                        {
                            var item = ItemManager.CreateByItemID(ingredient.itemid, (int)ingredient.amount * task.Amount);

                            if (!item.MoveToContainer(container))
                            {
                                item.Drop(Position + Recycler.transform.up * 1.25f, Recycler.GetDropVelocity(), Recycler.ServerRotation);
                            }
                        }
                    }

                    var droppedContainer = container.Drop(Constants.ItemDropPrefab, Position + Recycler.transform.up * 1.25f, Recycler.ServerRotation);
                    droppedContainer.playerName = Lang.Translate(null, "queue-items");
                }
            }

            Recycler.Kill();
            CodeLock?.Kill();

            if (!outputContainer.IsDestroyed)
            {
                // Remove rock from output container that keeps it from despawning when emptied
                outputInventory.GetSlot(outputInventory.capacity - 1).Remove();

                // Force kill output bag if there's nothing in it.
                if (!destroyOutputContainer && OutputInventory.AnyItems())
                {
                    // Enable physics on output container
                    outputContainer.GetComponent <Rigidbody>().isKinematic = false;
                }
                else
                {
                    outputContainer.Kill();
                }
            }
        }