示例#1
0
        private static void AddItemFromNearbyChests(Fermenter __instance)
        {
            if (!Configuration.Current.Fermenter.autoFuel || __instance.GetStatus() != Fermenter.Status.Empty || !__instance.m_nview.IsOwner())
            {
                return;
            }

            Stopwatch delta = GameObjectAssistant.GetStopwatch(__instance.gameObject);

            if (!delta.IsRunning || delta.ElapsedMilliseconds > 1000)
            {
                List <Container> nearbyChests = InventoryAssistant.GetNearbyChests(__instance.gameObject, Configuration.Current.Fermenter.autoRange, !Configuration.Current.Fermenter.ignorePrivateAreaCheck);
                foreach (Container c in nearbyChests)
                {
                    ItemDrop.ItemData item = __instance.FindCookableItem(c.GetInventory());
                    if (item != null)
                    {
                        if (InventoryAssistant.RemoveItemFromChest(c, item) == 0)
                        {
                            continue;
                        }

                        __instance.m_nview.InvokeRPC("AddItem", new object[] { item.m_dropPrefab.name });
                        ZLog.Log("Added " + item.m_shared.m_name + " to " + __instance.m_name);
                        break;
                    }
                }
                delta.Restart();
            }
        }