Пример #1
0
    private IEnumerator ProcessBin()
    {
        processing = true;
        do
        {
            if (this.is_online && this.active)
            {
                Recipe item      = processing_bin[0];
                bool   validated = true;
                foreach (Recipe.Ingreadient i in item.ingredients)
                {
                    int in_stock = storage.Inventory_Item_Count(i.item_type);
                    if (in_stock < i.qty)
                    {
                        validated = false; break;
                    }
                }
                if (validated == true)
                {
                    process_time    = item.make_time;
                    current_item    = item.item_type;
                    est_finish_time = new DateTimeOffset(DateTime.Now.AddSeconds(process_time));
                    yield return(new WaitForSeconds(process_time));

                    Recipe id = UnityFunctions.GetItemTypeItem(item.item_type);
                    if (storage != null)
                    {
                        if (id.resorce_type == Enums.enum_resorce_type.material)
                        {
                            //First check we have all the  items

                            //************************************
                            //We need to remove x items from stock
                            //************************************
                            foreach (Recipe.Ingreadient i in item.ingredients)
                            {
                                storage.remove_x_material(i.item_type, i.qty);
                            }
                            storage.Store_Material(item.item_type);
                        }
                    }
                }
                processing_bin.RemoveAt(0);
            }
        } while (processing_bin.Count > 0);
        processing = false;
        StopUsage();
    }
Пример #2
0
    void Reader.UpdateDisplayData()
    {
        if (storage != null && txt != null)
        {
            //**************
            //Set the colour
            //**************
            if (is_Blueprint && read_type == Enums.enum_read_type.replicator_make)
            {
                ColorBlock cb = but.colors;
                if (storage.Blueprint_Item_Count(recipe.required_blueprint) > 0)
                {
                    cb.disabledColor = Color.blue;
                    but.interactable = HasIngredients();
                }
                else
                {
                    but.interactable = false;
                    cb.disabledColor = Color.red;
                }
                but.colors = cb;
            }

            if (read_type == Enums.enum_read_type.replicator_que)
            {
                //**********************************
                //Counts items in the replicator que
                //**********************************
                if (replicator != null)
                {
                    txt.text = replicator.processbin_Item_Count(item_type).ToString();
                }
            }
            else if (read_type == Enums.enum_read_type.replicator_time)
            {
                //************************
                //Show the replicator time
                //************************
                if (replicator != null)
                {
                    if (replicator_time <= 0)
                    {
                        if (replicator.processing)
                        {
                            replicator_current_item = replicator.current_item;
                            replicator_time         = replicator.est_finish_time.Subtract(new DateTimeOffset(DateTime.Now)).Seconds;
                            txt.text = "Making " + replicator_current_item.ToString() + " Completion time " + replicator_time;
                        }
                        else
                        {
                            txt.text = "";
                        }
                    }
                    else
                    {
                        if (replicator.processing)
                        {
                            replicator_time = replicator.est_finish_time.Subtract(new DateTimeOffset(DateTime.Now)).Seconds;
                        }
                        else
                        {
                            replicator_time = 0;
                            txt.text        = "";
                        }
                        if (replicator_time < 0)
                        {
                            replicator_time = 0;
                            txt.text        = "";
                        }
                        else
                        {
                            txt.text = "Making " + replicator_current_item.ToString() + " Completion time " + replicator_time;
                        }
                    }
                }
            }
            else
            {
                //*************
                //Show the time
                //*************
                txt.text = storage.Inventory_Item_Count(item_type).ToString();
            }
        }
    }