Beispiel #1
0
 public void Clear_all_requests()
 {
     current_PART_request    = null;
     current_CHASSIS_request = null;
     next_PART_request       = null;
     next_CHASSIS_request    = null;
 }
Beispiel #2
0
 private void Send_parts(bool _dumpingParts)
 {
     if (parts_OUT.Length > 0)
     {
         List <VehiclePart> _SENT_PARTS = sendingLineTo.Recieve_parts(parts_OUT);
         if (_SENT_PARTS != null)
         {
             for (int _lineIndex = 0; _lineIndex < storageLines.Count; _lineIndex++)
             {
                 for (int _slotIndex = 0; _slotIndex < lineLength; _slotIndex++)
                 {
                     VehiclePart _SLOT = Get_data_slot(_lineIndex, _slotIndex);
                     if (_SLOT != null)
                     {
                         if (_SENT_PARTS.Contains(storageLines[_lineIndex].slots[_slotIndex]))
                         {
                             _SENT_PARTS.Remove(storageLines[_lineIndex].slots[_slotIndex]);
                             Clear_slot(_lineIndex, _slotIndex);
                         }
                         else
                         {
                             Position_part_in_storage(_SLOT, _lineIndex, _slotIndex);
                         }
                     }
                 }
             }
         }
     }
     if (!_dumpingParts)
     {
         current_PART_request    = null;
         current_CHASSIS_request = null;
     }
     Change_state(StorageState.IDLE);
 }
Beispiel #3
0
    // ATTEMPT TO EXECUTE REQUESTS
    private void Do_part_request(VehiclePartRequest _request)
    {
        sendingLineTo        = _request.deliverTo;
        current_PART_request = _request;
        for (int _lineIndex = 0; _lineIndex < storageLines.Count; _lineIndex++)
        {
            StorageLine _LINE  = storageLines[_lineIndex];
            var         _SLOTS = _LINE.slots;
            for (int _slotIndex = 0; _slotIndex < lineLength; _slotIndex++)
            {
                if (_SLOTS[_slotIndex] != null)
                {
                    if (_SLOTS[_slotIndex].partConfig == _request.part)
                    {
                        Set_outgoing_parts(_lineIndex, sendingLineTo);
                        Change_state(StorageState.FETCHING);
                        return;
                    }
                }
            }
        }

        if (!isLastInChain)
        {
            // IF YOU REACH THIS POINT - YOU DONT HAVE THE PARTS, request from the next storage in chain :)
            Change_state(StorageState.WAITING);
            getsPartsFrom.Request_part(new VehiclePartRequest(_request.part, this));
        }
        else
        {
            Factory.INSTANCE.ALERT_WorkshopPartUnavailable(_request.part);
        }
    }
Beispiel #4
0
    public void Change_state(StorageState _newState)
    {
        if (currentState != _newState)
        {
            taskStep     = 0;
            currentState = _newState;
            //Debug.Log(storageName + ": " + currentState);
            switch (currentState)
            {
            case StorageState.IDLE:
                // grab chassis / part if a request is pending
                if (current_CHASSIS_request != null)
                {
                    Request_chassis(current_CHASSIS_request);
                }
                else if (current_PART_request != null)
                {
                    Request_part(current_PART_request);
                }
                else if (next_CHASSIS_request != null)
                {
                    Debug.Log(storageName + " found NEXT CHASSIS req");
                    current_CHASSIS_request = next_CHASSIS_request;
                    next_CHASSIS_request    = null;
                    Request_chassis(current_CHASSIS_request);
                }
                else if (next_PART_request != null)
                {
                    current_PART_request = next_PART_request;
                    next_PART_request    = null;
                    Request_part(current_PART_request);
                }

                break;

            case StorageState.WAITING:
                break;

            case StorageState.FETCHING:
                break;
            }
        }
    }
Beispiel #5
0
    // REQUESTS

    public void Request_part(VehiclePartRequest _request)
    {
        if (currentState == StorageState.IDLE)
        { // I am free to take orders
            sendingLineTo = _request.deliverTo;
            sendingLineTo.waitingForPartType = _request.part;
            current_PART_request             = null;
            if (freeSpace > 0)
            { // do I have space for a new line?
                Do_part_request(_request);
            }
            else
            { // no room, DUMP a line
                current_PART_request = _request;
                Dump_line();
            }
        }
        else
        {
            next_PART_request = _request;
        }
    }