Exemplo n.º 1
0
        internal override void OnUpdate()
        {
            // assume that we are turned off
            Recepe recipe = FurnaceRecipes.Instance.Find(Input);

            if (recipe == null ||
                !Product.Content.Compatible(recipe.Product) ||
                Fuel.Content.IsEmpty)
            {
                TurnOff();
                return;
            }
            TurnOn();
            if (Product.Content.IsEmpty)
            {
                Product.Content.ReplaceWithEmptyCompatibleStack(recipe.Product);
            }
            if (Fuel.Content.Id != lastFuelId ||
                Input.Content.Id != lastInputId)
            {
                // check for recipe...
                combustionCounter = 0;
                energyCounter     = 0;
            }

            // ok we are burning!
            TurnOn();
            lastFuelId  = Fuel.Content.Id;
            lastInputId = Input.Content.Id;

            combustionCounter++;
            if (combustionCounter >= Entity.FromId(Fuel.Content.Id).HeatOfCombustion)
            {
                combustionCounter = 0;
                Fuel.Content.Remove(1);
            }
            energyCounter++;
            if (energyCounter >= Entity.FromId(Input.Content.Id).EnergyToTransform)
            {
                energyCounter = 0;
                Input.Content.Remove(1);
                Product.Content.Add(1);
                if (Changed != null)
                {
                    Changed(this, new EventArgs());
                }
            }
        }
Exemplo n.º 2
0
 protected void AddRecipe(Recepe recepe)
 {
     recepies.Add(recepe.Key, recepe);
 }