// Update is called once per frame
    void Update()
    {
        if (state == STATE.idle && switchingRecipe != null)
        {
            recipe          = switchingRecipe;
            switchingRecipe = null;
        }

        if (recipe == null)
        {
            ct.show();
            return;
        }

        switch (state)
        {
        case STATE.idle:
            //MAKE ORDERS
            for (int i = 0; i < recipe.nbInput; ++i)
            {
                rManager.postOrder(new Order(this, recipe.input));
            }
            //Debug.Log(transform.name + " posted " + recipe.input + " order(s).");
            state = STATE.waitingDelivery;
            break;

        case STATE.processing:
            if (processIndex++ >= recipe.rawTimeToProcess)
            {
                state = STATE.waitingPickUp;
                for (int i = 0; i < recipe.nbOutput; ++i)
                {
                    rManager.postPushResources(recipe.output, this);
                }
                loadOutput   = recipe.nbOutput;
                processIndex = 0;
            }
            break;

        case STATE.waitingDelivery:
            if (loadedInputR == recipe.nbInput)
            {
                loadedInputR = 0;
                state        = STATE.processing;
            }
            break;

        case STATE.waitingPickUp:
            if (loadOutput == 0)
            {
                state = STATE.idle;
            }
            break;
        }
    }