Beispiel #1
0
 public void Dump_nonViable_chassis(VehicleChassiRequest _request, int _lineIndex)
 {
     if (currentState == StorageState.IDLE)
     {
         List <VehiclePart> dumpList = new List <VehiclePart>();
         StorageLine        _LINE    = storageLines[_lineIndex];
         for (int _slotIndex = 0; _slotIndex < lineLength; _slotIndex++)
         {
             if (!Is_chassis_viable(_lineIndex, _slotIndex, _request))
             {
                 dumpList.Add(storageLines[_lineIndex].slots[_slotIndex]);
             }
         }
         sendingLineTo = getsPartsFrom;
         if (dumpList.Count > 0)
         {
             Change_state(StorageState.DUMP);
             Set_outgoing_parts(_lineIndex, dumpList.ToArray(), sendingLineTo);
         }
         else
         {
             Dump_from_line_exceptType(0, Vehicle_PartType.CHASSIS, 1);
         }
     }
 }
Beispiel #2
0
    public void Dump_from_line_exceptType(int _lineIndex, Vehicle_PartType _keepThisPart, int _maxKept)
    {
        if (currentState == StorageState.IDLE)
        {
            int partsKept = 0;
            Change_state(StorageState.DUMP);
            List <VehiclePart> dumpList = new List <VehiclePart>();
            StorageLine        _LINE    = storageLines[_lineIndex];
            for (int _slotIndex = 0; _slotIndex < lineLength; _slotIndex++)
            {
                VehiclePart _PART = _LINE.slots[_slotIndex];

                if (_PART != null)
                {
                    if (_PART.partConfig.partType == _keepThisPart)
                    {
                        if (partsKept < _maxKept)
                        {
                            partsKept++;
                        }
                        else
                        {
                            dumpList.Add(_PART);
                        }
                    }
                    else
                    {
                        dumpList.Add(_PART);
                    }
                }
            }
            sendingLineTo = getsPartsFrom;
            Set_outgoing_parts(_lineIndex, dumpList.ToArray(), sendingLineTo);
        }
    }
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 Dump_slots(int _count, int _lineIndex = 0)
 {
     if (currentState == StorageState.IDLE || currentState == StorageState.WAIT_FOR_PURGED_DATA)
     {
         Change_state(StorageState.DUMP);
         List <VehiclePart> dumpList = new List <VehiclePart>();
         StorageLine        _LINE    = storageLines[_lineIndex];
         for (int _slotIndex = 0; _slotIndex < _count; _slotIndex++)
         {
             if (_LINE.slots[_slotIndex] != null)
             {
                 dumpList.Add(_LINE.slots[_slotIndex]);
             }
         }
         sendingLineTo = getsPartsFrom;
         Set_outgoing_parts(_lineIndex, dumpList.ToArray(), sendingLineTo);
     }
 }
Beispiel #5
0
    private VehiclePart[] Attempt_store_new_data(VehiclePart[] _parts)
    {
        if (_parts.Length > 0)
        {
            List <VehiclePart> _STORED_PARTS = new List <VehiclePart>();
            int _partIndex = 0;
            for (int _lineIndex = 0; _lineIndex < storageLines.Count; _lineIndex++)
            {
                StorageLine _LINE = storageLines[_lineIndex];

                for (int _slotIndex = 0; _slotIndex < lineLength; _slotIndex++)
                {
                    VehiclePart _PART = _parts[_partIndex];
                    if (_LINE.slots[_slotIndex] == null && _PART != null)
                    {
                        Assign_slot(_lineIndex, _slotIndex, _PART);
                        _STORED_PARTS.Add(_parts[_partIndex]);
                        _partIndex++;
                    }
                    if (_partIndex >= _parts.Length)
                    {
                        break;
                    }
                }
                if (_partIndex >= _parts.Length)
                {
                    break;
                }
            }
            return(_STORED_PARTS.ToArray());
        }
        else
        {
            return(null);
        }
    }