예제 #1
0
        protected void tallyResources(WBIResourceDistributor distributor, Dictionary <string, TalliedResource> sharedResourceTally, Dictionary <string, TalliedResource> requiredResourceTally)
        {
            //If the distributor isn't actively participating then we're done.
            if (!distributor.isParticipating)
            {
                return;
            }
            List <PartResource> sharedResources   = new List <PartResource>();
            List <PartResource> requiredResources = new List <PartResource>();
            TalliedResource     talliedResource;
            PartResource        resource;
            int totalCount;

            //Get the list of shared and required resources
            distributor.GetResourcesToDistribute(out sharedResources, out requiredResources);
            Log("[WBIDistributionManager] - sharedResources count: " + sharedResources.Count());
            Log("[WBIDistributionManager] - requiredResources count: " + requiredResources.Count());

            //For each required resource, add the distributor to the required resources map.
            totalCount = requiredResources.Count;
            for (int index = 0; index < totalCount; index++)
            {
                resource = requiredResources[index];

                //Add the resource to the dictionary if needed.
                if (requiredResourceTally.ContainsKey(resource.resourceName) == false)
                {
                    talliedResource = new TalliedResource();
                    requiredResourceTally.Add(resource.resourceName, talliedResource);
                    Log("[WBIDistributionManager] - requiredResourceTally added: " + resource.resourceName);
                }

                //Add the distributor to the tallied resource.
                talliedResource = requiredResourceTally[resource.resourceName];
                talliedResource.distributors.Add(distributor);
            }

            //Now add all non-required resources
            totalCount = sharedResources.Count;
            for (int index = 0; index < totalCount; index++)
            {
                resource = sharedResources[index];

                //Add the resource to the dictionary if needed.
                if (sharedResourceTally.ContainsKey(resource.resourceName) == false)
                {
                    talliedResource = new TalliedResource();
                    sharedResourceTally.Add(resource.resourceName, talliedResource);
                    Log("[WBIDistributionManager] - sharedResourceTally added: " + resource.resourceName);
                }

                //Add the distributor to the tallied resource
                talliedResource = sharedResourceTally[resource.resourceName];
                talliedResource.distributors.Add(distributor);

                //Tally up the current and max amounts
                talliedResource.grandTotal    += resource.amount;
                talliedResource.grandCapacity += resource.maxAmount;
            }
        }
예제 #2
0
        protected void tallyResources(WBIResourceDistributor distributor)
        {
            List <PartResource> sharedResources   = new List <PartResource>();
            List <PartResource> requiredResources = new List <PartResource>();
            TalliedResource     talliedResource;
            PartResource        resource;
            int totalCount;

            //Get the list of shared and required resources
            distributor.GetResourcesToDistribute(sharedResources, requiredResources);

            //For each required resource, add the distributor to the required resources map.
            totalCount = requiredResources.Count;
            for (int index = 0; index < totalCount; index++)
            {
                resource = requiredResources[index];

                //Add the resource to the dictionary if needed.
                if (requiredResourceTally.ContainsKey(resource.resourceName) == false)
                {
                    talliedResource = new TalliedResource();
                    requiredResourceTally.Add(resource.resourceName, talliedResource);
                }

                //Add the distributor to the tallied resource.
                talliedResource = requiredResourceTally[resource.resourceName];
                talliedResource.distributors.Add(distributor);
            }

            //Now add all non-required resources
            totalCount = sharedResources.Count;
            for (int index = 0; index < totalCount; index++)
            {
                resource = sharedResources[index];

                //Add the resource to the dictionary if needed.
                if (sharedResourceTally.ContainsKey(resource.resourceName) == false)
                {
                    talliedResource = new TalliedResource();
                    sharedResourceTally.Add(resource.resourceName, talliedResource);
                }

                //Add the distributor to the tallied resource
                talliedResource = sharedResourceTally[resource.resourceName];
                talliedResource.distributors.Add(distributor);

                //Tally up the current and max amounts
                talliedResource.grandTotal    += resource.amount;
                talliedResource.grandCapacity += resource.maxAmount;
            }
        }