Exemplo n.º 1
0
 public override TaskStatus OnUpdate()
 {
     if (SearchFor.ItemInStorageStructures(itemType.Value, originGameObject.Value.transform.position, out Item item, out Storage storage, originGameObject.Value.GetComponent <StorageStructure>()))
     {
         outItem.Value    = item.gameObject;
         outStorage.Value = storage.gameObject;
         return(TaskStatus.Success);
     }
Exemplo n.º 2
0
    private void _Update()
    {
        if (worker && worker.WorkTime() && worker.fsm.ActiveStateName == "Idle")
        {        //Resupply Items for sale
            if (!supply)
            {
                supplyOrder = orders.Find(o => storage.Count(o.type) < o.min);
                if (supplyOrder != null)
                {
                    supply = true;
                }
            }
            else
            {
                if (storage.Count(supplyOrder.type) >= supplyOrder.max)
                {
                    supply = false;
                }
            }

            if (supply)
            {
                int missingCount = supplyOrder.max - storage.Count(supplyOrder.type);

                Item    item          = null;
                Storage sourceStorage = null;

                if (supplyStorage && SearchFor.ItemInStorage(supplyOrder.type, supplyStorage, out item))
                {
                    sourceStorage = supplyStorage;
                }
                if (!item)
                {
                    SearchFor.ItemInStorageStructures(supplyOrder.type, transform.position, out item, out sourceStorage);
                }
                if (!item)
                {
                    SearchFor.ItemInCraftStructures(supplyOrder.type, transform.position, out item);
                }
                //if (!item)
                //SearchFor.ItemInShopStructures(supplyOrder.type, transform.position, out item, out sourceStorage);

                //Store Item
                if (item)
                {
                    worker.fsm.Store(item, sourceStorage, storage);
                }
            }
        }
    }