Ejemplo n.º 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();
    }
Ejemplo n.º 2
0
    public GameObject Create_Module(ModuleSaveModel model)
    {
        //GameObject refab = Resources.Load(model.module_name.ToString()) as GameObject;
        Recipe r = UnityFunctions.GetItemTypeItem(model.item_type);

        if (r.preFab != null)
        {
            GameObject modules        = GameObject.Find("Modules");
            GameObject stored_modules = GameObject.Find("Stored_Modules");
            ShipModule sm             = modules.GetComponentInChildren <ShipModule>();

            GameObject obj_module = null;

            if (sm == null)
            {
                //Debug.Log("Loading Model");
                obj_module = Instantiate(r.preFab, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
                sm         = obj_module.GetComponent <ShipModule>();
                if (sm != null)
                {
                    sm.LoadMountPoints();
                }
            }
            else
            {
                if (model.is_internal_module == false)
                {
                    MountPoint mp = null;
                    if (model.is_in_storage == false)
                    {
                        mp = sm.mount_points[0];
                    }
                    else
                    {
                        mp = sm.mount_points[model.mount_point - 1];
                    }

                    if (mp != null)
                    {
                        obj_module = Instantiate(r.preFab, mp.transform.position, mp.transform.rotation) as GameObject;
                    }
                }
                else
                {
                    obj_module = Instantiate(r.preFab, stored_modules.transform) as GameObject;
                }
            }

            //Need to add the keybindings
            if (obj_module == null)
            {
                return(null);
            }
            ModuleSystemInfo mod_sys = obj_module.GetComponent <ModuleSystemInfo>();
            ItemResorce      ir      = obj_module.GetComponent <ItemResorce>();
            //mod_sys.key_mappings = model.key_mappings;
            //mod_sys.id = model.id;
            mod_sys.current_health     = model.health;
            mod_sys.mount_point        = model.mount_point;
            mod_sys.order_layer        = model.order_layer;
            mod_sys.is_internal_module = model.is_internal_module;
            mod_sys.active             = model.enabled;
            mod_sys.upgrades.Clear();
            //Load upgrades
            foreach (string s in model.upgrades)
            {
                Upgrade_Settings upgrade = Resources.Load(s) as Upgrade_Settings;
                mod_sys.upgrades.Add(upgrade);
            }
            return(obj_module);
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 3
0
 public Recipe GetItem()
 {
     return(UnityFunctions.GetItemTypeItem(Item_type));
 }