Пример #1
0
        private short GetFuelEfficiency()
        {
            if (FuelSlot.IsVoid())
            {
                return(0);
            }

            return(FuelSlot.Type < 256 ? BlockHelper.Instance.BurnEfficiency((byte)FuelSlot.Type) : BlockData.ItemBurnEfficiency[(BlockData.Items)FuelSlot.Type]);
        }
Пример #2
0
 private bool HasFuel()
 {
     if (FuelSlot.IsVoid())
     {
         return(false);
     }
     return((FuelSlot.Type < 256 && BlockHelper.Instance.IsIgnitable((byte)FuelSlot.Type)) ||
            (FuelSlot.Type >= 256 && BlockData.ItemBurnEfficiency.ContainsKey((BlockData.Items)FuelSlot.Type)));
 }
Пример #3
0
        public FurnaceUI(Ref <Item> input, Ref <Item> output, Ref <Item> fuel, FuelCore energyCore, string furnaceName)
        {
            this._input  = new InputOutputSlot(input, Main.inventoryBack10Texture);
            this._output = new InputOutputSlot(output, Main.inventoryBack10Texture);

            if (energyCore != null)
            {
                _energyBar = new UIEnergyBar(energyCore);
            }

            this._fuel        = new FuelSlot(fuel, Main.inventoryBack10Texture, energyCore);
            this._furnaceName = furnaceName;
        }
Пример #4
0
        private IEnumerator C_Burn()
        {
            while (true)
            {
                yield return(m_UpdateInterval);

                // If the fuel, or the items to burn finished, stop burning.
                if (!FuelSlot.CurrentItem || !InputSlot.CurrentItem)
                {
                    StopBurning();
                    yield break;
                }

                var burnTime = m_BurnTimeProperty.Float;
                burnTime.Current -= UPDATE_INTERVAL;
                m_BurnTimeProperty.SetValue(ItemProperty.Type.Float, burnTime);

                Progress.Set(1f - burnTime.Ratio);

                if (burnTime.Current <= 0f)
                {
                    ItemData resultedItem;
                    if (GameController.ItemDatabase.FindItemByName(m_ItemResult, out resultedItem))
                    {
                        CollectionUtils.AddItem(resultedItem, 1, LootSlots);
                    }
                    else
                    {
                        Debug.LogWarning("The item has burned but no result was given, make sure the item has the 'Burn Result' property, so we know what to add as a result of burning / smelting.", this);
                    }

                    if (InputSlot.CurrentItem.CurrentInStack == 1)
                    {
                        InputSlot.SetItem(null);
                        StopBurning();
                        yield break;
                    }
                    else
                    {
                        burnTime.Current = burnTime.Default;
                        m_BurnTimeProperty.SetValue(ItemProperty.Type.Float, burnTime);
                        InputSlot.CurrentItem.CurrentInStack--;
                    }
                }

                var fuelTime = m_FuelTimeProperty.Float;
                fuelTime.Current -= UPDATE_INTERVAL;
                m_FuelTimeProperty.SetValue(ItemProperty.Type.Float, fuelTime);

                if (fuelTime.Current <= 0f)
                {
                    if (FuelSlot.CurrentItem.CurrentInStack == 1)
                    {
                        FuelSlot.SetItem(null);
                        StopBurning();
                        yield break;
                    }
                    else
                    {
                        fuelTime.Current = fuelTime.Default;
                        m_FuelTimeProperty.SetValue(ItemProperty.Type.Float, fuelTime);
                        FuelSlot.CurrentItem.CurrentInStack--;
                    }
                }
            }
        }