private void transfer(IProviderContainer source, IProviderContainer target, bool exit = false)
        {
            ProviderType sourceProviderType = source.getProviderType();
            ProviderType targetProviderType = target.getProviderType();

            // Check if no transfer should be made
            if (sourceProviderType == ProviderType.NONE || targetProviderType == ProviderType.NONE)
            {
                return;
            }

            // Ensure one requestor and one provider
            if (sourceProviderType == targetProviderType)
            {
                Debug.LogWarning("LilGuy and Mothership " + source.getResourceType().ToString() + " containers are both set to ProviderType: " + sourceProviderType.ToString() + ".", this);
                return;
            }

            // Fill source from target
            if (sourceProviderType == ProviderType.REQUESTER)               // Implicitly: (&& targetProviderType == ProviderType.PROVIDER)
            // Request capacity - amount from target
            {
                float amountToRequest = source.getCapacity() - source.getAmount();
                source.add(target.remove(amountToRequest));
            }

            if (exit)
            {
                return;
            }

            // Fill target from source
            transfer(target, source, true);
        }
 public PermutationSolutionBuilder(
     int permutationLength, 
     ScheduleInfo[] items,
     IProviderContainer providerContainer)
 {
     _n = permutationLength;
     _items = items;
     _providerContainer = providerContainer;
 }
        // Transfer resources depending on ProviderType relationships
        private void redock()
        {
            foreach (ResourceType resourceType in ((ResourceType[])Enum.GetValues(typeof(ResourceType))))
            {
                IProviderContainer lilGuyContainer     = (IProviderContainer)lilGuyCargoHold.getContainer(resourceType);
                IProviderContainer mothershipContainer = (IProviderContainer)mothershipCargoHold.getContainer(resourceType);

                transfer(lilGuyContainer, mothershipContainer);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Contructor
 /// </summary>
 /// <param name="n">Number of permutation elements</param>
 public PermutationSolution(int n, ScheduleInfo[] items, IProviderContainer providerContainer)
 {
     Count = n;
     Items = items;
     _providerContainer = providerContainer;
 }